.stri11 \ If we get here then bit 6 of processAction is clear, \ so we smooth the tile strip by working our way along \ the strip and setting each tile's altitude to the \ average of its altitude with the three following tiles LDX #0 \ We now work our way along the strip, smoothing the \ altitudes of tiles 0 to 31, so set a tile counter in X \ \ We work along rows from left to right and columns from \ near to far .stri12 LDA #0 \ Set U = 0 to use as the high byte of (U A), which we STA U \ will use to calculate the sum of the neighbouring tile \ altitudes LDA stripData,X \ Set A to the altitude of the tile we are smoothing \ (the one at index X) CLC \ Add the altitude of the next tile along ADC stripData+1,X BCC stri13 \ If the addition overflowed then increment the high CLC \ byte in U, so we have the correct result of the sum INC U \ in (U A) .stri13 ADC stripData+2,X \ Add the altitude of the next tile along BCC stri14 \ If the addition overflowed then increment the high CLC \ byte in U, so we have the correct result of the sum INC U \ in (U A) .stri14 ADC stripData+3,X \ Add the altitude of the next tile along BCC stri15 \ If the addition overflowed then increment the high CLC \ byte in U, so we have the correct result of the sum INC U \ in (U A) .stri15 \ So by this point (U A) contains the sum of the \ altitudes of the tile we are smoothing, and the next \ three tiles along the strip LSR U \ Set (U A) = (U A) / 4 ROR A \ LSR U \ So (U A) contains the average of the four altitudes, ROR A \ and we know that the high byte in U will be zero as \ each of the four elements of the sum fits into one \ byte STA stripData,X \ Set the altitude of the tile we are smoothing to the \ average that we just calculated INX \ Increment the tile counter to move along the strip CPX #32 \ Loop back until we have worked our way through the BCC stri12 \ strip and have smoothed tiles 0 to 31 \ \ This means that when we exit the loop, X = 32 \ We now have a very short interlude to set up some of \ the anti-cracker code before continuing the smoothing \ process in part 4Name: SmoothTileCorners (Part 3 of 4) [Show more] Type: Subroutine Category: Landscape Summary: Smooth a strip by setting the tile corner altitudes to the average of the current tile corner altitude and three following cornersContext: See this subroutine in context in the source code References: No direct references to this subroutine in this source file
This part smoothes the strip by working along the strip and replacing the altitude of each tile corner with the average of that corner's altitude plus the next three corners, working along rows from left to right and columns from near to far.
[X]
Label stri12 is local to this routine
[X]
Label stri13 is local to this routine
[X]
Label stri14 is local to this routine
[X]
Label stri15 is local to this routine
[X]
Variable stripData (category: Landscape)
Storage for tile data when smoothing strips of tiles during the landscape generation process