Modules/VESA - Cleaned the code a little
authorJohn Hodge <[email protected]>
Sat, 22 Oct 2011 07:22:18 +0000 (15:22 +0800)
committerJohn Hodge <[email protected]>
Sat, 22 Oct 2011 07:22:18 +0000 (15:22 +0800)
Modules/Display/VESA/main.c

index 490e841..8b227ea 100644 (file)
@@ -29,6 +29,8 @@ Uint64        Vesa_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
  int   Vesa_Int_SetMode(int Mode);\r
  int   Vesa_Int_FindMode(tVideo_IOCtl_Mode *data);\r
  int   Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data);\r
+void   Vesa_int_HideCursor(void);\r
+void   Vesa_int_ShowCursor(void);\r
 void   Vesa_FlipCursor(void *Arg);\r
 \r
 // === GLOBALS ===\r
@@ -190,48 +192,19 @@ int Vesa_IOCtl(tVFS_Node *Node, int ID, void *Data)
                return Vesa_Int_ModeInfo((tVideo_IOCtl_Mode*)Data);\r
        \r
        case VIDEO_IOCTL_SETBUFFORMAT:\r
-               DrvUtil_Video_DrawCursor( &gVesa_BufInfo, -1, -1 );\r
-               giVesaCursorX = -1;\r
-               #if BLINKING_CURSOR\r
-               if(giVesaCursorTimer != -1) {\r
-                       Time_RemoveTimer(giVesaCursorTimer);\r
-                       giVesaCursorTimer = -1;\r
-               }\r
-               #endif\r
+               Vesa_int_HideCursor();\r
                ret = gVesa_BufInfo.BufferFormat;\r
                if(Data)        gVesa_BufInfo.BufferFormat = *(int*)Data;\r
                if(gVesa_BufInfo.BufferFormat == VIDEO_BUFFMT_TEXT)\r
                        DrvUtil_Video_SetCursor( &gVesa_BufInfo, &gDrvUtil_TextModeCursor );\r
+               Vesa_int_ShowCursor();\r
                return ret;\r
        \r
        case VIDEO_IOCTL_SETCURSOR:     // Set cursor position\r
-               DrvUtil_Video_RemoveCursor( &gVesa_BufInfo );\r
-               #if BLINKING_CURSOR\r
-               if(giVesaCursorTimer != -1) {\r
-                       Time_RemoveTimer(giVesaCursorTimer);\r
-                       giVesaCursorTimer = -1;\r
-               }\r
-               #endif\r
+               Vesa_int_HideCursor();\r
                giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x;\r
                giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y;\r
-               gbVesa_CursorVisible = (giVesaCursorX >= 0);\r
-               if(gVesa_BufInfo.BufferFormat == VIDEO_BUFFMT_TEXT)\r
-               {\r
-                       DrvUtil_Video_DrawCursor(\r
-                               &gVesa_BufInfo,\r
-                               giVesaCursorX*giVT_CharWidth,\r
-                               giVesaCursorY*giVT_CharHeight\r
-                               );\r
-                       #if BLINKING_CURSOR\r
-                       giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, NULL);\r
-                       #endif\r
-               }\r
-               else\r
-                       DrvUtil_Video_DrawCursor(\r
-                               &gVesa_BufInfo,\r
-                               giVesaCursorX,\r
-                               giVesaCursorY\r
-                               );\r
+               Vesa_int_ShowCursor();\r
                return 0;\r
        }\r
        return 0;\r
@@ -361,9 +334,41 @@ int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data)
        return 1;\r
 }\r
 \r
+void Vesa_int_HideCursor(void)\r
+{\r
+       DrvUtil_Video_RemoveCursor( &gVesa_BufInfo );\r
+       #if BLINKING_CURSOR\r
+       if(giVesaCursorTimer != -1) {\r
+               Time_RemoveTimer(giVesaCursorTimer);\r
+               giVesaCursorTimer = -1;\r
+       }\r
+       #endif\r
+}\r
+\r
+void Vesa_int_ShowCursor(void)\r
+{\r
+       gbVesa_CursorVisible = (giVesaCursorX >= 0);\r
+       if(gVesa_BufInfo.BufferFormat == VIDEO_BUFFMT_TEXT)\r
+       {\r
+               DrvUtil_Video_DrawCursor(\r
+                       &gVesa_BufInfo,\r
+                       giVesaCursorX*giVT_CharWidth,\r
+                       giVesaCursorY*giVT_CharHeight\r
+                       );\r
+               #if BLINKING_CURSOR\r
+               giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, NULL);\r
+               #endif\r
+       }\r
+       else\r
+               DrvUtil_Video_DrawCursor(\r
+                       &gVesa_BufInfo,\r
+                       giVesaCursorX,\r
+                       giVesaCursorY\r
+                       );\r
+}\r
+\r
 /**\r
- * \brief Updates the state of the text cursor\r
- * \note Just does a bitwise not on the cursor region\r
+ * \brief Swaps the text cursor on/off\r
  */\r
 void Vesa_FlipCursor(void *Arg)\r
 {\r

UCC git Repository :: git.ucc.asn.au