Prev: 8947 Up: Map Next: 899C
894F: Display Lives
Draw the 1UP and 2UP lives counts and the life UDG, or spaces if a player has none.
Controller for 1UP lives.
DisplayPlayerLives 894F LD HL,$0040 Call ScreenAddress with the pixel co-ordinates 0040 to get the 1UP lives screen address.
8952 CALL ScreenAddress
8955 CALL FetchLives_1UP A=1UP lives remaining (by calling FetchLives_1UP).
8958 AND A If 1UP lives are zero, jump to Handler1UPNoLives.
8959 JR Z,Handler1UPNoLives
895B CALL HandlerDisplayLives Else, there are lives to display so call HandlerDisplayLives.
Controller for 2UP lives.
Controller2UPLives 895E LD HL,$00B0 Call ScreenAddress with the pixel co-ordinates 00B0 to get the 2UP lives screen address.
8961 CALL ScreenAddress
8964 CALL FetchLives_2UP A=2UP lives remaining (by calling FetchLives_2UP).
8967 AND A If 2UP lives are zero, jump to Handler2UPNoLives.
8968 JR Z,Handler2UPNoLives
Handles displaying the lives count and UDG character.
HandlerDisplayLives 896A ADD A,$30 Add 30 to convert to an ASCII character (starting at "0").
896C CALL PrintScreen Call PrintScreen.
896F LD DE,$D151 DE=UDG_Life.
8972 PUSH BC Stash BC and DE on the stack.
8973 PUSH DE
8974 JP PrintCharacter_Draw Jump to PrintCharacter_Draw.
1UP has no lives.
Handler1UPNoLives 8977 CALL Handler2UPNoLives Call Handler2UPNoLives.
897A JR Controller2UPLives Jump to Controller2UPLives.
2UP has no lives.
Handler2UPNoLives 897C LD A,$20 A=ASCII " " (SPACE).
897E CALL PrintScreen Call PrintScreen.
8981 LD A,$20 A=ASCII " " (SPACE).
8983 JP PrintScreen Jump to PrintScreen.
Return the 1UP player's lives left.
FetchLives_1UP 8986 LD A,($5E65) If Flag_ActivePlayer is not zero then jump to InactivePlayerLives.
8989 AND A
898A JR NZ,InactivePlayerLives
Return currently active players lives left.
ActivePlayerLives 898C LD A,($5EA1) A=*ActivePlayer_Lives.
898F RET Return.
Return inactive players lives left.
InactivePlayerLives 8990 LD A,($5EA5) A=*InactivePlayer_Lives.
8993 RET Return.
Return the 2UP player's lives left.
FetchLives_2UP 8994 LD A,($5E65) If Flag_ActivePlayer is zero then jump to InactivePlayerLives.
8997 AND A
8998 JR Z,InactivePlayerLives
899A JR ActivePlayerLives Jump to ActivePlayerLives.
View the equivalent code in;
Prev: 8947 Up: Map Next: 899C