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
| | /* ======================================================================= */
/* SCREEN.CPP */
/* ======================================================================= */
#include "stdio.h"
#include "stdlib.h"
#include "dos.h"
#include "screen.h"
/* ----------------------------------------------------------------------- */
/* Cursor Position and Screen Buffering Functions */
/* ----------------------------------------------------------------------- */
unsigned char cursor_x, cursor_y;
static union REGS regs;
void goto_xy(unsigned char x, unsigned char y)
{
regs.h.ah = 2;
regs.h.bh = 0;
regs.h.dh = y;
regs.h.dl = x;
int86(0x10, ®s, ®s);
}
void hide_cursor(void)
{
goto_xy(0, NUM_ROWS);
}
void cursor_position(void)
{
regs.h.ah = 3;
regs.h.bh = 0;
int86(0x10, ®s, ®s);
cursor_x = regs.h.dl;
cursor_y = regs.h.dh;
}
void clear_screen(void)
{
unsigned int i, j;
char far *p;
p = SCREEN_START;
for (i = 0; i < NUM_ROWS; i++)
for (j = 0; j < 80; j++)
{
*p++ = ' ';
*p++ = LIGHTGRAY;
}
}
void write_xyc(int x, int y, char c)
{
char far *p;
p = SCREEN_FP(x, y);
*p++ = c;
*p = LIGHTGRAY;
}
|