From: John Hodge Date: Wed, 21 Apr 2010 05:24:26 +0000 (+0800) Subject: Fixed login text-entry bug, fixes to KMS (graphics is still buggy) X-Git-Tag: rel0.06~232 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=cea789b7006552c5365744d4ebaddbdc96387355;p=tpg%2Facess2.git Fixed login text-entry bug, fixes to KMS (graphics is still buggy) --- diff --git a/Kernel/Makefile.BuildNum b/Kernel/Makefile.BuildNum index bacdc56c..96d15cb1 100644 --- a/Kernel/Makefile.BuildNum +++ b/Kernel/Makefile.BuildNum @@ -1 +1 @@ -BUILD_NUM = 1933 +BUILD_NUM = 1946 diff --git a/Kernel/drv/vterm.c b/Kernel/drv/vterm.c index fe2ccd99..5c88786b 100644 --- a/Kernel/drv/vterm.c +++ b/Kernel/drv/vterm.c @@ -1,7 +1,7 @@ /* * Acess2 Virtual Terminal Driver */ -#define DEBUG 0 +#define DEBUG 1 #include #include #include @@ -19,8 +19,8 @@ #define MAX_INPUT_CHARS32 64 #define MAX_INPUT_CHARS8 (MAX_INPUT_CHARS32*4) #define VT_SCROLLBACK 2 // 2 Screens of text -#define DEFAULT_OUTPUT "VGA" -//#define DEFAULT_OUTPUT "BochsGA" +//#define DEFAULT_OUTPUT "VGA" +#define DEFAULT_OUTPUT "BochsGA" //#define DEFAULT_OUTPUT "Vesa" #define DEFAULT_INPUT "PS2Keyboard" #define DEFAULT_WIDTH 80 @@ -69,6 +69,7 @@ tVFS_Node *VT_FindDir(tVFS_Node *Node, char *Name); Uint64 VT_Read(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); Uint64 VT_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer); int VT_Terminal_IOCtl(tVFS_Node *Node, int Id, void *Data); +void VT_SetResolution(int IsTextMode, int Width, int Height); void VT_SetTerminal(int ID); void VT_KBCallBack(Uint32 Codepoint); void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count); @@ -204,6 +205,7 @@ void VT_InitOutput() { giVT_OutputDevHandle = VFS_Open(gsVT_OutputDevice, VFS_OPENFLAG_WRITE); VT_SetTerminal( 0 ); + VT_SetResolution(1, 640, 480); } /** @@ -490,6 +492,11 @@ void VT_SetTerminal(int ID) VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos); } + if( gpVT_CurTerm->Mode == TERM_MODE_TEXT ) + VT_SetResolution( 1, gpVT_CurTerm->Width*giVT_CharWidth, gpVT_CurTerm->Height*giVT_CharHeight ); + else + VT_SetResolution( 0, gpVT_CurTerm->Width, gpVT_CurTerm->Height ); + // Update the screen VT_int_UpdateScreen( &gVT_Terminals[ ID ], 1 ); } @@ -1009,7 +1016,7 @@ void VT_int_ChangeMode(tVTerm *Term, int NewMode) Uint8 *VT_Font_GetChar(Uint32 Codepoint); // === GLOBALS === -int giVT_CharWidth = FONT_WIDTH+1; +int giVT_CharWidth = FONT_WIDTH; int giVT_CharHeight = FONT_HEIGHT; // === CODE === diff --git a/Makefile.cfg b/Makefile.cfg index 51c4802d..57c285a2 100644 --- a/Makefile.cfg +++ b/Makefile.cfg @@ -28,7 +28,7 @@ DRIVERS = MODULES = Storage/ATA Storage/FDD MODULES += Network/NE2000 MODULES += Display/VESA -#MODULES += Display/BochsGA +MODULES += Display/BochsGA MODULES += Filesystems/Ext2 MODULES += Filesystems/FAT MODULES += IPStack diff --git a/Modules/Display/BochsGA/bochsvbe.c b/Modules/Display/BochsGA/bochsvbe.c index 8f73ccbd..3c8309e1 100644 --- a/Modules/Display/BochsGA/bochsvbe.c +++ b/Modules/Display/BochsGA/bochsvbe.c @@ -78,12 +78,11 @@ tDevFS_Driver gBGA_DriverStruct = { int giBGA_BufferFormat = 0; tVideo_IOCtl_Pos gBGA_CursorPos = {-1,-1}; Uint *gBGA_Framebuffer; -tBGA_Mode gpBGA_CurrentMode; +const tBGA_Mode *gpBGA_CurrentMode; const tBGA_Mode gBGA_Modes[] = { - {}, - {640,480,32, 0, 640*480*4}, - {800,600,32, 0, 800*600*4}, - {1024,768,32, 0, 1024*768*4} + {640,480,32, 640*480*4}, + {800,600,32, 800*600*4}, + {1024,768,32, 1024*768*4} }; #define BGA_MODE_COUNT (sizeof(gBGA_Modes)/sizeof(gBGA_Modes[0])) @@ -111,7 +110,7 @@ int BGA_Install(char **Arguments) } // Map Framebuffer to hardware address - gBGA_Framebuffer = (void *) MM_MapHWPage(VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768); // 768 pages (3Mb) + gBGA_Framebuffer = (void *) MM_MapHWPages(VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768); // 768 pages (3Mb) return MODULE_ERR_OK; } @@ -122,7 +121,7 @@ int BGA_Install(char **Arguments) void BGA_Uninstall() { DevFS_DelDevice( &gBGA_DriverStruct ); - MM_UnmapHWPage( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 ); + MM_UnmapHWPages( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 ); } /** @@ -153,8 +152,8 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer) // Check Mode if(giBGA_CurrentMode == -1) { - LEAVE('i', -1); - return -1; + Log_Notice("BGA", "Setting video mode to #0 (640x480x32)"); + BGA_int_UpdateMode(0); // Mode Zero is 640x480 } // Text Mode @@ -163,41 +162,39 @@ Uint64 BGA_Write(tVFS_Node *node, Uint64 off, Uint64 len, void *Buffer) case VIDEO_BUFFMT_TEXT: { tVT_Char *chars = Buffer; - int pitch = gpBGA_CurrentMode->width * giVT_CharWidth; - int x, y; + int x, y; // Characters/Rows + int widthInChars = gpBGA_CurrentMode->width/giVT_CharWidth; Uint32 *dest; off /= sizeof(tVT_Char); - dest = (void*)gBGA_Framebuffer; - x = (off % gpBGA_CurrentMode->width) * giVT_CharWidth; - y = (off / gpBGA_CurrentMode->width) * giVT_CharHeight; + len /= sizeof(tVT_Char); + + x = (off % widthInChars); + y = (off / widthInChars); // Sanity Check - if(y > gpBGA_CurrentMode->height) { + if(y > gpBGA_CurrentMode->height / giVT_CharHeight) { LEAVE('i', 0); return 0; } - dest += y * pitch; - dest += x * giVT_CharWidth; - len /= sizeof(tVT_Char); + dest = (Uint32 *)gBGA_Framebuffer; + dest += y * gpBGA_CurrentMode->width * giVT_CharHeight; while(len--) { VT_Font_Render( chars->Ch, - dest, pitch, + dest + x*giVT_CharWidth, gpBGA_CurrentMode->width, VT_Colour12to24(chars->BGCol), VT_Colour12to24(chars->FGCol) ); - dest += giVT_CharWidth; - chars ++; - x += giVT_CharWidth; - if( x >= pitch ) { + x ++; + if( x >= widthInChars ) { x = 0; - y += giVT_CharHeight; - dest += pitch*(giVT_CharHeight-1); + y ++; // Why am I keeping track of this? + dest += gpBGA_CurrentMode->width*giVT_CharHeight; } } } @@ -344,15 +341,9 @@ int BGA_int_UpdateMode(int id) // Sanity Check if(id < 0 || id >= BGA_MODE_COUNT) return -1; - // Check if it is a text mode - if( gBGA_Modes[id].flags & MODEFLAG_TEXT ) - BGA_int_SetMode( - gBGA_Modes[id].width*giVT_CharWidth, - gBGA_Modes[id].height*giVT_CharHeight); - else // Graphics? - BGA_int_SetMode( - gBGA_Modes[id].width, - gBGA_Modes[id].height); + BGA_int_SetMode( + gBGA_Modes[id].width, + gBGA_Modes[id].height); giBGA_CurrentMode = id; gpBGA_CurrentMode = &gBGA_Modes[id]; @@ -379,10 +370,6 @@ int BGA_int_FindMode(tVideo_IOCtl_Mode *info) LogF("Mode %i (%ix%ix%i), ", i, gBGA_Modes[i].width, gBGA_Modes[i].height, gBGA_Modes[i].bpp); #endif - // Check if this mode is the same type as what we want - if( !(gBGA_Modes[i].flags & MODEFLAG_TEXT) != !(info->flags & VIDEO_FLAG_TEXT) ) - continue; - // Ooh! A perfect match if(gBGA_Modes[i].width == info->width && gBGA_Modes[i].height == info->height @@ -417,10 +404,6 @@ int BGA_int_FindMode(tVideo_IOCtl_Mode *info) info->height = gBGA_Modes[best].height; info->bpp = gBGA_Modes[best].bpp; - info->flags = 0; - if(gBGA_Modes[best].flags & MODEFLAG_TEXT) - info->flags |= VIDEO_FLAG_TEXT; - return best; } @@ -441,10 +424,6 @@ int BGA_int_ModeInfo(tVideo_IOCtl_Mode *info) info->height = gBGA_Modes[info->id].height; info->bpp = gBGA_Modes[info->id].bpp; - info->flags = 0; - if(gBGA_Modes[info->id].flags & MODEFLAG_TEXT) - info->flags |= VIDEO_FLAG_TEXT; - return 1; } diff --git a/Usermode/Applications/login_src/main.c b/Usermode/Applications/login_src/main.c index 2866dbd6..cf58c1b2 100644 --- a/Usermode/Applications/login_src/main.c +++ b/Usermode/Applications/login_src/main.c @@ -87,6 +87,7 @@ char *GetUsername() while( (ch = fgetc(stdin)) != -1 && ch != '\n' ) { if(ch == '\b') { + if( pos == 0 ) continue; pos --; ret[pos] = '\0'; } @@ -122,6 +123,7 @@ char *GetPassword() while( (ch = fgetc(stdin)) != -1 && ch != '\n' ) { if(ch == '\b') { + if( pos == 0 ) continue; pos --; ret[pos] = '\0'; }