Skip to navigation

Aviator on the BBC Micro

3D geometry: AddTempToPoint (Part 2 of 2)

Name: AddTempToPoint (Part 2 of 2) [Show more] Type: Subroutine Category: 3D geometry Summary: Check whether the vector addition overflowed and set the point's visibility accordingly
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
.addv1 \ This routine follows on directly from the part 1 of \ AddTempToPoint PHP \ Store the flags for the z-axis addition on the stack, \ so we can check them below LDX #2 \ We now want to check whether the vector addition \ overflowed in any direction, so set as a counter for \ the three axes .addv2 PLP \ Retrieve the flags from the stack, so we work through \ the flags from the z-, y- and x-axes in turn BVC addv3 \ If the C flag is clear then this addition didn't \ overflow, so jump to addv3 to move on to the next axis LDA #%01000000 \ The addition overflowed for this axis, so set bit 6 of STA showLine \ showLine so the line containing this point is marked \ as not being visible .addv3 DEX \ Decrement the counter to move on to the next axis BPL addv2 \ Loop back until we have checked the flags from all \ three additions RTS \ Return from the subroutine