Prev: AD54 Up: Map Next: ADB0
AD66: Update Light Years
Used by the routine at RunGame.
Counts the light years down, prints the four digits in the counter box, inverts the last of them and copies the counter to the screen. When all of the digits and their animation steps are zero the game is over. The light years go down by one every eight frames.
Print the four digits into the buffer.
UpdateLightYears AD66 CALL DecrementLightYears Call DecrementLightYears.
AD69 CALL RollCounterDigits Call RollCounterDigits.
AD6C LD HL,$D4FA Point HL at ScreenBuffer_LightYears.
AD6F LD DE,$5B36 Point DE at LightYearsRemaining.
AD72 LD B,$04 Set a counter of four digits.
AD74 PUSH HL Stash the buffer address on the stack.
AD75 LD HL,$6308 Point HL at Font.
AD78 LD ($5B27),HL Set FontPointer.
AD7B POP HL Restore the buffer address from the stack.
UpdateLightYears_PrintDigit AD7C LD A,(DE) Fetch the digit and its animation step.
AD7D INC DE Move on to the next digit.
AD7E CALL PrintCounterDigit Call PrintCounterDigit.
AD81 DJNZ UpdateLightYears_PrintDigit Jump to UpdateLightYears_PrintDigit until all four digits have been printed.
Invert the last digit and copy the counter to the screen.
AD83 LD HL,$D41D Point HL at ScreenBuffer_LightYearsLastDigit.
AD86 LD B,$08 Set a counter of eight pixel rows.
AD88 LD DE,$0020 Set DE to 0020.
UpdateLightYears_InvertRow AD8B LD A,(HL) Fetch a row of the last digit.
AD8C CPL Invert it.
AD8D LD (HL),A Store it.
AD8E ADD HL,DE Move up to the next row.
AD8F DJNZ UpdateLightYears_InvertRow Jump to UpdateLightYears_InvertRow until all eight rows have been inverted.
AD91 LD BC,$10D0 Set the pixel position to D0, 10.
AD94 CALL CalculateScreenAddress Call CalculateScreenAddress.
AD97 CALL CalculateBufferAddress Call CalculateBufferAddress.
AD9A LD L,C Copy the buffer address to HL.
AD9B LD H,B
AD9C LD BC,$0804 Set the size to eight rows of four bytes.
AD9F CALL CopyBlockToScreen Call CopyBlockToScreen.
End the game if every digit is zero.
ADA2 LD HL,$5B36 Point HL at LightYearsRemaining.
ADA5 LD B,$04 Set a counter of four digits.
ADA7 XOR A Set A to 00.
UpdateLightYears_TestDigit ADA8 OR (HL) Combine the digit with the others.
ADA9 INC HL Move on to the next digit.
ADAA DJNZ UpdateLightYears_TestDigit Jump to UpdateLightYears_TestDigit until all four have been combined.
ADAC JP Z,GameOver Jump to GameOver if all of the digits are zero.
ADAF RET Return.
Prev: AD54 Up: Map Next: ADB0