Prev: B76D Up: Map Next: B814
B7CD: Display Lives
Used by the routines at GameComplete, AddLife, HandlePlayerDeath and StartTurn.
Shows the number of lives of each player at the top of the screen as a digit followed by a small picture of Sabreman. If a player has no lives left then spaces are printed. The lives of player 1 are on the left and the lives of player 2 are on the right.
Before
display-lives-before
After DisplayPlayerLives
display-lives-after
Controller for 1UP lives.
DisplayPlayerLives B7CD LD HL,$4008 Set the screen address of the 1UP lives in HL.
B7D0 CALL FetchLives_1UP Fetch the number of lives of 1UP.
B7D3 AND A Jump to Handler1UPNoLives if 1UP has no lives left.
B7D4 JR Z,Handler1UPNoLives
B7D6 CALL HandlerDisplayLives Display the lives of 1UP.
Controller for 2UP lives.
Controller2UPLives B7D9 LD HL,$4016 Set the screen address of the 2UP lives in HL.
B7DC CALL FetchLives_2UP Fetch the number of lives of 2UP.
B7DF AND A Jump to Handler2UPNoLives if 2UP has no lives left.
B7E0 JR Z,Handler2UPNoLives
Handles displaying the lives count and UDG character.
HandlerDisplayLives B7E2 ADD A,$30 Convert the number of lives to an ASCII digit.
B7E4 CALL PrintScreen Print the number of lives.
B7E7 LD DE,$B814 Point DE at the life icon at UDG_Life.
B7EA PUSH BC Stash BC and DE on the stack, ready for PrintScreen_Write.
B7EB PUSH DE
B7EC JP PrintScreen_Write Jump to PrintScreen_Write to draw the life icon.
1UP has no lives.
Handler1UPNoLives B7EF CALL Handler2UPNoLives Clear the lives of 1UP.
B7F2 JR Controller2UPLives Jump to Controller2UPLives.
2UP has no lives.
Handler2UPNoLives B7F4 LD A,$20 Set the character to a space.
B7F6 CALL PrintScreen Print a space, to clear the number of lives.
B7F9 LD A,$20 Set the character to a space.
B7FB JP PrintScreen Print a space, to clear the life icon.
Return the 1UP player's lives left.
FetchLives_1UP B7FE LD A,($969E) Jump to InactivePlayerLives if the active player is 2UP (so 1UP is inactive).
B801 AND A
B802 JR NZ,InactivePlayerLives
Return currently active players lives left.
ActivePlayerLives B804 LD A,($96BD) Fetch the lives of the active player from ActivePlayer_Lives.
B807 RET Return.
Return inactive players lives left.
InactivePlayerLives B808 LD A,($96E0) Fetch the lives of the inactive player from InactivePlayer_Lives.
B80B RET Return.
Return the 2UP player's lives left.
FetchLives_2UP B80C LD A,($969E) Jump to InactivePlayerLives if the active player is 1UP (so 2UP is inactive).
B80F AND A
B810 JR Z,InactivePlayerLives
B812 JR ActivePlayerLives Jump to ActivePlayerLives.
View the equivalent code in;
Prev: B76D Up: Map Next: B814