+/**\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;\r
+ int bytes_per_px = (gpVesaCurMode->bpp + 7) / 8;\r
+ int x = giVesaCursorX*giVT_CharWidth;\r
+ int y = giVesaCursorY*giVT_CharHeight;\r
+ int i;\r
+ Uint8 *fb = (void*)gpVesa_Framebuffer;\r
+ \r
+ //Debug("Cursor flip");\r
+ \r
+ // Sanity check\r
+ if(giVesaCursorX < 0 || giVesaCursorY < 0\r
+ || y*pitch + x + (giVT_CharHeight-1)*pitch > (int)gpVesaCurMode->fbSize) {\r
+ Log_Notice("VESA", "Cursor OOB (%i,%i)", x, y);\r
+ giVesaCursorTimer = -1;\r
+ return;\r
+ }\r
+ \r
+ // Draw cursor\r
+ fb += (y+1)*pitch + x*bytes_per_px;\r
+ \r
+ switch(bytes_per_px)\r
+ {\r
+ case 1:\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch )\r
+ *fb = ~*fb;\r
+ break;\r
+ case 2:\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {\r
+ fb[0] = ~fb[0];\r
+ fb[1] = ~fb[1];\r
+ }\r
+ break;\r
+ case 3:\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {\r
+ fb[0] = ~fb[0];\r
+ fb[1] = ~fb[1];\r
+ fb[2] = ~fb[2];\r
+ }\r
+ break;\r
+ case 4:\r
+ for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) {\r
+ fb[0] = ~fb[0];\r
+ fb[1] = ~fb[1];\r
+ fb[2] = ~fb[2];\r
+ fb[3] = ~fb[3];\r
+ }\r
+ break;\r
+ default:\r
+ Log_Error("VESA", "Vesa_FlipCursor - Bug Report, unknown bytes_per_px (%i)", bytes_per_px);\r
+ giVesaCursorTimer = -1;\r
+ return ;\r
+ }\r
+ \r
+ #if BLINKING_CURSOR\r
+ giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);\r
+ #endif\r
+}\r
+\r