Prev: 9845 Up: Map Next: 9924
9861: Handle shot (from ship) collision
Used by the routine at handle_collisions.
Input
IX Sprite data address of shot
handle_shot_collision 9861 LD A,(other_flags) Flags
9864 LD C,A C = flags
Check collision with sprites
9865 LD IY,$701A Data for sprite 2
9869 LD B,$1E 30 sprites
986B LD DE,$000C Size of each sprite
handle_shot_collision_0 986E BIT 7,(IY+$00) If deallocated
9872 JR NZ,handle_shot_collision_4 Then move to next sprite
9874 BIT 7,(IY+$01) If polar y is out of range
9878 JR NZ,handle_shot_collision_4 Then move to next sprite
987A LD A,(IY+$00) Get sprite type
987D CP $7F If deallocated
987F JR Z,handle_shot_collision_4 Then move to next sprite
9881 CP $0D If < $0D (explosion dot, should this have been $0E?)
9883 JR C,handle_shot_collision_4 Then move to next sprite
9885 CP $17 If laser fence
9887 JR Z,handle_shot_collision_4 Then move to next sprite
9889 CP $12 If < $12 (enemy missile)
988B JR C,handle_shot_collision_1 Then do further checks
988D CP $15 if < $15 (last fence end)
988F JR C,handle_shot_collision_4 Then move to next sprite
$0D <= type <= $11 or type >= $15 except $17
handle_shot_collision_1 9891 LD A,(IY+$01) Polar y other sprite
9894 SUB (IX+$01) Minus polar y shot
9897 JR NC,handle_shot_collision_2 Absolute value
9899 NEG ...
handle_shot_collision_2 989B CP $02 If >= 2
989D JR NC,handle_shot_collision_4 Then move to next sprite
989F LD A,(IY+$02) Polar x other sprite
98A2 BIT 1,C Is double shot activated?
98A4 JR Z,handle_shot_collision_3 If not, we need a precise match on x
98A6 PUSH BC Save counter
98A7 LD B,(IX+$02) Polar x other sprite
98AA CALL polar_x_distance Polar x distance
98AD POP BC Restore counter
98AE CP $03 If distance < 3
98B0 JP C,shot_hit_sprite Then we have a hit
98B3 JR handle_shot_collision_4 Then move to next sprite
handle_shot_collision_3 98B5 CP (IX+$02) Compare to polar x of shot
98B8 JP Z,shot_hit_sprite If equal we have a hit
handle_shot_collision_4 98BB ADD IY,DE Next sprite address
98BD DJNZ handle_shot_collision_0 Loop for 30 sprites
Check for collision with center enemies
98BF LD A,(IX+$01) Get polar y
98C2 CP $23 if < 35
98C4 JR C,handle_shot_collision_8 Then skip this step (not in center)
98C6 LD A,(center_map_entries) Get number of enemies in map
98C9 OR A If zero
98CA JR Z,handle_shot_collision_8 Then skip this step
98CC LD HL,center_enemy_map Map address
98CF LD B,$24 Size of map
handle_shot_collision_5 98D1 BIT 7,(HL) If not allocated
98D3 JR NZ,handle_shot_collision_7 Then move on to next
98D5 CALL polar_coord_from_map Now DE contains polar y,x
98D8 LD A,D Polar y
98D9 SUB (IX+$01) Subtract polar y of shot
98DC JR NC,handle_shot_collision_6 Take absolute value
98DE NEG ...
handle_shot_collision_6 98E0 CP $02 If < 2
98E2 JR NC,handle_shot_collision_7 Then move on to next
98E4 LD A,E Polar x
98E5 CP (IX+$02) Compare to polar x of shot
98E8 JP Z,shot_hit_center_enemy If equal we have a hit
handle_shot_collision_7 98EB INC HL Next map address
98EC DJNZ handle_shot_collision_5 Loop for all map entries
Check for collision with mines
handle_shot_collision_8 98EE LD IY,mines_background_data Mine data
98F2 LD DE,$0009 Size of each mine structure
98F5 LD B,$03 3 mines
handle_shot_collision_9 98F7 LD A,(IY+$04) If mine is gone
98FA OR (IY+$03) ...
98FD JR Z,handle_shot_collision_11 Then move to next mine
98FF LD A,(IY+$07) Get polar y of mine
9902 SUB (IX+$01) Subtract polar y of shot
9905 JR NC,handle_shot_collision_10 Absolute value
9907 NEG ...
handle_shot_collision_10 9909 CP $02 >= 2
990B JR NC,handle_shot_collision_11 Then move on to next mine
990D PUSH BC Save counter
990E LD A,(IY+$08) Get polar x of mine
9911 LD B,(IX+$02) Get polar x of shot
9914 CALL polar_x_distance Polar x distance
9917 POP BC Restore counter
9918 CP $04 If distance is < 4
991A JP C,shot_hit_mine Then we have a hit
handle_shot_collision_11 991D ADD IY,DE Next mine address
991F DJNZ handle_shot_collision_9 Loop for 3 mines
9921 JP handle_collisions_1 Jump back into collisions loop
Prev: 9845 Up: Map Next: 9924