Prev: ADB0 Up: Map Next: ADE5
ADC9: Take a light year off
Used by the routine at RUN_CLOCK.
Used by RUN_CLOCK, but only when the last digit has finished rolling (its count is 0). Takes one off the last digit, borrowing from the digits above it as a 0 becomes a 9; each digit that changes is given a count of 7, to roll into place.
CLOCK_BORROW ADC9 LD HL,CLOCK_LAST the last digit still rolling: nothing
ADCC LD B,$04
ADCE LD A,(HL)
ADCF AND $07
ADD1 RET NZ
CLOCK_BORROW_0 ADD2 LD A,(HL) not 0: one less, and roll
ADD3 LD C,A
ADD4 AND $F0
ADD6 JR Z,CLOCK_BORROW_1
ADD8 SUB $10
ADDA OR $07
ADDC LD (HL),A
ADDD RET
CLOCK_BORROW_1 ADDE LD A,$97 0: 9, rolling, and borrow from the next digit up
ADE0 LD (HL),A
ADE1 DEC HL
ADE2 DJNZ CLOCK_BORROW_0
ADE4 RET
Prev: ADB0 Up: Map Next: ADE5