Skip to navigation


Text: UpdatePositionInfo

Name: UpdatePositionInfo [Show more] Type: Subroutine Category: Text Summary: Apply any position changes and update the position information at the top of the screen
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * UpdateLapTimers calls UpdatePositionInfo
.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 subroutine