Skip to navigation

Revs on the BBC Micro

Car geometry: TurnPlayerAround

Name: TurnPlayerAround [Show more] Type: Subroutine Category: Car geometry Summary: Turn the player around and initialise the specified number of track segments in the new direction
Context: 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
.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 subroutine