Prev: 85F0 Up: Map Next: 862E
85F7: Handle Sparkle
The handler for the sparkle (sprite IDs 58 to 5B) that appears when a creature is created by SpawnCreature. The counter at offset 0E of the entity starts at 20 and the sprite is chosen from its bottom two bits to animate the sparkle. When the counter reaches zero the sparkle turns into the creature that is held at offset 02.
Input
IX The sparkle entity
HandlerSparkle 85F7 CALL StoreEntity Call StoreEntity to save the position of the sparkle.
85FA LD A,($EA91) Fetch the room of the player from PlayerRoom.
85FD CP (IX+$01) Jump to CountDownCreature if the sparkle is not in the same room as the player.
8600 JP NZ,CountDownCreature
8603 LD HL,$5E25 Point HL at the number of creatures at NumCreatures.
8606 INC (HL) Increment the number of creatures by one.
8607 DEC (IX+$0E) Decrease the counter at offset 0E by one.
860A JR Z,HandlerSparkle_Finish Jump to HandlerSparkle_Finish if it has reached zero.
860C LD A,(IX+$0E) Fetch the counter.
860F AND %00000011 Keep only bits 0-1.
8611 ADD A,$58 Add 58 to get the sprite ID of the sparkle.
8613 LD (IX+$00),A Update the sprite ID of the sparkle.
8616 LD (IX+$0F),$80 Write 80 to the counter at offset 0F.
861A LD A,($EA90) Fetch the sprite ID of the player from Player.
861D CP $31 Jump to PopCreature if the player sprite ID is 31 or more.
861F JP NC,PopCreature
8622 JP HandlerCharacter_Display Jump to HandlerCharacter_Display to display the sparkle.
The sparkle is finished, so it turns into the creature.
HandlerSparkle_Finish 8625 LD A,(IX+$02) Fetch the type of the creature from offset 02.
8628 LD (IX+$00),A Update the sprite ID of the entity.
862B JP HandlerCharacter_Display Jump to HandlerCharacter_Display to display the sparkle.
Prev: 85F0 Up: Map Next: 862E