Skip to Content
The Alchemy Project

src/field/field_internal.h

What every part of the field object shares: its includes and the names two or more parts use. More…

Included by field_decompress.c.

Structures

NameDescription
structACTOR_CAMERA_POINTA point the fixed camera looks from or at.
structACTOR_CAMERA_FIXEDThe start of the 3D camera's state (heap slot cameraState), as the fixed camera reads it: the eye and target it looks from and at, or the points that stand in for them.
structPLAYER_SPRThe leader's sprite, or a ripple's (SPR), as the player's movement sets them, a byte at a time, under SPR's names.
structMAP_HEADER_LAYEROne background layer's setup in a layout's header: its origin, its parallax and drift, and where it wraps.
structMAP_HEADERA layout's header: the camera's bounds, the layers' priorities, tile bases and setup, and the offsets, from the header's start, of its packed metatile tiles, collision, metatiles, shapes, tileset animation, blend script and script.
structMAP_GRID_TILE_POSA map layer's scroll position in whole 16-pixel metatiles.
structMAP_EDIT_STEPOne step of a map edit: the rectangle of metatiles to copy from and the wait after it.
structSPR_LAYER_VIEWA sprite (SPR) whose image priority, its layer, is copied a byte at a time, under SPR's names: a wading splash's.
structWAITING_ACTORThe actor as SC_SYNC clears it when it gives up waiting: its target, arrival axis and blocked count.
structSPR_PICTURE_CACHE_SOURCEA row of SpritePictureCacheSources: the packed resource that holds an animation number's pictures, which fdSpritePictureCacheLoad decodes into a sprite picture cache; a number of 0 ends the table.

Macros

NameDescription
#defineFIELD_PROBE_ANGLE (TRIG_TURN / 16)How far off its heading the leader's pad movement probes for a clear way: a sixteenth of a turn, 22.5 degrees, and three times that.
#defineFIELD_BLOCKED_TURN_MAX (TRIG_TURN / 16)The most a blocked actor turns toward its heading in one tick.
#defineSAME_METATILE (a, b) ((((a) - (b) + toFIXED(8)) >> 20) == 0)Two 16.16 coordinates fall in the same 16-pixel metatile, rounding to nearest.
#defineMAPGRID_ANIMATION_SCRIPT (RamMapCollision + 4096)Where a layout's tileset animation script is decoded, in the map collision buffer after the collision, as The Broken Seal's; its blend script follows at MAPGRID_BLEND_SCRIPT (field/map_grid.h).
#defineANIM_FACING_PICTURE_MASK 7A facing table entry's offset of its picture from the base picture.
#defineANIM_FACING_MIRRORED (1 << 7)A facing table entry's bit that mirrors its picture.
#defineFACING_SECTOR (direction, sectors)The sector a facing angle lies in, a turn cut into sectors.
#defineRENDER_LOAD_DECODER ()Copies fdRenderDecodePicture into the tick scratch slot, the block sized for the function and the colour tables it keeps after its code; the copy stops at the tables, which the decoder fills itself.

Typedefs

NameDescription
typedef void (*CONVERT_MAP_ROUTINE )(void *destination, void *source, void *saved);The map converter copied to RAM (fdRenderConvertMapCode), which joins a decoded map's planes into its metatile words.

Enumerations

NameDescription
enumANIMATION_FACING_KIND { ANIM_FACING_NONE, ANIM_FACING_ONE_PICTURE, ANIM_FACING_FRONT … }SPR_ANIMATION.kind: the facing table a sprite animation's pictures follow (fdSpriteComposePicture), as The Broken Seal names them; this game's five pictures cover 64 sectors.
enumanonymous enum { SPRITE_PICTURE_CACHE_COUNT, SPRITE_ANIMATION_COUNT, RUNNING_ … }The field's pool sizes, and a sprite animation's timer step at normal speed.
enumPLAYER_STEP_BLOCK { PLAYER_STEP_BLOCKED_BY_MAP, PLAYER_STEP_BLOCKED_BY_ACTOR, PL … }What stopped the leader's step this tick (fdActorUpdatePlayerControl, fdActorMoveOnWorldMap, fdActorUpdateHoverControl and the climbing and rope controls).
enumanonymous enum { FIELD_VIEW_FOCUS_X, FIELD_VIEW_FOCUS_Y, FIELD_VIEW_WIDTH, FI … }Layered-map viewport distances in 16.16 pixels.
enumMETATILE_TILES_PACKING { METATILE_TILES_PACKING_RAW, METATILE_TILES_PACKING_SPLIT_DEL … }How a layout's metatile tiles data is packed: the method byte fdTileMapDecodeStagedBuffer reads before the halfwords.
enumFOOTPRINT_ANIMATION { FOOTPRINT_ONE_FOOT, FOOTPRINT_BOTH_FEET }The footprints the leader leaves in snow and sand, and the leader's userValue that asks for the pair next.

