Prev: BCA3 Up: Map Next: BCCA
BCAE: Print BCD Number
Used by the routines at GameOver, PrintPercentageComplete, PrintDays and PrintLives.
Prints a number which is held in BCD, using the font with the digits. Every digit is printed, including leading zeroes.
Input
B Number of bytes
DE Address of the number
HL Address in the screen buffer
Point at the digit font.
PrintBCDNumber BCAE PUSH HL Stash the screen buffer address on the stack.
BCAF LD HL,$6108 Set FontPointer to Font.
BCB2 LD ($5BC7),HL
BCB5 POP HL Restore the screen buffer address from the stack.
Print the upper digit of the byte.
PrintBCDNumber_NextByte BCB6 LD A,(DE) Fetch a byte of the number.
BCB7 RRCA Move the upper digit to the lowest four bits.
BCB8 RRCA
BCB9 RRCA
BCBA RRCA
BCBB AND %00001111 Keep only bits 0 to 3.
BCBD CALL PrintCharacter Call PrintCharacter.
This entry point is used by the routine at PrintPercentageComplete.
Print the lower digit and move on.
PrintBCDNumber_SecondDigit BCC0 LD A,(DE) Fetch a byte of the number.
BCC1 AND %00001111 Keep only bits 0 to 3.
BCC3 CALL PrintCharacter Call PrintCharacter.
BCC6 INC DE Move on to the next byte.
BCC7 DJNZ PrintBCDNumber_NextByte Jump to PrintBCDNumber_NextByte until all of the bytes have been printed.
BCC9 RET Return.
View the equivalent code in;
Prev: BCA3 Up: Map Next: BCCA