Prev: 52140 Up: Map Next: 52253
52165: Start New Life
Used by the routines at StartGame and CheckPlayerDead.
Starts a new life for the player: sets up the objects for the player, sets the player's health, uses up a life and shows the lives that are left. The game is over when no lives are left.
StartNewLife 52165 LD HL,52278 Copy the template for the two objects that make up the player (legs and body) into the object table.
52168 LD DE,48270
52171 LD BC,32
52174 LDIR
52176 LD A,40 Set the player's materialise timer to 40.
52178 LD (48130),A
52181 LD A,3 Give the player 3 health.
52183 LD (48115),A
52186 LD HL,48077 Use up a life, and jump to GameOver if there were none left.
52189 DEC (HL)
52190 JP M,GameOver
52193 CALL ClearShortLivedObjects Remove the ghosts and other short-lived objects.
52196 LD IX,48270 Point IX at the player and mark the cell that the player starts in as visited.
52200 CALL MarkCellVisited_NewCell
Draw the lives that are left.
52203 LD HL,31471 Set the font to the knight icons, and use bright white ink (attribute 71).
52206 LD (48044),HL
52209 LD A,71
52211 EX AF,AF'
52212 LD DE,52270 Point at the characters of an icon, and set the screen address of the first icon to 20549 (in the screen buffer).
52215 LD HL,20549
52218 LD A,(48077) Find the number of lives left, and work out the number of lives that have been used (5 minus the lives left).
52221 LD B,A
52222 NEG
52224 ADD A,5
52226 LD C,A
StartNewLife_LifeLoop 52227 LD A,B Jump to StartNewLife_UsedLives if there are no more lives left to draw.
52228 AND A
52229 JR Z,StartNewLife_UsedLives
52231 CALL DrawLifeIcon Draw an icon, move on two positions and loop back until all of the lives left have been drawn.
52234 INC L
52235 INC L
52236 DJNZ StartNewLife_LifeLoop
StartNewLife_UsedLives 52238 LD A,65 Use blue ink (attribute 65) for the lives that have been used.
52240 EX AF,AF'
52241 LD A,C Return if no lives have been used.
52242 AND A
52243 RET Z
52244 LD B,A Set a counter for the lives that have been used.
StartNewLife_UsedLoop 52245 CALL DrawLifeIcon Draw an icon, move on two positions and loop back until all of the used lives have been drawn.
52248 INC L
52249 INC L
52250 DJNZ StartNewLife_UsedLoop
52252 RET Return.
Prev: 52140 Up: Map Next: 52253