Prev: 27388 Up: Map Next: 27531
27416: Handle Cleared Actor
The handler for an actor which has been cleared away (ID 15) after Charlie has lost his hat (see ConvertActors). The original ID of the actor is in byte 4 and is used to draw the actor; bit 0 of it is flipped every four frames. While byte 5 is not zero the actor moves sideways away from the middle of the screen four pixels at a time, until it reaches a side (and, if it is on the floor, it stops moving sideways at once). Then it drops four pixels at a time, and is removed when it reaches the bottom of the screen.
Input
IX Actor
HandleClearedActor 27416 LD HL,24347 Point HL at the number of actors in play.
27419 INC (HL) Increase the number of actors in play by one.
27420 LD A,(IX+0) Fetch the actor ID.
27423 PUSH AF Stash the actor ID on the stack.
27424 LD A,(IX+4) Fetch the original ID (byte 4 of the actor).
27427 LD (IX+0),A Update the actor ID.
27430 CALL StoreEntity Record the position of the sprite using StoreEntity.
27433 LD A,(IX+5) Fetch the movement of the actor (byte 5 of the actor).
27436 AND A Is the actor moving sideways?
27437 JR Z,HandleClearedActor_Drop Jump to HandleClearedActor_Drop if it is not.
27439 LD A,(IX+2) Fetch the vertical co-ordinate.
27442 CP 160 Jump to HandleClearedActor_Sideways if the actor is above the floor.
27444 JR C,HandleClearedActor_Sideways
27446 LD (IX+5),0 Write 0 to byte 5 of the actor.
HandleClearedActor_Sideways 27450 LD A,(IX+1) Fetch the horizontal co-ordinate.
27453 CP 104 Jump to HandleClearedActor_Right if the actor is in the right half of the screen.
27455 JR NC,HandleClearedActor_Right
27457 SUB 4 Subtract 4 to move the actor to the left.
27459 JR NC,HandleClearedActor_SetPosition Jump to HandleClearedActor_SetPosition if the actor has not reached the left side.
27461 XOR A Set A to 0 (the left edge).
27462 LD (IX+5),A Stop the actor moving sideways (byte 5 of the actor).
HandleClearedActor_SetPosition 27465 LD (IX+1),A Update the horizontal co-ordinate.
27468 JR HandleClearedActor_Flip Jump to HandleClearedActor_Flip.
The actor is dropping.
HandleClearedActor_Drop 27470 LD A,(IX+2) Fetch the vertical co-ordinate.
27473 ADD A,4 Add 4 to drop the actor.
27475 CP 184 Jump to HandleClearedActor_Remove if the actor has reached the bottom of the screen.
27477 JR NC,HandleClearedActor_Remove
27479 LD (IX+2),A Update the vertical co-ordinate.
HandleClearedActor_Flip 27482 LD A,(24349) Fetch the frame counter.
27485 AND %00000011 Keep only bits 0-1.
27487 LD A,(IX+4) Fetch the sprite ID (byte 4 of the actor).
27490 JR NZ,HandleClearedActor_Draw Jump to HandleClearedActor_Draw if the frame counter is not a multiple of 4.
27492 XOR %00000001 Flip bit 0.
27494 LD (IX+4),A Update the sprite ID (byte 4 of the actor).
HandleClearedActor_Draw 27497 LD (IX+0),A Update the actor ID.
27500 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
27503 CALL ColourSprite Colour the sprite using ColourSprite.
27506 POP AF Restore the actor ID from the stack.
27507 LD (IX+0),A Update the actor ID.
27510 RET Return.
The actor has dropped off the bottom of the screen.
HandleClearedActor_Remove 27511 LD (IX+0),0 Write 0 to the actor ID.
27515 POP AF Discard the saved actor ID from the stack.
27516 RET Return.
The actor is in the right half of the screen.
HandleClearedActor_Right 27517 ADD A,4 Add 4 to move the actor to the right.
27519 CP 192 Jump to HandleClearedActor_SetPosition if the actor has not reached the right side.
27521 JR C,HandleClearedActor_SetPosition
27523 XOR A Set A to 0.
27524 LD (IX+5),A Stop the actor moving sideways (byte 5 of the actor).
27527 LD A,192 Set A to 192 (the right edge).
27529 JR HandleClearedActor_SetPosition Jump to HandleClearedActor_SetPosition.
Prev: 27388 Up: Map Next: 27531