Prev: C2FF Up: Map Next: C332
C314: Print BCD Number
Used by the routine at PrintPercentage.
Prints a number which is held in BCD, using the font with the digits. Entering at PrintBCDNumber_LowerDigit prints only the lower digit of the first byte.
Input
B Number of bytes
DE Address of the number
HL Screen address of the first digit
Point at the digit font.
PrintBCDNumber C314 PUSH HL Stash the screen address on the stack.
C315 LD HL,$6CDE Set FontPointer to Font.
C318 LD ($BBAC),HL
C31B POP HL Restore the screen address from the stack.
Print the upper digit of the byte.
PrintBCDNumber_Loop C31C LD A,(DE) Fetch a byte of the number.
C31D RRCA Move the upper digit to the lowest four bits.
C31E RRCA
C31F RRCA
C320 RRCA
C321 AND %00001111 Keep only bits 0 to 3.
C323 CALL PrintCharacterWithAttribute Call PrintCharacterWithAttribute.
C326 INC L Move on to the next screen position.
This entry point is used by the routines at PrintPercentage and PrintScore.
Print the lower digit and move on.
PrintBCDNumber_LowerDigit C327 LD A,(DE) Fetch a byte of the number.
C328 AND %00001111 Keep only bits 0 to 3.
C32A CALL PrintCharacterWithAttribute Call PrintCharacterWithAttribute.
C32D INC L Move on to the next screen position.
C32E INC DE Move on to the next byte.
C32F DJNZ PrintBCDNumber_Loop Jump to PrintBCDNumber_Loop until all of the bytes have been printed.
C331 RET Return.
View the equivalent code in;
Prev: C2FF Up: Map Next: C332