src/field/field_internal.h
What every part of the field object shares: its includes and the names two or more parts use. More…
#include "fixed_math.h"#include "types.h"#include "resource_ids.h"#include "system.h"#include "field/sprite.h"#include "field/perspective.h"#include "field/world_map_affine.h"#include "field/actor.h"#include "field/facing.h"#include "battle/battle.h"#include "field/field.h"#include "field/field_state.h"#include "game/game.h"#include "graphics/graphics.h"#include "menu/menu.h"#include "sound/sound.h"#include "field/field_engine.h"#include "sprite_ids.h"
Included by field_decompress.c.
Structures
| Name | Description | |
|---|---|---|
struct | ACTOR_CAMERA_POINT | A point the fixed camera looks from or at. |
struct | ACTOR_CAMERA_FIXED | The 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. |
struct | PLAYER_SPR | The leader's sprite, or a ripple's (SPR), as the player's movement sets them, a byte at a time, under SPR's names. |
struct | MAP_HEADER_LAYER | One background layer's setup in a layout's header: its origin, its parallax and drift, and where it wraps. |
struct | MAP_HEADER | A 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. |
struct | MAP_GRID_TILE_POS | A map layer's scroll position in whole 16-pixel metatiles. |
struct | MAP_EDIT_STEP | One step of a map edit: the rectangle of metatiles to copy from and the wait after it. |
struct | SPR_LAYER_VIEW | A sprite (SPR) whose image priority, its layer, is copied a byte at a time, under SPR's names: a wading splash's. |
struct | WAITING_ACTOR | The actor as SC_SYNC clears it when it gives up waiting: its target, arrival axis and blocked count. |
struct | SPR_PICTURE_CACHE_SOURCE | A 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
| Name | Description | |
|---|---|---|
#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. |
#define | FIELD_BLOCKED_TURN_MAX (TRIG_TURN / 16) | The most a blocked actor turns toward its heading in one tick. |
#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. |
#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). |
#define | ANIM_FACING_PICTURE_MASK 7 | A facing table entry's offset of its picture from the base picture. |
#define | ANIM_FACING_MIRRORED (1 << 7) | A facing table entry's bit that mirrors its picture. |
#define | FACING_SECTOR (direction, sectors) | The sector a facing angle lies in, a turn cut into sectors. |
#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. |
Typedefs
| Name | Description | |
|---|---|---|
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
| Name | Description | |
|---|---|---|
enum | ANIMATION_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. |
enum | anonymous enum { SPRITE_PICTURE_CACHE_COUNT, SPRITE_ANIMATION_COUNT, RUNNING_ … } | The field's pool sizes, and a sprite animation's timer step at normal speed. |
enum | PLAYER_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). |
enum | anonymous enum { FIELD_VIEW_FOCUS_X, FIELD_VIEW_FOCUS_Y, FIELD_VIEW_WIDTH, FI … } | Layered-map viewport distances in 16.16 pixels. |
enum | METATILE_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. |
enum | FOOTPRINT_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
| Name | Description | |
|---|---|---|
Sint32 | fdMapGridCheckCollisionAbove (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. |
void | fdTileMapDrawRowsFromRam (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. |
void | fdWorldMapBuildScanlineTable (FIXED pitchSlope, Sint32 *pos, WORLD_MAP_SCANLINE *scanline) | Rebuilds the ground plane's scanline terms when the world map pitch changes. |
Variables
| Name | Description | |
|---|---|---|
extern Uint8 | fdWorldMapUpdateAffineLinesCodeSize [] | The size of fdWorldMapUpdateAffineLinesCode, an address equal to the size (ld_script.ld). |
extern Uint8 | fdRenderConvertMapCode [] | The map converter's Thumb entry and ARM code (map_grid_convert.s), copied to RAM to run. |
extern Uint8 | fdRenderConvertMapCodeSize [] | The size of fdRenderConvertMapCode (map_grid_convert.s). |
extern SPR_PICTURE_CACHE_SOURCE | SpritePictureCacheSources [] | Each animation number's packed pictures, ending at number 0 (sprite_sources.s). |
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). |
extern Uint8 | fdRenderCopyStridedCode [] | The strided copy's Thumb entry and ARM code (map_grid_convert.s), copied to RAM to run. |
extern Uint8 | fdRenderCopyStridedCodeSize [] | 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.
| Enumerator | Value | Description |
|---|---|---|
ANIM_FACING_NONE | 0 | The script's own picture whatever the facing. |
ANIM_FACING_ONE_PICTURE | 1 | 8 sectors: one picture, mirrored to the left. |
ANIM_FACING_FRONT_BACK | 2 | 8 sectors: a front and a back picture. |
ANIM_FACING_THREE_PICTURES | 3 | 16 sectors: front, side and back. |
ANIM_FACING_FOUR_PICTURES | 4 | Unused, 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_PICTURES | 5 | 64 sectors here, 16 in The Broken Seal. |
ANIM_FACING_SIX_PICTURES | 6 | Unused, with no facing table: drawn as ANIM_FACING_NONE. The sprite viewer still rings it ten round. |
ANIM_FACING_EIGHT_PICTURES | 8 | 8 sectors centred on the compass directions, a picture for each. |
ANIM_FACING_TWO_PART | 20 | ANIM_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_SWAPPED | 22 | As ANIM_FACING_FRONT_BACK, with the front picture mirrored the other way. |
ANIM_FACING_EIGHT_NO_TABLE | 44 | Unused, with no facing table: rung as eight facings by the sprite viewer, as The Broken Seal's is. |
ANIM_FACING_EIGHT_PICTURES_MIRRORED | 88 | Unused, 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.
| Enumerator | Value | Description |
|---|---|---|
SPRITE_PICTURE_CACHE_COUNT | 8 | ACTOR_SYSTEM_STATE.pictureCaches |
SPRITE_ANIMATION_COUNT | 4 | SPR.entries |
RUNNING_LIST_SLOTS | 14 | the actor slots fdActorListRunning reads |
SPRITE_ANIMATION_NORMAL_STEP | 16 | one 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).
| Enumerator | Value | Description |
|---|---|---|
PLAYER_STEP_BLOCKED_BY_MAP | 1 | every heading tried runs into the map |
PLAYER_STEP_BLOCKED_BY_ACTOR | 2 | a solid actor ahead, or one with no room to be pushed |
PLAYER_STEP_BLOCKED | 3 | either of the two |
PLAYER_STEP_STOPPED | 4 | no 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.
| Enumerator | Value | Description |
|---|---|---|
FIELD_VIEW_FOCUS_X | toFIXED(120) | followed point from the left edge |
FIELD_VIEW_FOCUS_Y | toFIXED(96) | followed point from the top edge |
FIELD_VIEW_WIDTH | toFIXED(240) | the screen's width |
FIELD_VIEW_HEIGHT | toFIXED(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.
| Enumerator | Value | Description |
|---|---|---|
METATILE_TILES_PACKING_RAW | 0 | copied as it is |
METATILE_TILES_PACKING_SPLIT_DELTA | 1 | All the high bytes, then all the low bytes; each value is XORed with the one before. |
METATILE_TILES_PACKING_DELTA | 2 | Each 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.
| Enumerator | Value | Description |
|---|---|---|
FOOTPRINT_ONE_FOOT | 1 | one print, fading |
FOOTPRINT_BOTH_FEET | 2 | two 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.