Various DOS related functions (2002)

This commit is contained in:
kougyokugentou 2021-10-24 16:14:48 -07:00
parent d671237f78
commit af5f8e9bff
1 changed files with 61 additions and 0 deletions

61
demos/dosfuncs.h Normal file
View File

@ -0,0 +1,61 @@
#include <dos.h>
#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,&regs,&regs);
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,&regs,&regs);
}
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,&regs,&regs);
}
void prnstring(char *string)
{
while(*string) //while there's a char to print
prnchar(*string++); //print it and increment
}