#include <tpl_drv_video.h>
#include <modules.h>
+// === CONSTANTS ===
+#define VGA_WIDTH 80
+#define VGA_HEIGHT 25
+
// === PROTOTYPES ===
int VGA_Install(char **Arguments);
Uint64 VGA_Write(tVFS_Node *Node, Uint64 Offset, Uint64 Length, void *Buffer);
int VGA_IOCtl(tVFS_Node *Node, int Id, void *Data);
Uint16 VGA_int_GetWord(tVT_Char *Char);
+void VGA_int_SetCursor(Sint16 x, Sint16 y);
// === GLOBALS ===
MODULE_DEFINE(0, 0x000A, VGA, VGA_Install, NULL, NULL);
NULL, "VGA",
{
.NumACLs = 0,
- .Size = 80*25*sizeof(tVT_Char),
+ .Size = VGA_WIDTH*VGA_HEIGHT*sizeof(tVT_Char),
//.Read = VGA_Read,
.Write = VGA_Write,
.IOCtl = VGA_IOCtl
case DRV_IOCTL_VERSION: *(int*)Data = 50; return 1;
case DRV_IOCTL_LOOKUP: return 0;
- case VIDEO_IOCTL_SETMODE: return 0; // Ignored (Text Only ATM)
case VIDEO_IOCTL_GETMODE: return 0; // Mode 0 only
+ case VIDEO_IOCTL_SETMODE: return 0; // Ignored (Text Only ATM)
case VIDEO_IOCTL_FINDMODE: return 0; // Text Only!
case VIDEO_IOCTL_MODEINFO:
if( ((tVideo_IOCtl_Mode*)Data)->id != 0) return 0;
- ((tVideo_IOCtl_Mode*)Data)->width = 80;
- ((tVideo_IOCtl_Mode*)Data)->height = 25;
+ ((tVideo_IOCtl_Mode*)Data)->width = VGA_WIDTH;
+ ((tVideo_IOCtl_Mode*)Data)->height = VGA_HEIGHT;
((tVideo_IOCtl_Mode*)Data)->bpp = 4;
return 1;
+ case VIDEO_IOCTL_SETCURSOR:
+ VGA_int_SetCursor( ((tVideo_IOCtl_Pos*)Data)->x, ((tVideo_IOCtl_Pos*)Data)->y );
+ return 1;
}
return 0;
}
return ret;
}
+
+/**
+ * \fn void VGA_int_SetCursor(Sint16 x, Sint16 y)
+ * \brief Updates the cursor position
+ */
+void VGA_int_SetCursor(Sint16 x, Sint16 y)
+{
+ int pos = x+y*VGA_WIDTH;
+ if(x == -1 || y == -1)
+ pos = -1;
+ outb(0x3D4, 14);
+ outb(0x3D5, pos >> 8);
+ outb(0x3D4, 15);
+ outb(0x3D5, pos);
+}
#define DEFAULT_HEIGHT 25
#define DEFAULT_COLOUR (VT_COL_BLACK|(VT_COL_WHITE<<16))
+#define VT_FLAG_HIDECSR 0x01
+
enum eVT_Modes {
VT_MODE_TEXT8, // UTF-8 Text Mode (VT100 Emulation)
VT_MODE_TEXT32, // UTF-32 Text Mode (Acess Native)
// === TYPES ===
typedef struct {
int Mode;
+ int Flags;
int Width, Height;
int ViewPos, WritePos;
Uint32 CurColour;
for( i = 0; i < NUM_VTS; i++ )
{
gVT_Terminals[i].Mode = VT_MODE_TEXT8;
+ gVT_Terminals[i].Flags = 0;
gVT_Terminals[i].Width = DEFAULT_WIDTH;
gVT_Terminals[i].Height = DEFAULT_HEIGHT;
gVT_Terminals[i].CurColour = DEFAULT_COLOUR;
//VT_int_PutString32(term, Buffer, Length);
break;
}
+
//LEAVE('i', 0);
return 0;
}
VT_int_PutChar(Term, val);
}
}
+
+ // Update cursor
+ if(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);
+ }
}
/**
VIDEO_IOCTL_FINDMODE,\r
//! \brief Get mode info - (tVideo_IOCtl_Mode *info)\r
VIDEO_IOCTL_MODEINFO,\r
+ //! \brief Sets the cursor position (tVideo_IOCtl_Pos *pos)\r
+ VIDEO_IOCTL_SETCURSOR,\r
//! \brief Request access to Framebuffer - (void *dest), Return Boolean Success\r
VIDEO_IOCTL_REQLFB\r
};\r
Uint16 height; //!< Height\r
Uint16 bpp; //!< Bits per Pixel\r
};\r
+struct sVideo_IOCtl_Pos {\r
+ Sint16 x;\r
+ Sint16 y;\r
+};\r
typedef struct sVideo_IOCtl_Mode tVideo_IOCtl_Mode; //!< Mode Type\r
+typedef struct sVideo_IOCtl_Pos tVideo_IOCtl_Pos; //!< Mode Type\r
\r
/**\r
* \struct sVT_Char\r