From 5e7356f58e28193b5f791a8922abd4e81cf33ab3 Mon Sep 17 00:00:00 2001 From: Jarkko Toivanen Date: Fri, 22 Sep 2023 17:42:46 +0300 Subject: [PATCH] VGA driver deprecated --- src/vga.c | 97 ------------------------------------------------------- src/vga.h | 24 -------------- 2 files changed, 121 deletions(-) delete mode 100644 src/vga.c delete mode 100644 src/vga.h diff --git a/src/vga.c b/src/vga.c deleted file mode 100644 index bac204d..0000000 --- a/src/vga.c +++ /dev/null @@ -1,97 +0,0 @@ -#include "vga.h" -#define VGA_WIDTH 80 -#define VGA_HEIGHT 25 -#define VGA_MEM_ADDR 0xb8000 -#define CURSOR_HOME (VGA_HEIGHT-1)*VGA_WIDTH -#define CURSOR_CHR 177; - -unsigned int cursor_loc = CURSOR_HOME; -unsigned char fgcolor; -unsigned char bgcolor; -unsigned short blank; - -static unsigned char vga_entry_color(enum vga_color fg, enum vga_color bg) { - return fg | bg << 4; -} -unsigned short vga_blank_entry() { - return vga_entry_color(fgcolor, bgcolor) << 8; -} -void draw_cursor(void) { - *((unsigned char *)VGA_MEM_ADDR + cursor_loc * 2) = CURSOR_CHR; - *((unsigned char *)VGA_MEM_ADDR+1 + cursor_loc * 2) = vga_entry_color(fgcolor, bgcolor); -} - -void vga_set_color(enum vga_color fg, enum vga_color bg) { - fgcolor = fg; - bgcolor = bg; -} -void vga_init(enum vga_color fg, enum vga_color bg) { - vga_set_color(fg, bg); - blank = vga_blank_entry(); - cls(); -} -void cls(void) { - int i; - for (i=0; i= VGA_HEIGHT*VGA_WIDTH) { - scroll(); - } - draw_cursor(); -} - -void vga_write(const char* text) { - int i = 0; - while(text[i]) { - putchar(text[i]); - i++; - } -} -void vga_write_color( const char* text, enum vga_color fg, enum vga_color bg) { - unsigned char prevfg = fgcolor; - unsigned char prevbg = bgcolor; - vga_set_color(fg, bg); - vga_write(text); - fgcolor = prevfg; - bgcolor = prevbg; -} -void vga_write_line(const char* text) { - if (cursor_loc != CURSOR_HOME) { - scroll(); - } - vga_write(text); - scroll(); -} -void vga_write_line_color(const char* text, enum vga_color fg, enum vga_color bg) { - unsigned char prevfg = fgcolor; - unsigned char prevbg = bgcolor; - vga_set_color(fg, bg); - vga_write_line(text); - fgcolor = prevfg; - bgcolor = prevbg; -} diff --git a/src/vga.h b/src/vga.h deleted file mode 100644 index b2aa979..0000000 --- a/src/vga.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef HEADER_VGA -#define HEADER_VGA - -enum vga_color { - VGA_COLOR_BLACK = 0, - VGA_COLOR_BLUE = 1, - VGA_COLOR_GREEN = 2, - VGA_COLOR_CYAN = 3, - VGA_COLOR_RED = 4, - VGA_COLOR_MAGENTA = 5, - VGA_COLOR_ORANGE = 6, - VGA_COLOR_GREY = 7, - VGA_COLOR_GRAY = 7, -}; - -void cls(void); -void vga_init(enum vga_color fg, enum vga_color bg); - -void vga_write(const char* text); -void vga_write_color( const char* text, enum vga_color fg, enum vga_color bg); -void vga_write_line(const char* text); -void vga_write_line_color( const char* text, enum vga_color fg, enum vga_color bg); - -#endif