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
case VIDEO_IOCTL_SETCURSOR: // Set cursor position\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(giVesaCursorTimer != -1) {\r
Time_RemoveTimer(giVesaCursorTimer);\r
+ giVesaCursorTimer = -1;\r
+ }\r
giVesaCursorX = -1;\r
giVesaCursorY = -1;\r
}\r
else {\r
+ // Log_Debug("VESA", "Updating timer %i?", giVesaCursorTimer);\r
if(giVesaCursorTimer == -1)\r
giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Node);\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 > 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
giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);\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