Prev: 6A73 Up: Map Next: 6AFC
6AA0: Handle Hat
The handler for Charlie's hat (ID 0D), which is in Charlie's actor slot. Charlie's co-ordinates were saved in bytes 04 and 05 of the actor by LoseHat. Each pass the hat moves up two pixels, and Charlie is redrawn without his hat. When the hat reaches the top of the screen it is erased, and Charlie is replaced with falling Charlie (ID 0E), who is handled by HandleFallingCharlie.
Input
IX Actor
HandleHat 6AA0 CALL StoreEntity Record the position of the sprite using StoreEntity.
6AA3 LD A,(IX+$02) Fetch the vertical co-ordinate.
6AA6 SUB $02 Subtract 02 to move the hat up the screen.
6AA8 JR C,HandleHat_Finished Jump to HandleHat_Finished if the hat has reached the top of the screen.
6AAA LD (IX+$02),A Update the vertical co-ordinate.
6AAD CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
6AB0 CALL ColourSprite Colour the sprite using ColourSprite.
Redraw Charlie without his hat, and then put the position of the hat back.
6AB3 LD L,(IX+$01) Fetch the horizontal co-ordinate of the hat.
6AB6 LD H,(IX+$02) Fetch the vertical co-ordinate of the hat.
6AB9 PUSH HL Stash the position of the hat on the stack.
6ABA LD A,(IX+$04) Fetch Charlie's horizontal co-ordinate (byte 04 of the actor).
6ABD LD (IX+$01),A Update the horizontal co-ordinate.
6AC0 LD A,(IX+$05) Fetch Charlie's vertical co-ordinate (byte 05 of the actor).
6AC3 LD (IX+$02),A Update the vertical co-ordinate.
6AC6 LD (IX+$00),$0C Change the ID to 0C (Charlie without his hat).
6ACA CALL StoreEntity Record the position of the sprite using StoreEntity.
6ACD CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
6AD0 CALL ColourSprite Colour the sprite using ColourSprite.
6AD3 POP HL Restore the position of the hat from the stack.
6AD4 LD (IX+$01),L Put the hat back at its horizontal co-ordinate.
6AD7 LD (IX+$02),H Put the hat back at its vertical co-ordinate.
6ADA LD (IX+$00),$0D Change the ID back to 0D (the hat).
6ADE RET Return.
The hat has reached the top of the screen, so erase it and replace Charlie with falling Charlie.
HandleHat_Finished 6ADF CALL DrawEntity Erase the hat using DrawEntity.
6AE2 LD A,(IX+$04) Fetch Charlie's horizontal co-ordinate (byte 04 of the actor).
6AE5 LD (IX+$01),A Update the horizontal co-ordinate.
6AE8 LD A,(IX+$05) Fetch Charlie's vertical co-ordinate (byte 05 of the actor).
6AEB LD (IX+$02),A Update the vertical co-ordinate.
6AEE LD (IX+$00),$0C Change the ID to 0C (Charlie without his hat).
6AF2 CALL DrawEntity Erase Charlie without his hat using DrawEntity.
6AF5 LD (IX+$00),$0E Change the ID to 0E (falling Charlie).
6AF9 JP DrawEntity Draw falling Charlie using DrawEntity.
Prev: 6A73 Up: Map Next: 6AFC