From: John Hodge Date: Sun, 4 Jul 2010 03:30:32 +0000 (+0800) Subject: Fiddling with VESA cursor, cleaning up VESA and VTerm X-Git-Tag: rel0.06~120 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1c821df6e9a345c41e0b7e5b71544ec6defb7faf;p=tpg%2Facess2.git Fiddling with VESA cursor, cleaning up VESA and VTerm --- diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index b19b3198..5545da77 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -24,8 +24,6 @@ #define DEFAULT_WIDTH 640 #define DEFAULT_HEIGHT 480 #define DEFAULT_SCROLLBACK 2 // 2 Screens of text + current screen -#define TEXTTERM_WIDTH (BOOT_WIDTH/8) -#define TEXTTERM_HEIGHT (BOOT_WIDTH/16) #define DEFAULT_COLOUR (VT_COL_BLACK|(0xAAA<<16)) #define VT_FLAG_HIDECSR 0x01 diff --git a/Modules/Display/VESA/main.c b/Modules/Display/VESA/main.c index 703e708f..e30d6406 100644 --- a/Modules/Display/VESA/main.c +++ b/Modules/Display/VESA/main.c @@ -48,6 +48,7 @@ tVM8086 *gpVesa_BiosState; int giVesaCurrentMode = 0; int giVesaCurrentFormat = VIDEO_BUFFMT_TEXT; tVesa_Mode *gVesa_Modes; +tVesa_Mode *gpVesaCurMode; int giVesaModeCount = 0; // --- Framebuffer --- char *gpVesa_Framebuffer = (void*)VESA_DEFAULT_FRAMEBUFFER; @@ -359,20 +360,25 @@ int Vesa_Ioctl(tVFS_Node *Node, int ID, void *Data) case VIDEO_IOCTL_SETCURSOR: // Set cursor position giVesaCursorX = ((tVideo_IOCtl_Pos*)Data)->x; giVesaCursorY = ((tVideo_IOCtl_Pos*)Data)->y; + //Log_Debug("VESA", "Cursor position (%i,%i)", giVesaCursorX, giVesaCursorY); if( giVesaCursorX < 0 || giVesaCursorY < 0 - || giVesaCursorX >= gVesa_Modes[giVesaCurrentMode].width - || giVesaCursorY >= gVesa_Modes[giVesaCurrentMode].height) + || giVesaCursorX >= gpVesaCurMode->width/giVT_CharWidth + || giVesaCursorY >= gpVesaCurMode->height/giVT_CharHeight) { - if(giVesaCursorTimer != -1) + if(giVesaCursorTimer != -1) { Time_RemoveTimer(giVesaCursorTimer); + giVesaCursorTimer = -1; + } giVesaCursorX = -1; giVesaCursorY = -1; } else { + // Log_Debug("VESA", "Updating timer %i?", giVesaCursorTimer); if(giVesaCursorTimer == -1) giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Node); } + //Log_Debug("VESA", "Cursor position (%i,%i) Timer %i", giVesaCursorX, giVesaCursorY, giVesaCursorTimer); return 0; case VIDEO_IOCTL_REQLFB: // Request Linear Framebuffer @@ -395,6 +401,7 @@ int Vesa_Int_SetMode(int mode) if(mode == giVesaCurrentMode) return 1; Time_RemoveTimer(giVesaCursorTimer); + giVesaCursorTimer = -1; LOCK( &glVesa_Lock ); @@ -419,6 +426,7 @@ int Vesa_Int_SetMode(int mode) // Record Mode Set giVesaCurrentMode = mode; + gpVesaCurMode = &gVesa_Modes[giVesaCurrentMode]; RELEASE( &glVesa_Lock ); @@ -482,16 +490,26 @@ int Vesa_Int_ModeInfo(tVideo_IOCtl_Mode *data) */ void Vesa_FlipCursor(void *Arg) { - int pitch = gVesa_Modes[giVesaCurrentMode].pitch/4; + int pitch = gpVesaCurMode->pitch/4; int x = giVesaCursorX*giVT_CharWidth; int y = giVesaCursorY*giVT_CharHeight; int i; Uint32 *fb = (void*)gpVesa_Framebuffer; - if(giVesaCursorX < 0 || giVesaCursorY < 0) return; + //Debug("Cursor flip"); + + // Sanity 1 + if(giVesaCursorX < 0 || giVesaCursorY < 0 + || y*pitch + x + giVT_CharHeight*pitch > gpVesaCurMode->fbSize/4) { + Debug("Cursor OOB (%i,%i)", x, y); + giVesaCursorTimer = -1; + return; + } - for( i = 1; i < giVT_CharHeight-1; i++ ) - fb[(y+i)*pitch+x] = ~fb[(y+i)*pitch+x]; + // Draw cursor + fb += (y+1)*pitch + x; + for( i = 1; i < giVT_CharHeight-1; i++, fb += pitch ) + *fb = ~*fb; giVesaCursorTimer = Time_CreateTimer(VESA_CURSOR_PERIOD, Vesa_FlipCursor, Arg); } @@ -501,11 +519,11 @@ void Vesa_FlipCursor(void *Arg) // ------------------------ void Vesa_2D_Fill(void *Ent, Uint16 X, Uint16 Y, Uint16 W, Uint16 H, Uint32 Colour) { - int scrnwidth = gVesa_Modes[giVesaCurrentMode].width; - Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*scrnwidth + X; + int pitch = gpVesaCurMode->pitch/4; + Uint32 *buf = (Uint32*)gpVesa_Framebuffer + Y*pitch + X; while( H -- ) { memsetd(buf, Colour, W); - buf += scrnwidth; + buf += pitch; } }