forked from elastomania/across
-
Notifications
You must be signed in to change notification settings - Fork 0
/
D_DD.CPP
178 lines (156 loc) · 3.07 KB
/
D_DD.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#include "all.h"
static void setpal( unsigned char* pal ) {
#ifndef DOS
outp( 0x3c8, 0 );
for( int i = 0; i < 768; i++ )
outp( 0x3c9, pal[i] );
#else
pal++;
hiba( "Itt nem szabadna lennie!" );
#endif
}
static int Resdd = 0;
ddpal::ddpal( unsigned char* tombp ) {
{ tomb = NEW(unsigned char*) unsigned char[768]; }
if( !tomb )
hiba( "memory ddpal-ban!" );
memcpy( tomb, tombp, 768 );
}
ddpal::~ddpal( void ) {
if( tomb )
DELETE tomb; }
}
void ddpal::set( void ) {
setpal( tomb );
}
static pic8* Ppicbuff = NULL;
void init_d_dd( void ) {
if( Ppicbuff )
hiba( "init_d_dd ketszer hivva!" );
{ Ppicbuff = NEW(pic8*) pic8( 320, 200 ); }
Resdd = 1;
}
unsigned char** lockbackbuffer( int* pxs, int* pys ) {
if( !Ppicbuff )
hiba( "lockbackbuffer init_d_dd hivasa nelkul!" );
*pxs = -1;
*pys = -1;
if( Resdd == 1 ) {
*pxs = 320;
*pys = 200;
}
if( Resdd == 2 ) {
*pxs = 320;
*pys = 240;
}
if( Resdd == 3 ) {
*pxs = 640;
*pys = 400;
}
if( Resdd == 4 ) {
*pxs = 640;
*pys = 480;
}
if( *pxs < 1 )
hiba( "unlockbackbuffer-ben fizxsize < 1!" );
return Ppicbuff->sormuttomb;
}
// Ki is teszi
void unlockbackbuffer( void ) {
if( !Ppicbuff )
hiba( "unlockbackbuffer init_d_dd hivasa nelkul!" );
int fizxsize = -1;
int fizysize = -1;
if( Resdd == 1 ) {
fizxsize = 320;
fizysize = 200;
}
if( Resdd == 2 ) {
fizxsize = 320;
fizysize = 240;
}
if( Resdd == 3 ) {
fizxsize = 640;
fizysize = 400;
}
if( Resdd == 4 ) {
fizxsize = 640;
fizysize = 480;
}
if( fizxsize < 1 )
hiba( "unlockbackbuffer-ben fizxsize < 1!" );
for( int y = 0; y < fizysize; y++ ) {
putline8_l( 0, y, Ppicbuff->sormuttomb[fizysize-y-1], fizxsize );
if( y == 220 )
hang();
}
if( fizysize < 390 )
return;
// torlendo: (interlace-elt kepkirakast demostralja):
/*unsigned char sor[110];
for( int i = 0; i < 100; i++ ) {
if( i > 20 )
sor[i] = 100;
else
sor[i] = 0;
}
while( 1 ) {
int dx = 2;
if( mk_kbhit() ) {
mk_getextchar();
hiba( "Vege!" );
}
int paros = 1;
for( int x = 0; x < 500; x += dx ) {
waitforcathode();
paros = !paros;
for( y = 0; y < 100; y += 2 ) {
if( y > 80 ) {
if( paros ) {
putline8_l( x, y+200, sor, 100 );
putline8_l( x, y+1+200, sor, 100 );
}
}
else {
if( paros )
putline8_l( x, y+200, sor, 100 );
else
putline8_l( x, y+1+200, sor, 100 );
}
}
}
}*/
}
// res: 1 -> 320x200, 3 -> 640x400, 4 -> 640x480:
void setresdd( int res ) {
if( res != 1 && res != 2 && res != 3 && res != 4 )
hiba( "setres-ben res != 1 && res != 2 && res != 3 && res != 4!" );
if( Resdd == res )
return;
Resdd = res;
int xsize = -1;
int ysize = -1;
if( Resdd == 1 ) {
xsize = 320;
ysize = 200;
}
if( Resdd == 2 ) {
xsize = 320;
ysize = 240;
}
if( Resdd == 3 ) {
xsize = 640;
ysize = 400;
}
if( Resdd == 4 ) {
xsize = 640;
ysize = 480;
}
if( xsize < 1 )
hiba( "setresdd-ben xsize < 1!" );
setmode8_l( Resdd );
if( !Ppicbuff )
hiba( "setresdd-ben !Ppicbuffer!" );
DELETE Ppicbuff; }
{ Ppicbuff = NEW(pic8*) pic8( xsize, ysize ); }
}