Prev: 37990 Up: Map Next: 38326
38193: Handler: Meteor
Count the meteor and drop it two pixels, exploding it at the ground line. Award points if its explode flag is set.
Input
IX Actor slot
PlaceSpawnedAlien 38193 LD HL,24158 HL=AlienCount.
38196 INC (HL) Increase AlienCount by one.
38197 LD A,(IX+4) Fetch the actor's Y position.
38200 ADD A,2 Add 2 to it.
38202 CP 176 Jump to PlaceSpawnedAlien_Explode if it has reached the ground line.
38204 JR NC,PlaceSpawnedAlien_Explode
38206 LD (IX+4),A Write the Y position back.
Set the actor type to one of the animation frames.
38209 LD A,(24130) Fetch GameTimer.
38212 AND %00000111 Keep only bits 0-2.
Sprite IDs begin at 80 ("Meteor: Frame 1").
38214 ADD A,80 Add 80 for the animation frames.
38216 LD (IX+0),A Write it to the actor type.
Age the alien, then apply its horizontal speed.
PlaceSpawnedAlien_Age 38219 LD A,(IX+10) Jump to PlaceSpawnedAlien_ClearAge if *IX+10 is not zero.
38222 AND A
38223 JR NZ,PlaceSpawnedAlien_ClearAge
38225 BIT 0,(IX+8) Jump to PlaceSpawnedAlien_ClearAge if bit 0 of the actor flags is set.
38229 JR NZ,PlaceSpawnedAlien_ClearAge
38231 INC (IX+23) Jump to PlaceSpawnedAlien_ApplySpeed if the age byte has not wrapped.
38234 JR NZ,PlaceSpawnedAlien_ApplySpeed
38236 JP Handler_Block_ClearType Jump to Handler_Block_ClearType.
PlaceSpawnedAlien_ClearAge 38239 LD (IX+23),0 Write 0 to the age byte.
Move the alien horizontally by its speed and redraw it.
PlaceSpawnedAlien_ApplySpeed 38243 LD H,(IX+3) Fetch the high byte of the world X.
38246 LD L,(IX+2) Fetch the low byte of the world X.
Turn the horizontal speed into a signed pixel step.
38249 LD A,(IX+5) Fetch the horizontal speed.
38252 LD D,0 Clear D for a positive step.
38254 SRA A Divide it by 16.
38256 SRA A
38258 SRA A
38260 SRA A
38262 JP P,PlaceSpawnedAlien_AddStep Jump to PlaceSpawnedAlien_AddStep if the step is positive.
38265 LD D,255 Set D=255 for a negative step.
Add the step to the world X and wrap it.
PlaceSpawnedAlien_AddStep 38267 LD E,A Store the pixel step in E.
38268 ADD HL,DE Add the step to the world X.
38269 LD A,H Fetch the high byte.
38270 AND %00011111 Keep only bits 0-4.
38272 LD (IX+3),A Write the high byte back.
38275 LD (IX+2),L Write the low byte back.
Redraw the alien and its colours.
38278 CALL DrawSprite Call DrawSprite.
38281 CALL ColouriseSprite Call ColouriseSprite.
Award a score if the explode flag is set.
38284 BIT 0,(IX+16) Jump to PlaceSpawnedAlien_TestHit if bit 0 of *IX+16 is reset.
38288 JR Z,PlaceSpawnedAlien_TestHit
Work out the points for this alien from its type.
38290 LD A,(IX+0) Fetch the actor type.
38293 RRA Rotate it right three times.
38294 RRA
38295 RRA
38296 AND %00011111 Keep only bits 0-4.
38298 ADD A,1 Add 1.
38300 DAA Convert that value to decimal.
38301 LD L,A Store it in HL.
38302 LD H,0
38304 ADD HL,HL Multiply it by 16.
38305 ADD HL,HL
38306 ADD HL,HL
38307 ADD HL,HL
38308 LD B,H Copy the points into BC.
38309 LD C,L
38310 CALL AddPointsToScore Call AddPointsToScore.
PlaceSpawnedAlien_TestHit 38313 CALL StartExplosion Call StartExplosion.
Kill Jetman and explode the alien if they are touching.
38316 CALL TickThenExplode_CloseRange Return if TickThenExplode_CloseRange does not set carry.
38319 RET NC
38320 CALL TickThenExplode_KillJetman Call TickThenExplode_KillJetman.
PlaceSpawnedAlien_Explode 38323 JP StartExplosion_SetSprite Jump to StartExplosion_SetSprite.
Prev: 37990 Up: Map Next: 38326