.plin16 LDY GG \ Set Y to the point ID, which we stored in GG before \ jumping here or falling through from above .plin17 \ We jump straight here if line ID >= 12 and bit 7 of \ the point's status byte is set (which means we have \ already processed this point) LDA HH \ If HH is non-zero, jump to plin18 to move on to the BNE plin18 \ end point and then check the z-coordinates LDX lineId \ Check whether this line ID is close enough to be JSR CheckLineDistance \ visible (so it gets hidden if it is further away than \ the visibility distance for this line) STA showLine \ The above call returns 1 if the line is too far away, \ or the previous value of showLine if it is close \ enough to be shown, so store the updated response in \ showLine BNE plin20 \ If the response is non-zero then the line is not \ visible and showLine contains a non-zero response, so \ jump to plin20 to return from the subroutine \ Otherwise the line is close enough to be visible and \ has passed all the other visibility checks so far, so \ now we check the z-coordinates .plin18 LDA #%10000000 \ Set bit 7 of the point's status byte, to indicate that ORA pointStatus,Y \ the point has now had its coordinates and visibility STA pointStatus,Y \ calculated DEC pointCount \ Decrement pointCount so we check the end point next BEQ plin19 \ If pointCount = 0 then we have checked both the start \ and end point, so jump to plin19 to check the line's \ z-coordinates \ If we get here then we have checked the start point, \ so we now loop back to check the end point LDY M \ Set M to the point ID for the line's end point, so \ when we run through the process above, we do it for \ the end point instead of the start point JMP plin3 \ Jump back to plin3 to check the visibility of the end \ point .plin19 LDY M \ If the end point's z-coordinate is positive, jump to LDA zPointHi,Y \ plin20 to return from the subroutine BPL plin20 LDY L \ If the start point's z-coordinate is positive, jump to LDA zPointHi,Y \ plin20 to return from the subroutine BPL plin20 \ If we get here then both the start and end point have \ negative z-coordinates, so they are both behind us and \ the line is therefore not visible LDA showLine \ Set bit 7 of showLine to indicate that the line is not ORA #%10000000 \ visible STA showLine LDY isObject \ If we processed an object above, then its ID will be \ in isObject, so fetch this into Y for the following \ call JSR NextObjectGroup \ If we just processed an object in an object group, \ i.e. isObject is 6, 7, 8 or 9, then increment the \ object's group number .plin20 RTS \ Return from the subroutineName: ProcessLine (Part 7 of 7) [Show more] Type: Subroutine Category: Visibility Summary: Check distance and z-coordinates and return the final result Deep dive: Visibility checksContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine CheckLineDistance (category: Visibility)
Check whether a point on a line is within the visible distance for the line
[X]
Subroutine NextObjectGroup (category: 3D geometry)
Cycle to the next object group
[X]
Variable isObject in workspace Main variable workspace
Temporary storage, used to store the object ID when we check the visibility of an object in ProcessLine and call SetObjectCoords to set its coordinates
[X]
Label plin18 is local to this routine
[X]
Label plin19 is local to this routine
[X]
Label plin20 is local to this routine
[X]
Label plin3 in subroutine ProcessLine (Part 3 of 7)
[X]
Variable pointCount in workspace Main variable workspace
Temporary storage, used as a counter in ProcessLine to check the start and end points of the line
[X]
Variable pointStatus in workspace Main variable workspace
Each point's status byte
[X]
Variable showLine in workspace Main variable workspace
Determines whether a line is visible
[X]
Variable zPointHi (category: 3D geometry)
High byte of the z-coordinate for a point