dos-vga-arena-shooter-game/system/pc_stuff.c
2024-02-21 08:25:55 -05:00

53 lines
947 B
C

#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, &regs, &regs);
}
void waitStartVbl() {
while (inp(INPUT_STATUS) & VBLANK);
}
void waitEndVbl() {
while (!(inp(INPUT_STATUS) & VBLANK));
}
#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, &regs, &regs);
regs.h.ah = 0x09;
regs.h.al = c;
regs.h.bh = 0x00;
regs.h.bl = 1;
regs.w.cx = 1;
int386(BIOS_VIDEO_INTERRUPT, &regs, &regs);
currentX++;
}
}