/*
* Acess2 Virtual Terminal Driver
*/
-#define DEBUG 1
+#define DEBUG 0
#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 "VGA"
//#define DEFAULT_OUTPUT "BochsGA"
-//#define DEFAULT_OUTPUT "Vesa"
+#define DEFAULT_OUTPUT "Vesa"
#define DEFAULT_INPUT "PS2Keyboard"
#define DEFAULT_WIDTH 80
#define DEFAULT_HEIGHT 25
// === PROTOTYPES ===
int VT_Install(char **Arguments);
+void VT_InitOutput(void);
+void VT_InitInput(void);
char *VT_ReadDir(tVFS_Node *Node, int Pos);
tVFS_Node *VT_FindDir(tVFS_Node *Node, char *Name);
int VT_Root_IOCtl(tVFS_Node *Node, int Id, void *Data);
// Add to DevFS
DevFS_AddDevice( &gVT_DrvInfo );
+ VT_InitOutput();
+ VT_InitInput();
+
// Set kernel output to VT0
Debug_SetKTerminal("/Devices/VTerm/0");
void VT_InitOutput()
{
giVT_OutputDevHandle = VFS_Open(gsVT_OutputDevice, VFS_OPENFLAG_WRITE);
+ if(giVT_InputDevHandle == -1) {
+ Log_Warning("VTerm", "Oh F**k, I can't open the video device '%s'", gsVT_OutputDevice);
+ return ;
+ }
VT_SetTerminal( 0 );
- VT_SetResolution(1, 640, 480);
+ VT_SetResolution(1, 640, 400);
}
/**
giVT_RealHeight = mode.height;
VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_GETSETMODE, &tmp );
-
-
- if(IsTextMode)
- tmp = VIDEO_BUFFMT_TEXT;
- else
- tmp = VIDEO_BUFFMT_FRAMEBUFFER;
+ tmp = IsTextMode ? VIDEO_BUFFMT_TEXT : VIDEO_BUFFMT_FRAMEBUFFER;
VFS_IOCtl( giVT_OutputDevHandle, VIDEO_IOCTL_SETBUFFORMAT, &tmp );
}
gpVT_CurTerm = &gVT_Terminals[ID];
// Update cursor
- if( !(gpVT_CurTerm->Flags & VT_FLAG_HIDECSR) )
+ if( gpVT_CurTerm->Mode == TERM_MODE_TEXT && !(gpVT_CurTerm->Flags & VT_FLAG_HIDECSR) )
{
tVideo_IOCtl_Pos pos;
pos.x = gpVT_CurTerm->WritePos % gpVT_CurTerm->Width;
}
}
-/**
- * \fn void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
- * \brief Print a string to the Virtual Terminal
- */
-void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
-{
- Uint32 val;
- int i;
- for( i = 0; i < Count; i++ )
- {
- if( Buffer[i] == 0x1B ) // Escape Sequence
- {
- i ++;
- i += VT_int_ParseEscape(Term, (char*)&Buffer[i]);
- continue;
- }
-
- if( Buffer[i] < 128 ) // Plain ASCII
- VT_int_PutChar(Term, Buffer[i]);
- else { // UTF-8
- i += ReadUTF8(&Buffer[i], &val);
- VT_int_PutChar(Term, val);
- }
- }
-
- // Update cursor
- if( Term == gpVT_CurTerm && !(Term->Flags & VT_FLAG_HIDECSR) )
- {
- tVideo_IOCtl_Pos pos;
- pos.x = Term->WritePos % Term->Width;
- pos.y = Term->WritePos / Term->Width;
- VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos);
- }
-}
-
/**
* \fn void VT_int_ClearLine(tVTerm *Term, int Num)
* \brief Clears a line in a virtual terminal
return j + 1;
}
+/**
+ * \fn void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
+ * \brief Print a string to the Virtual Terminal
+ */
+void VT_int_PutString(tVTerm *Term, Uint8 *Buffer, Uint Count)
+{
+ Uint32 val;
+ int i;
+ for( i = 0; i < Count; i++ )
+ {
+ if( Buffer[i] == 0x1B ) // Escape Sequence
+ {
+ i ++;
+ i += VT_int_ParseEscape(Term, (char*)&Buffer[i]);
+ continue;
+ }
+
+ if( Buffer[i] < 128 ) // Plain ASCII
+ VT_int_PutChar(Term, Buffer[i]);
+ else { // UTF-8
+ i += ReadUTF8(&Buffer[i], &val);
+ VT_int_PutChar(Term, val);
+ }
+ }
+ // Update Screen
+ VT_int_UpdateScreen( Term, 0 );
+
+ // Update cursor
+ if( Term == gpVT_CurTerm && !(Term->Flags & VT_FLAG_HIDECSR) )
+ {
+ tVideo_IOCtl_Pos pos;
+ pos.x = Term->WritePos % Term->Width;
+ pos.y = Term->WritePos / Term->Width;
+ VFS_IOCtl(giVT_OutputDevHandle, VIDEO_IOCTL_SETCURSOR, &pos);
+ }
+}
+
/**
* \fn void VT_int_PutChar(tVTerm *Term, Uint32 Ch)
* \brief Write a single character to a VTerm
{
case '\0': return; // Ignore NULL byte
case '\n':
+ VT_int_UpdateScreen( Term, 0 ); // Update the line before newlining
Term->WritePos += Term->Width;
case '\r':
Term->WritePos -= Term->WritePos % Term->Width;
//LOG("Scrolled screen");
VT_int_UpdateScreen( Term, 1 );
}
- else
- VT_int_UpdateScreen( Term, 0 );
//LEAVE('-');
}