+\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 pitch = gpVesaCurMode->pitch/4;\r
+ Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*pitch + X;\r
+ while( H -- ) {\r
+ memsetd(buf, Colour, W);\r
+ buf += pitch;\r
+ }\r
+}\r
+\r
+void Vesa_2D_Blit(void *Ent, Uint16 DstX, Uint16 DstY, Uint16 SrcX, Uint16 SrcY, Uint16 W, Uint16 H)\r
+{\r
+ int scrnpitch = gVesa_Modes[giVesaCurrentMode].pitch;\r
+ int dst = DstY*scrnpitch + DstX;\r
+ int src = SrcY*scrnpitch + SrcX;\r
+ int tmp;\r
+ \r
+ //Log("Vesa_2D_Blit: (Ent=%p, DstX=%i, DstY=%i, SrcX=%i, SrcY=%i, W=%i, H=%i)",\r
+ // Ent, DstX, DstY, SrcX, SrcY, W, H);\r
+ \r
+ if(SrcX + W > gVesa_Modes[giVesaCurrentMode].width)\r
+ W = gVesa_Modes[giVesaCurrentMode].width - SrcX;\r
+ if(DstX + W > gVesa_Modes[giVesaCurrentMode].width)\r
+ W = gVesa_Modes[giVesaCurrentMode].width - DstX;\r
+ if(SrcY + H > gVesa_Modes[giVesaCurrentMode].height)\r
+ H = gVesa_Modes[giVesaCurrentMode].height - SrcY;\r
+ if(DstY + H > gVesa_Modes[giVesaCurrentMode].height)\r
+ H = gVesa_Modes[giVesaCurrentMode].height - DstY;\r
+ \r
+ //Debug("W = %i, H = %i", W, H);\r
+ \r
+ if( dst > src ) {\r
+ // Reverse copy\r
+ dst += H*scrnpitch;\r
+ src += H*scrnpitch;\r
+ while( H -- ) {\r
+ dst -= scrnpitch;\r
+ src -= scrnpitch;\r
+ tmp = W;\r
+ for( tmp = W; tmp --; ) {\r
+ *(Uint32*)(gpVesa_Framebuffer + dst + tmp) = *(Uint32*)(gpVesa_Framebuffer + src + tmp);\r
+ }\r
+ }\r
+ }\r
+ else {\r
+ // Normal copy is OK\r
+ while( H -- ) {\r
+ memcpy((void*)gpVesa_Framebuffer + dst, (void*)gpVesa_Framebuffer + src, W*sizeof(Uint32));\r
+ dst += scrnpitch;\r
+ src += scrnpitch;\r
+ }\r
+ }\r
+}\r