Skip to navigation

Revs on the BBC Micro

Drivers: SwapDriverPosition

Name: SwapDriverPosition [Show more] Type: Subroutine Category: Drivers Summary: Swap the position for two drivers (i.e. overtake)
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessOvertaking (Part 1 of 3) calls SwapDriverPosition * ResetVariables calls SwapDriverPosition

Arguments: X The first position Y The second position
Returns: X The number of the driver now at position X Y The number of the driver now at position Y
.SwapDriverPosition LDA driversInOrder,X \ Set T to the number of the driver at position X STA T LDA driversInOrder,Y \ Set A to the number of the driver at position Y STA driversInOrder,X \ Set the driver at position X to the driver from \ position Y TAX \ Set X to the number of the driver now at position X LDA T \ Set the driver at position y to the driver from STA driversInOrder,Y \ position X TAY \ Set Y to the number of the driver now at position Y RTS \ Return from the subroutine