2024-02-15 01:15:55 +00:00
|
|
|
#include "pc_stuff.h"
|
|
|
|
|
|
|
|
#define INPUT_STATUS (0x03da)
|
|
|
|
#define VBLANK (0x08)
|
|
|
|
#define BIOS_SET_VIDEO_MODE (0x00)
|
|
|
|
|
|
|
|
byte *VGA = (byte *)0xA0000;
|
|
|
|
|
|
|
|
void setVideoMode(byte videoMode) {
|
|
|
|
union REGS regs;
|
|
|
|
|
|
|
|
regs.h.ah = BIOS_SET_VIDEO_MODE;
|
|
|
|
regs.h.al = videoMode;
|
|
|
|
int386(BIOS_VIDEO_INTERRUPT, ®s, ®s);
|
|
|
|
}
|
|
|
|
|
|
|
|
void waitStartVbl() {
|
|
|
|
while (inp(INPUT_STATUS) & VBLANK);
|
|
|
|
}
|
|
|
|
|
|
|
|
void waitEndVbl() {
|
|
|
|
while (!(inp(INPUT_STATUS) & VBLANK));
|
|
|
|
}
|
2024-02-20 11:48:12 +00:00
|
|
|
|
|
|
|
#define FAILSAFE (80)
|
|
|
|
|
|
|
|
void writeString(char *buffer, int x, int y) {
|
|
|
|
union REGS regs;
|
|
|
|
|
|
|
|
int i, currentX = x;
|
|
|
|
char c;
|
|
|
|
|
|
|
|
for (i = 0; i < FAILSAFE; ++i) {
|
|
|
|
c = buffer[i];
|
|
|
|
if (c == 0) break;
|
|
|
|
|
|
|
|
regs.h.ah = 0x02;
|
|
|
|
regs.h.bh = 0x00;
|
|
|
|
regs.h.dh = y;
|
|
|
|
regs.h.dl = currentX;
|
|
|
|
int386(BIOS_VIDEO_INTERRUPT, ®s, ®s);
|
|
|
|
|
|
|
|
regs.h.ah = 0x09;
|
|
|
|
regs.h.al = c;
|
|
|
|
regs.h.bh = 0x00;
|
|
|
|
regs.h.bl = 1;
|
|
|
|
regs.w.cx = 1;
|
|
|
|
int386(BIOS_VIDEO_INTERRUPT, ®s, ®s);
|
|
|
|
|
|
|
|
currentX++;
|
|
|
|
}
|
|
|
|
}
|