From af5f8e9bff801e32977d6a50c79a1bd7cb60ad92 Mon Sep 17 00:00:00 2001 From: kougyokugentou <41278462+kougyokugentou@users.noreply.github.com> Date: Sun, 24 Oct 2021 16:14:48 -0700 Subject: [PATCH] Various DOS related functions (2002) --- demos/dosfuncs.h | 61 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) create mode 100644 demos/dosfuncs.h diff --git a/demos/dosfuncs.h b/demos/dosfuncs.h new file mode 100644 index 0000000..1c91f95 --- /dev/null +++ b/demos/dosfuncs.h @@ -0,0 +1,61 @@ +#include +#define VIDEO 0x10 //video interrupt +#define COLS 80 //screen width +#define ROWS 25 //screen rows +#define PRINTER 0x17 //BIOS printer interrupt +#define LPT1 0x00 //LPT1. your first printer +#define EJECT 0x0c //Eject page printer command + +void cls(void); +void locate(int col,int row); +void eject(void); +void prnchar(char c); +void prnstring(char *string); + +void cls(void) +{ + union REGS regs; + + regs.h.ah=0x06; //func 6, scroll window + regs.h.al=0x00; //clear screen + regs.h.bh=0x07; //make screen "blank" + regs.h.ch=0x00; //upper left row + regs.h.cl=0x00; //upper left column + regs.h.dh=ROWS-1; //lower right row + regs.h.dl=COLS-1; //lower right column + int86(VIDEO,®s,®s); + + locate(0,0); //"Home" the cursor +} + +void locate(int col,int row) +{ + union REGS regs; + + regs.h.ah=0x02; //vid func 2, move cursor + regs.h.bh=0x00; //video screen (always 0) + regs.h.dh=row; //cursor's row pos + regs.h.dl=col; //cursor's col pos + int86(VIDEO,®s,®s); +} + +void eject(void) +{ + prnchar(EJECT); +} + +void prnchar(char c) +{ + union REGS regs; + + regs.h.ah=0x00; //print character function + regs.h.al=c; //character to print + regs.x.dx=LPT1; //printer port to print to + int86(PRINTER,®s,®s); +} + +void prnstring(char *string) +{ + while(*string) //while there's a char to print + prnchar(*string++); //print it and increment +}