![]() |
Routines |
| Prev: ADB0 | Up: Map | Next: ADE5 |
|
Used by the routine at UpdateLightYears.
Subtracts one from LightYearsRemaining when the animation step of its last digit has reached zero. A digit which is already zero becomes nine, with the next digit up borrowed from.
|
||||
|
See Infinite Light Years.
|
||||
| DecrementLightYears | ADC9 | LD HL,$5B39 | Point HL at LightYearsRemaining_LastDigit. | |
| ADCC | LD B,$04 | Set a counter of four digits. | ||
| ADCE | LD A,(HL) | Fetch the digit and its animation step. | ||
| ADCF | AND %00000111 | Keep bits 0 to 2. | ||
| ADD1 | RET NZ | Return if the digit is still rolling. | ||
| DecrementLightYears_SubtractFromDigit | ADD2 | LD A,(HL) | Fetch the digit and its animation step. | |
| ADD3 | LD C,A | Keep it in C. | ||
| ADD4 | AND %11110000 | Keep bits 4 to 7. | ||
| ADD6 | JR Z,DecrementLightYears_Borrow | Jump to DecrementLightYears_Borrow if the digit is zero. | ||
| ADD8 | SUB $10 | Subtract 10. | ||
| ADDA | OR %00000111 | Set bits 0 to 2. | ||
| ADDC | LD (HL),A | Store the digit and its step. | ||
| ADDD | RET | Return. | ||
| DecrementLightYears_Borrow | ADDE | LD A,$97 | Set the digit to 97. | |
| ADE0 | LD (HL),A | Store it. | ||
| ADE1 | DEC HL | Move on to the next digit up. | ||
| ADE2 | DJNZ DecrementLightYears_SubtractFromDigit | Jump to DecrementLightYears_SubtractFromDigit. | ||
| ADE4 | RET | Return. | ||
| Prev: ADB0 | Up: Map | Next: ADE5 |