Prev: 44372 Up: Map Next: 44464
44390: 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 44390 CALL DecrementLightYears Call DecrementLightYears.
44393 CALL RollCounterDigits Call RollCounterDigits.
44396 LD HL,54522 Point HL at ScreenBuffer_LightYears.
44399 LD DE,23350 Point DE at LightYearsRemaining.
44402 LD B,4 Set a counter of four digits.
44404 PUSH HL Stash the buffer address on the stack.
44405 LD HL,25352 Point HL at Font.
44408 LD (23335),HL Set FontPointer.
44411 POP HL Restore the buffer address from the stack.
UpdateLightYears_PrintDigit 44412 LD A,(DE) Fetch the digit and its animation step.
44413 INC DE Move on to the next digit.
44414 CALL PrintCounterDigit Call PrintCounterDigit.
44417 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.
44419 LD HL,54301 Point HL at ScreenBuffer_LightYearsLastDigit.
44422 LD B,8 Set a counter of eight pixel rows.
44424 LD DE,32 Set DE to 0032.
UpdateLightYears_InvertRow 44427 LD A,(HL) Fetch a row of the last digit.
44428 CPL Invert it.
44429 LD (HL),A Store it.
44430 ADD HL,DE Move up to the next row.
44431 DJNZ UpdateLightYears_InvertRow Jump to UpdateLightYears_InvertRow until all eight rows have been inverted.
44433 LD BC,4304 Set the pixel position to 208, 16.
44436 CALL CalculateScreenAddress Call CalculateScreenAddress.
44439 CALL CalculateBufferAddress Call CalculateBufferAddress.
44442 LD L,C Copy the buffer address to HL.
44443 LD H,B
44444 LD BC,2052 Set the size to eight rows of four bytes.
44447 CALL CopyBlockToScreen Call CopyBlockToScreen.
End the game if every digit is zero.
44450 LD HL,23350 Point HL at LightYearsRemaining.
44453 LD B,4 Set a counter of four digits.
44455 XOR A Set A to 0.
UpdateLightYears_TestDigit 44456 OR (HL) Combine the digit with the others.
44457 INC HL Move on to the next digit.
44458 DJNZ UpdateLightYears_TestDigit Jump to UpdateLightYears_TestDigit until all four have been combined.
44460 JP Z,GameOver Jump to GameOver if all of the digits are zero.
44463 RET Return.
Prev: 44372 Up: Map Next: 44464