.CheckForTileCentre \ We check the distance of the fractional coordinate in \ (xCoordLo, zCoordLo) from the centre of the tile by \ subtracting from (128, 128), as 128 represents 0.5 in \ fractional terms LDA xCoordLo \ Set A = |xCoordLo - 128| SEC SBC #128 BPL maxc1 EOR #%11111111 .maxc1 STA T \ Set T = |xCoordLo - 128| LDA zCoordLo \ Set A = |zCoordLo - 128| SEC SBC #128 BPL maxc2 EOR #%11111111 .maxc2 CMP T \ If A >= T then A is already set to the higher value BCS maxc3 \ out of A and T, so jump to maxc3 LDA T \ If we get here then A < T, so set A to the value of T \ so A is now set the higher value out of A and T .maxc3 STA T \ A is set to the higher value of A and T, so this does \ the following: \ \ T = max(A, T) \ \ = max(|xCoordLo - 128|, |zCoordLo - 128|) RTS \ Return from the subroutineName: CheckForTileCentre [Show more] Type: Subroutine Category: Maths (Geometry) Summary: Calculate max(|xCoordLo - 128|, |zCoordLo - 128|)Context: See this subroutine in context in the source code References: This subroutine is called as follows: * GetTileAltitude calls CheckForTileCentre
Arguments: xCoordLo The low byte of an x-coordinate for comparing to the centre of a tile (i.e. a fractional part) zCoordLo The low byte of an z-coordinate for comparing to the centre of a tile (i.e. a fractional part)
[X]
Label maxc1 is local to this routine
[X]
Label maxc2 is local to this routine
[X]
Label maxc3 is local to this routine