1 // ----------------------------------------------------------------------------
3 // ----------------------------------------------------------------------------
7 static char *VB_Name = "modElectron";
9 // ==========================================================================
11 // Animate/move Electrons
12 // ==========================================================================
14 int subAnimateElectrons(int si)
16 int subAnimateElectrons;
20 if (SnikSnaksElectronsFrozen == 1)
21 return subAnimateElectrons;
23 if (LowByte(PlayField16[si]) != fiElectron)
24 return subAnimateElectrons;
26 bx = HighByte(PlayField16[si]);
31 subElectronTurnLeft(si, bx); // turning, bx=0 -> point N, bx = 1 -> point NW etc.
35 subElectronTurnRight(si, bx); // turn right
39 subElectronFromBelow(si, bx); // access si from below
43 subElectronFromRight(si, bx); // access si from right
47 subElectronFromAbove(si, bx); // access si from above
51 subElectronFromLeft(si, bx); // access si from left
55 return subAnimateElectrons;
56 } // subAnimateElectrons
58 int subDrawAnimatedElectrons(int si)
60 int subDrawAnimatedElectrons;
64 // If SnikSnaksElectronsFrozen = 1 Then Exit Function
65 if (LowByte(PlayField16[si]) != fiElectron)
66 return subDrawAnimatedElectrons;
68 bx = HighByte(PlayField16[si]);
73 subDrawElectronTurnLeft(si, bx); // turning, bx=0 -> point N, bx = 1 -> point NW etc.
77 subDrawElectronTurnRight(si, bx); // turn right
81 subDrawElectronFromBelow(si, bx); // access si from below
85 subDrawElectronFromRight(si, bx); // access si from right
89 subDrawElectronFromAbove(si, bx); // access si from above
93 subDrawElectronFromLeft(si, bx); // access si from left
97 return subDrawAnimatedElectrons;
98 } // subDrawAnimatedElectrons
100 int subElectronTurnLeft(int si, int bx)
102 int subElectronTurnLeft;
104 int ax, ah, bl, dx, X, Y;
112 return subElectronTurnLeft;
115 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
118 StretchedSprites.BltEx(X, Y, aniElectron[bx]);
119 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
121 MovHighByte(&PlayField16[si], bx);
122 return subElectronTurnLeft;
125 bl = HighByte(PlayField16[si]);
138 return subElectronTurnLeft;
140 loc_g_7AE6: // pointing up
141 ax = PlayField16[si - FieldWidth];
142 if (ax == 0) // above is empty -> go up
145 if (LowByte(ax) == fiMurphy) // above is murphy -> explode
148 return subElectronTurnLeft;
150 loc_g_7AF5: // above is empty -> go up
151 PlayField16[si] = 0x1BB;
152 si = si - FieldWidth; // 1 field up
153 PlayField16[si] = 0x1018;
154 return subElectronTurnLeft;
156 loc_g_7B05: // pointing left
157 ax = PlayField16[si - 1];
158 if (ax == 0) // left is empty -> go there
161 if (LowByte(ax) == fiMurphy) // left is murphy -> explode
164 return subElectronTurnLeft;
166 loc_g_7B14: // left is empty -> go there
167 PlayField16[si] = 0x2BB;
168 si = si - 1; // 1 field left
169 PlayField16[si] = 0x1818;
170 return subElectronTurnLeft;
172 loc_g_7B24: // pointing down
173 ax = PlayField16[si + FieldWidth];
174 if (ax == 0) // below is empty -> go down
177 if (LowByte(ax) == fiMurphy) // below is murphy -> explode
180 return subElectronTurnLeft;
182 loc_g_7B33: // below is empty -> go down
183 PlayField16[si] = 0x3BB;
184 si = si + FieldWidth; // 1 field down
185 PlayField16[si] = 0x2018;
186 return subElectronTurnLeft;
188 loc_g_7B43: // pointing Right
189 ax = PlayField16[si + 1];
190 if (ax == 0) // right is empty -> go there
193 if (LowByte(ax) == fiMurphy) // right is murphy -> explode
196 return subElectronTurnLeft;
198 loc_g_7B55: // right is empty -> go there
199 PlayField16[si] = 0x4BB;
200 si = si + 1; // 1 field right
201 PlayField16[si] = 0x2818;
203 return subElectronTurnLeft;
204 } // subElectronTurnLeft
206 int subElectronTurnRight(int si, int bx)
208 int subElectronTurnRight;
210 int ax, ah, bl, dx, X, Y;
218 return subElectronTurnRight;
221 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
224 StretchedSprites.BltEx(X, Y, aniElectron[0x10 - bx]);
225 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
226 bx = ((bx + 1) & 0x7) | 8;
227 MovHighByte(&PlayField16[si], bx);
228 return subElectronTurnRight;
231 bl = HighByte(PlayField16[si]);
244 return subElectronTurnRight;
246 loc_g_7BBC: // pointing up
247 ax = PlayField16[si - FieldWidth];
248 if (ax == 0) // above is empty -> go up
251 if (LowByte(ax) == fiMurphy) // above is murphy -> explode
254 return subElectronTurnRight;
256 loc_g_7BCB: // above is empty -> go up
257 PlayField16[si] = 0x1BB;
258 si = si - FieldWidth; // 1 field up
259 PlayField16[si] = 0x1018;
260 return subElectronTurnRight;
262 loc_g_7BDB: // pointing left
263 ax = PlayField16[si - 1];
264 if (ax == 0) // left is empty -> go there
267 if (LowByte(ax) == fiMurphy) // left is murphy -> explode
270 return subElectronTurnRight;
272 loc_g_7BEA: // left is empty -> go there
273 PlayField16[si] = 0x2BB;
274 si = si - 1; // 1 field left
275 PlayField16[si] = 0x1818;
276 return subElectronTurnRight;
278 loc_g_7BFA: // pointing down
279 ax = PlayField16[si + FieldWidth];
280 if (ax == 0) // below is empty -> go down
283 if (LowByte(ax) == fiMurphy) // below is murphy -> explode
286 return subElectronTurnRight;
288 loc_g_7C09: // below is empty -> go down
289 PlayField16[si] = 0x3BB;
290 si = si + FieldWidth; // 1 field down
291 PlayField16[si] = 0x2018;
292 return subElectronTurnRight;
294 loc_g_7C19: // pointing Right
295 ax = PlayField16[si + 1];
296 if (ax == 0) // right is empty -> go there
299 if (LowByte(ax) == fiMurphy) // right is murphy -> explode
302 return subElectronTurnRight;
304 loc_g_7C2B: // right is empty -> go there
305 PlayField16[si] = 0x4BB;
306 si = si + 1; // 1 field right
307 PlayField16[si] = 0x2818;
309 return subElectronTurnRight;
310 } // subElectronTurnRight
312 int subElectronFromBelow(int si, int bx)
314 int subElectronFromBelow;
316 int ax, ah, bl, dx, X, Y;
318 bx = bx - 0xF; // get and increment sequence#
319 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
321 Y = GetStretchY(si + FieldWidth);
322 StretchedSprites.BltEx(X, Y, 0);
323 StretchedSprites.BltEx(X, Y - bx * TwoPixels, aniElectron[bx]);
324 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
326 if (bl == 7 && LowByte(PlayField16[si + FieldWidth]) != fiExplosion)
328 PlayField16[si + FieldWidth] = 0; // electron left that field
331 if (bl < 8) // electron still goes up
334 MovHighByte(&PlayField16[si], bl);
335 return subElectronFromBelow;
338 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
339 ax = PlayField16[si - 1]; // check left field
340 if (ax == 0 || LowByte(ax) == fiMurphy) // check for empty or murphy
342 MovHighByte(&PlayField16[si], 1); // start to turn left
343 return subElectronFromBelow;
346 ax = PlayField16[si - FieldWidth]; // cannot turn left -> check above
347 if (ax == 0) // check if empty
349 PlayField16[si] = 0x1BB; // mark as "electron leaving"
350 si = si - FieldWidth; // go up!
351 PlayField16[si] = 0x1018;
352 return subElectronFromBelow;
355 if (LowByte(ax) == fiMurphy) // check for murphy above
357 ExplodeFieldSP(si); // Explode
358 return subElectronFromBelow;
361 ax = PlayField16[si + 1]; // check right field
362 if (ax == 0 || LowByte(ax) == fiMurphy) // check for empty or murphy
364 MovHighByte(&PlayField16[si], 9); // start to turn right
365 return subElectronFromBelow;
368 // else: no way to go, start turning around
369 MovHighByte(&PlayField16[si], 1);
371 return subElectronFromBelow;
372 } // subElectronFromBelow
374 int subElectronFromRight(int si, int bx)
376 int subElectronFromRight;
378 int ax, ah, bl, dx, X, Y;
380 bx = bx - 0x17; // get and increment sequence#
381 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
382 X = GetStretchX(si + 1);
384 StretchedSprites.BltEx(X, Y, 0);
385 StretchedSprites.BltEx(X - bx * TwoPixels, Y, aniElectron[bx]);
386 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
388 if (bl == 7 && LowByte(PlayField16[si + 1]) != fiExplosion)
390 PlayField16[si + 1] = 0; // electron left that field
393 if (bl < 8) // sniksnak still goes left
396 MovHighByte(&PlayField16[si], bl);
397 return subElectronFromRight;
400 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
401 ax = PlayField16[si + FieldWidth]; // check below
402 if (ax == 0 || LowByte(ax) == fiMurphy) // empty or murphy?
404 MovHighByte(&PlayField16[si], 3); // yes -> turn left down
405 return subElectronFromRight;
408 ax = PlayField16[si - 1]; // check left, etc ... see the comments on subElectronFromBelow()
411 PlayField16[si] = 0x2BB;
412 si = si - 1; // 1 field left
413 PlayField16[si] = 0x1818;
414 return subElectronFromRight;
417 if (LowByte(ax) == fiMurphy)
419 ExplodeFieldSP(si); // Explode
420 return subElectronFromRight;
423 ax = PlayField16[si - FieldWidth]; // check above
424 if (ax == 0 || LowByte(ax) == fiMurphy)
426 MovHighByte(&PlayField16[si], 0xF);
427 return subElectronFromRight;
430 MovHighByte(&PlayField16[si], 3);
432 return subElectronFromRight;
433 } // subElectronFromRight
435 int subElectronFromAbove(int si, int bx)
437 int subElectronFromAbove;
439 int ax, ah, bl, dx, X, Y;
441 bx = bx - 0x1F; // get and increment sequence#
442 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
444 Y = GetStretchY(si - FieldWidth);
445 StretchedSprites.BltEx(X, Y, 0);
446 StretchedSprites.BltEx(X, Y + bx * TwoPixels, aniElectron[bx]);
447 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
449 if (bl == 7 && LowByte(PlayField16[si - FieldWidth]) != fiExplosion)
451 PlayField16[si - FieldWidth] = 0; // electron left that field
454 if (bl < 8) // electron still goes down
457 MovHighByte(&PlayField16[si], bl);
458 return subElectronFromAbove;
461 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
462 ax = PlayField16[si + 1]; // check right
463 if (ax == 0 || LowByte(ax) == fiMurphy)
465 MovHighByte(&PlayField16[si], 5);
466 return subElectronFromAbove;
469 ax = PlayField16[si + FieldWidth]; // check below
472 PlayField16[si] = 0x3BB;
473 si = si + FieldWidth; // 1 field down
474 PlayField16[si] = 0x2018;
475 return subElectronFromAbove;
478 if (LowByte(ax) == fiMurphy)
480 ExplodeFieldSP(si); // Explode
481 return subElectronFromAbove;
484 ax = PlayField16[si - 1]; // check left
485 if (ax == 0 || LowByte(ax) == fiMurphy)
487 MovHighByte(&PlayField16[si], 0xD);
488 return subElectronFromAbove;
491 MovHighByte(&PlayField16[si], 5);
493 return subElectronFromAbove;
494 } // subElectronFromAbove
496 int subElectronFromLeft(int si, int bx)
498 int subElectronFromLeft;
500 int ax, ah, bl, dx, X, Y;
502 bx = bx - 0x27; // get and increment sequence#
503 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
504 X = GetStretchX(si - 1);
506 StretchedSprites.BltEx(X, Y, 0);
507 StretchedSprites.BltEx(X + bx * TwoPixels, Y, aniElectron[bx]);
508 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
510 if (bl == 7 && LowByte(PlayField16[si - 1]) != fiExplosion)
512 PlayField16[si - 1] = 0; // electron left that field
515 if (bl < 8) // electron still goes right
518 MovHighByte(&PlayField16[si], bl);
519 return subElectronFromLeft;
522 PlayField16[si] = 0x18; // sequence#=8 -> arrived at the new field
523 ax = PlayField16[si - FieldWidth]; // check above
524 if (ax == 0 || LowByte(ax) == fiMurphy)
526 MovHighByte(&PlayField16[si], 7);
527 return subElectronFromLeft;
530 ax = PlayField16[si + 1]; // check right(straight on)
533 PlayField16[si] = 0x4BB;
534 si = si + 1; // 1 field right
535 PlayField16[si] = 0x2818;
536 return subElectronFromLeft;
539 if (LowByte(ax) == fiMurphy)
541 ExplodeFieldSP(si); // Explode
542 return subElectronFromLeft;
545 ax = PlayField16[si + FieldWidth]; // check below
546 if (ax == 0 || LowByte(ax) == fiMurphy)
548 MovHighByte(&PlayField16[si], 0xB);
549 return subElectronFromLeft;
552 MovHighByte(&PlayField16[si], 7);
554 return subElectronFromLeft;
555 } // subElectronFromLeft
557 int subDrawElectronTurnLeft(int si, int bx)
559 int subDrawElectronTurnLeft;
563 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
566 StretchedSprites.BltEx(X, Y, aniElectron[bx]);
567 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
569 return subDrawElectronTurnLeft;
572 int subDrawElectronTurnRight(int si, int bx)
574 int subDrawElectronTurnRight;
578 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
581 StretchedSprites.BltEx(X, Y, aniElectron[0x10 - bx]);
582 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
584 return subDrawElectronTurnRight;
587 int subDrawElectronFromBelow(int si, int bx)
589 int subDrawElectronFromBelow;
593 bx = bx - 0xF; // get and increment sequence#
594 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
596 Y = GetStretchY(si + FieldWidth);
597 StretchedSprites.BltEx(X, Y, 0);
598 StretchedSprites.BltEx(X, Y - bx * TwoPixels, aniElectron[bx]);
599 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
601 return subDrawElectronFromBelow;
604 int subDrawElectronFromRight(int si, int bx)
606 int subDrawElectronFromRight;
610 bx = bx - 0x17; // get and increment sequence#
611 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
612 X = GetStretchX(si + 1);
614 StretchedSprites.BltEx(X, Y, 0);
615 StretchedSprites.BltEx(X - bx * TwoPixels, Y, aniElectron[bx]);
616 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
618 return subDrawElectronFromRight;
621 int subDrawElectronFromAbove(int si, int bx)
623 int subDrawElectronFromAbove;
627 bx = bx - 0x1F; // get and increment sequence#
628 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
630 Y = GetStretchY(si - FieldWidth);
631 StretchedSprites.BltEx(X, Y, 0);
632 StretchedSprites.BltEx(X, Y + bx * TwoPixels, aniElectron[bx]);
633 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
635 return subDrawElectronFromAbove;
638 int subDrawElectronFromLeft(int si, int bx)
640 int subDrawElectronFromLeft;
644 bx = bx - 0x27; // get and increment sequence#
645 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
646 X = GetStretchX(si - 1);
648 StretchedSprites.BltEx(X, Y, 0);
649 StretchedSprites.BltEx(X + bx * TwoPixels, Y, aniElectron[bx]);
650 // +++++++++++++++++++++++++++++++++++++++++++++++++++++
652 return subDrawElectronFromLeft;