Espresso 0.0.2a

This commit is contained in:
2026-02-12 20:33:46 -06:00
parent c0dc95e255
commit 021fdbbcef
26 changed files with 452 additions and 27315 deletions

View File

@ -18,6 +18,12 @@ void terminal_initialize(void)
terminal_update_cursor();
}
void terminal_get_cursor(int* row, int* column)
{
*row = (int) terminal_row;
*column = (int) terminal_column;
}
void terminal_initializec(uint8_t color)
{
terminal_row = 0;
@ -170,12 +176,15 @@ void terminal_writeline(const char* data)
void terminal_writechar_r(const char ch)
{
unsigned char uch = ch;
size_t saved_row = terminal_row;
size_t saved_col = terminal_column;
for (size_t i = 0; i < VGA_WIDTH; i++)
{
terminal_putchar(uch);
terminal_putentryat(ch, terminal_color, i, saved_row);
}
terminal_set_cursor(saved_row, saved_col);
}
void terminal_clear(void)
@ -185,46 +194,49 @@ void terminal_clear(void)
void terminal_clearl(size_t num_lines)
{
if (num_lines == (size_t) -1)
if (num_lines == (size_t)-1)
{
terminal_initializec(terminal_getcolor());
}
else
{
/* XXX note to self: VGA_HEIGHT is 25, and VGA_WIDTH is 80 XXX */
/* static size_t terminal_row; static size_t terminal_column; */
terminal_row = VGA_HEIGHT;
terminal_column = 0;
while (terminal_row < num_lines)
if (num_lines > VGA_HEIGHT)
{
for (int32_t k = 0; k < (int32_t)VGA_WIDTH; k++)
{
terminal_putentryat((unsigned char)' ', terminal_getcolor(), (size_t)terminal_row, (size_t)k);
}
terminal_row -= 1;
num_lines = VGA_HEIGHT;
}
size_t start = VGA_HEIGHT - num_lines;
for (size_t y = start; y < VGA_HEIGHT; y++)
{
for (size_t x = 0; x < VGA_WIDTH; x++)
{
terminal_putentryat(' ', terminal_getcolor(), x, y);
}
}
terminal_set_cursor(start, 0);
}
}
void terminal_scroll(void)
{
memmove(
terminal_buffer,
terminal_buffer + VGA_WIDTH,
sizeof(uint16_t) * VGA_WIDTH * (VGA_HEIGHT/* + 1*/)
sizeof(uint16_t) * VGA_WIDTH * (VGA_HEIGHT - 1)
);
terminal_row = VGA_HEIGHT - 1;
for (int32_t k = 0; k < (int32_t)VGA_WIDTH; k++)
for (int32_t x = 0; x < (int32_t)VGA_WIDTH; x++)
{
terminal_putentryat((unsigned char)' ', terminal_getcolor(), (size_t)terminal_row, (size_t)k);
terminal_putentryat(' ', terminal_getcolor(), (size_t)x, (size_t)terminal_row);
}
terminal_column = 0;
terminal_update_cursor();
}
unsigned char terminal_get_shifted(unsigned char uc)
{
unsigned char lowerc[] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '\0' };