1 /* ======================================================================= */
2 /*                                SCREEN.CPP                               */
3 /* ======================================================================= */
4 
5 #include "stdio.h"
6 #include "stdlib.h"
7 #include "dos.h"
8 
9 #include "screen.h"
10 
11 /* ----------------------------------------------------------------------- */
12 /*              Cursor Position and Screen Buffering Functions             */
13 /* ----------------------------------------------------------------------- */
14 
15 unsigned char cursor_x, cursor_y;
16 static union REGS regs;
17 
goto_xy(unsigned char x,unsigned char y)18 void goto_xy(unsigned char x, unsigned char y)
19     {
20     regs.h.ah = 2;
21     regs.h.bh = 0;
22     regs.h.dh = y;
23     regs.h.dl = x;
24     int86(0x10, &regs, &regs);
25     }
26 
hide_cursor(void)27 void hide_cursor(void)
28     {
29     goto_xy(0, NUM_ROWS);
30     }
31 
cursor_position(void)32 void cursor_position(void)
33     {
34     regs.h.ah = 3;
35     regs.h.bh = 0;
36     int86(0x10, &regs, &regs);
37     cursor_x = regs.h.dl;
38     cursor_y = regs.h.dh;
39     }
40 
clear_screen(void)41 void clear_screen(void)
42     {
43     unsigned int i, j;
44     char far *p;
45 
46     p = SCREEN_START;
47     for (i = 0; i < NUM_ROWS; i++)
48         for (j = 0; j < 80; j++)
49             {
50             *p++ = ' ';
51             *p++ = LIGHTGRAY;
52             }
53     }
54 
write_xyc(int x,int y,char c)55 void write_xyc(int x, int y, char c)
56     {
57     char far *p;
58 
59     p = SCREEN_FP(x, y);
60     *p++ = c;
61     *p = LIGHTGRAY;
62     }
63