\ 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 subroutineName: GetTileViewAngles (Part 4 of 4) [Show more] Type: Subroutine Category: Drawing the landscape Summary: Calculate how much of the tile is on-screenContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Variable bufferMaxYawHi in workspace Zero page
The maximum allowed yaw angle for points in the current screen buffer (high byte)
[X]
Variable bufferMinYawHi in workspace Zero page
The minimum allowed yaw angle for points in the current screen buffer (high byte)
[X]
Variable bufferMinYawLo in workspace Zero page
The minimum allowed yaw angle for points in the current screen buffer (low byte)
[X]
Variable drawViewYawHi (category: Drawing the landscape)
Storage for the yaw angles of tiles and object points for drawing the current landscape view (high bytes)
[X]
Variable drawViewYawLo (category: Drawing the landscape)
Storage for the yaw angles of tiles and object points for drawing the current landscape view (low bytes)
[X]
Label tang10 is local to this routine
[X]
Label tang11 is local to this routine
[X]
Variable tileIsOnScreen in workspace Zero page
Information on whether a tile is fully on-screen, partially on-screen or fully off-screen
[X]
Variable yStoreTileView in workspace Zero page
Temporary storage for Y so it can be preserved through calls to GetTileViewAngles