Skip to navigation


Drawing the track: DrawGrassRight

Name: DrawGrassRight [Show more] Type: Subroutine Category: Drawing the track Summary: Draw a green byte into the screen buffer in the second dash data block for the edge Deep dive: Drawing the track verges
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * DrawSegmentEdge (Part 6 of 7) calls DrawGrassRight * DrawShallowToLeft calls DrawGrassRight * DrawShallowToRight calls DrawGrassRight

Arguments: X The value of X from the current drawing routine: * 0 to 3 if a pixel byte has already been drawn * 128 is no pixel byte has been drawn so far Y The track line to draw on (0 to 79) (Q P) Address of the second dash data block in the memory page containing the pixels at the start of the previous edge
Returns: X 128 A A is unchanged C flag Clear
.DrawGrassRight CPX #128 \ If X <> 128 then the pixel byte has already been drawn BNE grar2 \ in the calling routine (i.e. DrawShallowToLeft or \ DrawShallowToRight), so jump to grar2 to return from \ the subroutine CPY #44 \ If Y >= 44, jump to grar1 to skip the following check, BCS grar1 \ as offsets of 44 and above are always within a dash \ data block JSR CheckDashData \ Check whether offset Y points to dash data within \ block UU, clearing the C flag if it does BCC grar2 \ If offset Y does not point to dash data, jump to grar2 \ to return from the subroutine .grar1 TAX \ Y points into dash data, so set the Y-th byte of (Q P) LDA #%11111111 \ to four pixels of colour 3 (green) STA (P),Y TXA .grar2 LDX #128 \ Set X = 128 to reset the draw detection logic for the \ next byte to draw CLC \ Clear the C flag RTS \ Return from the subroutine