Prev: 27251 Up: Map Next: 27388
27296: Handle Hat
The handler for Charlie's hat (ID 13), which is in Charlie's actor slot. Charlie's co-ordinates were saved in bytes 4 and 5 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 14), who is handled by HandleFallingCharlie.
Input
IX Actor
HandleHat 27296 CALL StoreEntity Record the position of the sprite using StoreEntity.
27299 LD A,(IX+2) Fetch the vertical co-ordinate.
27302 SUB 2 Subtract 2 to move the hat up the screen.
27304 JR C,HandleHat_Finished Jump to HandleHat_Finished if the hat has reached the top of the screen.
27306 LD (IX+2),A Update the vertical co-ordinate.
27309 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
27312 CALL ColourSprite Colour the sprite using ColourSprite.
Redraw Charlie without his hat, and then put the position of the hat back.
27315 LD L,(IX+1) Fetch the horizontal co-ordinate of the hat.
27318 LD H,(IX+2) Fetch the vertical co-ordinate of the hat.
27321 PUSH HL Stash the position of the hat on the stack.
27322 LD A,(IX+4) Fetch Charlie's horizontal co-ordinate (byte 4 of the actor).
27325 LD (IX+1),A Update the horizontal co-ordinate.
27328 LD A,(IX+5) Fetch Charlie's vertical co-ordinate (byte 5 of the actor).
27331 LD (IX+2),A Update the vertical co-ordinate.
27334 LD (IX+0),12 Change the ID to 12 (Charlie without his hat).
27338 CALL StoreEntity Record the position of the sprite using StoreEntity.
27341 CALL DisplayEntity Erase the sprite and draw it in its new position using DisplayEntity.
27344 CALL ColourSprite Colour the sprite using ColourSprite.
27347 POP HL Restore the position of the hat from the stack.
27348 LD (IX+1),L Put the hat back at its horizontal co-ordinate.
27351 LD (IX+2),H Put the hat back at its vertical co-ordinate.
27354 LD (IX+0),13 Change the ID back to 13 (the hat).
27358 RET Return.
The hat has reached the top of the screen, so erase it and replace Charlie with falling Charlie.
HandleHat_Finished 27359 CALL DrawEntity Erase the hat using DrawEntity.
27362 LD A,(IX+4) Fetch Charlie's horizontal co-ordinate (byte 4 of the actor).
27365 LD (IX+1),A Update the horizontal co-ordinate.
27368 LD A,(IX+5) Fetch Charlie's vertical co-ordinate (byte 5 of the actor).
27371 LD (IX+2),A Update the vertical co-ordinate.
27374 LD (IX+0),12 Change the ID to 12 (Charlie without his hat).
27378 CALL DrawEntity Erase Charlie without his hat using DrawEntity.
27381 LD (IX+0),14 Change the ID to 14 (falling Charlie).
27385 JP DrawEntity Draw falling Charlie using DrawEntity.
Prev: 27251 Up: Map Next: 27388