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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
|
/*------------------------------[ vhdw.c ]-----------------------------*/
/* Hardware Interface Routines */
/*---------------------------------------------------------------------
/*---------------------------------------------------------------------*/
/* This code is a subset of a library copyrighted by Jeff Dunlop. */
/* License is hereby granted for unrestricted use. */
/*---------------------------------------------------------------------*/
/*---------------------------------------------------------------------*/
/* dv_info: get video and version info about DesqView */
/* get_rows: determine number of rows on screen */
/* get_cols: determine number of columns on screen */
/* get_vidpage: determine the current text mode video page */
/* get_vidbase: determine the base of video ram */
/* is_dv: determine if DesqView is loaded */
/* is_egavga: determine if monitor is ega/vga */
/*---------------------------------------------------------------------*/
/*--------------------------------------------------------------*/
/*-----------------------[ include files ]----------------------*/
/*--------------------------------------------------------------*/
#include <dos.h>
#ifndef MK_FP
#define MK_FP(seg,offset) \
((void _far *)(((unsigned long)(seg)<<16) | (unsigned)(offset)))
#endif
typedef struct
{
int ver_major;
int ver_minor;
unsigned regen_buf;
int win_rows;
int win_cols;
} DV_INFO;
/*------------------------[ get_vidpage ]-----------------------*/
/* Determine the current text mode video page */
/*--------------------------------------------------------------*/
/* local: */
/* regs = register storage buffer */
/* return: */
/* video page number as determined by bios call */
/*--------------------------------------------------------------*/
unsigned char get_vidpage(void)
{
union REGS regs;
regs.h.ah = 0x0f;
int86(0x10, ®s, ®s);
return regs.h.bh;
}
/*---------------------------[ is_dv ]--------------------------*/
/* Determine whether DesqView is active */
/*--------------------------------------------------------------*/
int is_dv(void)
{
union REGS regs;
regs.h.ah = 0x2b;
regs.x.cx = 0x4445; /* 'DE' */
regs.x.dx = 0x5351; /* 'SQ' */
regs.h.al = 1; /* get version */
int86(0x21, ®s, ®s);
return regs.h.al != 0xff;
}
/*--------------------------[ dv_info ]-------------------------*/
/* Return screen and version info about DesqView */
/*--------------------------------------------------------------*/
/* return: */
/* -1 on error */
/*--------------------------------------------------------------*/
int get_dvinfo(DV_INFO *dv_info)
{
union REGS regs;
regs.h.ah = 0x2b;
regs.x.cx = 0x4445; /* 'DE' */
regs.x.dx = 0x5351; /* 'SQ' */
regs.h.al = 1; /* get version */
int86(0x21, ®s, ®s);
if (regs.h.al == 0xff)
return -1;
dv_info->ver_major = regs.h.bh;
dv_info->ver_minor = regs.h.bl;
regs.h.al = 4; /* get screen info */
int86(0x21, ®s, ®s);
if (regs.h.al == 0xff)
return -1;
dv_info->regen_buf = regs.x.dx;
dv_info->win_rows = regs.h.bh;
dv_info->win_cols = regs.h.bl;
return 0;
}
/*------------------------[ get_vidbase ]-----------------------*/
/* Determine the base of video ram */
/*--------------------------------------------------------------*/
/* local: */
/* regs = register union for ISR */
/* return: */
/* the current text base segment */
/*--------------------------------------------------------------*/
unsigned get_vidbase(void)
{
union REGS regs;
DV_INFO dv_info;
if (is_dv() && get_dvinfo(&dv_info) != -1)
return dv_info.regen_buf;
else
{
regs.h.ah = 0xf;
int86(0x10, ®s, ®s);
if (regs.h.al == 7)
return 0xb000;
else
return 0xb800;
}
}
/*-------------------------[ get_rows ]-------------------------*/
/* Determine the number of rows in current text mode screen */
/*--------------------------------------------------------------*/
int is_egavga(void);
int get_rows(void)
{
DV_INFO dv_info;
char far *p = MK_FP(0x40, 0x84);
if (is_dv() && get_dvinfo(&dv_info) != -1)
return dv_info.win_rows;
else
return *p + is_egavga();
}
/*-------------------------[ get_cols ]-------------------------*/
/* Determine the number of columns in current text screen */
/*--------------------------------------------------------------*/
int get_cols(void)
{
DV_INFO dv_info;
int far *p = MK_FP(0x40, 0x4a);
if (is_dv() && get_dvinfo(&dv_info) != -1)
return dv_info.win_cols;
else
return *p;
}
/*-------------------------[ is_egavga ]------------------------*/
/* Determine whether the current text mode is ega/vga */
/*--------------------------------------------------------------*/
int is_egavga(void)
{
union REGS regs;
regs.h.ah = 0x1a;
regs.h.al = 0;
int86(0x10, ®s, ®s);
return regs.h.al == 0x1a;
}
|