Prev: A240 Up: Map Next: A311
A2CE: Display Lives
Used by the routines at StartGame and PreparePlayer.
Draws an icon of the character for each life that the player has left (up to three) in the side panel, and clears the icon of each life that has been lost. The icon is the first sprite of the character that was chosen in the menu (GameOptions bits 3-4).
Before After
display-lives-before display-lives-after
DisplayPlayerLives A2CE PUSH IX Stash IX on the stack.
A2D0 LD IX,$A17D Point IX at the entity to draw at EntityToDraw.
A2D4 LD A,($5E00) Fetch the character that was chosen from GameOptions.
A2D7 RLCA Rotate left once.
A2D8 AND %00110000 Keep only bits 4-5.
A2DA OR %00000001 Set bit 0, to get the first sprite of the character (01 11 or 21).
A2DC LD (IX+$00),A Write the sprite ID to *IX+00.
A2DF LD (IX+$05),$47 Write 47 (the attribute) to *IX+05.
A2E3 LD HL,$8DC8 HL=8DC8 (the Y position is 8D and the X position is C8).
A2E6 LD (IX+$03),L Write the X position to *IX+03.
A2E9 LD (IX+$04),H Write the Y position to *IX+04.
A2EC LD A,($5E21) Fetch the number of lives from PlayerLives and keep the number of lives left to draw in C.
A2EF LD C,A
A2F0 LD B,$03 B=03 (the number of icons).
DisplayPlayerLives_Loop A2F2 PUSH BC Stash the counters on the stack.
A2F3 CALL ClearSprite Clear the icon with ClearSprite.
A2F6 LD A,C Fetch the number of lives left to draw.
A2F7 AND A Jump to DisplayPlayerLives_Next if there are no lives left to draw.
A2F8 JR Z,DisplayPlayerLives_Next
A2FA CALL DrawEntity Draw the icon with DrawEntity.
DisplayPlayerLives_Next A2FD LD A,(IX+$03) Fetch the X position.
A300 ADD A,$10 Add 10 to move on to the next icon.
A302 LD (IX+$03),A Write the X position back to *IX+03.
A305 POP BC Restore the counters from the stack.
A306 DEC C Decrease the number of lives left to draw by one, and jump to DisplayPlayerLives_Count if it is not negative.
A307 JP P,DisplayPlayerLives_Count
A30A LD C,$00 C=00 (no lives left to draw).
DisplayPlayerLives_Count A30C DJNZ DisplayPlayerLives_Loop Decrease the icon counter by one and loop back to DisplayPlayerLives_Loop until it is zero.
A30E POP IX Restore IX from the stack.
A310 RET Return.
View the equivalent code in;
Prev: A240 Up: Map Next: A311