Prev: 46957 Up: Map Next: 47124
47053: 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 47053 LD HL,16392 Set the screen address of the 1UP lives in HL.
47056 CALL FetchLives_1UP Fetch the number of lives of 1UP.
47059 AND A Jump to Handler1UPNoLives if 1UP has no lives left.
47060 JR Z,Handler1UPNoLives
47062 CALL HandlerDisplayLives Display the lives of 1UP.
Controller for 2UP lives.
Controller2UPLives 47065 LD HL,16406 Set the screen address of the 2UP lives in HL.
47068 CALL FetchLives_2UP Fetch the number of lives of 2UP.
47071 AND A Jump to Handler2UPNoLives if 2UP has no lives left.
47072 JR Z,Handler2UPNoLives
Handles displaying the lives count and UDG character.
HandlerDisplayLives 47074 ADD A,48 Convert the number of lives to an ASCII digit.
47076 CALL PrintScreen Print the number of lives.
47079 LD DE,47124 Point DE at the life icon at UDG_Life.
47082 PUSH BC Stash BC and DE on the stack, ready for PrintScreen_Write.
47083 PUSH DE
47084 JP PrintScreen_Write Jump to PrintScreen_Write to draw the life icon.
1UP has no lives.
Handler1UPNoLives 47087 CALL Handler2UPNoLives Clear the lives of 1UP.
47090 JR Controller2UPLives Jump to Controller2UPLives.
2UP has no lives.
Handler2UPNoLives 47092 LD A,32 Set the character to a space.
47094 CALL PrintScreen Print a space, to clear the number of lives.
47097 LD A,32 Set the character to a space.
47099 JP PrintScreen Print a space, to clear the life icon.
Return the 1UP player's lives left.
FetchLives_1UP 47102 LD A,(38558) Jump to InactivePlayerLives if the active player is 2UP (so 1UP is inactive).
47105 AND A
47106 JR NZ,InactivePlayerLives
Return currently active players lives left.
ActivePlayerLives 47108 LD A,(38589) Fetch the lives of the active player from ActivePlayer_Lives.
47111 RET Return.
Return inactive players lives left.
InactivePlayerLives 47112 LD A,(38624) Fetch the lives of the inactive player from InactivePlayer_Lives.
47115 RET Return.
Return the 2UP player's lives left.
FetchLives_2UP 47116 LD A,(38558) Jump to InactivePlayerLives if the active player is 1UP (so 2UP is inactive).
47119 AND A
47120 JR Z,InactivePlayerLives
47122 JR ActivePlayerLives Jump to ActivePlayerLives.
View the equivalent code in;
Prev: 46957 Up: Map Next: 47124