Prev: 48291 Up: Map Next: 48330
48302: 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 48302 PUSH HL Stash the screen buffer address on the stack.
48303 LD HL,24840 Set FontPointer to Font.
48306 LD (23495),HL
48309 POP HL Restore the screen buffer address from the stack.
Print the upper digit of the byte.
PrintBCDNumber_NextByte 48310 LD A,(DE) Fetch a byte of the number.
48311 RRCA Move the upper digit to the lowest four bits.
48312 RRCA
48313 RRCA
48314 RRCA
48315 AND %00001111 Keep only bits 0 to 3.
48317 CALL PrintCharacter Call PrintCharacter.
This entry point is used by the routine at PrintPercentageComplete.
Print the lower digit and move on.
PrintBCDNumber_SecondDigit 48320 LD A,(DE) Fetch a byte of the number.
48321 AND %00001111 Keep only bits 0 to 3.
48323 CALL PrintCharacter Call PrintCharacter.
48326 INC DE Move on to the next byte.
48327 DJNZ PrintBCDNumber_NextByte Jump to PrintBCDNumber_NextByte until all of the bytes have been printed.
48329 RET Return.
View the equivalent code in;
Prev: 48291 Up: Map Next: 48330