Prev: 942F Up: Map Next: 9481
9443: Prepare Player
Used by the routines at StartGame and HandlerPlayerVanishing.
Sets up the player entity at Player for the start of a life. The template at PlayerTemplate is given the room that the player is in and the sprite ID of the character that was chosen in GameOptions, and is then copied over the player. Then the timer for the player appearing is set, the player is drawn (unless the number of lives is 03), the energy is refilled, and the chicken and the lives are drawn.
Work out the sprite ID to use.
Byte Character * 02 Only Bits 4-5 + 08
00 Knight (+ Keyboard) 00 00 Sprite ID: 08
08 Wizard (+ Kempston Joystick) 10 10 Sprite ID: 18
14 Serf (+ Cursor Joystick) 28 20 Sprite ID: 28
PreparePlayer 9443 LD A,($5E00) A=GameOptions * 02.
9446 RLCA
9447 AND %00110000 Keep only bits 4-5 (the base character address) + 08 frames (for the character direction).
9449 ADD A,$08
944B LD ($9488),A Write A to 9488.
Update the current room.
944E LD A,($EA91) Write PlayerRoom to 9482.
9451 LD ($9482),A
Copy the template over the player.
9454 LD HL,$9481 Copy 08 bytes of data from PlayerTemplate to Player.
9457 LD DE,$EA90
945A LD BC,$0008
945D LDIR
945F LD A,$68 Write 68 to FlashTimer, the timer for the player appearing.
9461 LD ($5E3C),A
9464 LD A,($5E21) Fetch the number of lives from PlayerLives.
9467 CP $03 Jump to PreparePlayer_Energy if the number of lives is 03.
9469 JR Z,PreparePlayer_Energy
946B PUSH IX Stash IX on the stack.
946D LD IX,$EA90 Point IX at the player at Player.
9471 CALL DrawEntity Call DrawEntity to draw the player.
9474 POP IX Restore IX from the stack.
Set starting energy.
PreparePlayer_Energy 9476 LD A,$F0 Write F0 to PlayerEnergy.
9478 LD ($5E28),A
947B CALL DrawChicken Call DrawChicken to draw the chicken.
947E JP DisplayPlayerLives Jump to DisplayPlayerLives to draw the lives.
Prev: 942F Up: Map Next: 9481