.fenc2 LDX #3 \ Set X = 3, to use as an index into the fencePixelsSky \ and fencePixelsGrass tables, so we draw pixel bytes \ repeatedly from these two tables to build up the fence \ effect .fenc3 CPY horizonLine \ If Y < horizonLine, then this pixel row is below the BCC fenc4 \ horizon, so jump to fenc4 to draw the fence with green \ grass behind it LDA fencePixelsSky,X \ Otherwise this pixel row is above the horizon, so set \ A to the correct pixel byte for the fence with blue \ sky behind it BNE fenc5 \ Jump to fenc5 (this BNE is effectively a JMP as A is \ never zero) .fenc4 LDA fencePixelsGrass,X \ Set A to the correct pixel byte for the fence with \ green grass behind it .fenc5 STA (P),Y \ Store A in the dash data block at (Q P), to draw this \ four-pixel part of the fence in the track view STA tyreRightEdge,Y \ Store A in the tyreRightEdge and dashRightEdge STA dashRightEdge,Y \ entries for this row, so the drawing routines can wrap \ the fence correctly around the dashboard and tyres DEX \ Decrement X to point to the next pixel byte in the \ fence pixel byte tables BPL fenc6 \ If we just decremented X to -1, set it back to 3, so LDX #3 \ X goes 3, 2, 1, 0, then 3, 2, 1, 0, and so on .fenc6 DEY \ Decrement the byte counter in Y to point to the next \ byte in the dash data block CPY U \ If Y <> U then we have not yet drawn the fence in all BNE fenc3 \ the bytes in the dash data block (as U contains the \ dashDataOffset for this block, which contains the \ offset of the last byte that we need to fill), so loop \ back to draw the next byte of the fence \ If we get here then we have drawn fence through the \ whole dash data block, so now we move on to the next \ block by updating the counter in T and pointing (Q P) \ to the next dash data block INC T \ Increment the loop counter to point to the next dash \ data block LDA P \ Set (Q P) = (Q P) + &80 EOR #&80 \ STA P \ starting with the low bytes \ \ We can do the addition more efficiently by using EOR \ to flip between &xx00 and &xx80, as the dash data \ blocks always start at these addresses BMI fenc7 \ We then increment the high byte, but only if the EOR INC Q \ set the low byte to &00 rather than &80 (if we just \ set it to the latter, the BMI will skip the INC) .fenc7 JMP fenc1 \ Loop back to part 1 to draw the fence in the next dash \ data block EQUB 0 \ This byte appears to be unusedName: DrawFence (Part 2 of 2) [Show more] Type: Subroutine Category: Screen buffer Summary: Draw the fence that we crash into when running off the trackContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Variable dashRightEdge (category: Dashboard)
Storage for the first track pixel byte along the right edge of the dashboard
[X]
Label fenc1 in subroutine DrawFence (Part 1 of 2)
[X]
Label fenc3 is local to this routine
[X]
Label fenc4 is local to this routine
[X]
Label fenc5 is local to this routine
[X]
Label fenc6 is local to this routine
[X]
Label fenc7 is local to this routine
[X]
Variable fencePixelsGrass (category: Screen buffer)
Pixel bytes for the fence with green grass behind it
[X]
Variable fencePixelsSky (category: Screen buffer)
Pixel bytes for the fence with blue sky behind it
[X]
Variable horizonLine in workspace Zero page
The track line number of the horizon
[X]
Variable tyreRightEdge in workspace Main variable workspace
Storage for the first track pixel byte along the right edge of the left tyre