Alchemy
Loading...
Searching...
No Matches

run_scene.c

Go to the documentation of this file.
1/// @file
2/// Running a field scene until the party leaves it, and its entrance.
3/// Part of object.c, the field object, compiled only through it.
4
6
7/// The object system's work (struct ObjectSystemWork), seen as the flag that
8/// suspends sprite projection while the menu opens.
9struct MenuCtrl {
12};
13
14/// Runs the current field scene, which the party entered by entrance, until it
15/// leaves; returns the exit kind it left by (for Scene_TakeExit), or 999 when
16/// the party fell outside battle. Sets the scene up (map, actors, encounters,
17/// return points), runs its initialization, fades it in, then runs the field
18/// loop: the party walks (Field_ProcessStep each frame) until a request is
19/// made, and then the requests are handled until none is left.
20///
21/// Called from Game_ResetForNewGame's main loop for every field scene, which
22/// passes the result to Scene_TakeExit. Allocates the field work in heap slot
23/// 27 (HEAP_SLOT_EVENT) and frees it on the way out, sets gGameState's default,
24/// next and defeat destinations, and clears FLAG_IN_BATTLE and, once the scene
25/// has started, FLAG_KEEP_PARTY_POSITION.
27 struct FieldWork *work;
28 struct FieldActor *actor;
29 s32 mode;
30 s32 result = 0;
31 s32 code;
32
33 // Set up the scene.
34 work = Runtime_AllocateBlock(27, sizeof(struct FieldWork));
35 Dma_Fill32(0, work, sizeof(struct FieldWork));
48 mode = MODE_WORLD_MAP;
50 } else {
52 mode = 2;
54 }
55 work->mode = mode;
59 work->events = gOverlayArea.events();
67 if (mode == MODE_WORLD_MAP) {
70 } else {
72 }
76 // The default fade is from the backdrop colour over 16 frames
77 // (SCENE_TRANSITION(TRANSITION_BACKDROP_FADE, 0)); the scene's initialization
78 // may choose another.
79 work->transition = 0x100;
80 work->transitionFrames = 16;
81 work->transitionActive = 0;
82 // Field_ProcessStep scales the leader's speed by this (16.16) into the
83 // distance counted towards PP and poison ticks: 0x10000 / 0x199 makes a
84 // tick about every 160 pixels walked. Scenes of variant 2 turn it off and
85 // block Retreat.
86 work->walkingDistanceScale = 0x199;
87 work->walkingDistance = 0;
88 if (gGameState.sceneVariant == 2) {
89 work->walkingDistanceScale = 0;
91 }
92 work->previousTile = (struct MapCell *)Ram_MapCellBuffer;
93 // A fresh entry (not a return from battle) resets the hazard count to its
94 // defaults (damage 1 every 16 steps), the stopped actor and Cloak.
102 }
104 work->queuedSound = -1;
106
107 // The scene's initialization may already have taken an exit.
108 code = work->exit;
109 if (code != 0) {
110 result = code;
111 work->exit = 0;
112 } else {
114 // Fade in, show the place name and give what was left pending.
115 if (Field_CountRequests() == 0) {
116 if (work->transitionActive == 0) {
118 work->transitionActive = 1;
119 PLTT_BACKDROP = 0;
121 WaitFrames((work->transitionFrames + 1) / 2);
122 }
126 }
127 if (gGameState.pendingDjinnEvent != 0) {
130 }
131 if (gGameState.pendingItem != 0) {
137 }
138 }
139
140 for (;;) {
141 // Flag 0x104 stays set while requests are handled and is cleared while
142 // the party walks (the Colosso wall scene tests it). Note where the
143 // leader is, for the requests to use.
144 GameFlag_SetBitFar(0x104);
145 actor = work->actors[gGameState.selectedActor];
147 gGameState.x = actor->x.fixed;
148 gGameState.y = 0;
149 gGameState.z = actor->z.fixed;
150 gGameState.heading = actor->facing;
151 gGameState.turn = actor->terrainId;
152
153 // Handle the pending requests, most urgent first.
154 while (Field_CountRequests() != 0) {
155 s32 next = work->exit;
156
157 if (next != 0) {
158 result = next;
159 work->exit = 0;
160 goto done;
161 }
162 if (work->event != 0) {
163 work->busy = 1;
164 if (work->event == -1) {
165 // Characters fell to poison or hazardous ground.
166 u32 i;
167
170 for (i = 0; i < work->fallenCount; i++) {
173 UiText_ShowPositionedMessageAndWaitFar(MsgFieldStrengthExhausted,
174 1);
175 }
176 if (work->survivorCount == 0) {
177 // The whole party fell: back to the last sanctum with 1 HP.
178 struct BattleUnit *vitals;
179
180 if (gGameState.selectedActor == 0) {
183 else
185 } else {
187 }
189 UiText_ShowPositionedMessageAndWaitFar(MsgFieldPartyAnnihilated,
190 1);
192 vitals->hp = 1;
193 Unit_UpdateGauges(vitals);
197 result = EXIT_NONE;
198 goto done;
199 }
201 } else if (work->event == -888) {
204 } else if (work->event == -889) {
207 } else {
209 }
210 work->busy = 0;
211 work->event = 0;
212 } else if (work->battle != 0) {
213 // A random encounter: save the actors and go to the battle scene.
218 gGameState.entrance = work->battle;
219 work->exit = EXIT_NONE;
221 work->encounterBias = 0;
222 work->battle = 0;
224 } else if (work->action != 0) {
225 work->busy = 1;
227 work->busy = 0;
228 work->action = 0;
229 } else if (work->input != 0) {
231 work->input = 0;
232 } else if (work->examine != 0) {
233 // Examine the actor or tile ahead, or open the menu if neither has an
234 // event.
235 s32 object;
236
239 mode = 0;
240 if (object != -1) {
241 mode = Scene_FindActorTalkEvent(object) != 0;
242 }
243 if (mode != 0) {
244 work->descriptor = object | 0x1000;
245 work->menu = 0;
246 } else {
248 if (mode != 0) {
249 work->tile = mode;
250 work->menu = 0;
251 } else {
252 work->menu = 1;
253 }
254 }
255 work->examine = 0;
256 } else if (work->menu != 0) {
257 // The main menu (B + Select in debug mode opens the debug menu).
263 if (gDebugMode != 0 && (gKeysHeld & KEY_B) != 0 &&
264 (gKeysHeld & KEY_SELECT) != 0) {
266 } else if (GameFlag_TestFar(0x107) != 0) {
267 // While flag 0x107 is set (Vault's chase sets it), the menu raises
268 // the scene's event 250 instead of opening.
269 work->event = 250;
270 } else {
271 work->effectTimerRunning = 0;
273 work->effectTimerRunning = 1;
274 }
278 work->menu = 0;
279 } else if ((s16)work->descriptor != 0) {
281 Scene_TalkToActor(work->descriptor & 0xfff);
283 work->descriptor = 0;
284 } else if (work->tile != 0) {
286 Field_SearchTile(work->tile);
288 work->tile = 0;
289 } else if (work->command != 0) {
294 work->command = 0;
295 } else if (work->item != 0) {
297 Field_UseItem(work->item, work->itemArgument);
299 work->item = 0;
300 } else if (work->start != 0) {
301 // The pause menu (in debug mode, B opens the debug menu and L the
302 // palette editor).
307 if (gDebugMode != 0 && (gKeysHeld & KEY_B) != 0) {
309 }
310 /* FAKEMATCH(volatile): gDebugMode read through a volatile pointer,
311 so this second test loads it again; as gDebugMode, 48 of 965
312 instructions differ in tbs-en. */
313 else if (*(volatile u8 *)&gDebugMode != 0 &&
314 (gKeysHeld & KEY_L) != 0) {
316 } else if (GameFlag_TestFar(0x107) != 0) {
317 // As for the main menu above.
318 work->event = 250;
319 } else {
324 // Wait a frame first when fewer than 136 of the 512 resource
325 // blocks are free.
326 struct MenuCtrl *ctrl = (struct MenuCtrl *)gMenuCtrlWork;
327 u8 *owner = gResourceBlockOwners;
328 s32 free = 0;
329 s32 n = 512;
330
331 do {
332 if (*owner++ == 0xff)
333 free++;
334 } while (--n != 0);
335 if (free - 136 < 0) {
336 ctrl->wait = 1;
337 WaitFrames(1);
338 }
340 ctrl->wait = 0;
341 } else {
342 UiText_ShowPositionedMessageAndWaitFar(MsgFieldPauseUnavailable,
343 1);
344 }
345 }
348 work->start = 0;
349 }
350 }
351
352 // Hand the leader back to the player, as climbing (mode 1), mode 2, on
353 // the world map or walking, and step until the next request.
355 actor = work->actors[gGameState.selectedActor];
356 if (actor != NULL) {
357 if (gGameState.movementMode == 2)
359 else if (gGameState.movementMode == 1)
361 else if (work->mode == MODE_WORLD_MAP)
363 (struct DispatchObject *)actor);
364 else
366 }
367 do {
368 WaitFrames(1);
369 actor = work->actors[gGameState.selectedActor];
370 // In debug mode, flag 0x163 turns step processing off.
371 if (gDebugMode == 0 || GameFlag_TestFar(0x163) == 0)
372 Field_ProcessStep(actor->terrainId, actor->x.fixed, actor->y.fixed,
373 actor->z.fixed);
374 } while (Field_CountRequests() == 0);
375 }
376 }
377
378done:
379 if (work->transitionActive != 0) {
381 work->transitionActive = 0;
383 }
385 return result;
386}
387
388/// A field actor (struct FieldActor), seen with its position as one vector.
389struct Object {
393 u8 pad1[14];
395 u8 pad2[0x2d];
397};
398
399/// Returns the collision code of the map cell 16 pixels ahead of the party
400/// leader when there is something to search there: a tile code from 242 to 247
401/// whose ground is no more than 64 pixels above the leader, or a code the
402/// scene has a search event for. Returns 0 otherwise.
403///
404/// Called by Field_RunScene for the A button (a non-zero result becomes
405/// work->tile, for Field_SearchTile), and by Menu_RunTopSelection's search
406/// entry through Object_GetTriggerTileAheadOfCurrentFar. Changes nothing.
408 u8 *workBytes;
409 u8 *mapBytes;
410 struct Object *leader;
411 union PolarOffsetPosition probePosition;
412 u8 *cell;
413 u8 *cells;
414 s32 collisionCode;
415 s32 terrainHeight;
416 s32 result;
417
418 result = 0;
420 workBytes = *(u8 **)Ram_EventWork;
421 mapBytes = *(u8 **)Ram_MapWork;
422 if (leader != 0) {
423 probePosition.vector.x = leader->pos.x;
424 probePosition.vector.y = leader->pos.y;
425 probePosition.vector.z = leader->pos.z;
426 Vector_AddPolarOffset(0x100000, leader->angle, probePosition.coordinates);
427 // World map blocks are 32 pixels square, 32 to a row; map cells 16
428 // pixels square, 128 to a row, four bytes each.
429 if (((struct FieldWork *)workBytes)->mode == MODE_WORLD_MAP) {
430 cell =
431 Ram_MapBlocks + ((((probePosition.vector.x / 0x200000) & 31) +
432 (((probePosition.vector.z / 0x200000) & 31) << 5))
433 << 2);
434 } else {
435 cells = *(u8 **)(mapBytes + 0x130);
436 cell = cells + (((probePosition.vector.x / 0x100000) +
437 ((probePosition.vector.z / 0x100000) << 7))
438 << 2);
439 }
440 collisionCode = cell[2];
441 if (collisionCode >= 242 && collisionCode <= 247) {
442 terrainHeight = Map_GetTerrainHeightFar(
443 leader->kind, probePosition.vector.x, probePosition.vector.z);
444 if (terrainHeight >= leader->pos.y &&
445 terrainHeight <= leader->pos.y + 0x400000) {
446 result = collisionCode;
447 }
448 } else if (Scene_FindEvent(EVENT_SEARCH, collisionCode) != 0) {
449 result = collisionCode;
450 }
451 }
452 return result;
453}
454
455/// Places the party at the entrance it came in by (the first matching entry, or
456/// the scene's first one) unless it keeps its position, and sets the map's
457/// scroll bounds, at least a screen (240 x 160 pixels) wide and tall.
458///
459/// Called by Field_RunScene once the scene's events are set. Writes
460/// gGameState's position, heading and turn, and the map's minX to maxY.
462 struct MapScrollWork *map = gMapWork[0];
463 s32 entrance = gGameState.entrance;
464 const struct SceneEntrance *entranceEntry = gOverlayArea.entrances();
465 s32 foundEntrance = 0;
466
467 while (entranceEntry->entrance != -1) {
468 if (entranceEntry->entrance == entrance &&
469 (entranceEntry->requiredFlag == -1 ||
470 GameFlag_TestFar(entranceEntry->requiredFlag))) {
471 foundEntrance = 1;
472 break;
473 }
474 entranceEntry++;
475 }
476 if (!foundEntrance)
477 entranceEntry = gOverlayArea.entrances();
478
479 // Camera bounds apply even when returning to a saved party position.
481 gGameState.x = REGION_FIXED(entranceEntry->x);
482 gGameState.y = REGION_FIXED(entranceEntry->y);
483 gGameState.z = REGION_FIXED(entranceEntry->z);
484 gGameState.heading = entranceEntry->facing;
485 gGameState.turn = 0;
486 }
487
488 if (entranceEntry->cameraLeft != -1)
489 map->minX = REGION_FIXED(entranceEntry->cameraLeft);
490 if (entranceEntry->cameraTop != -1)
491 map->minY = REGION_FIXED(entranceEntry->cameraTop);
492 if (entranceEntry->cameraRight != -1)
493 map->maxX = REGION_FIXED(entranceEntry->cameraRight);
494 if (entranceEntry->cameraBottom != -1)
495 map->maxY = REGION_FIXED(entranceEntry->cameraBottom);
496
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);
501}
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
Definition actors.c:462
void ObjectTable_ResetForObject(struct ScenePlacement *table)
Creates a scene's actors on entering it: the party leader where the game state puts it,...
Definition actors.c:217
void ObjectTable_Snapshot(void)
Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots,...
Definition actors.c:488
void ObjectTable_Restore(void)
Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.
Definition actors.c:545
#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.
Definition cloak.c:117
void BattleFx_ApplyColorToTargetBuffer(s32 mode, s32 half)
Sets the colours the buffer moves toward (see BattleFx_BuildBuffer); does nothing without a colour bu...
Definition color.c:398
void BattleEffect_InitializeBuffers(void)
Sets up the colour buffer (heap block 32) from the BG and OBJ palettes and starts updating the palett...
Definition color.c:373
s32 Field_StartEncounterTransition(s32 unused)
Starts the transition into a random battle: plays the scene's battle cue and the encounter sounds,...
Definition context.c:62
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...
Definition context.c:181
void Djinn_ResolvePendingEvent(s32 shown)
Settles a pending Djinni battle as a scene loads.
Definition djinni.c:209
void FieldObject_PlaceSceneActors(void)
Puts a Djinni's actor back where its battle started from: for a pending Djinni battle (pendingDjinnEv...
Definition djinni.c:168
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
Definition dma.h:30
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
@ EVENT_SEARCH
#define FLAG_SHOW_LOCATION_NAME
Definition flags.h:94
#define FLAG_IN_BATTLE
Set as a battle starts, cleared as a field scene starts.
Definition flags.h:21
#define FLAG_RETREAT_BLOCKED
Retreat is blocked, from Psynergy or an item.
Definition flags.h:55
#define FLAG_KEEP_PARTY_POSITION
Definition flags.h:93
#define FLAG_CHILDHOOD
the prologue: Isaac and Garet are children
Definition flags.h:10
#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 ...
Definition flags.h:80
#define FLAG_MENU_OPEN
Set while the field menu is open; scenes hold their moving actors still.
Definition flags.h:23
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
u8 gDebugMode
Debug builds: Start+Select pauses the frame loop.
struct GameState gGameState
void * gMapWork[]
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
Definition heap.c:80
@ KEY_B
Definition io_reg.h:244
@ KEY_SELECT
Definition io_reg.h:245
@ KEY_L
Definition io_reg.h:252
#define PLTT_BACKDROP
Definition io_reg.h:155
s32 Field_UseItem(s32 packedItem, s32 slot)
Uses an item on the field.
Definition items.c:65
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,...
Definition markers.c:30
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,...
Definition math.c:23
void Runtime_ReleaseHeapBlock(s32 slot)
struct ObjectSystemWork * gMenuCtrlWork
void Encounter_SelectSceneZones(s32 useRules)
Chooses the current scene's encounter zones, one for each kind of ground the party can stand on (gEve...
Definition encounter.c:49
void Scene_SetDefeatReturnPoint(void)
Sets the scene the party returns to after a defeat (gGameState.savedScene and savedEntrance),...
Definition encounter.c:357
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.
Definition events.c:111
s32 Scene_TalkToActor(s32 id)
Talks to actor id: shows its event's message or calls its event function, with the actor stopped and ...
Definition events.c:197
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 ...
Definition events.c:333
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...
Definition events.c:175
s32 Field_SearchTile(s32 tile)
Searches the tile ahead with the given collision code.
Definition events.c:429
s32 Scene_RunRaisedEvent(s32 value)
Runs the scene's raised event (kind 6) for value: its message or its function.
Definition events.c:301
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 ...
Definition events.c:389
s32 Field_UsePsynergy(u32 code)
Uses Psynergy on the field.
Definition psynergy.c:17
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
Definition targets.c:261
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...
Definition targets.c:33
void DisplayTransition_Start(s32 mode, s32 frames)
Fades the screen in over frames frames.
Definition transition.c:603
void DisplayTransition_Finish(s32 mode, s32 frames)
Fades the screen out over frames frames, as DisplayTransition_Start fades it in.
Definition transition.c:698
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.
Definition events.c:275
void Leader_StopMoving(void)
Stops the leader where it stands: no horizontal velocity, the normal walking speed (1....
Definition events.c:67
s32 Party_CheckItemLimit(s32 item)
Checks whether the party can carry one more of item: each member carries at most 30 of one item.
Definition events.c:248
void BattleFx_RunVisibilityTransition(void)
On the world map, zooms the view out (0x9d89) while L is held, then back.
Definition world_map.c:535
void Map_ShowWorldMap(s32 picture)
Borrows the map-cell buffer for the still map until A or B closes it.
Definition world_map.c:427
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.
@ SCENE_BATTLE
#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_MapBlocks
Definition ram_buffer.h:12
#define Ram_MapCellBuffer
Definition ram_buffer.h:10
#define Ram_EventWork
Definition ram_buffer.h:50
#define Ram_MapWork
Definition ram_buffer.h:48
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...
Definition run_scene.c:461
s32 Object_GetTriggerTileAheadOfCurrent(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader when there is somethin...
Definition run_scene.c:407
s32 Field_RunScene(s32 entrance)
Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit ...
Definition run_scene.c:26
char SceneId_Clear
void Scheduler_ResetTaskTable(void)
Empties the task table: every slot gets no routine, order 0xffff (sorted last) and no flags.
Definition scheduler.c:19
#define MUS_059
Definition songs.h:63
#define SE_MENU_CURSOR_MOVE
Definition songs.h:104
#define NULL
Definition bilibin.h:6
void WorldMap_EndEvent(void)
Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the cam...
Definition step.c:484
void WorldMap_BeginEvent(void)
Starts an event or menu on the world map: ends any colour ratio transition in progress,...
Definition step.c:464
void Field_ClearRequests(void)
Clears the field's twelve pending requests (see struct FieldWork).
Definition step.c:33
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...
Definition step.c:193
s32 Field_CountRequests(void)
Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-...
Definition step.c:56
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
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.
Definition battle.h:73
s32 y
16.16 fixed-point pixels
Definition battle.h:75
s32 z
16.16 fixed-point pixels
Definition battle.h:76
s32 x
16.16 fixed-point pixels
Definition battle.h:74
A field actor: a person or thing on the field with a position, motion toward a target,...
Definition field_obj.h:30
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
Definition field_obj.h:112
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
Definition game_state.h:43
s16 cloaked
1 under Cloak, which prevents battles
Definition game_state.h:114
s16 hazardLimit
Hazardous ground (the Lamakan Desert's heat): every hazardLimit steps the party takes hazardDamage (b...
Definition game_state.h:96
s32 z
16.16 fixed-point pixels
Definition game_state.h:52
s16 nextEntrance
where the event sends the party next; -1 for none
Definition game_state.h:44
s16 map
the scene's map; SceneId_Clear for the world map
Definition game_state.h:49
u8 perspectiveScene
set to 1 on the world map; not read by name in TBS
Definition game_state.h:89
s32 y
16.16 fixed-point pixels
Definition game_state.h:51
u16 turn
the leader's terrainId, kept with its position
Definition game_state.h:54
s16 defaultEntrance
the entrance it was entered by
Definition game_state.h:41
s16 pendingDjinnEvent
The Djinni battle pending (DJINNI_0 plus its number, flags in bits 15 to 11), resolved on returning t...
Definition game_state.h:103
s16 pausedObject
Halt: the stopped object; -1 for none.
Definition game_state.h:113
s32 encounterSteps
the encounter count, reset with a new group
Definition game_state.h:105
s16 defeatEntrance
where a defeat returns to; -1 for none
Definition game_state.h:46
u32 heading
1/65536 turns
Definition game_state.h:53
s16 hazardDamage
Definition game_state.h:98
s16 defeatScene
where a defeat returns to; -1 for none
Definition game_state.h:45
s16 defaultScene
the scene being run, kept as it starts
Definition game_state.h:40
s16 sceneVariant
the current scene's variant from its record
Definition game_state.h:107
s16 entrance
Definition game_state.h:37
s32 x
16.16 fixed-point pixels
Definition game_state.h:50
u8 movementMode
1 while the leader is climbing, 0 otherwise
Definition game_state.h:57
u16 pendingItem
given on returning to the field if the party has room
Definition game_state.h:106
s32 selectedActor
the leader: its unit and its actor
Definition game_state.h:59
s16 savedScene
where a defeat returns to without a defeat point
Definition game_state.h:38
s16 returnCue
music playing when the field left; -1 for none
Definition game_state.h:82
s16 hazardMode
0 counts on hazard cells only; 1 counts every step
Definition game_state.h:97
s16 savedEntrance
where a defeat returns to without a defeat point
Definition game_state.h:39
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
Definition map.h:13
The field map's work: the followed position, screen shake, tile animations, blend script,...
Definition map_scroll.h:27
s32 maxY
16.16 fixed-point pixels
Definition map_scroll.h:41
The object system's work (struct ObjectSystemWork), seen as the flag that suspends sprite projection ...
Definition run_scene.c:9
u16 wait
Definition run_scene.c:11
u8 unk00[4]
Definition run_scene.c:10
A field actor (struct FieldActor), seen with its position as one vector.
Definition run_scene.c:389
u8 pad2[0x2d]
Definition run_scene.c:395
u8 kind
Definition run_scene.c:394
struct EffectVector pos
Definition run_scene.c:392
struct AnimationObject * sprite
Definition run_scene.c:396
u8 pad1[14]
Definition run_scene.c:393
u8 pad0[6]
Definition run_scene.c:390
u16 angle
Definition run_scene.c:391
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
Definition field_scene.h:54
s16 requiredFlag
a flag that must be set, or -1 for none
Definition field_scene.h:56
s16 y
pixels
Definition field_scene.h:58
s16 cameraTop
pixels
Definition field_scene.h:63
s16 cameraRight
pixels
Definition field_scene.h:64
s16 cameraLeft
pixels
Definition field_scene.h:62
s16 entrance
the entrance number the game state names; -1 ends
Definition field_scene.h:55
s16 z
pixels
Definition field_scene.h:59
s16 x
pixels
Definition field_scene.h:57
u16 facing
1/65536 turns (enum Facing)
Definition field_scene.h:60
s16 cameraBottom
pixels
Definition field_scene.h:65
const struct SceneEntrance *(*) entrances(void)
const struct ScenePlacement *(*) placements(void)
const struct SceneEvent *(*) events(void)
s32(*) initialize(void)
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
Definition field_scene.h:81
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
The polar-offset routine walks three array elements.
struct EffectVector vector
#define MODE_WORLD_MAP
the world map
Definition object.h:78
u8 gResourceBlockOwners[VRAM_BLOCK_COUNT]