Prev: 25306 Up: Map Next: 25427
25368: Handle Explosion
Runs while the car is exploding (state 3 in the first byte of the player entity at Entity_Player). The explosion timer (the fifth byte of the entity, which starts at 192) counts down and when it reaches zero the game is over. Every four frames the sprite alternates between sprite IDs 33 and 34 (the sprites at Sprite_Explosion_1 and Sprite_Explosion_2). The only sound while the car is exploding is the engine note, as the speed is set to 1 on every frame (see SoundsEngine).
Input
IX Player entity (Entity_Player)
Before Explosion 1 Explosion 2
explosion-before explosion-frame-1 explosion-frame-2
HandlerExplosion 25368 LD A,(IX+11) Fetch the sprite ID of the current explosion frame from the end of the entity.
25371 LD (IX+0),A Write A to the first byte of the entity, as this is the sprite ID that StoreEntity copies.
25374 CALL StoreEntity Call StoreEntity to copy the position and sprite ID of the entity.
25377 CALL FlashPlayerMarker Call FlashPlayerMarker to keep the player's marker on the map flashing.
Count down the length of the explosion.
25380 DEC (IX+4) Decrease the explosion timer by one and jump to GameOver if the explosion has finished.
25383 JR Z,GameOver
25385 LD A,(IX+4) Fetch the explosion timer.
25388 AND %00000011 Keep only bits 0-1.
25390 JR NZ,HandlerExplosion_Draw If the result is not zero then keep the same sprite and jump to HandlerExplosion_Draw.
25392 BIT 2,(IX+4) If bit 2 of the explosion timer is not set then jump to HandlerExplosion_Frame2.
25396 JR Z,HandlerExplosion_Frame2
25398 LD (IX+11),33 Write 33 to the sprite ID.
25402 JR HandlerExplosion_Draw Jump to HandlerExplosion_Draw.
The other frame of the explosion.
HandlerExplosion_Frame2 25404 LD (IX+11),34 Write 34 to the sprite ID.
Redraw the explosion.
HandlerExplosion_Draw 25408 LD A,(IX+11) Fetch the sprite ID of the current explosion frame.
25411 LD (IX+0),A Write A to the first byte of the entity, as this is the sprite ID that DisplayEntity draws.
25414 CALL DisplayEntity Call DisplayEntity to erase the old sprite and draw the new one.
25417 LD (IX+0),3 Write 3 (the exploding state) to the first byte of the entity.
25421 LD A,1 Set the speed of the car to 1 which leaves the engine making a low note.
25423 LD (24077),A
25426 RET Return.
Prev: 25306 Up: Map Next: 25427