Skip to navigation

Revs on the BBC Micro

Drawing the track: CheckVergeOnScreen

Name: CheckVergeOnScreen [Show more] Type: Subroutine Category: Drawing the track Summary: Check whether a verge coordinate is on-screen Deep Dive: Drawing the track verges
Context: See this subroutine in context in the source code References: This subroutine is called as follows: * MapSegmentsToLines calls CheckVergeOnScreen

This routine tests whether the magnitude of a signed yaw angle is < 20. In other words, given a signed yaw angle x, this tests whether |x| < 20. As the field of view in Revs is 20 degrees, this tests whether or not a yaw angle is visible on-screen. It does this by adding 20 and then testing against 40, which gives the result we want as the following are all equivalent: -20 < x < 20 -20 + 20 < x < 20 + 20 0 < x < 40 Arguments: X The index within the track verge buffer of the verge to check: * horizonListIndex + 40 for the left verge * horizonListIndex for the right verge Returns: V The result, where x is the verge yaw angle: * Bit 7 is clear if |x| < 20 (visible on-screen) * Bit 7 is set if |x| >= 20 (not visible)
.CheckVergeOnScreen LDA xVergeRightHi,X \ Set A to the x-coordinate of the X-th entry in the \ track segment list CLC \ Set A = A + 20 ADC #20 CMP #40 \ Set bit 7 if A >= 40, clear it if A < 40 ROR V RTS \ Return from the subroutine