Skip to navigation

Revs on the BBC Micro

Car geometry: PushCarOffTrack

Name: PushCarOffTrack [Show more] Type: Subroutine Category: Car geometry Summary: Push a car off the track and out of the race Deep dive: Tactics of the non-player drivers
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessContact calls PushCarOffTrack

Arguments: X The driver number of the car to push off the track
.PushCarOffTrack CPX #20 \ If X >= 20 then this is not a valid driver, so return BCS BuildPlayerCar-1 \ from the subroutine (as BuildPlayerCar-1 contains an \ RTS) LDA carRacingLine,X \ Fetch the car's current racing line AND #%01111111 \ Clear bit 7 and set bits 0, 2 and 6 ORA #%01000101 STA carSteering,X \ Update the car's steering byte, so the car does the \ following: \ \ * Bit 7 clear = veer to the left \ \ * Bit 6 set = only apply this steering if there is \ room to do so, otherwise just keep the \ car on the track \ \ * Bits 0-5 = set steering amount to at least 5 \ (%101) LDA #%10010001 \ Set bits 0, 4 and 7 of the car's status byte, so: STA carStatus,X \ \ * Bit 0 set = do not update this carStatus byte when \ in the ProcessOvertaking routine, so \ overtaking tactics are disabled \ \ * Bit 4 set = do not follow the segment's steering \ line in segmentSteering, so the car \ doesn't automatically steer around \ corners \ \ * Bit 7 set = apply brakes \ Fall through into ClearTotalRaceTime to set the car \ object to be hidden and no longer racing, and reset \ the car's total race time