Prev: B20F Up: Map Next: B2A2
B218: Tick Then Explode
Move the actor by its fractional speed and thrust and cycle its frame. Start StartSmallExplosion when the timer at *IX+08 reaches zero, when the actor reaches the ground or leaves the top of the play area, or when it touches Jetman.
Input
IX Actor slot
Decrease the actor timer and explode when it reaches zero.
TickThenExplode B218 BIT 0,(IX+$10) Jump to ScoreSmallHit if bit 0 of the explode flag is set.
B21C JP NZ,ScoreSmallHit
B21F DEC (IX+$08) Decrease the actor timer by one.
B222 JP Z,StartSmallExplosion Jump to StartSmallExplosion if it is now zero.
Work out the horizontal step from the actor speed.
B225 LD A,(IX+$05) Fetch the actor speed.
B228 AND A Jump to AdvanceAnimation if the speed is positive.
B229 JP P,AdvanceAnimation
Add a negative speed to the X fraction and make the step negative.
B22C ADD A,(IX+$10) Add the X nibble.
B22F LD C,A Stash the sum in C.
B230 AND %00001111 Keep only bits 0-3.
B232 NEG Negate it.
B234 AND %11111110 Reset bit 0.
B236 LD (IX+$10),A Write it back as the X nibble.
Turn the carried bits of the sum into the negative step.
B239 LD A,C Copy the sum into A.
B23A NEG Negate it.
B23C RRCA Rotate the high nibble down into bits 0-3.
B23D RRCA
B23E RRCA
B23F RRCA
B240 AND %00001111 Keep only bits 0-3.
B242 NEG Negate it.
B244 LD B,$FF B=FF.
Move the world X by the step and wrap it.
TickThenExplode_AddX B246 ADD A,(IX+$02) Add the step to the world X.
B249 LD (IX+$02),A Write it back.
B24C LD A,(IX+$03) Fetch the high byte.
B24F ADC A,B Add the sign.
B250 AND %00011111 Keep only bits 0-4.
B252 LD (IX+$03),A Write the high byte back.
Work out the vertical step from the actor thrust.
B255 LD A,(IX+$06) Fetch the actor thrust.
B258 AND A Jump to AdvanceAnimation_AddYNibble if the thrust is positive.
B259 JP P,AdvanceAnimation_AddYNibble
Add a negative thrust to the Y fraction and make the step negative.
B25C ADD A,(IX+$11) Add the Y nibble.
B25F LD C,A Stash the sum in C.
B260 AND %00001111 Keep only bits 0-3.
B262 NEG Negate it.
B264 LD (IX+$11),A Write it back as the Y nibble.
Turn the carried bits of the sum into the negative step.
B267 LD A,C Copy the sum into A.
B268 NEG Negate it.
B26A RRCA Rotate the high nibble down into bits 0-3.
B26B RRCA
B26C RRCA
B26D RRCA
B26E AND %00001111 Keep only bits 0-3.
B270 NEG Negate it.
Move the actor Y, exploding on the ground or above the play area.
TickThenExplode_AddY B272 ADD A,(IX+$04) Add the step to the actor Y.
B275 CP $AF Compare it against AF.
B277 JP NC,StartSmallExplosion Jump to StartSmallExplosion if the actor is on the ground.
B27A CP $30 Compare it against 30.
B27C JP C,StartSmallExplosion Jump to StartSmallExplosion if the actor is above the play area.
B27F LD (IX+$04),A Write the new Y.
Advance the frame within the actor's type family.
B282 LD A,(IX+$00) Fetch the actor type.
B285 AND %11111100 Keep only bits 2-7.
B287 LD C,A Stash the family in C.
B288 LD A,(IX+$00) Fetch the actor type.
B28B INC A Increase it by one.
B28C AND %00000011 Keep only bits 0-1.
B28E OR C Merge the family back in.
B28F LD (IX+$00),A Write it to the actor type.
Draw the sprite and write its attributes.
B292 CALL DrawObjectSprite Call DrawObjectSprite.
B295 CALL ColouriseSprite Call ColouriseSprite.
Explode the actor if it is touching Jetman.
B298 CALL TickThenExplode_CloseRange Call TickThenExplode_CloseRange.
B29B RET NC Return if Jetman is out of range.
B29C CALL TickThenExplode_KillJetman Call TickThenExplode_KillJetman.
B29F JP StartSmallExplosion Jump to StartSmallExplosion.
Prev: B20F Up: Map Next: B2A2