Skip to navigation


Drivers: SetPlayerPositions

Name: SetPlayerPositions [Show more] Type: Subroutine Category: Drivers Summary: Set the current player's position, plus the positions behind and in front
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * FinishRace calls SetPlayerPositions * MoveAndDrawCars calls SetPlayerPositions * ResetVariables calls SetPlayerPositions * SortDrivers calls SetPlayerPositions
.SetPlayerPositions LDA currentPlayer \ Set A to the number of the current player LDX #19 \ We are about to work our way through the ordered list \ of drivers in driversInOrder, so set a loop counter \ in X, starting at the end of the list (i.e. last \ place) .ppos1 CMP driversInOrder,X \ If the driver in position X in the list matches the BEQ ppos2 \ current player, jump to ppos2 DEX \ Decrement the driver number BPL ppos1 \ Loop back until we have gone through the whole table .ppos2 \ By this point, X contains the position within the \ driversInOrder list of the current player (or -1 if \ the current player doesn't appear in the list) STX currentPosition \ Store the current player's position in currentPosition JSR GetPositionBehind \ Set X to the number of the position behind this one STX positionBehind \ Store the position behind the current player in \ positionBehind LDX currentPosition \ Set X to the number of the position ahead of the JSR GetPositionAhead \ current player's position STX positionAhead \ Store the position ahead of the current player in \ positionAhead RTS \ Return from the subroutine