+\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 = gVesa_Modes[giVesaCurrentMode].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
+ \r
+ for( i = 1; i < giVT_CharHeight-1; i++ )\r
+ fb[(y+i)*pitch+x] = ~fb[(y+i)*pitch+x];\r
+ \r
+ giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg);\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
+ while( H -- ) {\r
+ memsetd(buf, Colour, W);\r
+ buf += scrnwidth;\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