From 21491514b3642a321ce65f2a07428f63c4d9feb5 Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Sun, 8 Nov 2020 11:11:49 -0500 Subject: manual viewer, "swap colors" system call --- src/kernel/idt.c | 3 ++- src/kernel/isrs.asm | 2 +- src/kernel/vga.c | 5 +++++ src/kernel/vga.h | 1 + 4 files changed, 9 insertions(+), 2 deletions(-) (limited to 'src/kernel') diff --git a/src/kernel/idt.c b/src/kernel/idt.c index 1b8e548..ebeea17 100644 --- a/src/kernel/idt.c +++ b/src/kernel/idt.c @@ -120,7 +120,8 @@ void const *syscall_table[] = { &vga_print_at, &sc_count_of_dir, &vga_blank, - &vga_set_color + &vga_set_color, + &vga_swap_color }; //these aren't really void ()'s, but gcc complains if we take an address of a void, so we give it a type diff --git a/src/kernel/isrs.asm b/src/kernel/isrs.asm index e7573ae..472bb40 100644 --- a/src/kernel/isrs.asm +++ b/src/kernel/isrs.asm @@ -23,7 +23,7 @@ extern on_kbd_isr extern make_sure_tasks extern exception_halt -n_syscalls equ 0xf +n_syscalls equ 0x10 ;section .bss ;_debug_is_start_task resb 1 diff --git a/src/kernel/vga.c b/src/kernel/vga.c index 42da312..6ae1588 100644 --- a/src/kernel/vga.c +++ b/src/kernel/vga.c @@ -12,6 +12,11 @@ void vga_set_color(uint8_t new_color) { mask = new_color << 8; } +void vga_swap_color(uint16_t pos) { + uint8_t *color_byte = (uint8_t *)(VGA_START + (pos >> 8) * VGA_COLUMNS + (pos & 0xff)) + 1; + *color_byte = (*color_byte << 4) + (*color_byte >> 4); +} + static void vga_scroll() { for (uint32_t *i = (uint32_t *)VGA_START; i < (uint32_t *)(VGA_END - VGA_COLUMNS); ++i) *i = *(i + VGA_COLUMNS / 2); diff --git a/src/kernel/vga.h b/src/kernel/vga.h index fa97e11..dd1c906 100644 --- a/src/kernel/vga.h +++ b/src/kernel/vga.h @@ -7,5 +7,6 @@ void vga_print_at(uint16_t pos, const char *sz); void vga_set_color(uint8_t color); void vga_blank(); void vga_printch(char ch); +void vga_swap_color(uint16_t pos); #endif \ No newline at end of file -- cgit v1.2.3