Skip to navigation

# Track geometry: GetVergeAndMarkers (Part 3 of 4)

```       Name: GetVergeAndMarkers (Part 3 of 4)                        [Show more]
Type: Subroutine
Category: Track geometry
Summary: Process the segment's corner markers
Context: See this subroutine in context in the source code
References: No direct references to this subroutine in this source file

LDA W                  \ If bits 3 and 4 of W are clear, which are these bits
AND #%00011000         \ in the segment flags:
BEQ gmar9              \
\   * Bit 3 (show right corner markers)
\   * Bit 4 (show left corner markers)
\
\ then we do not show any corner markers for this
\ segment, so jump to gmar9 to move on to the verge
\ marks in part 4

\ If we get here then we have a marker to draw for this
\ segment

LDY markersToDraw      \ Set Y to the number of markers we have to draw

CPY #3                 \ If Y >= 3, then we already have three markers ready
BCS gmar9              \ to show, which is the maximum at any one time, so
\ jump to gmar9 to skip the following

LDA segmentListPointer \ Set markerListIndex for marker Y to segmentListPointer
STA markerListIndex,Y

LDA W                  \ Set markerData for marker Y to the segment flags for
STA markerData,Y       \ this marker in W

AND #1                 \ If bit 0 of W is clear, then this is a straight track
BEQ gmar8              \ section, so jump to gmar8 to skip the following
\ instruction

\ This is a curved section, so move the markers closer
\ to the track edge by halving the distance that we
\ store in xMarker

LSR U                  \ Set (U T) = (U T) >> 1
ROR T

.gmar8

LDA T                  \ Set (xMarkerHi xMarkerLo) for marker Y to (U T), so
STA xMarkerLo,Y        \ xMarker contains the width of the verge (halved if
LDA U                  \ this is a corner), which we can use as the x-axis
STA xMarkerHi,Y        \ distance from the track verge to the marker

INC markersToDraw      \ Increment markersToDraw, as we have just added a new
\ marker to the list
```