From 7e0f021a9aec35fd8e6725e87e3313b101d26f5e Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Sun, 27 Jan 2008 11:37:44 +0100 Subject: Initial import (2.0.2-6) --- reference/C/CONTRIB/SNIP/ansiload.c | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 reference/C/CONTRIB/SNIP/ansiload.c (limited to 'reference/C/CONTRIB/SNIP/ansiload.c') diff --git a/reference/C/CONTRIB/SNIP/ansiload.c b/reference/C/CONTRIB/SNIP/ansiload.c new file mode 100755 index 0000000..e4dadc0 --- /dev/null +++ b/reference/C/CONTRIB/SNIP/ansiload.c @@ -0,0 +1,66 @@ +/* +** ANSILOAD.C - tries to detect if an ANSI-style driver is loaded +** +** public domain by Bob Jarvis +*/ + +#include +#include + +typedef enum {FALSE, TRUE} LOGICAL; + +void goto_rc(int row, int col) +{ + union REGS regs; + + regs.h.ah = 2; + regs.h.bh = 0; /* assumes we're using video page 0 */ + regs.h.dh = (unsigned char)row; + regs.h.dl = (unsigned char)col; + + int86(0x10, ®s, ®s); +} + +void get_rc(int *row, int *col) +{ + union REGS regs; + + regs.h.ah = 3; + regs.h.bh = 0; /* again, assume video page 0 */ + + int86(0x10, ®s, ®s); + + *row = regs.h.dh; + *col = regs.h.dl; +} + +int is_ansi_loaded(void) +{ + int save_r, save_c; + int new_r, new_c; + int isloaded; + + get_rc(&save_r, &save_c); + goto_rc(15,15); + fputs("\x1B[0;0H", stderr); + + get_rc(&new_r, &new_c); + + if(new_r == 0 && new_c == 0) + isloaded = TRUE; + else + { + isloaded = FALSE; + fputs("\b\b\b\b\b\b \b\b\b\b\b\b", stderr); + } + + goto_rc(save_r, save_c); + return isloaded; +} + +void main(void) +{ + if(is_ansi_loaded()) + puts("ANSI.SYS is loaded"); + else puts("ANSI.SYS is NOT loaded"); +} -- cgit v1.2.3-54-g00ecf