1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
8 // ==========================================================================
10 // Animate/move Electrons
11 // ==========================================================================
13 void subAnimateElectrons(int si)
17 if (SnikSnaksElectronsFrozen == 1)
20 if (LowByte(PlayField16[si]) != fiElectron)
23 bx = HighByte(PlayField16[si]);
29 subElectronTurnLeft(si, bx); // turning, bx=0 -> point N, bx = 1 -> point NW etc.
33 subElectronTurnRight(si, bx); // turn right
37 subElectronFromBelow(si, bx); // access si from below
41 subElectronFromRight(si, bx); // access si from right
45 subElectronFromAbove(si, bx); // access si from above
49 subElectronFromLeft(si, bx); // access si from left
54 void subDrawAnimatedElectrons(int si)
58 // If SnikSnaksElectronsFrozen = 1 Then Exit Function
59 if (LowByte(PlayField16[si]) != fiElectron)
62 bx = HighByte(PlayField16[si]);
68 subDrawElectronTurnLeft(si, bx); // turning, bx=0 -> point N, bx = 1 -> point NW etc.
72 subDrawElectronTurnRight(si, bx); // turn right
76 subDrawElectronFromBelow(si, bx); // access si from below
80 subDrawElectronFromRight(si, bx); // access si from right
84 subDrawElectronFromAbove(si, bx); // access si from above
88 subDrawElectronFromLeft(si, bx); // access si from left
93 void subElectronTurnLeft(int si, int bx)
106 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
107 subDrawElectronTurnLeft(si, bx);
108 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
111 MovHighByte(&PlayField16[si], bx);
116 bl = HighByte(PlayField16[si]);
131 loc_g_7AE6: // pointing up
132 ax = PlayField16[si - FieldWidth];
133 if (ax == 0) // above is empty -> go up
136 if (LowByte(ax) == fiMurphy) // above is murphy -> explode
141 loc_g_7AF5: // above is empty -> go up
142 PlayField16[si] = 0x1BB;
143 si = si - FieldWidth; // 1 field up
144 PlayField16[si] = 0x1018;
148 loc_g_7B05: // pointing left
149 ax = PlayField16[si - 1];
150 if (ax == 0) // left is empty -> go there
153 if (LowByte(ax) == fiMurphy) // left is murphy -> explode
158 loc_g_7B14: // left is empty -> go there
159 PlayField16[si] = 0x2BB;
160 si = si - 1; // 1 field left
161 PlayField16[si] = 0x1818;
165 loc_g_7B24: // pointing down
166 ax = PlayField16[si + FieldWidth];
167 if (ax == 0) // below is empty -> go down
170 if (LowByte(ax) == fiMurphy) // below is murphy -> explode
175 loc_g_7B33: // below is empty -> go down
176 PlayField16[si] = 0x3BB;
177 si = si + FieldWidth; // 1 field down
178 PlayField16[si] = 0x2018;
182 loc_g_7B43: // pointing Right
183 ax = PlayField16[si + 1];
184 if (ax == 0) // right is empty -> go there
187 if (LowByte(ax) == fiMurphy) // right is murphy -> explode
192 loc_g_7B55: // right is empty -> go there
193 PlayField16[si] = 0x4BB;
194 si = si + 1; // 1 field right
195 PlayField16[si] = 0x2818;
198 void subElectronTurnRight(int si, int bx)
211 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
212 subDrawElectronTurnRight(si, bx);
213 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
215 bx = ((bx + 1) & 0x7) | 8;
216 MovHighByte(&PlayField16[si], bx);
221 bl = HighByte(PlayField16[si]);
236 loc_g_7BBC: // pointing up
237 ax = PlayField16[si - FieldWidth];
238 if (ax == 0) // above is empty -> go up
241 if (LowByte(ax) == fiMurphy) // above is murphy -> explode
246 loc_g_7BCB: // above is empty -> go up
247 PlayField16[si] = 0x1BB;
248 si = si - FieldWidth; // 1 field up
249 PlayField16[si] = 0x1018;
253 loc_g_7BDB: // pointing left
254 ax = PlayField16[si - 1];
255 if (ax == 0) // left is empty -> go there
258 if (LowByte(ax) == fiMurphy) // left is murphy -> explode
263 loc_g_7BEA: // left is empty -> go there
264 PlayField16[si] = 0x2BB;
265 si = si - 1; // 1 field left
266 PlayField16[si] = 0x1818;
270 loc_g_7BFA: // pointing down
271 ax = PlayField16[si + FieldWidth];
272 if (ax == 0) // below is empty -> go down
275 if (LowByte(ax) == fiMurphy) // below is murphy -> explode
280 loc_g_7C09: // below is empty -> go down
281 PlayField16[si] = 0x3BB;
282 si = si + FieldWidth; // 1 field down
283 PlayField16[si] = 0x2018;
287 loc_g_7C19: // pointing Right
288 ax = PlayField16[si + 1];
289 if (ax == 0) // right is empty -> go there
292 if (LowByte(ax) == fiMurphy) // right is murphy -> explode
297 loc_g_7C2B: // right is empty -> go there
298 PlayField16[si] = 0x4BB;
299 si = si + 1; // 1 field right
300 PlayField16[si] = 0x2818;
303 void subElectronFromBelow(int si, int bx)
307 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
308 subDrawElectronFromBelow(si, bx);
309 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
310 bx = bx - 0xF; // get and increment sequence#
313 if (bl == 7 && LowByte(PlayField16[si + FieldWidth]) != fiExplosion)
315 PlayField16[si + FieldWidth] = 0; // electron left that field
318 if (bl < 8) // electron still goes up
321 MovHighByte(&PlayField16[si], bl);
326 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
327 ax = PlayField16[si - 1]; // check left field
328 if (ax == 0 || LowByte(ax) == fiMurphy) // check for empty or murphy
330 MovHighByte(&PlayField16[si], 1); // start to turn left
335 ax = PlayField16[si - FieldWidth]; // cannot turn left -> check above
336 if (ax == 0) // check if empty
338 PlayField16[si] = 0x1BB; // mark as "electron leaving"
339 si = si - FieldWidth; // go up!
340 PlayField16[si] = 0x1018;
345 if (LowByte(ax) == fiMurphy) // check for murphy above
347 ExplodeFieldSP(si); // Explode
352 ax = PlayField16[si + 1]; // check right field
353 if (ax == 0 || LowByte(ax) == fiMurphy) // check for empty or murphy
355 MovHighByte(&PlayField16[si], 9); // start to turn right
360 // else: no way to go, start turning around
361 MovHighByte(&PlayField16[si], 1);
364 void subElectronFromRight(int si, int bx)
368 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
369 subDrawElectronFromRight(si, bx);
370 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
371 bx = bx - 0x17; // get and increment sequence#
374 if (bl == 7 && LowByte(PlayField16[si + 1]) != fiExplosion)
376 PlayField16[si + 1] = 0; // electron left that field
379 if (bl < 8) // sniksnak still goes left
382 MovHighByte(&PlayField16[si], bl);
387 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
388 ax = PlayField16[si + FieldWidth]; // check below
389 if (ax == 0 || LowByte(ax) == fiMurphy) // empty or murphy?
391 MovHighByte(&PlayField16[si], 3); // yes -> turn left down
396 ax = PlayField16[si - 1]; // check left, etc ... see the comments on subElectronFromBelow()
399 PlayField16[si] = 0x2BB;
400 si = si - 1; // 1 field left
401 PlayField16[si] = 0x1818;
406 if (LowByte(ax) == fiMurphy)
408 ExplodeFieldSP(si); // Explode
413 ax = PlayField16[si - FieldWidth]; // check above
414 if (ax == 0 || LowByte(ax) == fiMurphy)
416 MovHighByte(&PlayField16[si], 0xF);
421 MovHighByte(&PlayField16[si], 3);
424 void subElectronFromAbove(int si, int bx)
428 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
429 subDrawElectronFromAbove(si, bx);
430 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
431 bx = bx - 0x1F; // get and increment sequence#
434 if (bl == 7 && LowByte(PlayField16[si - FieldWidth]) != fiExplosion)
436 PlayField16[si - FieldWidth] = 0; // electron left that field
439 if (bl < 8) // electron still goes down
442 MovHighByte(&PlayField16[si], bl);
447 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
448 ax = PlayField16[si + 1]; // check right
449 if (ax == 0 || LowByte(ax) == fiMurphy)
451 MovHighByte(&PlayField16[si], 5);
456 ax = PlayField16[si + FieldWidth]; // check below
459 PlayField16[si] = 0x3BB;
460 si = si + FieldWidth; // 1 field down
461 PlayField16[si] = 0x2018;
466 if (LowByte(ax) == fiMurphy)
468 ExplodeFieldSP(si); // Explode
473 ax = PlayField16[si - 1]; // check left
474 if (ax == 0 || LowByte(ax) == fiMurphy)
476 MovHighByte(&PlayField16[si], 0xD);
481 MovHighByte(&PlayField16[si], 5);
484 void subElectronFromLeft(int si, int bx)
488 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
489 subDrawElectronFromLeft(si, bx);
490 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
491 bx = bx - 0x27; // get and increment sequence#
494 if (bl == 7 && LowByte(PlayField16[si - 1]) != fiExplosion)
496 PlayField16[si - 1] = 0; // electron left that field
499 if (bl < 8) // electron still goes right
502 MovHighByte(&PlayField16[si], bl);
507 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
508 ax = PlayField16[si - FieldWidth]; // check above
509 if (ax == 0 || LowByte(ax) == fiMurphy)
511 MovHighByte(&PlayField16[si], 7);
516 ax = PlayField16[si + 1]; // check right(straight on)
519 PlayField16[si] = 0x4BB;
520 si = si + 1; // 1 field right
521 PlayField16[si] = 0x2818;
526 if (LowByte(ax) == fiMurphy)
528 ExplodeFieldSP(si); // Explode
533 ax = PlayField16[si + FieldWidth]; // check below
534 if (ax == 0 || LowByte(ax) == fiMurphy)
536 MovHighByte(&PlayField16[si], 0xB);
541 MovHighByte(&PlayField16[si], 7);
544 void subDrawElectronTurnLeft(int si, int bx)
548 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
551 DDSpriteBuffer_BltImg(X, Y, aniElectron, bx);
552 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
555 void subDrawElectronTurnRight(int si, int bx)
559 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
562 DDSpriteBuffer_BltImg(X, Y, aniElectron, 0x10 - bx);
563 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
566 void subDrawElectronFromBelow(int si, int bx)
570 bx = bx - 0xF; // get and increment sequence#
572 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
574 Y = GetStretchY(si + FieldWidth);
575 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
576 DDSpriteBuffer_BltImg(X, Y - bx * TwoPixels, aniElectron, bx);
577 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
580 void subDrawElectronFromRight(int si, int bx)
584 bx = bx - 0x17; // get and increment sequence#
586 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
587 X = GetStretchX(si + 1);
589 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
590 DDSpriteBuffer_BltImg(X - bx * TwoPixels, Y, aniElectron, bx);
591 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
594 void subDrawElectronFromAbove(int si, int bx)
598 bx = bx - 0x1F; // get and increment sequence#
600 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
602 Y = GetStretchY(si - FieldWidth);
603 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
604 DDSpriteBuffer_BltImg(X, Y + bx * TwoPixels, aniElectron, bx);
605 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
608 void subDrawElectronFromLeft(int si, int bx)
612 bx = bx - 0x27; // get and increment sequence#
614 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
615 X = GetStretchX(si - 1);
617 DDSpriteBuffer_BltImg(X, Y, aniSpace, 0);
618 DDSpriteBuffer_BltImg(X + bx * TwoPixels, Y, aniElectron, bx);
619 // +++++++++++++++++++++++++++++++++++++++++++++++++++++