hos/kernel/display.c

97 lines
1.8 KiB
C

// display.c
// Author: Josh Holtrop
// Date: 08/07/04
// Modified: 08/21/04
#include "fs/devices.h"
#include "char/vconsole.h"
#include "display.h"
#include "lang/lang.h"
int display_activeConsole = -1; // start with no active console
display_t myDisplays[12]; // f1-f12 change displays
// initialization routine for display subsystem
int display_init()
{
minor_t vc;
if ((vc = vconsole_new(80, 25)))
{
myDisplays[11].type = DISPLAY_CONSOLE;
myDisplays[11].id = vc;
display_activeConsole = vc;
}
int i;
for (i = 0; i < 6; i++)
{
if ((vc = vconsole_new(80, 25)))
{
myDisplays[i].type = DISPLAY_CONSOLE;
myDisplays[i].id = vc;
}
}
return 0;
}
// activate the given display
int display_activate(u32_t id)
{
if (id > 11)
return -1;
switch (myDisplays[id].type)
{
case DISPLAY_CONSOLE:
display_activeConsole = myDisplays[id].id;
return vconsole_draw(display_activeConsole);
case DISPLAY_GRAPHICAL:
default:
return -2;
}
}
// routine to refresh a console window
int display_console_draw(minor_t id, int cursorPosition, u16_t *buffer)
{
if (id == display_activeConsole)
{
int i;
for (i = 0; i < 12; i++)
{
if (myDisplays[i].id == id)
{
memcpyw((void *)CONSOLE_MEMORY, buffer, 2000);
writeCursorPosition(cursorPosition);
return 0;
}
}
}
return -1;
}
// write a character to the screen
int display_console_put_char(minor_t id, u16_t c, int position)
{
if (id == display_activeConsole)
{
*(u16_t *)(CONSOLE_MEMORY + (position << 1)) = c;
return 0;
}
return -1;
}
// move the cursor on the screen
int display_console_update_cursor(minor_t id, int cursorPosition)
{
if (id == display_activeConsole)
{
writeCursorPosition(cursorPosition);
return 0;
}
return -1;
}