-
Notifications
You must be signed in to change notification settings - Fork 0
/
bonus.c
executable file
·219 lines (192 loc) · 8.61 KB
/
bonus.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
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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*****************************************************************************/
/* File Info : */
/* ----------- */
/* Nome File : bonus.c */
/* Dimensioni : 8794 bytes */
/* Data Ultima Modifica : Domenica 28 Maggio 2000 - 17:17 */
/* Autore : Esposito Gianluca (Matr.Num.056/100858) */
/* Breve Descrizione : Valori di colore dei pixel relativi ai bonus e */
/* funzioni per il loro disegno a video. */
/*****************************************************************************/
#define BONUS_TYPE 9
#define BONUS_X 16
#define BONUS_Y 8
#define LASER_X 5
#define LASER_Y 6
#define MAP_OBJECT 224
/* ------------- */
/* Counter Limit */
/* ------------- */
#define SPEED_CHANGE 6000
#define REVERSE_TIME 3000
#define LASER_TIME 2000
#define INT_LIMIT 32767
#define KILLEDLASER 0
#define OFF 0
int ball_lock;
int multiball = OFF;
int ballingame = 1;
int laserflag = OFF;
int xlaser = KILLEDLASER;
float ylaser = KILLEDLASER;
int lasercounter = 0;
int laserfired = OFF;
int reverseflag = OFF;
int reversecounter = 0;
enum bonus_type {
NB, /* Nessun Bonus */
LIVES, /* Aggiunge 1 Credit */
LASER, /* Abilita il laser */
BALL_LOCK, /* Blocca la pallina */
MULTI_BALL, /* 3 palline contemporaneamente */
EXTEND, /* Estende la barra */
REDUCE, /* Riduce la barra */
SPEED_DOWN, /* Riduce la velocita' della pallina */
REVERSE /* Inverte i controlli */
};
struct bonus {
int x;
float y;
int touched; /* Flag di controllo di scoperta del bonus */
int type;
int permission; /* Flag di permesso di caduta del bonus */
} Bonus[MAP_OBJECT];
/* ---------------------------------------- */
/* Pixel Map relative ai vari tipi di bonus */
/* ---------------------------------------- */
int BonusImg[BONUS_TYPE][BONUS_Y][BONUS_X] = {
/* "NULL BONUS" (NB in enum) */
{
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
{ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
},
/* "Lives" Pixel Map */
{
{ 0, 0, 2, 3, 3, 3, 3, 2, 4, 3, 3, 3, 2, 2, 0, 0},
{ 0, 3, 4, 6, 7, 15, 15, 15, 15, 15, 2, 5, 4, 4, 2, 0},
{ 2, 4, 5, 7, 8, 15, 15, 2, 6, 15, 15, 2, 5, 5, 4, 2},
{ 3, 4, 6, 7, 7, 15, 15, 2, 6, 15, 15, 2, 4, 4, 4, 2},
{ 3, 4, 6, 7, 6, 15, 15, 15, 15, 15, 2, 4, 4, 4, 4, 2},
{ 2, 4, 5, 6, 5, 15, 15, 2, 5, 4, 4, 4, 4, 4, 4, 2},
{ 0, 3, 4, 5, 6, 15, 15, 2, 5, 4, 4, 4, 4, 4, 2, 0},
{ 0, 0, 2, 2, 2, 2, 2, 2, 4, 2, 2, 2, 2, 2, 0, 0}
},
/* "Laser" Pixel Map */
{
{ 0, 0, 51, 52, 52, 52, 52, 50, 54, 52, 52, 52, 51, 50, 0, 0},
{ 0, 52, 54, 57, 58, 15, 15, 2, 58, 56, 56, 55, 54, 54, 51, 0},
{ 51, 54, 56, 58, 60, 15, 15, 2, 57, 55, 55, 55, 55, 55, 54, 50},
{ 52, 54, 57, 58, 58, 15, 15, 2, 57, 54, 55, 54, 54, 54, 54, 51},
{ 52, 54, 57, 58, 57, 15, 15, 2, 56, 54, 54, 54, 54, 54, 53, 51},
{ 51, 54, 55, 57, 55, 15, 15, 2, 56, 54, 54, 54, 54, 53, 53, 50},
{ 0, 52, 54, 55, 57, 15, 15, 15, 15, 15, 15, 2, 53, 53, 51, 0},
{ 0, 0, 50, 51, 51, 51, 51, 49, 53, 51, 51, 51, 51, 50, 0, 0}
},
/* "Ball Lock" Pixel Map */
{
{ 0, 0,243,244,244,244,244,242,246,244,244,244,243,242, 0, 0},
{ 0,244,246,249,250, 15, 2,246,250,248, 15, 2,246,246,243, 0},
{243,246,248,250,252, 15, 15, 2,249, 15, 15, 2,247,247,246,242},
{244,246,249,250,250, 15, 15, 15, 15, 15, 15, 2,246,246,246,243},
{244,246,249,250,249, 15, 15, 15, 15, 15, 15, 2,246,246,245,243},
{243,246,247,249,247, 15, 15, 2, 2, 15, 15, 2,246,245,245,242},
{ 0,244,246,247,249, 15, 15, 2, 2, 15, 15, 2,245,245,243, 0},
{ 0, 0,242,243,243,243,243,243,241,245,243,243,243,242, 0, 0}
},
/* "MultiBall" Pixel Map */
{
{ 0, 0,228,232,232,232,232,228,234,232,232,232,228,226, 0, 0},
{ 0,232,234,237,238, 15, 15, 15, 15, 15, 2,235,234,234,228, 0},
{228,234,236,238, 30, 15, 15, 2,237, 15, 15, 2,235,235,234,226},
{232,234,237,238,238, 15, 15, 2,237, 15, 15, 2,234,234,234,228},
{232,234,237,238,237, 15, 15, 2,236, 15, 15, 2,234,234,233,228},
{228,234,235,237,235, 15, 15, 2,236, 15, 15, 2,234,233,233,226},
{ 0,232,234,235,237, 15, 15, 15, 15, 15, 2,233,233,233,228, 0},
{ 0, 0,226,228,228,228,228,228,233,228,228,228,228,226, 0, 0}
},
/* "Extend" Pixel Map */
{
{ 0, 0, 19, 20, 20, 20, 20, 18, 22, 20, 20, 20, 19, 18, 0, 0},
{ 0, 20, 22, 25, 26, 15, 15, 15, 15, 15, 15, 2, 22, 22, 19, 0},
{ 19, 22, 24, 26, 28, 15, 15, 2, 25, 23, 23, 23, 23, 23, 22, 18},
{ 20, 22, 25, 26, 26, 15, 15, 15, 15, 2, 23, 22, 22, 22, 22, 19},
{ 20, 22, 25, 26, 26, 15, 15, 2, 24, 22, 22, 22, 22, 22, 21, 19},
{ 19, 22, 23, 25, 23, 15, 15, 2, 24, 22, 22, 22, 22, 21, 21, 18},
{ 0, 16, 22, 23, 25, 15, 15, 15, 15, 15, 15, 2, 21, 21, 19, 0},
{ 0, 0, 18, 19, 19, 19, 19, 17, 21, 19, 19, 19, 19, 18, 0, 0}
},
/* "Reduce" Pixel Map */
{
{ 0, 0,131,132,132,132,132,130,134,132,132,132,131,130, 0, 0},
{ 0,132,134,137,138, 15, 15, 15, 15, 15, 2,135,134,134,131, 0},
{131,134,136,138,140, 15, 15, 2,137, 15, 15, 2,135,135,134,130},
{132,134,137,138,138, 15, 15, 2,137, 15, 15, 2,134,134,134,131},
{132,134,137,138,137, 15, 15, 15, 15, 15, 2,134,134,134,133,131},
{131,134,135,137,135, 15, 15, 2,136, 15, 15, 2,134,133,133,130},
{ 0,132,134,135,137, 15, 15, 2,135, 15, 15, 2,133,133,131, 0},
{ 0, 0,130,131,131,131,131,129,133,131,131,131,131,130, 0, 0}
},
/* "Speed Down" Pixel Map */
{
{ 0, 0,147,148,148,148,148,146,150,148,148,148,147,146, 0, 0},
{ 0,148,150,153,154,152, 15, 15, 15, 15, 15, 2,150,150,147, 0},
{147,150,152,154,156, 15, 15, 2,153,151,151,151,151,151,150,146},
{148,150,153,154,154,153, 15, 15, 15, 15, 2,150,150,150,150,147},
{148,150,153,154,153,151,150,149,152, 15, 15, 2,150,150,149,147},
{147,150,151,153,151,151,151,148,152, 15, 15, 2,150,149,149,146},
{ 0,148,150,151,153, 15, 15, 15, 15, 15, 2,149,149,149,147, 0},
{ 0, 0,146,147,147,147,147,145,149,147,147,147,147,146, 0, 0}
},
/* "Reverse" Pixel Map */
{
{ 0, 0, 83, 84, 84, 84, 84, 82, 86, 84, 84, 84, 83, 82, 0, 0},
{ 0, 84, 86, 89, 90, 15, 15, 15, 15, 15, 0, 87, 87, 86, 83, 0},
{ 83, 86, 88, 90, 92, 15, 15, 0, 89, 15, 15, 0, 87, 87, 86, 82},
{ 84, 86, 89, 90, 90, 15, 15, 15, 15, 15, 0, 86, 86, 86, 86, 83},
{ 84, 86, 89, 90, 89, 15, 15, 0, 88, 15, 15, 0, 86, 86, 85, 83},
{ 83, 86, 87, 89, 87, 15, 15, 0, 88, 15, 15, 0, 86, 85, 85, 82},
{ 0, 84, 86, 87, 89, 15, 15, 15, 15, 15, 0, 85, 85, 85, 83, 0},
{ 0, 0, 82, 83, 83, 83, 83, 81, 85, 83, 83, 83, 83, 82, 0, 0}
}
};
int laser[LASER_Y][LASER_X] = {
{ 0, 35, 0 },
{35, 39, 35 },
{39, 37, 39 },
{37, 35, 37 },
{35, 32, 35 },
{32, 0, 32 }
};
void DrawBonus(int x, int y, int type, int mode);
void InitBonus(void);
void DrawBonus(int x, int y, int type, int mode)
/* Versione specifica della funzione DrawObject: */
/* i valori di colore dei pixel dei bonus sono contenuti in */
/* un array tridimensionale. */
{
int i,j;
for(j=0;j<BONUS_Y;j++) {
for(i=0;i<BONUS_X;i++) {
if(mode == OMBRA) vga_setcolor(0);
else if(mode == SOLID) vga_setcolor(BonusImg[type][j][i]);
vga_drawpixel(x+i, y+j);
}
}
}
void InitBonus(void)
{
int i;
for(i=0;i<MAP_OBJECT;i++) {
Bonus[i].x = -100;
Bonus[i].y = -100.0;
Bonus[i].touched = FALSE;
Bonus[i].type = NB;
Bonus[i].permission = FALSE;
}
}