.GetSectionCoords JSR GetSectionCoord \ Copy the following 16-bit coordinate: \ \ * The Y-th xTrackSectionI to the X-th xSegmentCoordI \ \ * The Y-th yTrackSectionI to the X-th ySegmentCoordI \ \ * The Y-th zTrackSectionI to the X-th zSegmentCoordI LDA xTrackSectionOLo,Y \ Copy the following 16-bit coordinate: STA xSegmentCoordOLo,X \ LDA zTrackSectionOLo,Y \ * The Y-th xTrackSectionO to the X-th xSegmentCoordO STA zSegmentCoordOLo,X \ \ * The Y-th zTrackSectionO to the X-th zSegmentCoordO \ \ starting with the low bytes LDA xTrackSectionOHi,Y \ And then the high bytes STA xSegmentCoordOHi,X LDA zTrackSectionOHi,Y STA zSegmentCoordOHi,X LDA trackSectionFrom,Y \ Set thisVectorNumber = the Y-th trackSectionFrom STA thisVectorNumber \ Fall through into CopySectionData to copy the \ following 16-bit coordinate: \ \ * The Y-th yTrackSectionI to the X-th ySegmentCoordO \ \ This works because the call to GetSectionCoord already \ stored the Y-th yTrackSectionI in the X-th \ ySegmentCoordI, and the following now copies that into \ the X-th ySegmentCoordOName: GetSectionCoords [Show more] Type: Subroutine Category: Track geometry Summary: Copy two three-part 16-bit coordinates from the track section data 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 GetSectionCoords
This routine is normally called with X as a multiple of 3 in the range 0 to 117, representing track segments 0 to 39. The routine copies the following track section coordinates from the track section data for section Y * 8: * xTrackSectionI * yTrackSectionI * zTrackSectionI and stores them in the X-th coordinate in (xSegmentCoordI, ySegmentCoordI, zSegmentCoordI). It also copies the following track section coordinates: * xTrackSectionO * yTrackSectionI * zTrackSectionO and stores them in the X-th coordinate in (xSegmentCoordO, ySegmentCoordO, zSegmentCoordO). Note that the y-coordinate is set to the same value as the y-coordinate from the first copy. It also sets thisVectorNumber to trackSectionFrom for the Y-th track section data. Specifically, this copies data from the Y-th track section entry: (xTrackSectionIHi xTrackSectionILo) (yTrackSectionIHi yTrackSectionILo) (zTrackSectionIHi zTrackSectionILo) (xTrackSectionOHi xTrackSectionOLo) (yTrackSectionIHi yTrackSectionILo) (zTrackSectionOHi zTrackSectionOLo) trackSectionFrom and stores it in the X-th track segment: (xSegmentCoordIHi xSegmentCoordILo) (ySegmentCoordIHi ySegmentCoordILo) (zSegmentCoordIHi zSegmentCoordILo) (xSegmentCoordOHi xSegmentCoordOLo) (ySegmentCoordOHi ySegmentCoordOLo) (zSegmentCoordOHi zSegmentCoordOLo) thisVectorNumber
Arguments: Y The number of the track section * 8 whose coordinates we want to fetch X The index * 3 of the track segment where we store the coordinates
[X]
Subroutine GetSectionCoord (category: Track geometry)
Copy a three-part 16-bit coordinate from the track section data
[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 trackSectionFrom in workspace trackData
The number of the first segment vector in each section, which enables us to fetch the segment vectors for a given track section
[X]
Variable xSegmentCoordOHi in workspace Main variable workspace
The high byte of the 3D x-coordinate for an outer track segment in the track segment buffer
[X]
Variable xSegmentCoordOLo in workspace Main variable workspace
The low byte of the 3D x-coordinate for an outer track segment in the track segment buffer
[X]
Variable xTrackSectionOHi in workspace trackData
High byte of the x-coordinate of the starting point of the outside verge of each track section
[X]
Variable xTrackSectionOLo in workspace trackData
Low byte of the x-coordinate of the starting point of the outside verge of each track section
[X]
Variable zSegmentCoordOHi in workspace Main variable workspace
The high byte of the 3D z-coordinate for an outer track segment in the track segment buffer
[X]
Variable zSegmentCoordOLo in workspace Main variable workspace
The low byte of the 3D z-coordinate for an outer track segment in the track segment buffer
[X]
Variable zTrackSectionOHi in workspace trackData
High byte of the z-coordinate of the starting point of the outside verge of each track section
[X]
Variable zTrackSectionOLo in workspace trackData
Low byte of the z-coordinate of the starting point of the outside verge of each track section