Prev: 85F7 Up: Map Next: 8672
862E: Handle Ghostlet
The handler for the ghostlet (sprite IDs 4E and 4F). It is the same as HandlerPumpkin at the start, but the player is checked for touching before the weapon. The ghostlet changes to a new random velocity every time the counter at offset 07 wraps round to zero (every 0100 steps) and then moves by MoveCreature.
Input
IX The ghostlet entity
HandlerGhostlet 862E CALL StoreEntity Call StoreEntity to save the position of the ghostlet.
8631 LD A,($EA91) Fetch the room of the player from PlayerRoom.
8634 CP (IX+$01) Jump to CountDownCreature if the ghostlet is not in the same room as the player.
8637 JP NZ,CountDownCreature
863A LD HL,$5E25 Point HL at the number of creatures at NumCreatures.
863D INC (HL) Increment the number of creatures by one.
863E CALL CheckPlayerTouch Call CheckPlayerTouch to check whether the entity is touching the player.
8641 DEC E Jump to HandleTouchingCreature if the ghostlet touched the player.
8642 JP Z,HandleTouchingCreature
8645 CALL CheckWeaponHit Call CheckWeaponHit to check whether the weapon has hit the entity.
8648 DEC E Jump to PopCreature if the ghostlet was hit by a weapon.
8649 JP Z,PopCreature
864C LD (IX+$05),$45 Set the attribute of the entity to INK:CYAN, PAPER:BLACK (BRIGHT).
8650 INC (IX+$07) Increment the step counter at offset 07.
8653 CALL Z,RandomiseVelocity Call RandomiseVelocity if it has wrapped round to zero.
Animate the ghostlet by changing the sprite every fourth step.
8656 LD A,(IX+$07) Fetch the step counter.
8659 RRA Divide the step counter by four, so that the sprite changes every fourth step.
865A RRA
865B AND %00000001 Keep only bit 0.
865D LD C,A Keep the animation frame in C.
865E LD A,(IX+$00) Fetch the sprite ID of the ghostlet.
8661 AND %11111110 Reset bit 0.
8663 ADD A,C Add the animation frame to the sprite ID.
8664 LD (IX+$00),A Update the sprite ID of the ghostlet.
8667 LD DE,($5E1D) Fetch the size of the room from CurrentRoom_Width.
866B LD (IX+$0F),$00 Write 00 to offset 0F of the ghostlet, so it is not removed.
866F JP MoveCreature Jump to MoveCreature to move the creature.
Prev: 85F7 Up: Map Next: 8672