Skip to navigation

Track geometry: GetPlayerIndex

Name: GetPlayerIndex [Show more] Type: Subroutine Category: Track geometry Summary: Set the index for the player's segment in the track section buffer to be 32 segments behind the front segment Deep dive: Data structures for the track calculations
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * GetTrackSegment (Part 3 of 3) calls GetPlayerIndex
.GetPlayerIndex LDA frontSegmentIndex \ Set A = the front track segment index * 3 - 96 SEC \ SBC #96 \ So this is 32 segments before the front track segment \ in the track segment buffer, as each buffer entry has \ three bytes BPL zsta1 \ If A < 0, set A = A + 120, so the index number wraps CLC \ around to the end of the stack ADC #120 .zsta1 STA playerSegmentIndex \ Set playerSegmentIndex to the updated index RTS \ Return from the subroutine