-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathscreen.c
69 lines (51 loc) · 1.5 KB
/
screen.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
/*
Screen handling
*/
#include <conio.h>
static unsigned char screen_bgc;
static unsigned char screen_borderc;
static unsigned char screen_textc;
static unsigned char *spaces = " ";
/* initialize screen mode */
void InitScreen(unsigned char *title, unsigned char border, unsigned char bg, unsigned char text) {
screen_borderc = bordercolor(border);
screen_bgc = bgcolor(bg);
screen_textc = textcolor(text);
clrscr();
revers(1);
cprintf(title);
revers(0);
}
/* restore basic screen mode */
void ExitScreen(void) {
bordercolor(screen_borderc);
bgcolor(screen_bgc);
textcolor(screen_textc);
clrscr();
}
/* Draw petscii box */
void DrawBox(unsigned char xsize, unsigned char ysize, unsigned char xpos, unsigned char ypos) {
/* Top line */
gotoxy(xpos,ypos);
cputc(CH_ULCORNER);
chline(xsize - 2);
cputc(CH_URCORNER);
/* Vertical line, left side */
cvlinexy(xpos, ypos + 1, ysize - 2);
/* Bottom line */
cputc(CH_LLCORNER);
chline(xsize - 2);
cputc(CH_LRCORNER);
/* Vertical line, right side */
cvlinexy(xpos + xsize - 1, ypos + 1, ysize - 2);
}
/* Clear screen area */
void ClearBox(unsigned char xsize, unsigned char ysize, unsigned char xpos, unsigned char ypos) {
unsigned char *s;
unsigned char line;
s = spaces + 80 - xsize;
for (line = 0; line < ysize; ++line) {
gotoxy(xpos, ypos + line);
cprintf(s);
}
}