Skip to navigation

Track geometry: IncSectionPointers

Name: IncSectionPointers [Show more] Type: Subroutine Category: Track geometry Summary: Increment the track section list pointers following a shuffle 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: * ShuffleSectionList calls IncSectionPointers

This routine increments sectionListValid and sectionListPointer so they move along with the newly shuffled track section list.
.IncSectionPointers LDX sectionListValid \ Set X = sectionListValid + 1 INX \ \ If the whole section list is valid, then this marks \ the first entry in the list as invalid, which we want \ to do as we just shuffled the list and inserted a \ dummy entry into the start of the list \ \ If the whole section is not valid, then this moves \ the valid pointer along with the shuffled entries CPX #6 \ If X < 6, then the new value of sectionListValid is BCC incp1 \ within the list, so jump to incp1 to skip the \ following LDX #6 \ Set X = 6, so the maximum value of sectionListValid \ is 6 .incp1 CPX sectionListStart \ If X >= sectionListStart, then the new value of BCS incp2 \ sectionListValid is within the list, so jump to incp2 \ to skip the following LDX sectionListStart \ Set X = sectionListStart, so the minimum value of \ sectionListValid is sectionListStart, at the start of \ the list .incp2 STX sectionListValid \ Store the updated value of X in sectionListValid, so \ we mark the new entry that we shuffled in as invalid LDX sectionListPointer \ Set X = sectionListPointer + 1 INX \ Fall through into SetSectionPointers to set the track \ section list pointer to the new value, i.e. increment \ the pointer so it moves along with the shuffled values