Prev: 9466 Up: Map Next: 95B6
9531: 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 9531 LD HL,$5E5E HL=AlienCount.
9534 INC (HL) Increase AlienCount by one.
9535 LD A,(IX+$04) Fetch the actor's Y position.
9538 ADD A,$02 Add 02 to it.
953A CP $B0 Jump to PlaceSpawnedAlien_Explode if it has reached the ground line.
953C JR NC,PlaceSpawnedAlien_Explode
953E LD (IX+$04),A Write the Y position back.
Set the actor type to one of the animation frames.
9541 LD A,($5E42) Fetch GameTimer.
9544 AND %00000111 Keep only bits 0-2.
Sprite IDs begin at 50 ("Meteor: Frame 1").
9546 ADD A,$50 Add 50 for the animation frames.
9548 LD (IX+$00),A Write it to the actor type.
Age the alien, then apply its horizontal speed.
PlaceSpawnedAlien_Age 954B LD A,(IX+$0A) Jump to PlaceSpawnedAlien_ClearAge if *IX+0A is not zero.
954E AND A
954F JR NZ,PlaceSpawnedAlien_ClearAge
9551 BIT 0,(IX+$08) Jump to PlaceSpawnedAlien_ClearAge if bit 0 of the actor flags is set.
9555 JR NZ,PlaceSpawnedAlien_ClearAge
9557 INC (IX+$17) Jump to PlaceSpawnedAlien_ApplySpeed if the age byte has not wrapped.
955A JR NZ,PlaceSpawnedAlien_ApplySpeed
955C JP Handler_Block_ClearType Jump to Handler_Block_ClearType.
PlaceSpawnedAlien_ClearAge 955F LD (IX+$17),$00 Write 00 to the age byte.
Move the alien horizontally by its speed and redraw it.
PlaceSpawnedAlien_ApplySpeed 9563 LD H,(IX+$03) Fetch the high byte of the world X.
9566 LD L,(IX+$02) Fetch the low byte of the world X.
Turn the horizontal speed into a signed pixel step.
9569 LD A,(IX+$05) Fetch the horizontal speed.
956C LD D,$00 Clear D for a positive step.
956E SRA A Divide it by 10.
9570 SRA A
9572 SRA A
9574 SRA A
9576 JP P,PlaceSpawnedAlien_AddStep Jump to PlaceSpawnedAlien_AddStep if the step is positive.
9579 LD D,$FF Set D=FF for a negative step.
Add the step to the world X and wrap it.
PlaceSpawnedAlien_AddStep 957B LD E,A Store the pixel step in E.
957C ADD HL,DE Add the step to the world X.
957D LD A,H Fetch the high byte.
957E AND %00011111 Keep only bits 0-4.
9580 LD (IX+$03),A Write the high byte back.
9583 LD (IX+$02),L Write the low byte back.
Redraw the alien and its colours.
9586 CALL DrawSprite Call DrawSprite.
9589 CALL ColouriseSprite Call ColouriseSprite.
Award a score if the explode flag is set.
958C BIT 0,(IX+$10) Jump to PlaceSpawnedAlien_TestHit if bit 0 of *IX+10 is reset.
9590 JR Z,PlaceSpawnedAlien_TestHit
Work out the points for this alien from its type.
9592 LD A,(IX+$00) Fetch the actor type.
9595 RRA Rotate it right three times.
9596 RRA
9597 RRA
9598 AND %00011111 Keep only bits 0-4.
959A ADD A,$01 Add 01.
959C DAA Convert that value to decimal.
959D LD L,A Store it in HL.
959E LD H,$00
95A0 ADD HL,HL Multiply it by 10.
95A1 ADD HL,HL
95A2 ADD HL,HL
95A3 ADD HL,HL
95A4 LD B,H Copy the points into BC.
95A5 LD C,L
95A6 CALL AddPointsToScore Call AddPointsToScore.
PlaceSpawnedAlien_TestHit 95A9 CALL StartExplosion Call StartExplosion.
Kill Jetman and explode the alien if they are touching.
95AC CALL TickThenExplode_CloseRange Return if TickThenExplode_CloseRange does not set carry.
95AF RET NC
95B0 CALL TickThenExplode_KillJetman Call TickThenExplode_KillJetman.
PlaceSpawnedAlien_Explode 95B3 JP StartExplosion_SetSprite Jump to StartExplosion_SetSprite.
Prev: 9466 Up: Map Next: 95B6