forked from vonj/snippets.org
-
Notifications
You must be signed in to change notification settings - Fork 1
/
ansitest.c
94 lines (68 loc) · 2.69 KB
/
ansitest.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* *
* ANSITEST.C *
* *
* Demonstration of ANSICODE.H (includes ANSI detection) *
* *
* Donated to the public domain 96-11-12 by *
* Tom Torfs ([email protected], 2:292/516@fidonet) *
* *
* The ANSI detection in this module is not the usual method, *
* but unlike most of the other methods it allows detection *
* through a serial connection etc. (e.g. BBS software) *
* *
* This module requires DOSGETCH.ASM. *
* *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include <dos.h>
#include "ansicode.h"
#include "dosgetch.h"
int main(void)
{
int ch;
int x,y;
clock_t waitclock;
ANSI_report();
waitclock = clock() + CLK_TCK; /* wait at most 1 second */
do
ch = dosgetch();
while (ch==EOF && clock()<waitclock);
if (ch!=27 || scanf("[%d;%dR",&y,&x)!=2)
{
printf("No ANSI screen driver detected.\n");
return 1;
}
ANSI_attrcolor(ANSI_WHITE,ANSI_BLUE,ANSI_BOLD);
ANSI_cls();
ANSI_fgcolor(ANSI_RED);
printf("Very primitive ANSI screen I/O demonstration\n\n");
ANSI_fgcolor(ANSI_GREEN);
printf("The cursor position at startup was %d,%d.\n",x,y);
ANSI_fgcolor(ANSI_WHITE);
ANSI_locate(1,12);
printf("On a regular screen this should be about the middle.\n");
ANSI_down(2);
printf("And this is a few lines lower.\n");
ANSI_locate(1,25);
ANSI_attrib(ANSI_BLINK);
printf("Press any key to continue..."); /* no \n, don't want to scroll */
doswaitkey();
ANSI_videomode(ANSI_640x350x2);
ANSI_attrcolor(ANSI_WHITE,ANSI_BLACK,ANSI_NORMAL);
ANSI_cls();
printf("You like EGA 640x350x2 graphics mode ?\n\n");
printf("If not, press a key...\n");
doswaitkey();
ANSI_videomode(ANSI_80x25);
ANSI_attrcolor(ANSI_WHITE,ANSI_RED,ANSI_BOLD);
ANSI_cls();
printf("Aah that's better...\n\n");
printf("Press any key to exit...\n");
doswaitkey();
ANSI_attrcolor(ANSI_WHITE,ANSI_BLACK,ANSI_NORMAL);
ANSI_cls();
return 0;
}