Skip to navigation


Track geometry: GetSectionCoord

Name: GetSectionCoord [Show more] Type: Subroutine Category: Track geometry Summary: Copy a three-part 16-bit coordinate from the track section data Deep dive: Building a 3D track from sections and segments
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * BuildRoadSign calls GetSectionCoord * GetSectionAngles (Part 3 of 3) calls GetSectionCoord * GetSectionCoords calls GetSectionCoord

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 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). Specifically, this copies data from the Y-th track section entry: (xTrackSectionIHi xTrackSectionILo) (yTrackSectionIHi yTrackSectionILo) (zTrackSectionIHi zTrackSectionILo) and stores it in the X-th track segment: (xSegmentCoordIHi xSegmentCoordILo) (ySegmentCoordIHi ySegmentCoordILo) (zSegmentCoordIHi zSegmentCoordILo) This routine is also called with X = &FD, in which case it copies the following: Y-th (xTrackSectionIHi xTrackSectionILo) to (xCoord2Hi xCoord2Lo) Y-th (yTrackSectionIHi yTrackSectionILo) to (yCoord2Hi yCoord2Lo) Y-th (zTrackSectionIHi zTrackSectionILo) to (zCoord2Hi zCoord2Lo)
Arguments: Y The number of the track section * 8 whose coordinates we want to fetch X The place to store the data: * 0-117 = The index * 3 of the track segment where we store the coordinates * &FD = Copy to (xCoord2, yCoord2, zCoord2)
.GetSectionCoord LDA xTrackSectionILo,Y \ Copy the following 16-bit coordinates: STA xSegmentCoordILo,X \ LDA yTrackSectionILo,Y \ * The Y-th xTrackSectionI to the X-th xSegmentCoordI STA ySegmentCoordILo,X \ LDA zTrackSectionILo,Y \ * The Y-th yTrackSectionI to the X-th ySegmentCoordI STA zSegmentCoordILo,X \ \ * The Y-th zTrackSectionI to the X-th zSegmentCoordI \ \ starting with the low bytes LDA xTrackSectionIHi,Y \ And then the high bytes STA xSegmentCoordIHi,X LDA yTrackSectionIHi,Y STA ySegmentCoordIHi,X LDA zTrackSectionIHi,Y STA zSegmentCoordIHi,X RTS \ Return from the subroutine