Prev: 34295 Up: Map Next: 34418
34350: Handle Ghostlet
The handler for the ghostlet (sprite IDs 78 and 79). 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 7 wraps round to zero (every 256 steps) and then moves by MoveCreature.
Input
IX The ghostlet entity
HandlerGhostlet 34350 CALL StoreEntity Call StoreEntity to save the position of the ghostlet.
34353 LD A,(60049) Fetch the room of the player from PlayerRoom.
34356 CP (IX+1) Jump to CountDownCreature if the ghostlet is not in the same room as the player.
34359 JP NZ,CountDownCreature
34362 LD HL,24101 Point HL at the number of creatures at NumCreatures.
34365 INC (HL) Increment the number of creatures by one.
34366 CALL CheckPlayerTouch Call CheckPlayerTouch to check whether the entity is touching the player.
34369 DEC E Jump to HandleTouchingCreature if the ghostlet touched the player.
34370 JP Z,HandleTouchingCreature
34373 CALL CheckWeaponHit Call CheckWeaponHit to check whether the weapon has hit the entity.
34376 DEC E Jump to PopCreature if the ghostlet was hit by a weapon.
34377 JP Z,PopCreature
34380 LD (IX+5),69 Set the attribute of the entity to INK:CYAN, PAPER:BLACK (BRIGHT).
34384 INC (IX+7) Increment the step counter at offset 7.
34387 CALL Z,RandomiseVelocity Call RandomiseVelocity if it has wrapped round to zero.
Animate the ghostlet by changing the sprite every fourth step.
34390 LD A,(IX+7) Fetch the step counter.
34393 RRA Divide the step counter by four, so that the sprite changes every fourth step.
34394 RRA
34395 AND %00000001 Keep only bit 0.
34397 LD C,A Keep the animation frame in C.
34398 LD A,(IX+0) Fetch the sprite ID of the ghostlet.
34401 AND %11111110 Reset bit 0.
34403 ADD A,C Add the animation frame to the sprite ID.
34404 LD (IX+0),A Update the sprite ID of the ghostlet.
34407 LD DE,(24093) Fetch the size of the room from CurrentRoom_Width.
34411 LD (IX+15),0 Write 0 to offset 15 of the ghostlet, so it is not removed.
34415 JP MoveCreature Jump to MoveCreature to move the creature.
Prev: 34295 Up: Map Next: 34418