79 work->transition = 0x100;
80 work->transitionFrames = 16;
81 work->transitionActive = 0;
86 work->walkingDistanceScale = 0x199;
87 work->walkingDistance = 0;
89 work->walkingDistanceScale = 0;
162 if (work->
event != 0) {
164 if (work->
event == -1) {
201 }
else if (work->
event == -888) {
204 }
else if (work->
event == -889) {
212 }
else if (work->
battle != 0) {
224 }
else if (work->
action != 0) {
229 }
else if (work->
input != 0) {
232 }
else if (work->
examine != 0) {
256 }
else if (work->
menu != 0) {
284 }
else if (work->
tile != 0) {
289 }
else if (work->
command != 0) {
295 }
else if (work->
item != 0) {
300 }
else if (work->
start != 0) {
332 if (*owner++ == 0xff)
335 if (free - 136 < 0) {
432 (((probePosition.
vector.
z / 0x200000) & 31) << 5))
435 cells = *(
u8 **)(mapBytes + 0x130);
436 cell = cells + (((probePosition.
vector.
x / 0x100000) +
437 ((probePosition.
vector.
z / 0x100000) << 7))
440 collisionCode = cell[2];
441 if (collisionCode >= 242 && collisionCode <= 247) {
444 if (terrainHeight >= leader->
pos.
y &&
445 terrainHeight <= leader->pos.y + 0x400000) {
446 result = collisionCode;
449 result = collisionCode;
465 s32 foundEntrance = 0;
467 while (entranceEntry->
entrance != -1) {
497 if (map->
minX + (240 << 16) > map->
maxX)
498 map->
minX = map->
maxX - (240 << 16);
499 if (map->
minY + (160 << 16) > map->
maxY)
500 map->
minY = map->
maxY - (160 << 16);
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
void ObjectTable_ResetForObject(struct ScenePlacement *table)
Creates a scene's actors on entering it: the party leader where the game state puts it,...
void ObjectTable_Snapshot(void)
Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots,...
void ObjectTable_Restore(void)
Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.
#define Unit_UpdateGauges(unit)
Recalculates HP and PP gauges, keeping at least one when any points remain.
void FieldFx_ResumeCloakCheck(void)
Starts the Cloak tile check if the leader is hidden.
void BattleFx_ApplyColorToTargetBuffer(s32 mode, s32 half)
Sets the colours the buffer moves toward (see BattleFx_BuildBuffer); does nothing without a colour bu...
void BattleEffect_InitializeBuffers(void)
Sets up the colour buffer (heap block 32) from the BG and OBJ palettes and starts updating the palett...
s32 Field_StartEncounterTransition(s32 unused)
Starts the transition into a random battle: plays the scene's battle cue and the encounter sounds,...
s32 ObjectEffect_RunPendingFlagEvent(void)
Plays the leader's arrival for the way the last scene was left: through an exit of kind 0x20 (flag 0x...
void Djinn_ResolvePendingEvent(s32 shown)
Settles a pending Djinni battle as a scene loads.
void FieldObject_PlaceSceneActors(void)
Puts a Djinni's actor back where its battle started from: for a pending Djinni battle (pendingDjinnEv...
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
void ObjectDispatch_StartKeyCheckFar(struct DispatchObject *obj)
s32 Map_LoadLayeredSceneFar(s32 index)
void ObjectDispatch_StartMoveByKeysFar(struct DispatchObject *obj)
s32 Map_GetTerrainHeightFar(s32 layer, s32 x, s32 y)
void ObjectSystem_InitializeFar(s32 mode)
void WorldMap_LoadGraphicsFar(s32 x, s32 z)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_StartPlayerControlFar(struct DispatchObject *obj)
s32 Map_InitializePerspectiveSceneFar(void)
void Map_UpdateCurrentTileBlockFar(void)
void Map_CenterOnFollowedPointFar(void)
void ObjectDispatch_StartWorldMapControlFar(struct DispatchObject *obj)
void ObjectDispatch_StartIdleFar(struct DispatchObject *obj)
struct BattleUnit * UnitGetFar(u32 owner)
s32 GameFlag_TestFar(s32 flag)
s32 GameFlag_SetBitFar(s32 flag)
void GameFlag_RefreshLureCapFar(void)
void GameFlag_ClearBitFar(s32 flag)
void AudioCommand_PlayFar(s32 id)
s32 AudioCommand_GetSecondaryStateByteFar(void)
s16 Menu_RunSelectionFar(void)
void UiText_ShowPositionedMessageAndWaitFar(s32 no, s32 flags)
void UiTimedNotice_CloseIfActiveFar(void)
s32 Menu_RunTopSelectionFar(void)
s32 Menu_RunWorkspaceResultLoopFar()
s32 Menu_RunSelectionWithCursorObjectFar(void)
void UiTimedNotice_CreateFar()
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiWork_InitializeWithResourceCountersFar(void)
struct SceneEntries gOverlayArea
#define FLAG_SHOW_LOCATION_NAME
#define FLAG_IN_BATTLE
Set as a battle starts, cleared as a field scene starts.
#define FLAG_RETREAT_BLOCKED
Retreat is blocked, from Psynergy or an item.
#define FLAG_KEEP_PARTY_POSITION
#define FLAG_CHILDHOOD
the prologue: Isaac and Garet are children
#define FLAG_IN_LINK_LOBBY
Set when the cleared game's menu goes to the link lobby: there Psynergy has no effect and the system ...
#define FLAG_MENU_OPEN
Set while the field menu is open; scenes hold their moving actors still.
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
u8 gDebugMode
Debug builds: Start+Select pauses the frame loop.
struct GameState gGameState
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
s32 Field_UseItem(s32 packedItem, s32 slot)
Uses an item on the field.
volatile u32 gKeysHeld
Keys down now.
void Field_PlaceMapMarkers(void)
Places an actor at each of the map's markers (ids 100 to 239) that the scene has an event for,...
void Vector_AddPolarOffset(s32 radius, s32 angle, void *position)
Moves the point position by radius in direction angle on the ground plane: x by the cosine,...
void Runtime_ReleaseHeapBlock(s32 slot)
void Encounter_SelectSceneZones(s32 useRules)
Chooses the current scene's encounter zones, one for each kind of ground the party can stand on (gEve...
void Scene_SetDefeatReturnPoint(void)
Sets the scene the party returns to after a defeat (gGameState.savedScene and savedEntrance),...
struct EffectDescriptor * Scene_FindEvent(s32 kind, s32 target)
Returns the first of the scene's events of kind for target whose condition holds, or NULL.
s32 Scene_TalkToActor(s32 id)
Talks to actor id: shows its event's message or calls its event function, with the actor stopped and ...
s32 Scene_RunTouchOrExit(s32 value)
Runs the touch event (kind 2) of what the leader touched, or else takes its exit (kind 1): plays the ...
s32 Scene_FindActorTalkEvent(s32 id)
Returns the talk event of actor id: for the actor the party has stopped, its kind 7 event if it has o...
s32 Field_SearchTile(s32 tile)
Searches the tile ahead with the given collision code.
s32 Scene_RunRaisedEvent(s32 value)
Runs the scene's raised event (kind 6) for value: its message or its function.
s32 Field_RunPushTileEvent(s32 collisionCode)
Runs the event of a tile the leader pushes against (codes 0xf9 and 0xfc to 0xfe), once it has pushed ...
s32 Field_UsePsynergy(u32 code)
Uses Psynergy on the field.
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
s32 Field_FindNearbyTalkTarget(s32 id)
Returns the actor nearest to actor id that it could talk to, or -1: within 48 pixels of height and 32...
void DisplayTransition_Start(s32 mode, s32 frames)
Fades the screen in over frames frames.
void DisplayTransition_Finish(s32 mode, s32 frames)
Fades the screen out over frames frames, as DisplayTransition_Start fades it in.
s32 PartyInventory_GiveItem(s32 item, s32 unused)
The event command "give item": gives item to the first party member with room for it and says so.
void Leader_StopMoving(void)
Stops the leader where it stands: no horizontal velocity, the normal walking speed (1....
s32 Party_CheckItemLimit(s32 item)
Checks whether the party can carry one more of item: each member carries at most 30 of one item.
void BattleFx_RunVisibilityTransition(void)
On the world map, zooms the view out (0x9d89) while L is held, then back.
void Map_ShowWorldMap(s32 picture)
Borrows the map-cell buffer for the still map until A or B closes it.
What every part of object.c shares: its includes and the macros and types more than one part uses.
#define REGION_FIXED(value)
A scene region's bounds, in pixels, as 16.16 fixed point.
#define EXIT_NONE
Field_RunScene's result when the scene was not left (scene.c, run_scene.c).
void Debug_RunPaletteEditor(void)
The debug palette editor (L on the pause menu in debug mode).
#define Ram_MapCellBuffer
char ResourceId_WorldMapPicture
void Scene_ApplyEntrance(void)
Places the party at the entrance it came in by (the first matching entry, or the scene's first one) u...
s32 Object_GetTriggerTileAheadOfCurrent(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader when there is somethin...
s32 Field_RunScene(s32 entrance)
Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit ...
void Scheduler_ResetTaskTable(void)
Empties the task table: every slot gets no routine, order 0xffff (sorted last) and no flags.
#define SE_MENU_CURSOR_MOVE
void WorldMap_EndEvent(void)
Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the cam...
void WorldMap_BeginEvent(void)
Starts an event or menu on the world map: ends any colour ratio transition in progress,...
void Field_ClearRequests(void)
Clears the field's twelve pending requests (see struct FieldWork).
void Field_ProcessStep(s32 layer, s32 x, s32 y, s32 z)
Handles one step of the party leader onto the cell at (x, y, z) of map layer: records step events and...
s32 Field_CountRequests(void)
Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-...
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
s16 hp
current HP, 0 when downed
A field object as the object dispatcher's far calls take it.
A world position, as Camera_WorldToScreen converts it to the screen.
s32 y
16.16 fixed-point pixels
s32 z
16.16 fixed-point pixels
s32 x
16.16 fixed-point pixels
A field actor: a person or thing on the field with a position, motion toward a target,...
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Full event work allocated by Field_RunScene (heap slot 27).
s16 exit
the exit taken, which ends the scene
u16 transitionActive
set once the opening transition has started
u16 descriptor
an actor's event, as actor | 0x1000
s16 input
a tile code (252 to 254) for Field_RunPushTileEvent
s16 event
A raised event for Scene_RunRaisedEvent, or -1 when characters fell to poison or hazard damage,...
s16 command
a field Psynergy to use, as owner << 10 | Psynergy
s16 effectTimerRunning
Nonzero lets the Reveal countdown advance; menus and other effects pause it.
s16 queuedSound
a sound BattleFx_PlayQueuedSound plays; -1 for none
s32 transition
SCENE_TRANSITION(style, variant); 0x100 on entry.
s16 itemArgument
the inventory slot Field_UseItem receives
u16 busy
Set while a raised or touch event runs; FieldEvent_Begin then resets the effect counter.
s16 tile
a tile's collision code, for Field_SearchTile
s16 start
the Start button: open the pause menu
s16 fallenOwners[9]
the characters who fell, from the active party
s32 encounterBias
randomized distance adjustment between battles
s16 battle
the enemy group of a random encounter
s16 survivorCount
0 when the whole party fell
s16 menu
open the main menu
s16 mode
MODE_WORLD_MAP (3) on the world map.
s16 examine
the A button: examine what is ahead
s16 item
an item to use, packed as Field_UseItem reads it
s16 action
The twelve requests: each nonzero value asks the field loop for one thing; Field_ClearRequests clears...
struct FieldActor * actors[66]
The actors by id: 0 to 7 the party's characters, 8 on the placed actors.
s16 fallenCount
the characters who fell this step
s32 transitionFrames
frames; 16 on entry and at each event
s16 nextScene
where the event sends the party next; -1 for none
s16 cloaked
1 under Cloak, which prevents battles
s16 hazardLimit
Hazardous ground (the Lamakan Desert's heat): every hazardLimit steps the party takes hazardDamage (b...
s32 z
16.16 fixed-point pixels
s16 nextEntrance
where the event sends the party next; -1 for none
s16 map
the scene's map; SceneId_Clear for the world map
u8 perspectiveScene
set to 1 on the world map; not read by name in TBS
s32 y
16.16 fixed-point pixels
u16 turn
the leader's terrainId, kept with its position
s16 defaultEntrance
the entrance it was entered by
s16 pendingDjinnEvent
The Djinni battle pending (DJINNI_0 plus its number, flags in bits 15 to 11), resolved on returning t...
s16 pausedObject
Halt: the stopped object; -1 for none.
s32 encounterSteps
the encounter count, reset with a new group
s16 defeatEntrance
where a defeat returns to; -1 for none
s16 defeatScene
where a defeat returns to; -1 for none
s16 defaultScene
the scene being run, kept as it starts
s16 sceneVariant
the current scene's variant from its record
s32 x
16.16 fixed-point pixels
u8 movementMode
1 while the leader is climbing, 0 otherwise
u16 pendingItem
given on returning to the field if the party has room
s32 selectedActor
the leader: its unit and its actor
s16 savedScene
where a defeat returns to without a defeat point
s16 returnCue
music playing when the field left; -1 for none
s16 hazardMode
0 counts on hazard cells only; 1 counts every step
s16 savedEntrance
where a defeat returns to without a defeat point
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
A field actor (struct FieldActor), seen with its position as one vector.
struct AnimationObject * sprite
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
s16 requiredFlag
a flag that must be set, or -1 for none
s16 entrance
the entrance number the game state names; -1 ends
u16 facing
1/65536 turns (enum Facing)
const struct SceneEntrance *(*) entrances(void)
const struct ScenePlacement *(*) placements(void)
const struct SceneEvent *(*) events(void)
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
The polar-offset routine walks three array elements.
struct EffectVector vector
#define MODE_WORLD_MAP
the world map
u8 gResourceBlockOwners[VRAM_BLOCK_COUNT]