Prev: 46828 Up: Map Next: 46981
46897: Handler: Bombs
Copy the template into Bomb_States when that slot is empty, then place the bomb from the rover or Jetman.
Copy the bomb template into Bomb_States when that slot is empty.
Handler_Bombs 46897 LD DE,24984 DE=Bomb_States.
46900 LD A,(DE) Return if a bomb is already active.
46901 AND A
46902 RET NZ
46903 LD HL,46957 HL=Bomb_Actor_Template.
46906 LD BC,24 Copy the 24-byte template into the bomb slot.
46909 LDIR
Take the spawn X from the rover or from Jetman.
46911 LD A,(24720) Fetch Rover_Slot.
46914 SUB 26 Subtract 26.
46916 CP 16 Compare it with 16.
46918 JR C,Handler_Bombs_FromRover Jump to Handler_Bombs_FromRover if the rover type is in range.
46920 LD HL,(24698) Fetch Jetman_Position.
Offset the spawn X by 48 to the right, or to the left when the rover is outside the alien base range.
Handler_Bombs_Loop 46923 PUSH HL Stash the spawn X on the stack.
46924 LD HL,(24722) Fetch Rover_Position.
46927 LD BC,(24962) Fetch AlienBase_WorldX.
46931 CALL Handler_Missile_CompareWorldX Call Handler_Missile_CompareWorldX.
46934 JR NC,Handler_Bombs_OffsetLeft Jump to Handler_Bombs_OffsetLeft if the rover is outside the 4096 range of AlienBase_WorldX.
46936 LD BC,48 Set the offset in BC to 0048.
Add the offset to the spawn X and write it to the bomb slot.
Handler_Bombs_PlaceX 46939 POP HL Restore the spawn X from the stack.
46940 CALL MaskWorldX Call MaskWorldX.
46943 LD (24986),HL Write it to 24986.
46946 RET Return.
Handler_Bombs_FromRover 46947 LD HL,(24722) Fetch Rover_Position.
46950 JR Handler_Bombs_Loop Jump to Handler_Bombs_Loop.
Handler_Bombs_OffsetLeft 46952 LD BC,65488 Set the offset in BC to 65488 (-48).
46955 JR Handler_Bombs_PlaceX Jump to Handler_Bombs_PlaceX.
Bomb_Actor_Template 46957 DEFB 236,0,0,0,175,0,1,68 Bomb actor template.
46965 DEFB 0,0,0,0,0,0,0,0
46973 DEFB 0,6,6,0,0,0,0,0
Prev: 46828 Up: Map Next: 46981