Skip to navigation


Screen buffer: ResetTrackLines

Name: ResetTrackLines [Show more] Type: Subroutine Category: Screen buffer Summary: Reset the track lines below the horizon in the track view
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MainDrivingLoop (Part 2 of 5) calls ResetTrackLines * ProcessShiftedKeys calls ResetTrackLines

This routine does the following: * Set horizonLine+1 bytes at rightGrassStart to &80 * Set horizonLine+1 bytes at leftVergeStart to &80 * Set horizonLine+1 bytes at rightVergeStart to &80 * Set horizonLine+1 bytes at leftTrackStart to &80 * Set 80 bytes at backgroundColour to 0 Setting each of the four verge edges to &80 effectively pushes the edges off the right edge of the screen, which resets the verge edges on that track line. By resetting the first horizonLine+1 bytes in each verge edge block, we are resetting all the edges for track lines below the horizon, i.e. from track line 0 at the bottom of the screen to track line horizonLine+1 on the horizon. Setting the 80 bytes at backgroundColour to zero resets the background colour for all track lines.
.ResetTrackLines LDX horizonLine \ We start by setting horizonLine+1 bytes at \ leftVergeStart, rightGrassStart rightVergeStart and \ leftTrackStart to &80, so set a byte counter in X LDA #&80 \ Set A = &80 to use as our reset value .resl1 STA leftVergeStart,X \ Set the X-th byte of leftVergeStart to &80 STA leftTrackStart,X \ Set the X-th byte of leftTrackStart to &80 STA rightVergeStart,X \ Set the X-th byte of rightVergeStart to &80 STA rightGrassStart,X \ Set the X-th byte of rightGrassStart to &80 DEX \ Decrement the byte counter BPL resl1 \ Loop back until we have zeroed all horizonLine+1 bytes LDX #79 \ We now zero the 80 bytes at backgroundColour, so set a \ byte counter in X LDA #0 \ Set A = 0 to use as our zero value .resl2 STA backgroundColour,X \ Zero the X-th byte of backgroundColour DEX \ Decrement the byte counter BPL resl2 \ Loop back until we have zeroed all 80 bytes RTS \ Return from the subroutine