Prev: 37935 Up: Map Next: 38017
37955: 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 3), the energy is refilled, and the chicken and the lives are drawn.
Work out the sprite ID to use.
Byte Character * 2 Only Bits 4-5 + 8
0 Knight (+ Keyboard) 0 0 Sprite ID: 8
8 Wizard (+ Kempston Joystick) 16 16 Sprite ID: 24
20 Serf (+ Cursor Joystick) 40 32 Sprite ID: 40
PreparePlayer 37955 LD A,(24064) A=GameOptions * 2.
37958 RLCA
37959 AND %00110000 Keep only bits 4-5 (the base character address) + 8 frames (for the character direction).
37961 ADD A,8
37963 LD (38024),A Write A to 38024.
Update the current room.
37966 LD A,(60049) Write PlayerRoom to 38018.
37969 LD (38018),A
Copy the template over the player.
37972 LD HL,38017 Copy 8 bytes of data from PlayerTemplate to Player.
37975 LD DE,60048
37978 LD BC,8
37981 LDIR
37983 LD A,104 Write 104 to FlashTimer, the timer for the player appearing.
37985 LD (24124),A
37988 LD A,(24097) Fetch the number of lives from PlayerLives.
37991 CP 3 Jump to PreparePlayer_Energy if the number of lives is 3.
37993 JR Z,PreparePlayer_Energy
37995 PUSH IX Stash IX on the stack.
37997 LD IX,60048 Point IX at the player at Player.
38001 CALL DrawEntity Call DrawEntity to draw the player.
38004 POP IX Restore IX from the stack.
Set starting energy.
PreparePlayer_Energy 38006 LD A,240 Write 240 to PlayerEnergy.
38008 LD (24104),A
38011 CALL DrawChicken Call DrawChicken to draw the chicken.
38014 JP DisplayPlayerLives Jump to DisplayPlayerLives to draw the lives.
Prev: 37935 Up: Map Next: 38017