100 tileX = (fixedX >> 21) & 31;
105 tileY = (fixedZ >> 21) & 31;
107 tile = (
u8 *)
gMapBlocks + ((tileX + (tileY << 5)) << 2);
116 u32 tileX = fixedX >> 20;
122 tile = (
u8 *)((
u32)tile + ((tileX + ((fixedZ >> 20) << 7)) << 2));
165 exitValue = region->
value;
170 work->
exit = exitValue;
218 s32 accumulatedDistance;
219 s32 fullEncounterRate;
227 for (i = 0; i < partyCount; i++)
232 (((z / 0x200000) & 31) << 5)];
238 tile = &tile[(x / 0x100000) + ((z / 0x100000) << 7)];
260 encounterSpeed <<= 1;
262 fullEncounterRate = 1;
278 if (!fullEncounterRate)
282 if (accumulatedDistance > 0xffff) {
283 amount = accumulatedDistance / 0x10000;
339 for (i = 0; i < partyCount; i++) {
345 if (unitVitals->
hp > 0) {
347 }
else if (previousHp[i] != 0) {
366 for (partyIndex = 0; partyIndex < partyCount; partyIndex++)
395 for (partyIndex = 0; partyIndex < partyCount; partyIndex++) {
400 hpDelta = unit->
maxHp * amount / 100;
421 for (partyIndex = 0; partyIndex < partyCount; partyIndex++) {
427 hpDelta = -((unit->
maxHp + 10) / 20);
430 if (worstPoison <= 0)
434 hpDelta = -((unit->
maxHp + 5) / 10);
437 if (worstPoison <= 1)
447 if (worstPoison != 0) {
471 if ((transition !=
NULL) && (transition->
step != 0)) {
472 transition->
start = 0;
475 transition->
step = 0;
void BattleFx_StartBufferInterpolation(s32 frames)
Starts moving the shown colours to the target colours over frames frames: sets work->duration,...
void BattleFx_ApplyColorToSourceBuffer(s32 mode, s32 half)
Sets the colours the buffer shows now (see BattleFx_BuildBuffer).
s32 DjinnRecovery_TickFar(void)
void WorldMap_BeginStillViewFar(void)
void Map_LoadAreaGraphicsFar(void)
struct BattleUnit * UnitGetFar(u32 owner)
s16 Unit_AddPpFar(s32 owner, s32 delta)
s32 GameFlag_TestFar(s32 flag)
s32 Unit_AddHpFar(s32 owner, s32 delta)
s32 Party_CountActiveOwnersFar(void)
void AudioCommand_PlayFar(s32 id)
#define ACTOR_NO_TARGET
A target coordinate that is not set: the object has no target.
struct SceneEntries gOverlayArea
#define FLAG_LURE_CAP
Set while the Lure Cap is worn: random encounters come twice as fast.
struct GameState gGameState
struct EffectStep gMapCellBuffer[]
Map cells; battle effects reuse this as a particle array.
void * Runtime_AllocateBlock(s32 kind, s32 size)
As Runtime_AllocateHeapBlock, but tries EWRAM first, for blocks that need room more than speed: the b...
#define WORK_SLOT(n)
Reads slots through their own addresses; adjacent slots are reached by offsets.
#define Iwram_MulQ16(left, right)
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,...
s32 Encounter_RollWorldMap(s32 pos, s32 steps)
Rolls a random battle on the world map, taking the zone from the tile at pos.
s32 Encounter_RollTerrain(u32 terrain, s32 steps)
Rolls a random battle on the encounter zone of the ground underfoot.
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
void Leader_StopMoving(void)
Stops the leader where it stands: no horizontal velocity, the normal walking speed (1....
void Event_ClearInvalidPackedValues(void)
Clears each button shortcut whose Psynergy can no longer be cast: zeroes gGameState....
void BattleFx_ConfigureLinkedObject(s32 actor, s32 flags)
The event command "actor set attached effect": with mode (the low 2 bits) 0 removes the object attach...
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.
struct EventWork * gEventWork
StepTileEvent
The collision codes of map cells that mean something when stepped on.
@ STEP_EVENT_FIRST
1 to 239: the scene's step events
@ STEP_TERRAIN_FIRST
240 and 241: ground with its own encounters
@ STEP_EVENT_HAZARD
ground that hurts the party over time
@ STEP_WARP_FIRST
252 to 254: ledges and climbing spots the leader pushes against (Field_RunPushTileEvent)
void WorldMap_EndEvent(void)
Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the cam...
void BattleParty_ApplyDrain(s32 amount, s32 unused)
Gives each character in the party amount PP (PP regenerates as the party walks).
s32 BattleParty_ApplyStatusDamage(void)
Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a ...
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_GetCollisionAheadOfLeader(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on ...
s32 Field_CountRequests(void)
Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-...
void Field_CheckExitRegions(s32 positionX, s32 positionY, s32 positionZ)
Takes the exit of the first of the scene's exit regions that contains the position (x,...
void BattleParty_ApplyHealthDelta(s32 amount, s32 percent)
Changes each party member's HP by amount, or by that percentage of maximum HP when percent is set.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
s8 poison
1 poisoned, 2 deadly poison
s16 hp
current HP, 0 when downed
s16 maxHp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
The display transition state (heap block 31): two pages of window edges for every line,...
s8 end
the value's last step; 64 hides BG1 to BG3 and sprites
s8 start
the value's first step
s8 duration
frames; 0 when the value is not moving
s32 y
16.16 fixed-point pixels
s32 z
16.16 fixed-point pixels
s32 x
16.16 fixed-point pixels
Full event work allocated by Field_RunScene (heap slot 27).
s16 exit
the exit taken, which ends the scene
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 tile
a tile's collision code, for Field_SearchTile
struct MapCell * previousTile
the cell before it
u8 encounterGroups[8]
encounter zone for each kind of ground
s16 start
the Start button: open the pause menu
s16 fallenOwners[9]
the characters who fell, from the active party
s16 battle
the enemy group of a random encounter
s16 survivorCount
0 when the whole party fell
s32 walkingDistanceScale
scales movement for PP and status updates
struct ObjectRuntime * camera
the object the map view follows
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
struct MapCell * currentTile
the cell the leader last stepped onto
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 walkingDistance
accumulated 16.16 distance awaiting an update
s16 hazardLimit
Hazardous ground (the Lamakan Desert's heat): every hazardLimit steps the party takes hazardDamage (b...
s32 avoidDistance
distance left of Avoid, 16.16 pixels; 0 when off
s16 hazardSteps
reset on entering a new scene group
s16 sceneVariant
the current scene's variant from its record
u8 activeOwners[8]
the party in order
u8 movementMode
1 while the leader is climbing, 0 otherwise
s32 selectedActor
the leader: its unit and its actor
s16 hazardMode
0 counts on hazard cells only; 1 counts every step
One cell of a map layer: its metatile and flags, its collision code and an attribute indexing the col...
u8 collisionCode
The step code: 1 to 239 scene events, 240 and 241 encounter ground, 250 hazard, 252 to 254 for Field_...
struct MapCell * cells
the layer's first cell (MapLayerScroll's cells)
The map work in heap slot 8 (struct MapScrollWork), seen as its tile animation channels,...
struct MapLayer layers[4]
Each layer's cells, at MapScrollWork's layers[i].cells; readers mask the layer with 3,...
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 velocityY
16.16 fixed-point pixels per frame
u8 movementState
nonzero skips its script and motion (paused)
s32 z
16.16 fixed-point pixels
s32 targetX
16.16 fixed-point pixels; 0x80000000 when unset
s32 x
16.16 fixed-point pixels
s32 speedLimit
16.16 fixed-point pixels per frame
s32 y
16.16 fixed-point pixels
const struct SceneRegion *(*) regions(void)
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
s16 value
the exit kind, stored in FieldWork's exit
s16 minZ
pixels, inclusive; minX -1 ends the table
s16 condition
-1 always, a flag | 0x1000 set, else the flag clear
s16 maxZ
pixels, exclusive
A party member's battle unit, seen as the HP and poison a step reads.
u8 unitFieldsBeforeHp[0x38]
u8 unitFieldsBeforePoison[0x131 - 0x3a]
The polar-offset routine walks three array elements.
struct EffectVector vector
#define MODE_WORLD_MAP
the world map