Prev: 62DA Up: Map Next: 6353
6318: Handle Explosion
Runs while the car is exploding (state 03 in the first byte of the player entity at Entity_Player). The explosion timer (the fifth byte of the entity, which starts at C0) counts down and when it reaches zero the game is over. Every four frames the sprite alternates between sprite IDs 21 and 22 (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 01 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 6318 LD A,(IX+$0B) Fetch the sprite ID of the current explosion frame from the end of the entity.
631B LD (IX+$00),A Write A to the first byte of the entity, as this is the sprite ID that StoreEntity copies.
631E CALL StoreEntity Call StoreEntity to copy the position and sprite ID of the entity.
6321 CALL FlashPlayerMarker Call FlashPlayerMarker to keep the player's marker on the map flashing.
Count down the length of the explosion.
6324 DEC (IX+$04) Decrease the explosion timer by one and jump to GameOver if the explosion has finished.
6327 JR Z,GameOver
6329 LD A,(IX+$04) Fetch the explosion timer.
632C AND %00000011 Keep only bits 0-1.
632E JR NZ,HandlerExplosion_Draw If the result is not zero then keep the same sprite and jump to HandlerExplosion_Draw.
6330 BIT 2,(IX+$04) If bit 2 of the explosion timer is not set then jump to HandlerExplosion_Frame2.
6334 JR Z,HandlerExplosion_Frame2
6336 LD (IX+$0B),$21 Write 21 to the sprite ID.
633A JR HandlerExplosion_Draw Jump to HandlerExplosion_Draw.
The other frame of the explosion.
HandlerExplosion_Frame2 633C LD (IX+$0B),$22 Write 22 to the sprite ID.
Redraw the explosion.
HandlerExplosion_Draw 6340 LD A,(IX+$0B) Fetch the sprite ID of the current explosion frame.
6343 LD (IX+$00),A Write A to the first byte of the entity, as this is the sprite ID that DisplayEntity draws.
6346 CALL DisplayEntity Call DisplayEntity to erase the old sprite and draw the new one.
6349 LD (IX+$00),$03 Write 03 (the exploding state) to the first byte of the entity.
634D LD A,$01 Set the speed of the car to 01 which leaves the engine making a low note.
634F LD ($5E0D),A
6352 RET Return.
Prev: 62DA Up: Map Next: 6353