Prev: F0EE Up: Map Next: F165
F107: Print BCD Score
Used by the routines at Draw_Score_Entry and Display_High_Score_Screen.
Prints a BCD-encoded score of B bytes from (HL) as decimal digits on screen, suppressing leading zeros. Each zero nibble advances the column by C without printing; once a non-zero digit is found, all remaining digits are printed. Each digit is positioned using an AT sequence (16) via PrintDispatch; D is the starting column, E is the row, and D advances by C after each digit.
Input
HL Pointer to the BCD score data
B Number of BCD bytes
C Column step between digits
D Starting column position
E Row position
Print_BCD_Score F107 LD B,$04 Set the BCD byte count to 04.
This entry point is used by the routine at Draw_Score_Entry.
Leading zero suppression: skip zero nibbles, advancing the column.
Print_BCD_Score_Suppress_Loop F109 LD A,(HL) Read the high nibble of the current score byte; jump to Print_High_Digit to print it if non-zero.
F10A SRL A
F10C SRL A
F10E SRL A
F110 SRL A
F112 JR NZ,Print_High_Digit
F114 LD A,D Advance the column position past the suppressed high digit.
F115 ADD A,C
F116 LD D,A
F117 LD A,B Jump to print the units digit via Read_Low_Digit if this is the last byte.
F118 CP $01
F11A JR Z,Read_Low_Digit
F11C LD A,(HL) Read the current score byte for the low nibble check.
F11D AND %00001111 Isolate the low nibble.
F11F JR NZ,Print_Low_Digit Jump to print it via Print_Low_Digit if non-zero.
F121 LD A,D Advance the column position past the suppressed low digit.
F122 ADD A,C
F123 LD D,A
F124 INC HL Move to the next score byte and repeat.
F125 DJNZ Print_BCD_Score_Suppress_Loop
Digit print loop: print both nibbles of each remaining byte.
Print_BCD_Score_Print_Loop F127 LD A,(HL) Read the high nibble of the current score byte.
F128 SRL A
F12A SRL A
F12C SRL A
F12E SRL A
Print_High_Digit F130 ADD A,$30 Convert to ASCII and stash the digit character on the stack.
F132 PUSH AF
F133 LD A,$16 Position the cursor at column D, row E via PrintDispatch and print the digit character.
F135 CALL PrintDispatch
F138 LD A,D
F139 CALL PrintDispatch
F13C LD A,E
F13D CALL PrintDispatch
F140 POP AF
F141 CALL PrintDispatch
F144 LD A,D Advance the column position.
F145 ADD A,C
F146 LD D,A
Read_Low_Digit F147 LD A,(HL) Read the current score byte for the low nibble.
F148 AND %00001111 Isolate the low nibble.
Print_Low_Digit F14A ADD A,$30 Convert to ASCII and stash the digit character on the stack.
F14C PUSH AF
F14D LD A,$16 Position the cursor at column D, row E via PrintDispatch and print the digit character.
F14F CALL PrintDispatch
F152 LD A,D
F153 CALL PrintDispatch
F156 LD A,E
F157 CALL PrintDispatch
F15A POP AF
F15B CALL PrintDispatch
F15E LD A,D Advance the column position.
F15F ADD A,C
F160 LD D,A
F161 INC HL Move to the next score byte and repeat.
F162 DJNZ Print_BCD_Score_Print_Loop
F164 RET Return.
Prev: F0EE Up: Map Next: F165