Skip to navigation


Main loop: MainDrivingLoop (Part 5 of 5)

Name: MainDrivingLoop (Part 5 of 5) [Show more] Type: Subroutine Category: Main loop Summary: Main driving loop: Process driving keys, potentially leaving the track, and loop back to part 2 Deep dive: Program flow of the main game loop
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.main10 IF _ACORNSOFT OR _4TRACKS LDY #9 \ Check for all the shifted keys (i.e. those that need JSR ProcessShiftedKeys \ SHIFT holding down to trigger) and process them \ accordingly ELIF _SUPERIOR OR _REVSPLUS LDY #11 \ Check for all the shifted keys (i.e. those that need JSR ProcessShiftedKeys \ SHIFT holding down to trigger) and process them \ accordingly ENDIF LDA configStop \ If configStop = 0, then we aren't pressing one of the BEQ main11 \ keys that stops the race, so jump to main11 to keep \ iterating round the main driving loop BPL main9 \ If bit 7 of configStop is clear then we must be \ pressing SHIFT-f7 to retire from the race, so jump to \ main9 to leave the track AND #%01000000 \ If bit 6 of configStop is clear (and we know bit 7 is BEQ main13 \ set), then we must be pressing SHIFT and right arrow, \ so jump to main13 to leave the track and restart the \ game \ If we get here then we know both bit 6 and bit 7 must \ be set, so we must be pressing SHIFT-f0 to return to \ the pits LDA playerMoving \ If playerMoving = 0 then the player's car is BEQ main13 \ stationary, so jump to main13 to leave the track and \ return to the pits LDA #0 \ We can't enter the pits if the car is moving, so set STA configStop \ configStop = 0 so we clear out the SHIFT-f4 key press .main11 LDX leaveTrackTimer \ Set X to the current value of the leave track timer BEQ main12 \ If X = 0 then the leave track timer is not running, so \ jump to main12 to continue with the main driving loop DEX \ The leave track timer is running, so decrement the \ timer value in X BEQ main9 \ If X = 0 then the leave track timer was 1 before the \ decrement and has now run down, so jump to main9 to \ leave the track STX leaveTrackTimer \ Store the decremented leave track timer so that it \ continues counting down towards 1 .main12 JSR MakeDrivingSounds \ Make the relevant sounds for the engine and tyres JSR UpdateDashboard \ Update the rev counter on the dashboard JMP main5 \ Loop back to main5 to repeat the main driving loop .main13 \ If we get here then we leave the track and switch back \ to mode 7, either to visit the pits or because the \ driving is done LDA #%10000000 \ Copy the dash data from screen memory back to the main JSR CopyDashData \ game code JSR KillCustomScreen \ Disable the custom screen mode and switch to mode 7 RTS \ Return from the subroutine