.UpdateVectorNumber LDA directionFacing \ If our car is facing backwards, jump to uvec1 BMI uvec1 LDY thisVectorNumber \ Set Y to the current segment vector number INY \ Increment Y to point to the next segment vector number \ along the track CPY trackVectorCount \ If Y <> trackVectorCount, then we have not reached the BNE uvec3 \ last vector, so jump to uvec3 to store the new value \ of thisVectorNumber LDY #0 \ If we get here then we have reached the last vector, \ so set Y = 0 to wrap around to the first vector BEQ uvec3 \ Jump to uvec3 to set thisVectorNumber = 0 (this BEQ is \ effectively a JMP as Y is always zero) .uvec1 \ If we get here then our car is facing backwards LDY thisVectorNumber \ Set Y to the current segment vector number BNE uvec2 \ If Y <> 0, then we are not on the first segment \ vector, so jump to uvec2 to decrement to the previous \ vector LDY trackVectorCount \ Set Y = trackVectorCount, so we wrap around to the \ last vector .uvec2 DEY \ Decrement Y to point to the previous segment vector \ number, i.e. backwards along the track .uvec3 STY thisVectorNumber \ Update thisVectorNumber with the new value that we set \ above .uvec4 RTS \ Return from the subroutineName: UpdateVectorNumber [Show more] Type: Subroutine Category: Track geometry Summary: Move to the next segment vector along the track in the direction we are facing Deep dive: Building a 3D track from sections and segmentsContext: See this subroutine in context in the source code References: This subroutine is called as follows: * GetFirstSegment calls UpdateVectorNumber
Returns: thisVectorNumber Set to the number of the next segment vector along the track in the direction in which we are facing
[X]
Variable directionFacing in workspace Zero page
The direction that our car is facing
[X]
Variable thisVectorNumber in workspace Zero page
The number of the segment vector for the current track segment, ready to store in the track segment buffer as segmentVector
[X]
Variable trackVectorCount in workspace trackData
The total number of segment vectors in the segment vector tables
[X]
Label uvec1 is local to this routine
[X]
Label uvec2 is local to this routine
[X]
Label uvec3 is local to this routine