Prev: 6AFC Up: Map Next: 6B8B
6B18: Handle Cleared Actor
The handler for an actor which has been cleared away (ID 0F) after Charlie has lost his hat (see ConvertActors). The original ID of the actor is in byte 04 and is used to draw the actor; bit 0 of it is flipped every four frames. While byte 05 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 6B18 LD HL,$5F1B Point HL at the number of actors in play.
6B1B INC (HL) Increase the number of actors in play by one.
6B1C LD A,(IX+$00) Fetch the actor ID.
6B1F PUSH AF Stash the actor ID on the stack.
6B20 LD A,(IX+$04) Fetch the original ID (byte 04 of the actor).
6B23 LD (IX+$00),A Update the actor ID.
6B26 CALL StoreEntity Record the position of the sprite using StoreEntity.
6B29 LD A,(IX+$05) Fetch the movement of the actor (byte 05 of the actor).
6B2C AND A Is the actor moving sideways?
6B2D JR Z,HandleClearedActor_Drop Jump to HandleClearedActor_Drop if it is not.
6B2F LD A,(IX+$02) Fetch the vertical co-ordinate.
6B32 CP $A0 Jump to HandleClearedActor_Sideways if the actor is above the floor.
6B34 JR C,HandleClearedActor_Sideways
6B36 LD (IX+$05),$00 Write 00 to byte 05 of the actor.
HandleClearedActor_Sideways 6B3A LD A,(IX+$01) Fetch the horizontal co-ordinate.
6B3D CP $68 Jump to HandleClearedActor_Right if the actor is in the right half of the screen.
6B3F JR NC,HandleClearedActor_Right
6B41 SUB $04 Subtract 04 to move the actor to the left.
6B43 JR NC,HandleClearedActor_SetPosition Jump to HandleClearedActor_SetPosition if the actor has not reached the left side.
6B45 XOR A Set A to 00 (the left edge).
6B46 LD (IX+$05),A Stop the actor moving sideways (byte 05 of the actor).
HandleClearedActor_SetPosition 6B49 LD (IX+$01),A Update the horizontal co-ordinate.
6B4C JR HandleClearedActor_Flip Jump to HandleClearedActor_Flip.
The actor is dropping.
HandleClearedActor_Drop 6B4E LD A,(IX+$02) Fetch the vertical co-ordinate.
6B51 ADD A,$04 Add 04 to drop the actor.
6B53 CP $B8 Jump to HandleClearedActor_Remove if the actor has reached the bottom of the screen.
6B55 JR NC,HandleClearedActor_Remove
6B57 LD (IX+$02),A Update the vertical co-ordinate.
HandleClearedActor_Flip 6B5A LD A,($5F1D) Fetch the frame counter.
6B5D AND %00000011 Keep only bits 0-1.
6B5F LD A,(IX+$04) Fetch the sprite ID (byte 04 of the actor).
6B62 JR NZ,HandleClearedActor_Draw Jump to HandleClearedActor_Draw if the frame counter is not a multiple of 04.
6B64 XOR %00000001 Flip bit 0.
6B66 LD (IX+$04),A Update the sprite ID (byte 04 of the actor).
HandleClearedActor_Draw 6B69 LD (IX+$00),A Update the actor ID.
6B6C CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
6B6F CALL ColourSprite Colour the sprite using ColourSprite.
6B72 POP AF Restore the actor ID from the stack.
6B73 LD (IX+$00),A Update the actor ID.
6B76 RET Return.
The actor has dropped off the bottom of the screen.
HandleClearedActor_Remove 6B77 LD (IX+$00),$00 Write 00 to the actor ID.
6B7B POP AF Discard the saved actor ID from the stack.
6B7C RET Return.
The actor is in the right half of the screen.
HandleClearedActor_Right 6B7D ADD A,$04 Add 04 to move the actor to the right.
6B7F CP $C0 Jump to HandleClearedActor_SetPosition if the actor has not reached the right side.
6B81 JR C,HandleClearedActor_SetPosition
6B83 XOR A Set A to 00.
6B84 LD (IX+$05),A Stop the actor moving sideways (byte 05 of the actor).
6B87 LD A,$C0 Set A to C0 (the right edge).
6B89 JR HandleClearedActor_SetPosition Jump to HandleClearedActor_SetPosition.
Prev: 6AFC Up: Map Next: 6B8B