.UpdatePositionInfo LDA positionChangeBCD \ Set A = positionChangeBCD BEQ posi1 \ If A = 0 then the race position has not changed, so \ jump to posi1 to skip updating the position number \ Otherwise we need to add the position change to the \ current position number, so we can update the number \ at the top of the screen SED \ Set the D flag to switch arithmetic to Binary Coded \ Decimal (BCD) CLC \ Set A = currentPositionBCD + A ADC currentPositionBCD \ = currentPositionBCD + positionChangeBCD STA currentPositionBCD \ Set currentPositionBCD = A CLD \ Clear the D flag to switch arithmetic to normal BEQ posi1 \ If A = 0, jump to posi1 CMP #&21 \ If A >= &21, jump to posi1 BCS posi1 LDX #0 \ Set positionChangeBCD = 0, as we have now applied the STX positionChangeBCD \ change of position to currentPositionBCD STX G \ Set G = 0 so the call to Print2DigitBCD below will \ print the second digit and will not print leading \ zeroes when printing the position number LDX #10 \ Print the position number in A at column 10, pixel LDY #24 \ row 24, on the first text line at the top of the JSR Print2DigitBCD-6 \ screen .posi1 BIT updateDriverInfo \ If bit 7 of updateDriverInfo is clear, jump to posi2 BPL posi2 \ to skip printing the driver names at the top of the \ screen LDY positionAhead \ Set Y to the position of the driver in front of us LDA #24 \ Print the name of driver Y in the "In front:" part of JSR PrintNearestDriver \ the header LDY positionBehind \ Set Y to the position of the driver behind us LDA #33 \ Print the name of driver Y in the "Behind:" part of JSR PrintNearestDriver \ the header .posi2 LSR updateDriverInfo \ Clear bit 7 of updateDriverInfo so we don't update the \ driver names until the value of updateDriverInfo \ changes RTS \ Return from the subroutineName: UpdatePositionInfo [Show more] Type: Subroutine Category: Text Summary: Apply any position changes and update the position information at the top of the screenContext: See this subroutine in context in the source code References: This subroutine is called as follows: * UpdateLapTimers calls UpdatePositionInfo
[X]
Entry point Print2DigitBCD-6 in subroutine Print2DigitBCD (category: Text)
Print the number at screen coordinate (X, Y), where X is the character column and Y is the pixel row of the bottom of the character
[X]
Subroutine PrintNearestDriver (category: Text)
Print a driver's name in the "In front" or "Behind" slot in the header
[X]
Variable currentPositionBCD in workspace Zero page
The current race position in BCD
[X]
Label posi1 is local to this routine
[X]
Label posi2 is local to this routine
[X]
Variable positionAhead in workspace Zero page
The number of the position ahead of the current player's position
[X]
Variable positionBehind in workspace Zero page
The number of the position behind the current player's position
[X]
Variable positionChangeBCD in workspace Zero page
The change in BCD for the player's race position
[X]
Variable updateDriverInfo (category: Text)
Flag that controls whether the driver names are updated in the information block at the top of the screen