.TurnPlayerAround LDA directionFacing \ Flip bit 7 of directionFacing to denote that our car EOR #%10000000 \ is facing in the other direction STA directionFacing JSR UpdateCurveVector \ If this is a curved track section, update the value of \ thisVectorNumber to the next segment vector along the \ track in the new direction we are facing STX segmentCounter \ We now want to initialise X track segments in the new \ direction, so set a loop counter in segmentCounter \ that starts from X and counts down .turn1 JSR GetTrackSegment \ Initialise the next track segment in the track segment \ buffer DEC segmentCounter \ Decrement the loop counter BNE turn1 \ Loop back until we have set all X track segments RTS \ Return from the subroutineName: TurnPlayerAround [Show more] Type: Subroutine Category: Car geometry Summary: Turn the player around and initialise the specified number of track segments in the new directionContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ChangeDirection calls TurnPlayerAround * MovePlayerBack calls TurnPlayerAround
Arguments: X The number of track segments to initialise in the new direction
Returns: directionFacing Bit 7 is flipped to point us in the opposite direction
[X]
Subroutine GetTrackSegment (Part 1 of 3) (category: Track geometry)
Set up the next track segment in the track segment buffer
[X]
Subroutine UpdateCurveVector (category: Track geometry)
Move to the next segment vector along in the direction we are facing, but only for curved track sections
[X]
Variable directionFacing in workspace Zero page
The direction that our car is facing
[X]
Variable segmentCounter in workspace Zero page
A counter for the track segment we are processing
[X]
Label turn1 is local to this routine