+++ /dev/null
-#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 };
-
-static uint16_t __far *vmem;
-static uint16_t cur_attr;
-static int cur_x, cur_y;
-static int cur_scroll;
-static int mono;
-
-void init_disp(void)
-{
- detect_video();
-}
-
-static void detect_video(void)
-{
- mono = 0;
- disp_type = DISP_UNK;
-
- if(detect_vgainfo() == 0) {
- goto done;
- }
- if(detect_egainfo() == 0) {
- goto done;
- }
- detect_eqlist();
-
-done:
- vmem = mono ? MK_FP(0xb000, 0) : MK_FP(0xb800, 0);
-}
-
-static int detect_vgainfo(void)
-{
- union regs regs;
-
- regs.w.ax = 0x1a00;
- int86(0x10, ®s, ®s);
- if(regs.h.al != 0x1a) {
- return -1;
- }
-
- switch(regs.h.bl) {
- case 1:
- disp_type = DISP_MDA;
- mono = 1;
- break;
- case 2:
- disp_type = DISP_CGA;
- break;
- case 4:
- disp_type = DISP_EGA;
- break;
- case 5:
- disp_type = DISP_EGA;
- mono = 1;
- break;
- case 6:
- disp_type = DISP_PGA;
- break;
- case 7:
- disp_type = DISP_VGA;
- mono = 1;
- break;
- case 8:
- disp_type = DISP_VGA;
- break;
- case 0xa:
- case 0xc:
- disp_type = DISP_MCGA;
- break;
- case 0xb:
- disp_type = DISP_MCGA;
- mono = 1;
- break;
- default:
- return -1;
- }
- return 0;
-}
-
-static int detect_egainfo(void)
-{
- union regs regs;
-
- regs.w.ax = 0x1200;
- regs.w.bx = 0xff10;
- int86(0x10, ®s, ®s);
- if(regs.h.bh == 0xff) {
- return -1;
- }
-
- disp_type = DISP_EGA;
- mono = regs.h.bh;
- return 0;
-}
-
-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);
- }
-}
-
-