/*
* Acess2 Virtual Terminal Driver
*/
-#define DEBUG 0
+#define DEBUG 1
#include <acess.h>
#include <fs_devfs.h>
#include <modules.h>
#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
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);
{
giVT_OutputDevHandle = VFS_Open(gsVT_OutputDevice, VFS_OPENFLAG_WRITE);
VT_SetTerminal( 0 );
+ VT_SetResolution(1, 640, 480);
}
/**
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 );
}
Uint8 *VT_Font_GetChar(Uint32 Codepoint);
// === GLOBALS ===
-int giVT_CharWidth = FONT_WIDTH+1;
+int giVT_CharWidth = FONT_WIDTH;
int giVT_CharHeight = FONT_HEIGHT;
// === CODE ===
int giBGA_BufferFormat = 0;\r
tVideo_IOCtl_Pos gBGA_CursorPos = {-1,-1};\r
Uint *gBGA_Framebuffer;\r
-tBGA_Mode gpBGA_CurrentMode;\r
+const tBGA_Mode *gpBGA_CurrentMode;\r
const tBGA_Mode gBGA_Modes[] = {\r
- {},\r
- {640,480,32, 0, 640*480*4},\r
- {800,600,32, 0, 800*600*4},\r
- {1024,768,32, 0, 1024*768*4}\r
+ {640,480,32, 640*480*4},\r
+ {800,600,32, 800*600*4},\r
+ {1024,768,32, 1024*768*4}\r
};\r
#define BGA_MODE_COUNT (sizeof(gBGA_Modes)/sizeof(gBGA_Modes[0]))\r
\r
}\r
\r
// Map Framebuffer to hardware address\r
- gBGA_Framebuffer = (void *) MM_MapHWPage(VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768); // 768 pages (3Mb)\r
+ gBGA_Framebuffer = (void *) MM_MapHWPages(VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768); // 768 pages (3Mb)\r
\r
return MODULE_ERR_OK;\r
}\r
void BGA_Uninstall()\r
{\r
DevFS_DelDevice( &gBGA_DriverStruct );\r
- MM_UnmapHWPage( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 );\r
+ MM_UnmapHWPages( VBE_DISPI_LFB_PHYSICAL_ADDRESS, 768 );\r
}\r
\r
/**\r
\r
// Check Mode\r
if(giBGA_CurrentMode == -1) {\r
- LEAVE('i', -1);\r
- return -1;\r
+ Log_Notice("BGA", "Setting video mode to #0 (640x480x32)");\r
+ BGA_int_UpdateMode(0); // Mode Zero is 640x480\r
}\r
\r
// Text Mode\r
case VIDEO_BUFFMT_TEXT:\r
{\r
tVT_Char *chars = Buffer;\r
- int pitch = gpBGA_CurrentMode->width * giVT_CharWidth;\r
- int x, y;\r
+ int x, y; // Characters/Rows\r
+ int widthInChars = gpBGA_CurrentMode->width/giVT_CharWidth;\r
Uint32 *dest;\r
\r
off /= sizeof(tVT_Char);\r
- dest = (void*)gBGA_Framebuffer;\r
- x = (off % gpBGA_CurrentMode->width) * giVT_CharWidth;\r
- y = (off / gpBGA_CurrentMode->width) * giVT_CharHeight;\r
+ len /= sizeof(tVT_Char);\r
+ \r
+ x = (off % widthInChars);\r
+ y = (off / widthInChars);\r
\r
// Sanity Check\r
- if(y > gpBGA_CurrentMode->height) {\r
+ if(y > gpBGA_CurrentMode->height / giVT_CharHeight) {\r
LEAVE('i', 0);\r
return 0;\r
}\r
\r
- dest += y * pitch;\r
- dest += x * giVT_CharWidth;\r
- len /= sizeof(tVT_Char);\r
+ dest = (Uint32 *)gBGA_Framebuffer;\r
+ dest += y * gpBGA_CurrentMode->width * giVT_CharHeight;\r
while(len--)\r
{\r
VT_Font_Render(\r
chars->Ch,\r
- dest, pitch,\r
+ dest + x*giVT_CharWidth, gpBGA_CurrentMode->width,\r
VT_Colour12to24(chars->BGCol),\r
VT_Colour12to24(chars->FGCol)\r
);\r
\r
- dest += giVT_CharWidth;\r
- \r
chars ++;\r
- x += giVT_CharWidth;\r
- if( x >= pitch ) {\r
+ x ++;\r
+ if( x >= widthInChars ) {\r
x = 0;\r
- y += giVT_CharHeight;\r
- dest += pitch*(giVT_CharHeight-1);\r
+ y ++; // Why am I keeping track of this?\r
+ dest += gpBGA_CurrentMode->width*giVT_CharHeight;\r
}\r
}\r
}\r
// Sanity Check\r
if(id < 0 || id >= BGA_MODE_COUNT) return -1;\r
\r
- // Check if it is a text mode\r
- if( gBGA_Modes[id].flags & MODEFLAG_TEXT )\r
- BGA_int_SetMode(\r
- gBGA_Modes[id].width*giVT_CharWidth,\r
- gBGA_Modes[id].height*giVT_CharHeight);\r
- else // Graphics?\r
- BGA_int_SetMode(\r
- gBGA_Modes[id].width,\r
- gBGA_Modes[id].height);\r
+ BGA_int_SetMode(\r
+ gBGA_Modes[id].width,\r
+ gBGA_Modes[id].height);\r
\r
giBGA_CurrentMode = id;\r
gpBGA_CurrentMode = &gBGA_Modes[id];\r
LogF("Mode %i (%ix%ix%i), ", i, gBGA_Modes[i].width, gBGA_Modes[i].height, gBGA_Modes[i].bpp);\r
#endif\r
\r
- // Check if this mode is the same type as what we want\r
- if( !(gBGA_Modes[i].flags & MODEFLAG_TEXT) != !(info->flags & VIDEO_FLAG_TEXT) )\r
- continue;\r
- \r
// Ooh! A perfect match\r
if(gBGA_Modes[i].width == info->width\r
&& gBGA_Modes[i].height == info->height\r
info->height = gBGA_Modes[best].height;\r
info->bpp = gBGA_Modes[best].bpp;\r
\r
- info->flags = 0;\r
- if(gBGA_Modes[best].flags & MODEFLAG_TEXT)\r
- info->flags |= VIDEO_FLAG_TEXT;\r
- \r
return best;\r
}\r
\r
info->height = gBGA_Modes[info->id].height;\r
info->bpp = gBGA_Modes[info->id].bpp;\r
\r
- info->flags = 0;\r
- if(gBGA_Modes[info->id].flags & MODEFLAG_TEXT)\r
- info->flags |= VIDEO_FLAG_TEXT;\r
- \r
return 1;\r
}\r
\r