1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
7 // static char *VB_Name = "modZonk";
10 // ==========================================================================
12 // Animate Zonks (falling)
13 // ==========================================================================
15 int subAnimateZonks(int si)
22 // int ax, bx, cx, dx, di, X, Y;
24 // int ah, bh, ch, dh, al, bl, cl, dl;
27 tFld = PlayField16[si];
28 if ((tFld & 0xFF) != fiZonk)
29 return subAnimateZonks;
33 if (FreezeZonks == 2) // Do Zonks fall? (debug)
34 return subAnimateZonks;
36 ax = PlayField16[si + FieldWidth]; // select case playfield16(si+60)
49 return subAnimateZonks;
51 loc_g_0D35: // Case fiZonk, fiInfotron, fiRAM
52 ax = PlayField16[si + FieldWidth - 1];
53 if (ax == 0 || ax == 0x8888 || ax == 0xAAAA)
57 ax = PlayField16[si + FieldWidth + 1];
58 if (ax == 0 || ax == 0x8888 || ax == 0xAAAA)
61 return subAnimateZonks;
63 loc_g_0D64: // Case fiSpace
64 MovHighByte(&PlayField16[si], 0x40);
67 loc_g_0D6B: // roll left?
68 if (PlayField16[si - 1] == 0)
74 MovHighByte(&PlayField16[si], 0x50);
75 PlayField16[si - 1] = 0x8888;
78 loc_g_0D81: // roll right?
79 if (PlayField16[si + 1] == 0)
82 if (PlayField16[si + 1] != 0x9999) // wow right is different from left!
83 return subAnimateZonks;
85 if (LowByte(PlayField16[si - FieldWidth + 1]) != 1)
86 return subAnimateZonks;
89 MovHighByte(&PlayField16[si], 0x60);
90 PlayField16[si + 1] = 0x8888;
94 // from now on the zonk is definitely moving,
95 // maybe the sequence is in an advanced frame
96 // or just beeing initialized due to the code above
97 bl = HighByte(PlayField16[si]);
101 if (al == 0x10) // zonk comes falling from above
104 if (al == 0x20) // zonk comes rolling from right to left
107 if (al == 0x30) // zonk comes rolling from left to right
110 if (FreezeZonks == 2)
111 return subAnimateZonks;
113 if (al == 0x40) // zonk falls straight down
116 if (al == 0x50) // zonk rolls left
119 if (al == 0x60) // zonk rolls right
122 if (al == 0x70) // intermediate state
125 return subAnimateZonks;
127 loc_g_0DE8: // zonk comes falling from above
128 // To Do: draw zonk falling from above
129 // according to position in (bl And &H07)
130 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
132 Y = GetStretchY(si - FieldWidth);
134 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
135 DDSpriteBuffer_BltImg(X, Y + TwoPixels * (dx + 1), aniZonk, dx);
136 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
138 bl = HighByte(PlayField16[si]) + 1;
141 MovHighByte(&PlayField16[si], bl);
142 subCleanUpForZonksAbove(si - FieldWidth);
143 return subAnimateZonks;
148 MovHighByte(&PlayField16[si], bl);
149 return subAnimateZonks;
152 MovHighByte(&PlayField16[si], 0); // zonk arrived at the field
153 if ((FreezeZonks & 0xFF) == 2)
154 return subAnimateZonks;
156 // loc_g_0E42: // now check if the zonk may go on falling somehow
157 ax = PlayField16[si + FieldWidth];
158 if (ax == 0) // below is empty!-> go on falling 'loc_g_0E4C:
161 if (ax == 0x9999) // below is only temporarily used ' loc_g_0E57:
164 if ((ax & 0xFF) == fiMurphy) // Murphy dies 'loc_g_0E61:
167 if ((ax & 0xFF) == fiSnikSnak) // SnikSnak dies 'loc_g_0E6B:
170 if (ax == 0x2BB) // loc_g_0E76:
173 if (ax == 0x4BB) // loc_g_0E81:
176 if ((ax & 0xFF) == fiElectron) // Electron cracked! 'loc_g_0E8B:
179 if (ax == fiOrangeDisk) // OrangeDisk explodes 'loc_g_0E95:
183 // play the zonk sound, 'cause zonk hits something "hard"
184 subSoundFX(si, fiZonk, actImpact);
186 subSoundFXZonk(); // play the zonk sound,'cause zonk hits something "hard"
189 if (! (ax == fiZonk || ax == fiInfotron || ax == fiRAM))
190 return subAnimateZonks;
192 // loc_g_0EAE: ' Zonk rolls somewhere
193 ax = PlayField16[si + FieldWidth - 1];
194 if (ax == 0 || ax == 0x8888 || ax == 0xAAAA) // may roll left
197 ax = PlayField16[si + FieldWidth + 1];
198 if (ax == 0 || ax == 0x8888 || ax == 0xAAAA) // may roll right
201 return subAnimateZonks;
203 loc_g_0EDD: // go on falling down?
204 PlayField16[si] = 0x7001; // go into intermediate waitstate
205 PlayField16[si + FieldWidth] = 0x9999; // mark as "zonk waiting to access"
206 return subAnimateZonks;
208 loc_g_0EEA: // test if zonk may roll left
209 // This if(if true) jumps up far above
210 // to the according rountine for fixed zonks!
211 if (PlayField16[si - 1] != 0) // Remarkable!!! ' loc_g_0EF4:
214 MovHighByte(&PlayField16[si], 0x50); // zonk rolls left
215 PlayField16[si - 1] = 0x8888; // mark as zonk accessing?
216 return subAnimateZonks;
218 loc_g_0F00: // test if zonk may roll right
219 if (PlayField16[si + 1] != 0) // loc_g_0F08:
220 return subAnimateZonks;
222 MovHighByte(&PlayField16[si], 0x60); // zonk rolls right
223 PlayField16[si + 1] = 0x8888; // mark as zonk accessing?
224 return subAnimateZonks;
226 loc_g_0F14: // Murphy dies, but not in any case
227 bl = HighByte(PlayField16[si + FieldWidth]);
228 if (bl == 0xE || bl == 0xF || bl == 0x28)
229 return subAnimateZonks;
231 if (bl == 0x29 || bl == 0x25 || bl == 0x26)
232 return subAnimateZonks;
235 ax = LowByte(PlayField16[si + FieldWidth - 1]);
236 if (ax == fiElectron) // loc_g_0F43:
237 PlayField16[si + FieldWidth] = fiElectron;
240 PlayField16[si + FieldWidth - 1] = 0;
245 ax = LowByte(PlayField16[si + FieldWidth + 1]);
246 if (ax == fiElectron) // loc_g_0F5F:
247 PlayField16[si + FieldWidth] = fiElectron;
250 PlayField16[si + FieldWidth + 1] = 0;
254 loc_g_0F6E: // someone dies/explodes
255 si = si + FieldWidth; // 1 field down
256 ExplodeFieldSP(si); // Explode
257 return subAnimateZonks;
259 loc_g_0F75: // OrangeDisk explodes next cycle
260 si = si + FieldWidth; // 1 field down
261 PlayField8[si] = fiHardWare;
262 return subAnimateZonks;
264 loc_g_0F83: // zonk comes rolling from right to left
265 // To Do: draw zonk rolling from right
266 // according to position in (bl And &H07)
267 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
268 X = GetStretchX(si + 1);
271 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
272 DDSpriteBuffer_BltImg(X - (TwoPixels * dx), Y, aniZonkRollLeft, dx - 1);
273 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
275 bl = HighByte(PlayField16[si]) + 1; // get and increment sequence#
277 PlayField16[si + 1] = 0xAAAA;
281 MovHighByte(&PlayField16[si], bl);
282 subCleanUpForZonksAbove(si + 1);
286 MovHighByte(&PlayField16[si], bl);
290 PlayField16[si] = 0xFFFF;
291 si = si + FieldWidth; // 1 field down
292 PlayField16[si] = 0x1001; // convert rolling zonk to a falling zonk
295 return subAnimateZonks;
297 loc_g_0FE8: // zonk comes rolling from left to right
298 // To Do: draw zonk rolling from left
299 // according to position in (bl And &H07)
300 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
301 X = GetStretchX(si - 1);
304 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
305 DDSpriteBuffer_BltImg(X + (TwoPixels * dx), Y, aniZonkRollRight, dx - 1);
306 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
308 bl = HighByte(PlayField16[si]) + 1;
310 PlayField16[si - 1] = 0xAAAA;
314 MovHighByte(&PlayField16[si], bl);
315 subCleanUpForZonksAbove(si - 1);
319 MovHighByte(&PlayField16[si], bl);
323 PlayField16[si] = 0xFFFF;
324 si = si + FieldWidth; // 1 field down
325 PlayField16[si] = 0x1001; // convert rolling zonk to a falling zonk
328 return subAnimateZonks;
330 loc_g_104D: // zonk falls straight down
334 MovHighByte(&PlayField16[si], bl);
336 else if (PlayField16[si + FieldWidth] != 0)
338 bl = bl - 1; // stay waiting
339 MovHighByte(&PlayField16[si], bl);
343 PlayField16[si] = 0xFFFF; // mark as "zonk leaving"
344 si = si + FieldWidth; // 1 field down
345 PlayField16[si] = 0x1001; // go falling
348 return subAnimateZonks;
350 loc_g_107B: // zonk rolls left
351 // To Do: draw zonk rolling to left
352 // according to position in (bl And &H0F)
353 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
357 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
358 DDSpriteBuffer_BltImg(X - (TwoPixels * dx), Y, aniZonkRollLeft, dx - 1);
359 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
361 bl = HighByte(PlayField16[si]) + 1; // retrieve and increment sequence#
364 MovHighByte(&PlayField16[si], bl);
365 return subAnimateZonks;
368 if (PlayField16[si + FieldWidth - 1] != 0)
371 if (PlayField16[si - 1] != 0)
373 if (PlayField16[si - 1] != 0x8888)
377 PlayField16[si] = 0xFFFF;
378 si = si - 1; // 1 field left
379 PlayField16[si] = 0x2201;
380 PlayField16[si + FieldWidth] = 0xFFFF;
381 return subAnimateZonks;
383 loc_g_10E2: // stay waiting
385 MovHighByte(&PlayField16[si], bl);
386 return subAnimateZonks;
388 loc_g_10E9: // zonk rolls right
389 // To Do: draw zonk rolling to right
390 // according to position in (bl And &H07)
391 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
395 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
396 DDSpriteBuffer_BltImg(X + (TwoPixels * dx), Y, aniZonkRollRight, dx - 1);
397 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
399 bl = HighByte(PlayField16[si]) + 1;
402 MovHighByte(&PlayField16[si], bl);
403 return subAnimateZonks;
406 if (PlayField16[si + FieldWidth + 1] != 0)
409 if (PlayField16[si + 1] != 0)
411 if (PlayField16[si + 1] != 0x8888)
415 PlayField16[si] = 0xFFFF;
417 PlayField16[si] = 0x3201;
418 PlayField16[si + FieldWidth] = 0xFFFF;
419 return subAnimateZonks;
421 loc_g_1150: // stay waiting
423 MovHighByte(&PlayField16[si], bl);
424 return subAnimateZonks;
426 loc_g_1157: // intermediate state
427 ax = PlayField16[si + FieldWidth];
428 if (ax == 0 || ax == 0x9999)
430 PlayField16[si] = 0xFFFF;
431 si = si + FieldWidth; // 1 field down
432 PlayField16[si] = 0x1001; // start falling down
436 return subAnimateZonks;
437 } // subAnimateZonks endp
439 int subCleanUpForZonksAbove(int si)
441 int subCleanUpForZonksAbove;
445 if (LowByte(PlayField16[si]) != fiExplosion)
448 if (PlayField16[si - FieldWidth] != 0)
450 if (PlayField16[si - FieldWidth] != 0x9999)
451 return subCleanUpForZonksAbove;
453 if (LowByte(PlayField16[si - 2 * FieldWidth]) != fiInfotron)
454 return subCleanUpForZonksAbove;
457 if (PlayField16[si - FieldWidth - 1] != fiZonk)
459 if (PlayField16[si - FieldWidth + 1] != fiZonk)
460 return subCleanUpForZonksAbove;
465 ax = PlayField16[si - 1];
466 if (ax == fiZonk || ax == fiInfotron || ax == fiRAM)
468 PlayField16[si - FieldWidth - 1] = 0x6001;
469 PlayField16[si - FieldWidth] = 0x8888;
470 return subCleanUpForZonksAbove;
473 if (PlayField16[si - FieldWidth + 1] != fiZonk)
474 return subCleanUpForZonksAbove;
477 ax = PlayField16[si + 1];
478 if (ax == fiZonk || ax == fiInfotron || ax == fiRAM)
480 PlayField16[si - FieldWidth + 1] = 0x5001;
481 PlayField16[si - FieldWidth] = 0x8888;
484 return subCleanUpForZonksAbove;
485 } // subCleanUpForZonksAbove