// === CONSTANTS ===\r
#define FLAG_LFB 0x1\r
#define VESA_DEFAULT_FRAMEBUFFER (KERNEL_BASE|0xA0000)\r
-#define VESA_CURSOR_PERIOD 1000\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 giVesaCurrentMode = 0;\r
int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT;\r
tVesa_Mode *gVesa_Modes;\r
+tVesa_Mode *gpVesaCurMode;\r
int giVesaModeCount = 0;\r
// --- Framebuffer ---\r
char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER;\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 >= gVesa_Modes[giVesaCurrentMode].width\r
- || giVesaCursorY >= gVesa_Modes[giVesaCurrentMode].height)\r
+ || giVesaCursorX >= gpVesaCurMode->width/giVT_CharWidth\r
+ || giVesaCursorY >= gpVesaCurMode->height/giVT_CharHeight)\r
{\r
- if(giVesaCursorTimer != -1)\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
if(mode == giVesaCurrentMode) return 1;\r
\r
Time_RemoveTimer(giVesaCursorTimer);\r
+ giVesaCursorTimer = -1;\r
\r
LOCK( &glVesa_Lock );\r
\r
\r
// Record Mode Set\r
giVesaCurrentMode = mode;\r
+ gpVesaCurMode = &gVesa_Modes[giVesaCurrentMode];\r
\r
RELEASE( &glVesa_Lock );\r
\r
*/\r
void Vesa_FlipCursor(void *Arg)\r
{\r
- int pitch = gVesa_Modes[giVesaCurrentMode].pitch/4;\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
- if(giVesaCursorX < 0 || giVesaCursorY < 0) return;\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
- for( i = 1; i < giVT_CharHeight-1; i++ )\r
- fb[(y+i)*pitch+x] = ~fb[(y+i)*pitch+x];\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
// ------------------------\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