.CheckLineDistance LDA xPointHi,Y \ Set A to the high byte of the point's x-coordinate BPL dist1 \ If the x-coordinate is positive, skip the following \ instruction EOR #&FF \ Otherwise flip the x-coordinate so it's positive, so: \ \ A = |xPointHi| .dist1 CMP maxLineDistance,X \ If A >= this line's visible distance, then the point BCS dist4 \ is too far away to be seen in the x-axis, so jump to \ dist4 to return a "not visible" result LDA yPointHi,Y \ Set A to the high byte of the point's y-coordinate BPL dist2 \ If the y-coordinate is positive, skip the following \ instruction EOR #&FF \ Otherwise flip the y-coordinate so it's positive, so: \ \ A = |yPointHi| .dist2 CMP maxLineDistance,X \ If A >= this line's visible distance, then the point BCS dist4 \ is too far away to be seen in the y-axis, so jump to \ dist4 to return a "not visible" result LDA zPointHi,Y \ Set A to the high byte of the point's z-coordinate BPL dist3 \ If the z-coordinate is positive, skip the following \ instruction EOR #&FF \ Otherwise flip the z-coordinate so it's positive, so: \ \ A = |zPointHi| .dist3 CMP maxLineDistance,X \ If A < this line's visible distance, then the point BCC dist5 \ is close enough to be visible in the z-axis, so jump \ to dist5 to return an "is visible" result .dist4 \ If we get here then the point is too far away to be \ visible in at least one axis LDA #1 \ Set A = 1 as the return value for a "not visible" \ result RTS \ Return from the subroutine .dist5 LDA #0 \ The point is close enough to be visible, so return the ORA showLine \ current value of showLine (this could be achieved by a \ simple LDA showLine instruction, so perhaps this more \ convoluted approach is left over from a different \ version of the routine) RTS \ Return from the subroutineName: CheckLineDistance [Show more] Type: Subroutine Category: Visibility Summary: Check whether a point on a line is within the visible distance for the lineContext: See this subroutine in context in the source code References: This subroutine is called as follows: * ProcessLine (Part 7 of 7) calls CheckLineDistance * ProcessRunwayLine (Part 3 of 5) calls CheckLineDistance * UpdateBullets calls CheckLineDistance
Arguments: X The line ID of the line to check Y The point ID of the point to check
Returns: A Contains the result as follows: * The current value of showLine if the point is close enough to be visible * 1 if the point is too far away to be visible
[X]
Label dist1 is local to this routine
[X]
Label dist2 is local to this routine
[X]
Label dist3 is local to this routine
[X]
Label dist4 is local to this routine
[X]
Label dist5 is local to this routine
[X]
Variable maxLineDistance (category: Visibility)
The furthest distance at which each line is visible
[X]
Variable showLine in workspace Main variable workspace
Determines whether a line is visible
[X]
Variable xPointHi (category: 3D geometry)
High byte of the x-coordinate for a point
[X]
Variable yPointHi in workspace Main variable workspace
The high byte of the y-coordinate for the point with ID X is at yPointHi,X
[X]
Variable zPointHi (category: 3D geometry)
High byte of the z-coordinate for a point