Skip to navigation

Drawing the landscape: GetTileViewAngles (Part 4 of 4)

Name: GetTileViewAngles (Part 4 of 4) [Show more] Type: Subroutine Category: Drawing the landscape Summary: Calculate how much of the tile is on-screen
Context: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
\ By this point we have pitch and yaw angles for the \ vector between the viewer and the tile that we are \ analysing, relative to the viewing gaze, so we now \ need to work out the value of tileIsOnScreen to return \ \ We set tileIsOnScreen to zero at the start of the \ routine, to indicate that the tile is not on-screen \ \ We now set the following bits if applicable: \ \ * Set bit 7 when \ drawViewYaw(Hi Lo) >= bufferMinYaw(Hi Lo) \ \ * Set bit 0 when drawViewYawHi >= bufferMaxYawHi \ \ So bit 7 is set when the tile corner is inside the \ minimum yaw limit, and bit 0 is set when the tile \ corner is inside (but not on) the maximum yaw limit \ \ If the yaw limit is the screen size, then the two bits \ determine whether the tile is on-screen LDA drawViewYawHi,Y \ If drawViewYawHi < bufferMinYawHi, jump to tang11 to CMP bufferMinYawHi \ return with tileIsOnScreen = 0, as the tile is off the BCC tang11 \ left of the screen edge BNE tang10 \ If drawViewYawHi > bufferMinYawHi, jump to tang10 with \ the C flag set to set bit 7 of tileIsOnScreen \ If we get here then drawViewYawHi = bufferMinYawHi, so \ we now check the low bytes LDA drawViewYawLo,Y \ If drawViewYawLo < bufferMinYawLo, jump to tang11 to CMP bufferMinYawLo \ return with tileIsOnScreen = 0 BCC tang11 LDA drawViewYawHi,Y \ If we get here then drawViewYawLo >= bufferMinYawLo, \ so the C flag is set, and we set A to drawViewYawHi \ for the comparison below .tang10 \ If we get here then the C flag is set, as we have to \ pass through a BCC to get here ROR tileIsOnScreen \ Set bit 7 of tileIsOnScreen, so bit 7 is set if the \ tile is on or to the right of the minimum yaw limit, \ i.e. to the right of the left edge of the screen CMP bufferMaxYawHi \ If drawViewYawHi < bufferMaxYawHi, jump to tang11 to BCC tang11 \ return from the routine with bit 0 of tileIsOnScreen \ clear \ If we get here then drawViewYawHi >= bufferMaxYawHi, \ so the tile is off-screen to the right INC tileIsOnScreen \ Set bit 0 of tileIsOnScreen to indicate that the tile \ is to the right of the maximum yaw limit, i.e. to the \ right of the right edge of the screen .tang11 LDY yStoreTileView \ Restore Y so that it's preserved LDA tileIsOnScreen \ Set A to the value of tileIsOnScreen, to return from \ the subroutine CLC \ Clear the C flag to indicate that we have not gone \ past the end of the tile row, which is used when \ calling this routine via GetTileEdgeToLeft or \ GetTileEdgeToRight RTS \ Return from the subroutine