Skip to content
Snippets Groups Projects
Commit 8e36781e authored by y2-shaffan's avatar y2-shaffan
Browse files

Update file kernel.c

parent 2ab3eaf2
No related branches found
No related tags found
No related merge requests found
......@@ -79,6 +79,60 @@ void terminal_setcolor(uint8_t color) {
terminal_color = color;
}
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
if (y == VGA_HEIGHT) {
// Scroll the screen up one row
for (size_t i = 1; i < VGA_HEIGHT; i++) {
for (size_t j = 0; j < VGA_WIDTH; j++) {
terminal_buffer[(i - 1) * VGA_WIDTH + j] = terminal_buffer[i * VGA_WIDTH + j];
}
}
// Clear the last row
for (size_t x = 0; x < VGA_WIDTH; x++) {
terminal_buffer[(VGA_HEIGHT - 1) * VGA_WIDTH + x] = make_vgaentry(' ', color);
}
// Move the cursor to the last row
y = VGA_HEIGHT - 1;
}
const size_t index = y * VGA_WIDTH + x;
terminal_buffer[index] = make_vgaentry(c, color);
// Increment the cursor position
if (++x == VGA_WIDTH) {
x = 0;
if (++y == VGA_HEIGHT) {
y = 0;
}
}
terminal_row = y;
terminal_column = x;
}
void terminal_setcolor(uint8_t color) {
terminal_color = color;
}
void terminal_putentryat(char c, uint8_t color, size_t x, size_t y) {
if (y == VGA_HEIGHT) {
// Scroll the screen up one row
for (size_t i = 1; i < VGA_HEIGHT; i++) {
for (size_t j = 0; j < VGA_WIDTH; j++) {
terminal_buffer[(i - 1) * VGA_WIDTH + j] = terminal_buffer[i * VGA_WIDTH + j];
}
}
// Clear the last row
for (size_t x = 0; x < VGA_WIDTH; x++) {
terminal_buffer[(VGA_HEIGHT - 1) * VGA_WIDTH + x] = make_vgaentry(' ', color);
}
// Move the cursor to the last row
y = VGA_HEIGHT - 1;
}
const size_t index = y * VGA_WIDTH + x;
terminal_buffer[index] = make_vgaentry(c, color);
}
void terminal_putchar(char c) {
if (c == '\n') {
terminal_column = 0;
......@@ -98,6 +152,7 @@ void terminal_putchar(char c) {
}
}
void terminal_writestring(const char* data) {
size_t datalen = strlen(data);
for (size_t i = 0; i < datalen; i++)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment