// === CONSTANTS ===\r
#define FLAG_LFB 0x1\r
#define VESA_DEFAULT_FRAMEBUFFER (KERNEL_BASE|0xA0000)\r
+#define BLINKING_CURSOR 0\r
+#if BLINKING_CURSOR\r
+# define VESA_CURSOR_PERIOD 1000\r
+#endif\r
\r
// === PROTOTYPES ===\r
int Vesa_Install(char **Arguments);\r
int Vesa_Int_SetMode(int Mode);\r
int Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);\r
int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data);\r
+void Vesa_FlipCursor(void *Arg);\r
// --- 2D Acceleration Functions --\r
void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour);\r
void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H);\r
};\r
tSpinlock glVesa_Lock;\r
tVM8086 *gpVesa_BiosState;\r
+ int giVesaDriverId = -1;\r
+// --- Video Modes ---\r
int giVesaCurrentMode = 0;\r
int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT;\r
- int giVesaDriverId = -1;\r
-char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\r
tVesa_Mode *gVesa_Modes;\r
+tVesa_Mode *gpVesaCurMode;\r
int giVesaModeCount = 0;\r
- int giVesaPageCount = 0;\r
+// --- Framebuffer ---\r
+char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\r
+ int giVesaPageCount = 0; //!< Framebuffer size in pages\r
+// --- Cursor Control ---\r
+ int giVesaCursorX = -1;\r
+ int giVesaCursorY = -1;\r
+ int giVesaCursorTimer = -1; // Invalid timer\r
+// --- 2D Video Stream Handlers ---\r
tDrvUtil_Video_2DHandlers gVesa_2DFunctions = {\r
NULL,\r
Vesa_2D_Fill,\r
);\r
\r
// Sanity Check\r
+ if( Offset > (Uint64)(heightInChars*widthInChars) ) {\r
+ LEAVE('i', 0);\r
+ return 0;\r
+ }\r
if(y >= heightInChars) {\r
LEAVE('i', 0);\r
return 0;\r
}\r
\r
- if( Offset + Length > heightInChars*widthInChars ) {\r
+ \r
+ if( (int)Offset + (int)Length > heightInChars*widthInChars ) {\r
Log_Debug("VESA", "%i + %i > %i*%i (%i)",\r
(int)Offset, (int)Length, heightInChars, widthInChars, heightInChars*widthInChars);\r
Length = heightInChars*widthInChars - Offset;\r
\r
LOG("dest = %p", dest);\r
\r
- for( i = 0; i < Length; i++ )\r
+ for( i = 0; i < (int)Length; i++ )\r
{\r
VT_Font_Render(\r
chars->Ch,\r
return ret;\r
\r
case VIDEO_IOCTL_SETCURSOR: // Set cursor position\r
+ #if !BLINKING_CURSOR\r
+ if(giVesaCursorX > 0 && giVesaCursorY)\r
+ Vesa_FlipCursor(Node);\r
+ #endif\r
+ giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x;\r
+ giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y;\r
+ //Log_Debug("VESA", "Cursor position (%i,%i)", giVesaCursorX, giVesaCursorY);\r
+ if(\r
+ giVesaCursorX < 0 || giVesaCursorY < 0\r
+ || giVesaCursorX >= gpVesaCurMode->width/giVT_CharWidth\r
+ || giVesaCursorY >= gpVesaCurMode->height/giVT_CharHeight)\r
+ {\r
+ #if BLINKING_CURSOR\r
+ if(giVesaCursorTimer != -1) {\r
+ Time_RemoveTimer(giVesaCursorTimer);\r
+ giVesaCursorTimer = -1;\r
+ }\r
+ #endif\r
+ giVesaCursorX = -1;\r
+ giVesaCursorY = -1;\r
+ }\r
+ else {\r
+ #if BLINKING_CURSOR\r
+ // Log_Debug("VESA", "Updating timer %i?", giVesaCursorTimer);\r
+ if(giVesaCursorTimer == -1)\r
+ giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Node);\r
+ #else\r
+ Vesa_FlipCursor(Node);\r
+ #endif\r
+ }\r
+ //Log_Debug("VESA", "Cursor position (%i,%i) Timer %i", giVesaCursorX, giVesaCursorY, giVesaCursorTimer);\r
return 0;\r
\r
case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer\r
return 0;\r
}\r
\r
+/**\r
+ * \brief Updates the video mode\r
+ */\r
int Vesa_Int_SetMode(int mode)\r
{\r
Log_Log("VESA", "Setting mode to %i", mode);\r
// Check for fast return\r
if(mode == giVesaCurrentMode) return 1;\r
\r
+ Time_RemoveTimer(giVesaCursorTimer);\r
+ giVesaCursorTimer = -1;\r
+ \r
LOCK( &glVesa_Lock );\r
\r
gpVesa_BiosState->AX = 0x4F02;\r
\r
// Record Mode Set\r
giVesaCurrentMode = mode;\r
+ gpVesaCurMode = &gVesa_Modes[giVesaCurrentMode];\r
\r
RELEASE( &glVesa_Lock );\r
\r
return 1;\r
}\r
\r
+/**\r
+ * \brief Updates the state of the text cursor\r
+ * \note Just does a bitwise not on the cursor region\r
+ */\r
+void Vesa_FlipCursor(void *Arg)\r
+{\r
+ int pitch = gpVesaCurMode->pitch/4;\r
+ int x = giVesaCursorX*giVT_CharWidth;\r
+ int y = giVesaCursorY*giVT_CharHeight;\r
+ int i;\r
+ Uint32 *fb = (void*)gpVesa_Framebuffer;\r
+ \r
+ //Debug("Cursor flip");\r
+ \r
+ // Sanity 1\r
+ if(giVesaCursorX < 0 || giVesaCursorY < 0\r
+ || y*pitch + x + giVT_CharHeight*pitch > (int)gpVesaCurMode->fbSize/4) {\r
+ Debug("Cursor OOB (%i,%i)", x, y);\r
+ giVesaCursorTimer = -1;\r
+ return;\r
+ }\r
+ \r
+ // Draw cursor\r
+ fb += (y+1)*pitch + x;\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch )\r
+ *fb = ~*fb;\r
+ \r
+ #if BLINKING_CURSOR\r
+ giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);\r
+ #endif\r
+}\r
+\r
// ------------------------\r
// --- 2D Accelleration ---\r
// ------------------------\r
void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour)\r
{\r
- int scrnwidth = gVesa_Modes[giVesaCurrentMode].width;\r
- Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*scrnwidth + X;\r
+ int pitch = gpVesaCurMode->pitch/4;\r
+ Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*pitch + X;\r
while( H -- ) {\r
memsetd(buf, Colour, W);\r
- buf += scrnwidth;\r
+ buf += pitch;\r
}\r
}\r
\r