Skip to navigation

Revs on the BBC Micro

Track geometry: SetSectionPointers

Name: SetSectionPointers [Show more] Type: Subroutine Category: Track geometry Summary: Set the track section list pointer to a specific value and update the validity pointer accordingly
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * GetSectionAngles (Part 3 of 3) calls SetSectionPointers

Arguments: X The new value for sectionListPointer
.SetSectionPointers INX \ Set X = X + 1 \ \ So X points to the entry above the proposed pointer \ value in the list CPX sectionListValid \ If X >= sectionListValid, then this entry is valid, so BCS secp1 \ jump to secp1 to skip the following STX sectionListValid \ Set sectionListValid = X, so the value at the proposed \ pointer is flagged as not valid, but the value above \ it is valid .secp1 DEX \ Set X = X - 1 \ \ so X is back to its original value, the proposed value \ of sectionListPointer CPX sectionListStart \ If X >= sectionListStart, then the proposed pointer BCS secp2 \ value is not before the start of the list, so jump to \ secp2 to skip the following LDX #5 \ The proposed pointer is not within the list, so set \ X = 5, so we set sectionListPointer to 5 below .secp2 CPX #6 \ If X < 6, then the proposed pointer valus is not past BCC secp3 \ the end of the list, so jump to secp3 to skip the \ following LDX #5 \ The proposed pointer is past the end of the list, so \ set X = 5, so we set sectionListPointer to 5 below .secp3 STX sectionListPointer \ Store the updated value of X in sectionListPointer RTS \ Return from the subroutine