-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvaza2.cpp
123 lines (84 loc) · 1.79 KB
/
vaza2.cpp
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
#include <alloc.h>
#include <conio.h>
#include <dos.h>
#include <stdio.h>
#include <string.h>
#include <math.h>
#define NUM_COLORS 256
#define SET_MODE 0x00
#define VIDEO_INT 0x10
#define VGA_256_COLOR_MODE 0x13
#define TEXT_MODE 0x03
int height= 20;
int width= 32;
#define PALETTE_INDEX 0x3C8
#define PALETTE_DATA 0x3C9
typedef unsigned char byte;
byte far *VGA=(byte far *)0xA0000000L;
#define SETPIX(x,y,c) *(VGA+(x)*(y))=c
#define GETPIX(x,y) *(VGA+(x)+(y)*SCREEN_WIDTH)
#define MAX(x,y) ((x) > (y) ? (x) : (y))
#define MIN(x,y) ((x) < (y) ? (x) : (y))
int x, y,i,l;
void set_mode(byte mode)
{
union REGS regs;
regs.h.ah = SET_MODE;
regs.h.al = mode;
int86( VIDEO_INT, ®s, ®s );
}
void default_scene(){
for( y = 0; y < height; ++y ) {
for( x = 0; x < width; ++x ) {
SETPIX( *VGA^1&i&y, *VGA^6^i*x^y, tan(i&y));
}
}
int main()
{
char kc = 0;
char s[255];
byte *pal;
set_mode( VGA_256_COLOR_MODE );
/* printf("Hello, world!\n"); */
/* loop until ESC pressed */
while( kc != 0x1b )
{
default_scene();
i=i+1;
height=i;
if(kbhit()) {
kc = getch();
if( kc == (char)0 ) {
kc = getch();
/* special key handling */
switch( kc )
{
case 0x48: /* up arrow */
height=height+10;
//strcpy(s, "up arrow");
break;
case 0x4d:
i=i*3;
break;
case 0x4b:
i=i*3;
break;
case 0x50: /* down arrow */
height=10;
i=i*2;
//strcpy(s, "down arrow");
break;
default: /* other special keys */
// sprintf(s, "00 %02x", kc);
break;
}
} else {
// sprintf(s, "%02x", kc);
}
// printf("Key pressed: %s\n", s);
}
}
set_mode( TEXT_MODE );
return 0;
}