10,29 → 10,51 |
#include <dos.h> |
#include "video.h" /* include self for control */ |
|
/* pointers to VGA/MDA screens */ |
static unsigned short far *vga = (unsigned short far *)0xB8000000L; |
static unsigned short far *mda = (unsigned short far *)0xB0000000L; |
/* pointer to the VGA/MDA screen */ |
static unsigned short far *scr = (unsigned short far *)0xB8000000L; |
|
void video_clear(unsigned short attr, int offset) { |
int x; |
for (x = offset; x < 2000; x++) { |
vga[x] = attr; |
mda[x] = attr; |
scr[x] = attr; |
} |
} |
|
/* inits screen, returns 0 for color mode, 1 for mono */ |
int video_init(void) { |
union REGS r; |
int monoflag; |
/* get current video mode to detect color (7 = mono, anything else is color) */ |
r.h.ah = 0x0F; |
int86(0x10, &r, &r); |
/* set the monoflag to detected value and prepare the next mode we will set */ |
if (r.h.al == 7) { |
monoflag = 1; |
r.h.al = 7; /* 80x25 2 colors (MDA / Hercules) */ |
scr = (unsigned short far *)0xB0000000L; |
} else if (r.h.al == 2) { /* 80x25 grayscale */ |
monoflag = 1; |
r.h.al = 2; /* 80x25 grayscale */ |
scr = (unsigned short far *)0xB8000000L; |
} else { |
monoflag = 0; |
r.h.al = 3; /* 80x25 16 colors */ |
scr = (unsigned short far *)0xB8000000L; |
} |
/* (re)set video mode to be sure what we are dealing with */ |
r.h.ah = 0; |
int86(0x10, &r, &r); |
return(monoflag); |
} |
|
void video_putchar(int y, int x, unsigned short attr, int c) { |
int offset = (y << 6) + (y << 4) + x; |
vga[offset] = attr | c; |
mda[offset] = attr | c; |
scr[(y << 6) + (y << 4) + x] = attr | c; |
} |
|
void video_putcharmulti(int y, int x, unsigned short attr, int c, int repeat, int step) { |
int offset = (y << 6) + (y << 4) + x; |
while (repeat-- > 0) { |
vga[offset] = attr | c; |
mda[offset] = attr | c; |
scr[offset] = attr | c; |
offset += step; |
} |
} |
40,10 → 62,7 |
void video_putstring(int y, int x, unsigned short attr, char *s) { |
x += (y << 6) + (y << 4); /* I use x as an offset now */ |
while (*s != 0) { |
unsigned short b = attr | *s; |
vga[x] = b; |
mda[x] = b; |
x++; |
scr[x++] = attr | *s; |
s++; |
} |
} |
51,12 → 70,8 |
void video_putstringfix(int y, int x, unsigned short attr, char *s, int w) { |
x += (y << 6) + (y << 4); /* I use x as an offset now */ |
while (w-- > 0) { |
unsigned short b; |
b = attr | *s; |
scr[x++] = attr | *s; |
if (*s != 0) s++; |
vga[x] = b; |
mda[x] = b; |
x++; |
} |
} |
|