Sherlock: annotated disassembly

Routines

Prev: A476 Up: Map Next: A490
A480: Print one digit of HL / DE, skipping leading zeros (C)
Used by the routine at A490.
Input
HL The number
DE The place value (100 or 10)
C 0 while still skipping leading zeros
Output
HL The remainder
C Non-zero once a digit has been printed
A480 CALL $A476 One digit of the number (A476)
A483 ADD A,$30 Make it an ASCII digit
A485 DEC C Subtract one from C - C = the leading-zero flag: still zero?
A486 INC C Add one to C
A487 JR NZ,$A48D If C is not zero, skip ahead to A48D
A489 CP $30 Compare A with $30 - A '0' while leading: print nothing
A48B RET Z If A equals $30, return
A48C INC C Otherwise from now on print zeros too (C = 1)
A48D JP $A9B7 Print the digit (A9B7)
Prev: A476 Up: Map Next: A490