Prev: F8B5 Up: Map Next: F93A
F8B9: Asteroids : Check for collision with lightning
Used by the routine at EDF7.
F8B9 LD IX,$80A9 Point IX at the movement table.
F8BD LD A,$08 Moving objects decrease endurance by 8.
F8BF LD ($F26E),A
F8C2 LD B,$0C 0C entries to check.
F8C4 PUSH BC Remember the count in BC.
F8C5 LD BC,$F8B5 Point BC at the bounds table. (F8B5)
F8C8 LD A,(IX+$00)
F8CB CP $FF
F8CD JR NZ,$F8D6 Jump forward if it isn't.
F8CF CALL $EF88 Move to the next entry and return.
F8D2 INC IX
F8D4 JR $F936
The lightning bolt is active.
F8D6 CALL $EF35 Update the position.
F8D9 LD A,(IX+$00) Get the current graphic ID.
F8DC CALL $A8A0 Put it in the sprite buffer.
F8DF INC IX Move to the next position in the table.
F8E1 LD A,(IY+$05) Get the player's x co-ordinate.
F8E4 SUB (IX-$05) Is it close enough to the lightning?
F8E7 SUB $08
F8E9 CP $F0
F8EB JR C,$F8FA Jump forward if it isn't.
F8ED LD A,(IY+$0A) Get the player's y co-ordinate.
F8F0 SUB (IX-$04) Is it close enough to the lightning?
F8F3 SUB $08
F8F5 CP $F0
F8F7 CALL NC,$E33F If it is, the player has hit the lightning, so decrease endurance.
F8FA LD A,($F672) Has the missile hit a boundary in X?
F8FD OR A
F8FE JR Z,$F918 Jump forward if it hasn't.
If the missile hits a boundary, the usual logic for moving objects needs changing. Instead of reversing direction, move to the other end of the screen, and keep the existing direction.
F900 LD A,(IX-$05) If the position is F0 set it to 02. Otherwise, it must be 0, so set it to EE.
F903 CP $F0
F905 JR Z,$F90B
F907 LD A,$EE
F909 JR $F90D
F90B LD A,$02
F90D LD (IX-$05),A Set the new x co-ordinate.
F910 LD A,(IX-$03) Restore the sign of the direction, that was changed in the previous call to EF35.
F913 NEG
F915 LD (IX-$03),A
F918 LD A,($F673) Has the missile hit a boundary in Y?
F91B OR A
F91C JR Z,$F936 Jump forward if it hasn't.
Update the boundary logic as earlier.
F91E LD A,(IX-$04) If the position is 40 set it to AE. Otherwise it must be B0 so set it to 42.
F921 CP $40
F923 JR NZ,$F929
F925 LD A,$AE
F927 JR $F92B
F929 LD A,$42
F92B LD (IX-$04),A Set the new y co-ordinate.
F92E LD A,(IX-$02) Restore the sign of the direction, that was changed in the previous call to EF35.
F931 NEG
F933 LD (IX-$02),A
F936 POP BC Restore the count in BC.
F937 DJNZ $F8C4 Loop while there is more lightning to draw.
F939 RET Otherwise return.
Prev: F8B5 Up: Map Next: F93A