.SmoothTileCorners ORA smoothingAction \ We configured the smoothing action in bit 6 of STA processAction \ smoothingAction in the SmoothTileData routine before \ calling this routine, and bit 7 of A tells us whether \ to smooth a row or a column of tile corners, so this \ combines both configurations from bit 6 and bit 7 into \ one byte that we store in processAction LDX #34 \ We start by copying the tile data for the row/column \ that we want to smooth into the stripData workspace, \ so we can process it before copying it back into the \ tileData table \ \ In the following commentary I will refer to this \ copied row or column of tile corners as a "strip of \ tiles", as saying "row or column of tile corners" \ every time is a bit of a mouthful \ \ We actually create a strip of tile data containing 35 \ tile corners, with offsets 0 to 31 being the tile data \ for the strip we are smoothing and offsets 32 to 34 \ being repeats of the data for tile corners 0 to 2 \ \ So we effectively duplicate the first three tile \ corners onto the end of the strip so we can wrap the \ smoothing calculations around past the end of the \ strip .stri1 TXA \ Set A = X mod 32 AND #31 \ \ This ensures that for X = 32 to 34, we copy the tile \ data for tiles 0 to 2 (as A = 0 to 2 for X = 32 to 34) BIT processAction \ If bit 7 of processAction is clear then we are BPL stri2 \ smoothing a row of tiles at z-coordinate zTile, so \ jump to stri2 to iterate across xTile STA zTile \ If we get here then we are smoothing a column of tiles \ so set zTile to the counter in X so we iterate along \ the z-coordinate (i.e. coming out of the screen) JMP stri3 \ Jump to stri3 to skip the following .stri2 STA xTile \ If we get here then we are smoothing a row of tiles \ so set xTile to the counter in X so we iterate along \ the x-coordinate (i.e. from right to left) .stri3 JSR GetTileData \ Set A to the tile data for the tile anchored at \ (xTile, zTile) STA stripData,X \ Store the tile data for (xTile, zTile) into the X-th \ byte in our temporary workspace DEX \ Decrement the tile counter in X BPL stri1 \ Loop back until we have copied tile data for all 32 \ tiles in the strip, plus three more tiles on the end BIT processAction \ If bit 6 of processAction is clear then we need to BVC stri11 \ smooth the strip by averaging tile altitudes, so jump \ to part 3 to implement this \ Otherwise fall through into part 2 to smooth the strip \ by moving outlier tilesName: SmoothTileCorners (Part 1 of 4) [Show more] Type: Subroutine Category: Landscape Summary: Smooth a row or column of tile corners (a "strip of tiles")Context: See this subroutine in context in the source code References: This subroutine is called as follows: * SmoothTileData calls SmoothTileCorners
This part copies the row or column of tile corners to a temporary workspace.
Arguments: A Controls which tile corners we smooth in the tile data: * Bit 7 clear = smooth the row of tile corners at z-coordinate zTile * Bit 7 set = smooth the column of tile corners at x-coordinate xTile
[X]
Subroutine GetTileData (category: Landscape)
Get the tile data and tile data address for a specific tile
[X]
Variable processAction in workspace Zero page
Defines the following
[X]
Variable smoothingAction in workspace Zero page
The action that's applied to tile data by the SmoothTileData routine
[X]
Label stri1 is local to this routine
[X]
Label stri11 in subroutine SmoothTileCorners (Part 3 of 4)
[X]
Label stri2 is local to this routine
[X]
Label stri3 is local to this routine
[X]
Variable stripData (category: Landscape)
Storage for tile data when smoothing strips of tiles during the landscape generation process