-
Notifications
You must be signed in to change notification settings - Fork 46
/
Copy pathansiload.c
71 lines (55 loc) · 1.31 KB
/
ansiload.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/*
** ANSILOAD.C - tries to detect if an ANSI-style driver is loaded
**
** public domain by Bob Jarvis
*/
#include <stdio.h>
#include <dos.h>
#include "sniptype.h"
#include "ansiload.h"
static 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);
}
static 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;
}
#ifdef TEST
main()
{
if(is_ansi_loaded())
puts("ANSI.SYS is loaded");
else puts("ANSI.SYS is NOT loaded");
return 0;
}
#endif /* TEST */