Functions

NameDescription
Sint32fdMapGridCheckCollisionAbove (ACTOR *actor, POS *pos)field_terrain.c's test of the ground the hovering leader cannot float over, which the script commands call before it.
voidfdTileMapDrawRowsFromRam (const WORLD_MAP_AFFINE_PAIR *lines, Uint8 *pixels)field_view.c's functions, which field_tile_animation.c and field_world_map.c call before it.
voidfdWorldMapBuildScanlineTable (FIXED pitchSlope, Sint32 *pos, WORLD_MAP_SCANLINE *scanline)Rebuilds the ground plane's scanline terms when the world map pitch changes.

Variables

NameDescription
extern Uint8fdWorldMapUpdateAffineLinesCodeSize []The size of fdWorldMapUpdateAffineLinesCode, an address equal to the size (ld_script.ld).
extern Uint8fdRenderConvertMapCode []The map converter's Thumb entry and ARM code (map_grid_convert.s), copied to RAM to run.
extern Uint8fdRenderConvertMapCodeSize []The size of fdRenderConvertMapCode (map_grid_convert.s).
extern SPR_PICTURE_CACHE_SOURCESpritePictureCacheSources []Each animation number's packed pictures, ending at number 0 (sprite_sources.s).
extern const Uint8ActorShadowTiles []The sprites' shadow, 16 by 8 at 256 colours, loaded into VRAM cache entry VRAM_CACHE_ENTRY_ACTOR_SHADOW (actor_shadow.list.tsv).
extern Uint8fdRenderCopyStridedCode []The strided copy's Thumb entry and ARM code (map_grid_convert.s), copied to RAM to run.
extern Uint8fdRenderCopyStridedCodeSize []The size of fdRenderCopyStridedCode (map_grid_convert.s).

Description

What every part of the field object shares: its includes and the names two or more parts use. field.c includes it before the parts, and each part includes it too, so that a part read on its own still resolves. It places no bytes.

Macros in detail

FIELD_PROBE_ANGLE

#define FIELD_PROBE_ANGLE (TRIG_TURN / 16)

How far off its heading the leader's pad movement probes for a clear way: a sixteenth of a turn, 22.5 degrees, and three times that.

