Skip to Content
The Alchemy Project

src/field/world_map_lines.c

The World Map's tilt: each line of the screen draws the flat map at its own scale and turn, so the ground seems to stretch away to a horizon. More…

Macros

NameDescription
#defineFIXEDtoQ_8_8 (value) ((value) / (toFIXED(1) / Q_8_8(1)))A 16.16 value in the 8.8 fixed point of the affine registers, rounded toward zero, and an 8.8 value back in 16.16.
#defineQ_8_8toFIXED (value) ((value) * (toFIXED(1) / Q_8_8(1)))

Functions

NameDescription
voidfdWorldMapUpdateAffineLines (VECTOR3 *eye, VECTOR3 *target, WORLD_MAP_SCANLINE *line, WORLD_MAP_AFFINE_LINE *affine)Builds the world map's per-scanline affine table for one tick: the ground plane seen from eye towards target. line points at the 160 scanlines' ground terms, whose rotation terms stay cached while the yaw (ScanlineAngle) is unchanged; affine receives each line's parameters twice, for BG2 and then BG3, as the HBlank DMA writes both.

Description

The World Map's tilt: each line of the screen draws the flat map at its own scale and turn, so the ground seems to stretch away to a horizon. The function runs from its copy in HEAP_SLOT_RAM_CODE (field_world_map.c), so it calls the arctangent, sine and cosine through the stub table of the system library's module.

Macros in detail

FIXEDtoQ_8_8

#define FIXEDtoQ_8_8(value) ((value) / (toFIXED(1) / Q_8_8(1)))

A 16.16 value in the 8.8 fixed point of the affine registers, rounded toward zero, and an 8.8 value back in 16.16.

Referenced by fdWorldMapUpdateAffineLines().

Definition at line 17 of file world_map_lines.c.

Q_8_8toFIXED

#define Q_8_8toFIXED(value) ((value) * (toFIXED(1) / Q_8_8(1)))

Referenced by fdWorldMapUpdateAffineLines().

Definition at line 18 of file world_map_lines.c.

Functions in detail

fdWorldMapUpdateAffineLines

void fdWorldMapUpdateAffineLines(VECTOR3 *eye, VECTOR3 *target, WORLD_MAP_SCANLINE *line, WORLD_MAP_AFFINE_LINE *affine)

Builds the world map's per-scanline affine table for one tick: the ground plane seen from eye towards target. line points at the 160 scanlines' ground terms, whose rotation terms stay cached while the yaw (ScanlineAngle) is unchanged; affine receives each line's parameters twice, for BG2 and then BG3, as the HBlank DMA writes both.

References line, ProjectionWork, ScanlineAngle, Sint32, StubsSystem, syMulFXArm() and TickCount.

Referenced by fdWorldMapInitPerspective().

Definition at line 25 of file world_map_lines.c.