Prev: 44664 Up: Map Next: 45115
44828: Handler: Sideways Missile
Fly a sideways missile (types 160 and 164). Flash the left or right warning marker, take laser hits off its hit count, step its X by its speed and steer its Y by its distance from the target. It explodes at Handler_Missile_FreezeWorld on reaching Jetman or the rover.
Input
IX Actor slot
Colour the missile banner and apply hits.
Handler_SidewaysMissile 44828 CALL TickThenExplode_CloseRange Call TickThenExplode_CloseRange.
44831 JP C,Handler_Missile_InRange Jump to Handler_Missile_InRange if Jetman is in range.
Flash the banner tile on the side where the missile is.
44834 CALL Handler_Missile Call Handler_Missile.
44837 JR NC,Handler_Missile_FlashBanner Jump to Handler_Missile_FlashBanner if the missile is not to the left of Jetman.
The missile is to the left, so flash the first tile (22651) and set the second tile (22653) to a steady colour.
44839 CALL FlashAttributeAlternative Call FlashAttributeAlternative to fetch the flashing attribute.
44842 LD HL,22651 Point HL at the first banner tile (22651).
44845 CALL Handler_Colour2x2 Call Handler_Colour2x2 to colour the tile with A.
44848 LD HL,22653 Point HL at the second banner tile (22653).
44851 JR Handler_Missile_BannerColour Jump to Handler_Missile_BannerColour to set the other tile to a steady colour.
The missile is not to the left, so flash the second tile (22653) and set the first tile (22651) to a steady colour.
Handler_Missile_FlashBanner 44853 CALL FlashAttributeAlternative Call FlashAttributeAlternative to fetch the flashing attribute.
44856 LD HL,22653 Point HL at the second banner tile (22653).
44859 CALL Handler_Colour2x2 Call Handler_Colour2x2 to colour the tile with A.
44862 LD HL,22651 Point HL at the first banner tile (22651).
Set the other banner tile to INK:RED, PAPER:BLACK (BRIGHT).
Handler_Missile_BannerColour 44865 LD A,66 Set the steady attribute in A to INK:RED, PAPER:BLACK (BRIGHT).
44867 CALL Handler_Colour2x2 Call Handler_Colour2x2 to colour the tile with A.
Cycle the missile colour on even frames.
44870 LD A,(24130) Fetch GameTimer.
44873 AND %00000001 Keep only bit 0.
44875 JR NZ,Handler_Missile_TakeHit Jump to Handler_Missile_TakeHit if this is an odd frame.
44877 LD A,(IX+7) Fetch the actor colour.
44880 CP 70 Jump to Handler_Missile_TakeHit if it is already INK:YELLOW, PAPER:BLACK (BRIGHT).
44882 JR Z,Handler_Missile_TakeHit
44884 LD A,(24128) Fetch RandomNumber.
44887 AND %00000111 Keep only bits 0-2.
44889 JR NZ,Handler_Missile_WriteBright Jump to Handler_Missile_WriteBright if the result is not zero, else force 1.
44891 INC A
Handler_Missile_WriteBright 44892 OR %01000000 Set bit 6.
44894 LD (IX+7),A Write it to the actor colour.
Skip to the movement unless the missile has been hit.
Handler_Missile_TakeHit 44897 BIT 0,(IX+16) Jump to Handler_Missile_StepX if bit 0 of the explode flag is reset.
44901 JR Z,Handler_Missile_StepX
Take one hit off the missile hit count.
44903 DEC (IX+22) Decrease *IX+22 by one.
Handler_Missile_Target 44906 JR Z,Handler_Missile_Destroyed Jump to Handler_Missile_Destroyed if the missile has been destroyed.
44908 CALL SoundsLaserMissileHit Call SoundsLaserMissileHit.
Each missile hit adds 256 points.
44911 LD BC,256 Set the points to award in BC to 256.
44914 CALL AddPointsToScore Call AddPointsToScore.
44917 LD (IX+7),66 Write INK:RED, PAPER:BLACK (BRIGHT) to the actor colour.
44921 LD (IX+16),0 Write 0 to the explode flag.
Step the missile world X from its speed.
Handler_Missile_StepX 44925 LD L,(IX+2) Fetch the actor world X.
44928 LD H,(IX+3) Fetch the high byte.
44931 LD C,(IX+5) Fetch the actor speed.
44934 LD B,0 Clear B.
44936 LD A,C Copy the speed into A.
44937 AND A Jump to Handler_Missile_WriteSteppedX if the speed is positive.
44938 JP P,Handler_Missile_WriteSteppedX
44941 DEC B Sign-extend into B.
Handler_Missile_WriteSteppedX 44942 ADD HL,BC Add the speed to the world X.
44943 LD A,H Fetch the high byte.
44944 AND %00011111 Keep only bits 0-4.
44946 LD H,A Write it back.
44947 LD (IX+2),L Write the low byte.
44950 LD (IX+3),H Write the high byte.
Test the target range, then steer the Y from the distance.
44953 CALL Handler_Missile_TestJetmanRange Call Handler_Missile_TestJetmanRange.
44956 JR C,Handler_Missile_FreezeWorld Jump to Handler_Missile_FreezeWorld if the missile has reached its target.
Pick the Y steering band from the distance left, or just draw.
44958 LD A,H Fetch the high byte of the distance left in HL.
44959 CP 2 Jump to Handler_Missile_LowBand if it is less than 2.
44961 JR C,Handler_Missile_LowBand
44963 CP 16 Jump to Handler_Missile_MidBand if it is less than 16.
44965 JR C,Handler_Missile_MidBand
44967 CP 32 Jump to Handler_Missile_SteerY if it is less than 32.
44969 JR C,Handler_Missile_SteerY
Handler_Missile_Draw 44971 JP DrawCurrentActor_Draw Jump to DrawCurrentActor_Draw.
Kill Jetman if he is in range, then destroy the missile.
Handler_Missile_InRange 44974 CALL TickThenExplode_KillJetman Call TickThenExplode_KillJetman.
Handler_Missile_Destroyed 44977 LD A,1 Write 1 to Missile_Destroyed_Flag.
44979 LD (24981),A
Destroying the missile adds 1280 points.
44982 LD BC,1280 Set the points to award in BC to 1280.
44985 CALL AddPointsToScore Call AddPointsToScore.
44988 LD DE,47784 Point DE at the tune at Tune_Extra_1.
44991 CALL QueueTune Call QueueTune.
44994 JP StartExplosion_SetSprite Jump to StartExplosion_SetSprite.
Steer the missile Y toward a band from the high byte.
Handler_Missile_SteerY 44997 LD A,(IX+4) Fetch the actor Y.
45000 CP 80 Compare it against 80.
Draw the missile once the Y matches its band, otherwise nudge it.
Handler_Missile_YReached 45002 JR Z,Handler_Missile_Draw Jump to Handler_Missile_Draw if they are equal.
45004 JR NC,Handler_Missile_DecreaseY Jump to Handler_Missile_DecreaseY if the Y is already past the band.
45006 INC A Increase the Y by two.
45007 INC A
Handler_Missile_DecreaseY 45008 DEC A Decrease the Y by one.
45009 LD (IX+4),A Write it back.
45012 JR Handler_Missile_Draw Jump to Handler_Missile_Draw.
In the middle band, steer the Y toward 128.
Handler_Missile_MidBand 45014 LD A,(IX+4) Fetch the actor Y.
45017 CP 128 Compare it against 128.
45019 JR Handler_Missile_YReached Jump to Handler_Missile_YReached.
In the low band, steer the Y toward 167.
Handler_Missile_LowBand 45021 LD A,(IX+4) Fetch the actor Y.
45024 CP 167 Compare it against 167.
45026 JR Z,Handler_Missile_Draw Jump to Handler_Missile_Draw if they are equal.
45028 INC A Increase the Y by one.
45029 CP 167 Compare it against 167.
45031 JR Handler_Missile_YReached Jump to Handler_Missile_YReached.
The missile has reached Jetman or the rover: set PlayerInactive, then turn the world slots, the bomb and the aliens into craters and explosions.
Handler_Missile_FreezeWorld 45033 LD A,1 Write 1 to PlayerInactive.
45035 LD (24172),A
45038 LD A,192 A=192.
45040 LD (24792),A Write it to World_Slot_3.
45043 LD (24744),A Write it to World_Slot_1.
45046 LD (24768),A Write it to World_Slot_2.
Turn world slot 4 into an explosion if it is in use.
45049 LD A,(24816) Fetch World_Slot_4.
45052 AND A Jump to Handler_Missile_HideBomb if it is free.
45053 JR Z,Handler_Missile_HideBomb
45055 LD A,92 Write 92 to World_Slot_4.
45057 LD (24816),A
Turn the bomb into a crater if it is in use.
Handler_Missile_HideBomb 45060 LD A,(24984) Fetch Bomb_States.
45063 AND A Jump to Handler_Missile_ScanAliens if it is free.
45064 JR Z,Handler_Missile_ScanAliens
45066 LD A,192 Write 192 to Bomb_States.
45068 LD (24984),A
Turn every active alien into an explosion.
Handler_Missile_ScanAliens 45071 LD HL,25008 HL=Alien_Slot_1.
45074 LD DE,24 DE=0024.
45077 LD B,6 Set an alien slot counter in B for 6 loops.
Handler_Missile_TestAlienSlot 45079 LD A,(HL) Fetch the slot type.
45080 AND A Jump to Handler_Missile_NextAlienSlot if the slot is free.
45081 JR Z,Handler_Missile_NextAlienSlot
Work out from the slot type how to convert it.
45083 AND %11111110 Reset bit 0.
45085 CP 90 Jump to Handler_Missile_ConvertAlien if the type is 90.
45087 JR Z,Handler_Missile_ConvertAlien
45089 CP 182 Jump to Handler_Missile_ConvertAlien if the type is 182.
45091 JR Z,Handler_Missile_ConvertAlien
45093 AND %11111100 Keep only bits 2-7.
45095 CP 100 Jump to Handler_Missile_NextAlienSlot if the type is 100.
45097 JR Z,Handler_Missile_NextAlienSlot
45099 CP 200 Jump to Handler_Missile_ConvertAlien if the type is 200.
45101 JR Z,Handler_Missile_ConvertAlien
45103 LD (HL),92 Write 92 to the slot.
Move onto the next slot, looping until every alien is done.
Handler_Missile_NextAlienSlot 45105 ADD HL,DE Move onto the next slot.
45106 DJNZ Handler_Missile_TestAlienSlot Decrease the slot counter by one and loop back to Handler_Missile_TestAlienSlot until every alien is processed.
45108 JP StartExplosion_SetSprite Jump to StartExplosion_SetSprite.
Handler_Missile_ConvertAlien 45111 LD (HL),100 Write 100 to the slot.
45113 JR Handler_Missile_NextAlienSlot Jump to Handler_Missile_NextAlienSlot.
Prev: 44664 Up: Map Next: 45115