.gaze5 \ If we get here then the tile is not flat and A is set \ to the tile altitude from the tile data STA S \ Set S to the tile altitude STA W \ Set W to the tile altitude \ \ This ensures that when we access the altitudes of the \ four tile corners in part 5 using variables S, T, U \ and V, the list wraps around in memory into variable W \ to support corner pairs for all four edges - see part \ 5 for details LSR considerObjects \ Clear bit 7 of considerObjects so GetTileAltitude will \ only extract the altitude and flatness of the tiles \ when we call it below, ignoring any objects on the \ landscape INC xTile \ Move along the x-axis to fetch the next tile to the \ right JSR GetTileAltitude \ Call GetTileAltitude with bit 7 of considerObjects \ clear to extract the following tile data: \ \ * A = the high byte of the tile's altitude (which \ is also the altitude of the tile corner) \ \ * C flag = the tile's shape, clear if the tile is \ flat or set if the tile is not flat STA V \ Set V to the altitude of the tile to the right INC zTile \ Move along the x-axis to fetch the next tile into the \ screen JSR GetTileAltitude \ Call GetTileAltitude with bit 7 of considerObjects \ clear to extract the following tile data: \ \ * A = the high byte of the tile's altitude (which \ is also the altitude of the tile corner) \ \ * C flag = the tile's shape, clear if the tile is \ flat or set if the tile is not flat STA U \ Set U to the altitude of the tile behind DEC xTile \ Move back along the x-axis to fetch the next tile to \ the left JSR GetTileAltitude \ Call GetTileAltitude with bit 7 of considerObjects \ clear to extract the following tile data: \ \ * A = the high byte of the tile's altitude (which \ is also the altitude of the tile corner) \ \ * C flag = the tile's shape, clear if the tile is \ flat or set if the tile is not flat STA T \ Set V to the altitude of the tile to the left DEC zTile \ Move out of the screen, back along the z-axis to take \ us back to the tile we are processing \ So at this point we have the altitudes of four tile \ corners, as follows, with the view from above: \ \ ^ [T] [U] \ | \ | [S] [V] \ z-axis \ into \ screen x-axis from left to right ---> \ \ S is the altitude of the tile corner that anchors the \ tile below the current position along the viewer's \ gaze, and T, U and V are the altitudes of the tile's \ other three corners, so now we can analyse how the \ gaze interacts with the shape of the tile JSR GetTileData \ Set A to the tile data for the tile anchored at \ (xTile, zTile) AND #%00001111 \ The tile shape is in the low nibble of the tile data, \ so extract the tile shape into A CMP #4 \ If the tile shape is 4 then jump to gaze6 BEQ gaze6 CMP #12 \ If the tile shape is 12 then keep going, otherwise BNE gaze8 \ jump to gaze8 .gaze6 \ The tile shape is 4 or 12, so fall through into part 3 \ to process this shapeName: FollowGazeVector (Part 2 of 5) [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Calculate the altitudes of the four corners in a non-flat tileContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
[X]
Subroutine GetTileAltitude (category: Landscape)
Calculate the altitude of a tile, optionally including platform objects and trees in the calculation
[X]
Subroutine GetTileData (category: Landscape)
Get the tile data and tile data address for a specific tile
[X]
Variable considerObjects in workspace Zero page
Controls whether the GetTileAltitude routine takes platform objects into consideration when calculating tile altitudes (bit 7) and returns details about the gaze vector (bit 6)
[X]
Label gaze6 is local to this routine
[X]
Label gaze8 in subroutine FollowGazeVector (Part 4 of 5)