From d67095d0b91873967843394eb090f13e847c1e2d Mon Sep 17 00:00:00 2001 From: John Tsiombikas Date: Sat, 19 Nov 2022 11:01:07 +0200 Subject: [PATCH] foo --- kern/src/disp.c | 68 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 64 insertions(+), 4 deletions(-) diff --git a/kern/src/disp.c b/kern/src/disp.c index f6e9014..e5fbd9a 100644 --- a/kern/src/disp.c +++ b/kern/src/disp.c @@ -1,6 +1,10 @@ #include "disp.h" +#include "asmutil.h" static void detect_video(void); +static int detect_vgainfo(void); +static int detect_egainfo(void); +static void detect_eqlist(void); struct console con_disp = { clear_disp, disp_putc, 0 }; @@ -26,9 +30,7 @@ static void detect_video(void) if(detect_egainfo() == 0) { goto done; } - if(detect_eqlist() == 0) { - goto done; - } + detect_eqlist(); done: vmem = mono ? MK_FP(0xb000, 0) : MK_FP(0xb800, 0); @@ -99,6 +101,64 @@ static int detect_egainfo(void) return 0; } -static int detect_eqlist(void) +static void detect_eqlist(void) +{ + union regs regs; + + int86(0x11, ®s, ®s); + switch(regs.w.ax & 0x30) { + case 0: + disp_type = DISP_EGA; + break; + + case 0x10: + case 0x20: + disp_type = DISP_CGA; + break; + + case 0x30: + disp_type = DISP_MDA; + mono = 1; + break; + } +} + +void clear_disp(void) +{ +} + +void scroll_disp(int line) { } + +void set_cursor(int x, int y) +{ + cur_x = x; + cur_y = y; +} + +void set_fgcolor(int color) +{ + cur_attr = (cur_attr & 0xf0) | color; +} + +void set_bgcolor(int color) +{ + cur_attr = (cur_attr & 0x0f) | (color << 4); +} + +void draw_glyph(int x, int y, int c, int attr) +{ + vmem[y * 80 + x] = (uint16_t)c | ((uint16_t)attr << 8); +} + +void draw_text(int x, int y, const char *s, int attr) +{ + uint16_t __far *ptr = vmem + y * 80 + x; + + while(*s) { + *ptr++ = (uint16_t)*s++ | ((uint16_t)attr << 8); + } +} + + -- 1.7.10.4