Prev: C536 Up: Map Next: C5C1
C544: Print Player Score
Used by the routines at Clear_Colour_Bar_Column and RenderHUD.
Draws the player's score on screen from the packed BCD bytes at Player_1_State (two decimal digits per byte), terminated by FF. Each digit occupies six screen rows; the display row starts at *C414 and advances by 06 per digit. All digits are printed at column 02 via PrintDispatch. After the last digit the score display attributes are refreshed by UpdateAttributeBar_FillBorder. Called from Erase_Narrow_Entity_Sprite and RenderHUD.
PrintPlayerScore C544 LD A,($C414) Load the initial display row for this score line into C.
C547 LD C,A
C548 LD HL,$C403 Point HL at the active player's BCD score at Player_1_State.
PrintPlayerScore_NextByte C54B LD A,(HL) Read the next byte from the BCD score string.
C54C CP $FF Jump to PrintPlayerScore_Terminator if all score digits have been printed (terminator FF).
C54E JP Z,PrintPlayerScore_Terminator
C551 AND %11110000 Isolate the tens digit (high BCD nibble).
C553 JP NZ,PrintPlayerScore_HighNibble Jump to PrintPlayerScore_HighNibble if the tens digit is non-zero.
C556 LD A,C Advance the display row by 06 (skip the blank tens-digit row).
C557 ADD A,$06
C559 LD C,A
C55A LD A,(HL) Reload the BCD byte to test the units digit.
C55B AND %00001111 Isolate the units digit (low BCD nibble).
C55D JP NZ,PrintPlayerScore_LowNibbleOnly Jump to PrintPlayerScore_LowNibbleOnly if the units digit is non-zero.
C560 LD A,C Advance the display row by 06 (skip the blank units-digit row).
C561 ADD A,$06
C563 LD C,A
C564 INC HL Advance HL to the next BCD byte.
C565 JP PrintPlayerScore_NextByte Jump back to PrintPlayerScore_NextByte to process the next BCD byte.
The tens digit is non-zero; position the score cursor and print both digits of this BCD byte.
PrintPlayerScore_HighNibble C568 LD A,$16 Position the score cursor at row C, column 02.
C56A CALL PrintDispatch
C56D LD A,C
C56E CALL PrintDispatch
C571 LD A,$02
C573 CALL PrintDispatch
C576 LD A,(HL) Reload the BCD byte for digit extraction.
PrintPlayerScore_NextDigitHigh C577 SRL A Shift A right four places to extract the tens digit.
C579 SRL A
C57B SRL A
C57D SRL A
C57F OR %00110000 Convert the tens digit to its ASCII character code.
C581 CALL PrintDispatch Print the tens digit of this score byte.
PrintPlayerScore_PrintLowNibble C584 LD A,(HL) Reload the BCD byte for the units digit.
C585 AND %00001111 Isolate the units digit (low BCD nibble).
C587 OR %00110000 Convert the units digit to its ASCII character code.
C589 CALL PrintDispatch Print the units digit of this score byte.
C58C INC HL Advance HL and read the next BCD byte.
C58D LD A,(HL)
C58E CP $FF Jump back to PrintPlayerScore_NextDigitHigh if more score digits remain.
C590 JP NZ,PrintPlayerScore_NextDigitHigh
C593 CALL UpdateAttributeBar_FillBorder Call UpdateAttributeBar_FillBorder to refresh the score display attributes.
C596 RET Return.
The tens digit is 00 but the units digit is non-zero; position the score cursor, then jump to PrintPlayerScore_PrintLowNibble to print only the units digit.
PrintPlayerScore_LowNibbleOnly C597 LD A,$16 Position the score cursor at row C, column 02.
C599 CALL PrintDispatch
C59C LD A,C
C59D CALL PrintDispatch
C5A0 LD A,$02
C5A2 CALL PrintDispatch
C5A5 JP PrintPlayerScore_PrintLowNibble Jump to PrintPlayerScore_PrintLowNibble to print the units digit only.
All BCD bytes printed; place a trailing zero at the last digit row (row C - 06) and refresh the score display attributes.
PrintPlayerScore_Terminator C5A8 LD A,$16 Position the score cursor at row C - 06 column 02.
C5AA CALL PrintDispatch
C5AD LD A,C
C5AE SUB $06
C5B0 CALL PrintDispatch
C5B3 LD A,$02
C5B5 CALL PrintDispatch
C5B8 LD A,$30 Print a trailing zero (30) at the final score digit position.
C5BA CALL PrintDispatch
C5BD CALL UpdateAttributeBar_FillBorder Call UpdateAttributeBar_FillBorder to refresh the score display attributes.
C5C0 RET Return.
Prev: C536 Up: Map Next: C5C1