Referenced by fdActorFlyOnWorldMap(), fdActorMoveAsSand(), fdActorMoveAsSandOnWorldMap(), fdActorMoveOnWorldMap(), fdActorSailOnMap(), fdActorSailOnWorldMap(), fdActorUpdateHoverControl(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 29 of file field_internal.h.

FIELD_BLOCKED_TURN_MAX

#define FIELD_BLOCKED_TURN_MAX (TRIG_TURN / 16)

The most a blocked actor turns toward its heading in one tick.

Referenced by fdActorFlyOnWorldMap(), fdActorSailOnMap(), fdActorSailOnWorldMap(), fdActorUpdateHoverControl() and fdTurnToward().

Definition at line 31 of file field_internal.h.

SAME_METATILE

#define SAME_METATILE(a, b) ((((a) - (b) + toFIXED(8)) >> 20) == 0)

Two 16.16 coordinates fall in the same 16-pixel metatile, rounding to nearest.

Referenced by fdActorSailOnMap(), fdActorUpdatePlayerControl() and fdActorUpdateWalkingControl().

Definition at line 34 of file field_internal.h.

MAPGRID_ANIMATION_SCRIPT

#define MAPGRID_ANIMATION_SCRIPT (RamMapCollision + 4096)

Where a layout's tileset animation script is decoded, in the map collision buffer after the collision, as The Broken Seal's; its blend script follows at MAPGRID_BLEND_SCRIPT (field/map_grid.h).

Referenced by fdMapGridLoadMap(), fdWorldMapLoadGraphics() and fdWorldMapPreloadCurrentTileBlock().

Definition at line 119 of file field_internal.h.

ANIM_FACING_PICTURE_MASK

#define ANIM_FACING_PICTURE_MASK 7

A facing table entry's offset of its picture from the base picture.

Referenced by fdSpriteComposePicture().

Definition at line 234 of file field_internal.h.

ANIM_FACING_MIRRORED

#define ANIM_FACING_MIRRORED (1 << 7)

A facing table entry's bit that mirrors its picture.

Referenced by fdSpriteComposePicture().

Definition at line 236 of file field_internal.h.

FACING_SECTOR

#define FACING_SECTOR(direction, sectors)

The sector a facing angle lies in, a turn cut into sectors.

Referenced by fdSpriteComposePicture().

Definition at line 238 of file field_internal.h.

RENDER_LOAD_DECODER

#define RENDER_LOAD_DECODER()

Copies fdRenderDecodePicture into the tick scratch slot, the block sized for the function and the colour tables it keeps after its code; the copy stops at the tables, which the decoder fills itself. As RAM_CODE_LOAD_SLOT, a statement.

Referenced by fdActorSystemPlaceSprites(), fdActorSystemProjectSprites() and fdSpriteComposePicture().

Definition at line 326 of file field_internal.h.

Typedefs in detail

CONVERT_MAP_ROUTINE

typedef void (*CONVERT_MAP_ROUTINE)(void *destination, void *source, void *saved);

The map converter copied to RAM (fdRenderConvertMapCode), which joins a decoded map's planes into its metatile words.

Referenced by fdTileMapConvertBuffer().

Definition at line 45 of file field_internal.h.

Enumerations in detail

ANIMATION_FACING_KIND

enum ANIMATION_FACING_KIND

SPR_ANIMATION.kind: the facing table a sprite animation's pictures follow (fdSpriteComposePicture), as The Broken Seal names them; this game's five pictures cover 64 sectors.

EnumeratorValueDescription
ANIM_FACING_NONE0The script's own picture whatever the facing.
ANIM_FACING_ONE_PICTURE18 sectors: one picture, mirrored to the left.
ANIM_FACING_FRONT_BACK28 sectors: a front and a back picture.
ANIM_FACING_THREE_PICTURES316 sectors: front, side and back.
ANIM_FACING_FOUR_PICTURES4Unused, with no facing table: drawn as ANIM_FACING_NONE. The sprite viewer rings it ten round, as The Broken Seal's does its four pictures.
ANIM_FACING_FIVE_PICTURES564 sectors here, 16 in The Broken Seal.
ANIM_FACING_SIX_PICTURES6Unused, with no facing table: drawn as ANIM_FACING_NONE. The sprite viewer still rings it ten round.
ANIM_FACING_EIGHT_PICTURES88 sectors centred on the compass directions, a picture for each.
ANIM_FACING_TWO_PART20ANIM_FACING_FRONT_BACK's table for a sprite drawn in two parts, the second the next sprite id (the sprite viewer).
ANIM_FACING_FRONT_BACK_SWAPPED22As ANIM_FACING_FRONT_BACK, with the front picture mirrored the other way.
ANIM_FACING_EIGHT_NO_TABLE44Unused, with no facing table: rung as eight facings by the sprite viewer, as The Broken Seal's is.
ANIM_FACING_EIGHT_PICTURES_MIRRORED88Unused, with no facing table: The Broken Seal's eight pictures with three mirrored, rung as eight facings by the sprite viewer.

Definition at line 193 of file field_internal.h.

anonymous enum

enum { SPRITE_PICTURE_CACHE_COUNT, SPRITE_ANIMATION_COUNT, RUNNING_LIST_SLOTS, SPRITE_ANIMATION_NORMAL_STEP }

The field's pool sizes, and a sprite animation's timer step at normal speed.

EnumeratorValueDescription
SPRITE_PICTURE_CACHE_COUNT8ACTOR_SYSTEM_STATE.pictureCaches
SPRITE_ANIMATION_COUNT4SPR.entries
RUNNING_LIST_SLOTS14the actor slots fdActorListRunning reads
SPRITE_ANIMATION_NORMAL_STEP16one tick a tick, in sixteenths of a tick

Definition at line 242 of file field_internal.h.

PLAYER_STEP_BLOCK

enum PLAYER_STEP_BLOCK

What stopped the leader's step this tick (fdActorUpdatePlayerControl, fdActorMoveOnWorldMap, fdActorUpdateHoverControl and the climbing and rope controls).

EnumeratorValueDescription
PLAYER_STEP_BLOCKED_BY_MAP1every heading tried runs into the map
PLAYER_STEP_BLOCKED_BY_ACTOR2a solid actor ahead, or one with no room to be pushed
PLAYER_STEP_BLOCKED3either of the two
PLAYER_STEP_STOPPED4no step, not blocked: pad not held or climb meets a wall

Definition at line 255 of file field_internal.h.

anonymous enum

enum { FIELD_VIEW_FOCUS_X, FIELD_VIEW_FOCUS_Y, FIELD_VIEW_WIDTH, FIELD_VIEW_HEIGHT }

Layered-map viewport distances in 16.16 pixels. The followed point is below the vertical centre; scroll bounds and camera following share this origin.

EnumeratorValueDescription
FIELD_VIEW_FOCUS_XtoFIXED(120)followed point from the left edge
FIELD_VIEW_FOCUS_YtoFIXED(96)followed point from the top edge
FIELD_VIEW_WIDTHtoFIXED(240)the screen's width
FIELD_VIEW_HEIGHTtoFIXED(160)the screen's height

Definition at line 267 of file field_internal.h.

METATILE_TILES_PACKING

enum METATILE_TILES_PACKING

How a layout's metatile tiles data is packed: the method byte fdTileMapDecodeStagedBuffer reads before the halfwords.

EnumeratorValueDescription
METATILE_TILES_PACKING_RAW0copied as it is
METATILE_TILES_PACKING_SPLIT_DELTA1All the high bytes, then all the low bytes; each value is XORed with the one before.
METATILE_TILES_PACKING_DELTA2Each value is XORed with the one before.

Definition at line 277 of file field_internal.h.

FOOTPRINT_ANIMATION

enum FOOTPRINT_ANIMATION

The footprints the leader leaves in snow and sand, and the leader's userValue that asks for the pair next. Every function that moves the leader by the pad sets it on a stop.

EnumeratorValueDescription
FOOTPRINT_ONE_FOOT1one print, fading
FOOTPRINT_BOTH_FEET2two prints side by side, fading: laid first after a stop

Definition at line 349 of file field_internal.h.

Variables in detail

fdWorldMapUpdateAffineLinesCodeSize

extern Uint8 fdWorldMapUpdateAffineLinesCodeSize[]

The size of fdWorldMapUpdateAffineLinesCode, an address equal to the size (ld_script.ld).

Referenced by fdWorldMapInitPerspective().

Definition at line 298 of file field_internal.h.

fdRenderConvertMapCode

extern Uint8 fdRenderConvertMapCode[]

The map converter's Thumb entry and ARM code (map_grid_convert.s), copied to RAM to run.

Referenced by fdTileMapConvertBuffer().

Definition at line 302 of file field_internal.h.

fdRenderConvertMapCodeSize

extern Uint8 fdRenderConvertMapCodeSize[]

The size of fdRenderConvertMapCode (map_grid_convert.s).

Referenced by fdTileMapConvertBuffer().

Definition at line 305 of file field_internal.h.

SpritePictureCacheSources

extern SPR_PICTURE_CACHE_SOURCE SpritePictureCacheSources[]

Each animation number's packed pictures, ending at number 0 (sprite_sources.s).

Referenced by fdSpritePictureCacheLoad().

Definition at line 309 of file field_internal.h.

ActorShadowTiles

extern const Uint8 ActorShadowTiles[]

The sprites' shadow, 16 by 8 at 256 colours, loaded into VRAM cache entry VRAM_CACHE_ENTRY_ACTOR_SHADOW (actor_shadow.list.tsv).

Referenced by fdActorShadowLoadTiles() and fdActorSystemConfigure().

Definition at line 313 of file field_internal.h.

fdRenderCopyStridedCode

extern Uint8 fdRenderCopyStridedCode[]

The strided copy's Thumb entry and ARM code (map_grid_convert.s), copied to RAM to run.

Referenced by fdActorSystemConfigure().

Definition at line 317 of file field_internal.h.

fdRenderCopyStridedCodeSize

extern Uint8 fdRenderCopyStridedCodeSize[]

The size of fdRenderCopyStridedCode (map_grid_convert.s).

Referenced by fdActorSystemConfigure().

Definition at line 320 of file field_internal.h.