Skip to navigation


Visibility: ProcessLine (Part 7 of 7)

Name: 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 checks
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.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 subroutine