Skip to Content
The Alchemy Project

include/field/curve.h

The ground height of a map metatile from its shape's height samples, one function for each kind of slope, and the tables they read.

Included by field_terrain.c and map_grid_data.c.

Enumerations

NameDescription
enumanonymous enum { CURVE_VALUE_SHIFT, CURVE_HALF_STEPS, CURVE_FULL_STEPS }

Functions

NameDescription
FIXEDfdTerrainGetFlatHeight (const Sint8 *samples)The ground height functions (MapGridTerrainHeightFunctions): each takes a metatile's height samples after its kind byte and a pixel (x, y) within the 16x16 metatile, and returns the ground height there in 16.16 pixels.
FIXEDfdTerrainGetSlopeXHeight (const Sint8 *samples, Sint32 pos)The height of a slope across x at position (0 to 15 of the metatile): a straight line from samples[0] to samples[1].
FIXEDfdTerrainGetSlopeYHeight (const Sint8 *samples, Sint32 unused, Sint32 pos)A slope along y: from sample 0 at the top to sample 1 at the bottom.
FIXEDfdTerrainGetStepSumDiagonalHeight (const Sint8 *samples, Sint32 start, Sint32 end)A step across the diagonal x + y = 15: sample 0 before it, sample 1 after it and the higher of the two on it.
FIXEDfdTerrainGetSampleTableHeight (const Sint8 *samples, Uint32 pos, Uint32 row)The sample TerrainSampleIndexTable picks for (x, y): a byte per pixel of the metatile, row by row.

Variables

NameDescription
extern Uint8TerrainRoundedSquareMask []A rounded square, a byte per pixel of a 16-pixel metatile, row by row: 1 where the square stands (fdTerrainGetRoundedSquareHeight takes the second height there) and 0 in its four cut corners.
extern Uint8TerrainSampleIndexTable []The sample fdTerrainGetSampleTableHeight reads at each position: 0, 1 or 2, split along two diagonals.

Description

The ground height of a map metatile from its shape's height samples, one function for each kind of slope, and the tables they read.

Enumerations in detail

anonymous enum

enum { CURVE_VALUE_SHIFT, CURVE_HALF_STEPS, CURVE_FULL_STEPS }

EnumeratorValueDescription
CURVE_VALUE_SHIFT19converts an 8-pixel height sample into 16.16 fixed-point pixels
CURVE_HALF_STEPS8pixels to the middle of a 16-pixel metatile
CURVE_FULL_STEPS16pixels across a metatile

Definition at line 15 of file curve.h.