Alchemy
Loading...
Searching...
No Matches

object.h File Reference

Go to the source code of this file.

Data Structures

struct  EffectDescriptor
 One of the scene's events (the same 12 bytes as struct SceneEvent). More...

Macros

#define OBJ_LAST   66
 the last actor slot searched
#define MARKER_MAX   10
#define MODE_WORLD_MAP   3
 the world map

Functions

void Scene_TakeExit (s32 exitKind)
 Chooses the scene and entrance to go to when the party leaves the current scene.
void Scene_ReturnFromBattle (s32 result)
 Chooses where the game continues after a battle or another scene that is not a field map (see Game_ResetForNewGame).
s32 BattleFx_GetResourceGroup (s32 scene)
 Returns the group scene belongs to.
void Game_ResetForNewGame (s32 mode)
 The game's main loop, which never returns.
void Scene_LoadOverlay (s32 unused)
 Loads the current scene's overlay code (its resource) into gOverlayArea.
void Scene_ResetFlagsOnEnter (s32 unused, s32 keep)
 Updates the flags and state that last for one scene or one group of scenes, on entering the current scene.
void Audio_PlayCueFromEventWork (void)
 Starts the current scene's field music, chosen by Scene_ResolveInteractionResult.
void Encounter_SelectSceneZones (s32 useRules)
 Chooses the current scene's encounter zones, one for each kind of ground the party can stand on (gEventWork->encounterGroups, read by EffectRuntime_LookupByTableEntry), from the first rule matching the scene and entrance.
s32 Encounter_ResolveWorldMapZoneAndBackdrop (void *pos)
 Returns the world map encounter zone for the terrain at pos (0 for none), and chooses the battle backdrop for that terrain (gGameState.special).
s32 Encounter_SelectEnemyGroup (s32 zone, s32 steps)
 Advances the encounter counter for zone and returns the enemy group to fight, or 0 for no battle.
s32 Encounter_RollTerrain (u32 terrain, s32 steps)
 Rolls a random battle on the encounter zone of the ground underfoot.
s32 Encounter_RollWorldMap (s32 pos, s32 steps)
 Rolls a random battle on the world map, taking the zone from the tile at pos.
u16 Encounter_GetEnemyGroupAtSlot (s32 zone, s32 slot)
 Returns the enemy group in slot (0 to 7) of zone; 14 halfwords make a zone.
s16 Encounter_GetDjinnEnemyGroup (s32 djinni)
 Returns the enemy group of Djinni battle djinni, which the table gives as a zone and slot.
void Scene_ResolveInteractionResult (void)
 Chooses the current scene's field music (gGameState.cue) from the first rule matching the scene or its group and the entrance; MUS_018 when none does.
s32 Scene_GetAreaNameIndex (s32 scene, s32 entrance)
 Returns the place name of scene and entrance, from the first rule matching the scene or its group; 0 when none does.
void Scene_SetDefeatReturnPoint (void)
 Sets the scene the party returns to after a defeat (gGameState.savedScene and savedEntrance), from the first rule of gParty_PairResolveRules that matches the current scene and entrance: {scene, entrance (-1 for any), return scene, return entrance}, ended by scene -1.
s16 Event_GetSpecialValue (void)
 Returns the battle backdrop chosen for the current scene.
void Battle_SelectSceneBackdrop (void)
 Chooses the battle backdrop for the current scene.
void Battle_SelectTerrainBackdrop (s32 behavior)
 Chooses the battle backdrop for a world map terrain behavior (1 to 7; any other gives Sol Sanctum's) and sets gGameState.special.
void BattleFx_ShrinkObjectAndDestroySlow (union FieldObject *object)
 Spins and shrinks an object by 0x1c0 a frame, then releases it.
void BattleFx_ShrinkObjectAndDestroyFast (union FieldObject *object)
 Spins and shrinks an object by 0x400 a frame, then releases it.
void FieldFx_RunLift (void)
 Lift cast with no target: objects appear above the caster and to either side, move apart and scatter into shards.
void FieldFx_RunCarry (void)
 Carry cast with no target: objects appear above the caster and to either side, move apart and scatter into shards.
s32 Party_RemapCharacterIdByFlags (s32 character)
 Returns the sprite of character, which is the character itself except that FLAG_CHILDHOOD gives characters 0 and 1 sprites 0x12 and 0x13, and FLAG_ISAAC_WEARS_TUNIC gives grown Isaac sprite 0x11.
s32 Party_RemapCharacterIdIfEnabled (s32 character, s32 childhood)
 Returns the sprite of character as Party_RemapCharacterIdByFlags would with FLAG_CHILDHOOD set to childhood (as recorded in a save file's summary).
void Event_SpawnObjectTable (struct ScenePlacement *entry, s32 slot)
 Creates the actors of a scene's placement table (ended by sprite -1), and records the table among the scene's tables.
void ObjectTable_DestroyAtIndex (s32 actorIndex)
 Destroys the actor in slot actorIndex, if there is one, and empties the slot.
void ObjectTable_ResetForObject (struct ScenePlacement *table)
 Creates a scene's actors on entering it: the party leader where the game state puts it, then the scene's placement table from actor slot 8, and the camera that follows the leader.
s32 ObjectTable_FindLastActiveId (void)
 Returns the slot after the last placed actor (8 when there is none), or -1 when slot 65 is occupied.
void * ObjectTable_GetSlotAddress (u32 actorIndex)
 Returns the address of actor slot index in the event work.
void Scene_AssignViewFlags (struct ScenePlacement *entry)
 Gives each placement with condition 0 a condition saying whether it lies within the map's view bounds, so that only those inside appear.
void BattleEffect_ClearOutOfBoundsObjects (void)
 Destroys the placed actors far from the view's centre: more than 160 pixels to either side, 200 pixels north or 100 pixels south.
void BattleEffect_ClearAllObjects (void)
 Destroys every placed actor and places the scene's actors again from its first placement table after the leader's.
void ObjectTable_ClearAll (void)
 Empties all 66 actor slots, without destroying the actors.
void * ObjectTable_Get (u32 actorIndex)
 Returns the actor in slot index (0 to 65), or NULL.
void ObjectTable_Snapshot (void)
 Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots, with each one's slot, animation, sprite flags and priority, so that ObjectTable_Restore can put them back.
void ObjectTable_Restore (void)
 Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.
void Field_ClearRequests (void)
 Clears the field's twelve pending requests (see struct FieldWork).
s32 Field_CountRequests (void)
 Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-zero while any request is pending.
s32 Field_GetCollisionAheadOfLeader (void)
 Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on the world map), or 0 without a leader.
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, y, z) and whose condition holds: records the region's exit value for Field_RunScene, plays the exit sound and starts leaving the scene.
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 push tiles, takes exits, and while walking advances the encounter counter, regenerates PP, hurts the party with poison and hazardous ground, and wears Avoid off.
void BattleParty_ApplyDrain (s32 amount, s32 unused)
 Gives each character in the party amount PP (PP regenerates as the party walks).
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.
s32 BattleParty_ApplyStatusDamage (void)
 Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a tenth (at least 1).
void WorldMap_BeginEvent (void)
 Starts an event or menu on the world map: ends any colour ratio transition in progress, pauses camera movement and freezes the perspective view as a still picture.
void WorldMap_EndEvent (void)
 Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the camera's movement state back to 0.
s32 Field_RunScene (s32 entrance)
 Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit kind it left by (for Scene_TakeExit), or 999 when the party fell outside battle.
s32 Object_GetTriggerTileAheadOfCurrent (void)
 Returns the collision code of the map cell 16 pixels ahead of the party leader when there is something to search there: a tile code from 242 to 247 whose ground is no more than 64 pixels above the leader, or a code the scene has a search event for.
void Scene_ApplyEntrance (void)
 Places the party at the entrance it came in by (the first matching entry, or the scene's first one) unless it keeps its position, and sets the map's scroll bounds, at least a screen (240 x 160 pixels) wide and tall.
void Debug_RunPaletteEditor (void)
 The debug palette editor (L on the pause menu in debug mode).
struct ScenePlacement * Scene_FindActorPlacement (s32 id)
 Returns the placement of actor id in the scene's placement tables, or NULL: for a party character (0 to 7) the row with its sprite, and for a placed actor (8 on) the row it was created from, counting the placed rows in order.
s32 GameFlag_IsConditionActive (s32 condition)
 Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while that flag is set, any other while its flag is clear.
u32 Event_SearchIgnoresCondition (s32 flags, s32 result)
 Returns 1 for a search event (kind 3) that holds whatever its condition: one with more flags than its kind, unless its result is a mimic battle (type 0x005 in its top 12 bits).
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.
void Runtime_CallWorkBlockEntry (void)
 Nothing calls this.
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 one.
s32 Scene_TalkToActor (s32 id)
 Talks to actor id: shows its event's message or calls its event function, with the actor stopped and turned as its placement says.
s32 Scene_RunRaisedEvent (s32 value)
 Runs the scene's raised event (kind 6) for value: its message or its function.
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 exit's sound (and effect) and records where it leads.
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 for more than 12 frames; the count then restarts.
s32 Field_SearchTile (s32 tile)
 Searches the tile ahead with the given collision code.
s32 Field_GetPsynergyTargetRange (s32 kind)
 Returns how far, in pixels, a field Psynergy of the given kind reaches: gBattleFx_TargetRangeByMode pairs kinds with ranges, ended by -1, and a kind not listed reaches 16 pixels.
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 pixels of distance and, beyond 11 pixels, within 0x2fff of the direction it faces.
s32 Field_FindNearbyPsynergyTarget (s32 id, s32 kind)
 Returns the actor nearest in front of actor id that a field Psynergy of the given kind can reach, or -1.
s32 BattleFx_PlayCueAndStartEmitterOnTarget (s32 actor, s32 target, s32 itemId)
 If actor target exists, plays SE_124, gives it animation 4 and, 12 frames later, shows itemId in front of actor with sparkles.
void Animation_ApplyChildPalette (struct MotionObject *object, s32 palette)
 Gives every part of a motion object's sprite (but those at palette 15) palette - 1, or for palette 0 the next palette of a cycle that changes every 2 frames.
void Battle_ResetEffectCounter (void)
 Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs its ending events.
s32 Field_FindItemEvent (s32 item)
 Returns the scene's item event (kind 4) for item that applies to what the leader faces, or 0 (item 0 matches any item).
s32 Field_UseItem (s32 packedItem, s32 slot)
 Uses an item on the field.
void * BattleFx_FindMatchingEvent (s32 eventFlags, s32 group, void *target)
 Returns the scene's Psynergy event (kind 5) for Psynergy of the given group that applies to what the leader faces, or NULL; stores the actor the Psynergy would target in *target.
s32 Field_RunPsynergyEvents (s32 packed)
 Runs the scene's events for Psynergy without paying its PP or showing its usual effect (phases 3 and 2, around the event's own effect), as for a Psynergy that ends by itself: packed holds the Psynergy (bits 0 to 9) and its user (bits 10 to 13).
s32 Field_UsePsynergy (u32 code)
 Uses Psynergy on the field.
s32 BattleFx_HasMatchingEvent5 (s32 group)
 Returns whether the scene has a Psynergy event, in any phase, for Psynergy of group and what the leader faces.
u32 BattleFx_HasTrigger (u16 item)
 Returns whether the scene has an event for item and what the leader faces.
void ObjectMotion_SnapToTerrain (void *object)
 Sets an actor's y and terrainHeight to the map's height at its x and z.
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, up to ten: a chest (actor 20) for a chest event, shown open once its flag is set and gone once its mimic was beaten, and a Psynergy stone (actor 28) for a search event giving one, until it is taken.
s32 Marker_FindSlot (s32 id)
 Returns the marker slot (0 to 9) whose event trigger is id, or -1.
void EffectRuntime_ReservedNoOp (void)
void Marker_CloseChest (s32 id)
 Closes the chest of marker id again (its item could not be carried), with SE_125.
void Marker_LaunchMimic (s32 id)
 Makes the chest of marker id jump up as a mimic: after 18 frames it takes animation 7, plays SE_146 and gets an upward velocityY of 8 << 16.
void Marker_OpenChest (s32 id)
 Opens the chest of marker id (animation 4) with SE_124, and waits 12 frames.
void Marker_ShowOpened (s32 id)
 Shows the chest of marker id open (animation 2), with no sound.
struct ObjectRuntime * Marker_GetActor (s32 id)
 Returns the actor of marker id, or NULL when no slot has it.
void Marker_Hide (s32 id)
 Hides the actor of marker id by clearing its animationKind.
void Marker_SetActorPosition (s32 id, s32 x, s32 z)
 Moves the actor of marker id to (x, z) on the ground; -1 keeps the centre of its cell on that axis.
void Marker_MoveLeaderAway (void)
 Keeps the party leader off the markers: a leader within 16 pixels of a marker cell's centre is moved 20 pixels from that centre, in the direction it stood, and loses its move target.
void ItemDisplay_EmitSparkles (union FieldObject *fieldObject)
 Each frame of a found item's picture: one time in ten, a sparkle appears within 16 pixels of it.
struct EffectObj * BattleFx_StartRandomParticleEmitter (s32 actor, s32 item)
 Shows the picture of item (0 for none) at the centre of the cell 16 pixels in front of character actor, 16 pixels up, with sparkles.
void Object_DestroyIfPresent (void *object)
 Releases object unless it is NULL.
void ItemDisplay_RaiseAboveLeader (struct ObjectRuntime *object)
 Raises a found item's picture to 36 pixels above the party leader, who holds it up (animation 28) facing the screen.
void EffectRuntime_RunRisingObjectSequence (void *object, s32 flags)
 Shows a found item's picture: flags bit 0 adds sparkles and bit 1 raises it above the leader, with waits of 60 and 80 frames around that when both are set.
void BattleFx_StartEffectObject22 (s32 item, s32 flags)
 Shows the picture of item 36 pixels above the party leader for 80 frames; flags bit 0 adds sparkles and bit 1 raises it as a found item.
void BattleFx_ClearRandomParticles (void)
void RevealMarker_EmitSparkles (union FieldObject *fieldObject)
 Each frame of a Reveal marker: one time in ten, a sparkle appears within 16 pixels of it.
s32 Field_IsRevealActive (struct ScriptInterpreter *interpreter)
 Returns 1 while Reveal is active, else 0.
void FieldEffect_SpawnNearbyMarkers (void)
 Reveal: marks with sparkles the hidden things within 8 cells left or right and 5 up or down of the leader: map places 100 to 239 with no marker actor, whose search event (kind 3) gives an item, coins, a Psynergy stone or a mimic (types 0 to 3 and 5) and whose flag is not yet set.
void BattleFx_StartWindowHBlankDma (void)
 Each frame, before drawing: turns windows 0 and 1 on, writes the first four values of the shown page into WININ, WINOUT, WIN0H and WIN1H, and has DMA 0 copy the rest into WIN0H and WIN1H one word each HBlank, so that every line of the screen gets its own window edges.
void DisplayTransition_UpdateScanlineTable (void)
 Each frame of a window transition: advances its value toward its end (and at the end turns the windows off, or moves to the next mode), then builds the next page of window edges, WININ and WINOUT first and then a (left << 8 | right) pair for each of the 160 lines.
void DisplayTransition_InitializeBattleEffectState (s32 mode)
 Starts window transition mode at value 0, with no duration: the caller moves it.
void DisplayTransition_SuspendCallbacks (void)
 Suspends the window transition's two callbacks.
struct DisplayTransitionState * DisplayTransition_AllocateAndClearState (void)
 Allocates the display transition state (heap block 31) and clears it.
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.
void DisplayState_ClearFlags (s32 clearBg3, s32 clearBg2, s32 clearBg1)
 Clears the map's display-control bits for backgrounds 3, 2 and 1 (0x0800, 0x0400 and 0x0200) for each argument that is set.
void DisplayTransition_Update (void)
 Each frame of the centre-line transition: moves the value toward its end and sets the two lines where the screen switches between shown and blank.
void DisplayTransition_UpdateFromCentre (void)
 As DisplayTransition_Update, but the lines flicker every other frame.
void DisplayTransition_UpdateScanline (void)
 The VCount interrupt of the centre-line transition: switches the display to mode 2 (nothing shown) at the first line and back to mode 0 at the second.
void DisplayTransition_UpdateFrame (void)
 Each frame of the dissolve: moves the value toward its end and sets two more of the solid tile's 64 pixels, in the order of gDisplayTransition_DitherTable, to colour 15 (or 0 when closing).
void DisplayTransition_FillTilemapAndSolidTile (s32 color)
 Fills background screen block 4 with tile 0 in palette 15 and, unless color is -1, makes tile 0 solid color.
void DisplayTransition_InitializeState (s32 value)
 Starts a dissolve of the given mode and waits 120 frames.
void BattleFx_InterpolateBuffers (s16 *source, s16 *target, s16 *step, s32 frames)
 Sets each of the 1344 colour channels of step to the amount to add each frame for source to reach target in frames frames; with frames 0 or less step is left as it was.
void BattlePalette_UpdateBlend (void)
 Each frame (unless flag 0x152 is set): moves the colour buffer one step toward its target, packs it into RGB555 and queues it for the BG and OBJ palettes.
void BattleEffect_InitializeBuffers (void)
 Sets up the colour buffer (heap block 32) from the BG and OBJ palettes and starts updating the palettes from it each frame.
void BattlePalette_StopBlendAndReleaseBuffer (void)
 Stops the colour buffer and frees it: removes BattlePalette_UpdateBlend and releases heap slot 32.
void BattleFx_ApplyColorToTargetBuffer (s32 mode, s32 half)
 Sets the colours the buffer moves toward (see BattleFx_BuildBuffer); does nothing without a colour buffer.
void BattleFx_ApplyColorToSourceBuffer (s32 mode, s32 half)
 Sets the colours the buffer shows now (see BattleFx_BuildBuffer).
void BattleFx_SetPrimaryBufferValue (u32 color)
 Sets the buffer's source backdrop colour (BG colour 0 of its palette copy).
void BattleFx_StartBufferInterpolation (s32 frames)
 Starts moving the shown colours to the target colours over frames frames: sets work->duration, clears work->step and fills work->delta.
s32 BattleFx_ClampRgb555Channel (s32 value)
 Clamps a 5-bit colour channel to 0 to 31.
s32 BattleFx_ClampRgb555Component (s32 value)
 Clamps a colour channel shifted up 10 bits to at most 31 << 10.
void FadeOverlay_DrawMarks (void)
 Each frame of the fade overlay: on each of the two cells beside the actor (left and right of it), where the ground one or two cells south rises above the actor's floor, draws a semi-transparent 16-pixel-wide sprite of colour 1 at the height of that ground.
void BattleFx_StartFadeOverlay (void *object)
 Starts the fade overlay on object (the party leader when NULL): loads its solid tiles, sets the blending and draws it each frame.
void FadeOverlay_Suspend (void)
 Stops drawing the fade overlay, keeping its work.
void FadeOverlay_Resume (void)
 Draws the fade overlay again after FadeOverlay_Suspend.
struct BattleEffectEntry * BattleFx_FindDefinition (u32 id)
 Returns the speaker definition of sprite id from gBattleFx_DefinitionTable, or its last entry when there is none.
s32 BattleFx_GetAnimationValue (s32 id)
 Returns the sprite id stored by a live actor's animated sprite, or 0 when that actor has no animated sprite or its sprite-id pointer is absent.
s32 BattleFx_GetResourceId (u32 id)
 Returns the portrait shown beside the messages of sprite id (0x100 plus its definition's value), or 0 with no portrait or with gGameState.speech off.
s32 BattleFx_GetFlags (s32 id)
 Returns the definition flags of actor id's sprite, which choose its line when it has nothing to say.

Macro Definition Documentation

◆ OBJ_LAST

#define OBJ_LAST   66

the last actor slot searched

Definition at line 71 of file object.h.

Referenced by Field_FindNearbyPsynergyTarget(), Field_FindNearbyTalkTarget(), and ObjectGroup_SetActionForOthers().

◆ MARKER_MAX

#define MARKER_MAX   10

Definition at line 76 of file object.h.

Referenced by Field_PlaceMapMarkers().

◆ MODE_WORLD_MAP

Function Documentation

◆ Scene_TakeExit()

void Scene_TakeExit ( s32 exitKind)

Chooses the scene and entrance to go to when the party leaves the current scene.

exitKind is the kind of exit Field_RunScene ended on; the scene's exit table gives the first exit of that kind (or of any kind) whose flag, if it has one, is not set. An exit of kind 0 or the end of the scene's exits falls back to the scene of its first exit. Called by Game_ResetForNewGame with Field_RunScene's result; sets gGameState.scene and .entrance, and leaves them alone for EXIT_NONE or a scene with no header in the table.

Definition at line 25 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_TakeExit().

◆ Scene_ReturnFromBattle()

void Scene_ReturnFromBattle ( s32 result)

Chooses where the game continues after a battle or another scene that is not a field map (see Game_ResetForNewGame).

result is that scene's result: -1 when the party was defeated, which revives the leader with 1 HP (and, with FLAG_CHILDHOOD, fully heals the first two characters) and returns to the defeat point, or to the last saved point when none is set. Any other result goes to the next scene the event set, or to the default scene with the party keeping its position (FLAG_KEEP_PARTY_POSITION). Called by Game_ResetForNewGame after each scene above SCENE_BLANK; stores result in gGameState.sceneChangeReason and sets gGameState.scene and .entrance.

Definition at line 95 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_ReturnFromBattle().

◆ BattleFx_GetResourceGroup()

s32 BattleFx_GetResourceGroup ( s32 scene)

Returns the group scene belongs to.

The scenes of one place share a group, which selects their music, area name and the flags kept while inside it. Called by Scene_ResolveInteractionResult.

Definition at line 156 of file scene.c.

Referenced by BattleFx_GetResourceGroup(), and Scene_GetAreaNameIndex().

◆ Game_ResetForNewGame()

void Game_ResetForNewGame ( s32 mode)

The game's main loop, which never returns.

mode chooses the first scene: 0 starts at the title screen with a fresh game state; in debug mode, 1 starts in Isaac's home in Vale and 2 at the clear screen. Each pass resets the runtime, then either runs a battle or minigame and picks the scene to return to, or loads a field scene's code, starts its music and runs it until the party takes an exit. Called with mode 0 through Game_ResetForNewGameFar by System_Initialize at power-on and by Game_Restart.

Definition at line 204 of file scene.c.

Referenced by Game_ResetForNewGame().

◆ Scene_LoadOverlay()

void Scene_LoadOverlay ( s32 unused)

Loads the current scene's overlay code (its resource) into gOverlayArea.

Called by Game_ResetForNewGame before Field_RunScene.

Definition at line 294 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_LoadOverlay().

◆ Scene_ResetFlagsOnEnter()

void Scene_ResetFlagsOnEnter ( s32 unused,
s32 keep )

Updates the flags and state that last for one scene or one group of scenes, on entering the current scene.

Unless keep is set (the party returns to where it was, as after a battle), the flags of the last scene are cleared, and on entering a new group so are the group's flags and step counters, the location name is shown and the entrance becomes the point Retreat returns to. Then the group's visited flag (0x180 + group) is set. Called by Game_ResetForNewGame before each field scene, with keep from FLAG_KEEP_PARTY_POSITION; sets gGameState.sceneGroup and .sceneVariant.

Definition at line 311 of file scene.c.

Referenced by Game_ResetForNewGame(), and Scene_ResetFlagsOnEnter().

◆ Audio_PlayCueFromEventWork()

◆ Encounter_SelectSceneZones()

void Encounter_SelectSceneZones ( s32 useRules)

Chooses the current scene's encounter zones, one for each kind of ground the party can stand on (gEventWork->encounterGroups, read by EffectRuntime_LookupByTableEntry), from the first rule matching the scene and entrance.

Ground 0 has none, and grounds 1 to 7 take consecutive zones from the rule's first one. With useRules 0, or no matching rule, no ground has encounters. Also resets the encounter counters and chooses the battle backdrop. Called by Field_RunScene on scene load, with useRules 0 on the world map and 1 in a field scene; writes work->encounterGroups, encounterBias and encounterThreshold, and gGameState.special.

Definition at line 49 of file encounter.c.

Referenced by Encounter_SelectSceneZones(), and Field_RunScene().

◆ Encounter_ResolveWorldMapZoneAndBackdrop()

s32 Encounter_ResolveWorldMapZoneAndBackdrop ( void * pos)

Returns the world map encounter zone for the terrain at pos (0 for none), and chooses the battle backdrop for that terrain (gGameState.special).

Called by Encounter_RollWorldMap on each step, and by Field_RequestBattleFromEncounterTable and Field_RequestDjinnBattle on the world map, which use only the backdrop.

Definition at line 103 of file encounter.c.

Referenced by Encounter_ResolveWorldMapZoneAndBackdrop(), Encounter_RollWorldMap(), Field_RequestBattleFromEncounterTable(), and Field_RequestDjinnBattle().

◆ Encounter_SelectEnemyGroup()

s32 Encounter_SelectEnemyGroup ( s32 zone,
s32 steps )

Advances the encounter counter for zone and returns the enemy group to fight, or 0 for no battle.

steps (16.16) scales how far the counter moves; a battle starts once it reaches encounterThreshold. FLAG_NO_ENCOUNTERS, flag 353 and gGameState.cloaked prevent battles. Flag 351 skips the checks and the counting and draws a group at once. Called by Encounter_RollTerrain and Encounter_RollWorldMap; adds to gGameState.encounterSteps, sets or clears work->encounterBias, and on a battle sets gGameState.sceneCue.

Definition at line 130 of file encounter.c.

Referenced by Encounter_RollTerrain(), Encounter_RollWorldMap(), and Encounter_SelectEnemyGroup().

◆ Encounter_RollTerrain()

s32 Encounter_RollTerrain ( u32 terrain,
s32 steps )

Rolls a random battle on the encounter zone of the ground underfoot.

terrain: the terrain number, 0 for ordinary ground. steps: the step weight, passed on to Encounter_SelectEnemyGroup. Returns the enemy group to fight, or 0 for no battle. Called by Field_ProcessStep in a field scene, which stores the result in work->battle; steps is the leader's speed limit, doubled with FLAG_LURE_CAP.

Definition at line 226 of file encounter.c.

Referenced by Encounter_RollTerrain(), and Field_ProcessStep().

◆ Encounter_RollWorldMap()

s32 Encounter_RollWorldMap ( s32 pos,
s32 steps )

Rolls a random battle on the world map, taking the zone from the tile at pos.

Returns the enemy group to fight, or 0 for no battle. Called by Field_ProcessStep on the world map.

Definition at line 236 of file encounter.c.

Referenced by Encounter_RollWorldMap(), and Field_ProcessStep().

◆ Encounter_GetEnemyGroupAtSlot()

u16 Encounter_GetEnemyGroupAtSlot ( s32 zone,
s32 slot )

Returns the enemy group in slot (0 to 7) of zone; 14 halfwords make a zone.

Called by Field_RequestBattleFromEncounterTable, Encounter_GetDjinnEnemyGroup and the scene event runner (events.c, zone 99).

Definition at line 244 of file encounter.c.

Referenced by Encounter_GetDjinnEnemyGroup(), Encounter_GetEnemyGroupAtSlot(), Field_RequestBattleFromEncounterTable(), and Field_SearchTile().

◆ Encounter_GetDjinnEnemyGroup()

s16 Encounter_GetDjinnEnemyGroup ( s32 djinni)

Returns the enemy group of Djinni battle djinni, which the table gives as a zone and slot.

Called by Field_RequestDjinnBattle.

Definition at line 251 of file encounter.c.

Referenced by Encounter_GetDjinnEnemyGroup(), and Field_RequestDjinnBattle().

◆ Scene_ResolveInteractionResult()

void Scene_ResolveInteractionResult ( void )

Chooses the current scene's field music (gGameState.cue) from the first rule matching the scene or its group and the entrance; MUS_018 when none does.

Called by Game_ResetForNewGame on entering each field scene, before Audio_PlayCueFromEventWork plays it.

Definition at line 279 of file encounter.c.

Referenced by Game_ResetForNewGame(), and Scene_ResolveInteractionResult().

◆ Scene_GetAreaNameIndex()

s32 Scene_GetAreaNameIndex ( s32 scene,
s32 entrance )

Returns the place name of scene and entrance, from the first rule matching the scene or its group; 0 when none does.

Called by the save, debug and location windows through Scene_GetAreaNameIndexFar, and by Map_UpdateWorldMapMarkers; most add it to MsgDebugEntryName for the message. The save stores it as its area (save_state.h).

Definition at line 326 of file encounter.c.

Referenced by Map_UpdateWorldMapMarkers(), and Scene_GetAreaNameIndex().

◆ Scene_SetDefeatReturnPoint()

void Scene_SetDefeatReturnPoint ( void )

Sets the scene the party returns to after a defeat (gGameState.savedScene and savedEntrance), from the first rule of gParty_PairResolveRules that matches the current scene and entrance: {scene, entrance (-1 for any), return scene, return entrance}, ended by scene -1.

Without a match the return point stays as it was. Called by Field_RunScene on scene load.

Definition at line 357 of file encounter.c.

Referenced by Field_RunScene(), and Scene_SetDefeatReturnPoint().

◆ Event_GetSpecialValue()

s16 Event_GetSpecialValue ( void )

Returns the battle backdrop chosen for the current scene.

The battle setup (battle/encounter.c) reads it through Event_GetSpecialValueFar as the battle's background.

Definition at line 375 of file encounter.c.

Referenced by Event_GetSpecialValue().

◆ Battle_SelectSceneBackdrop()

void Battle_SelectSceneBackdrop ( void )

Chooses the battle backdrop for the current scene.

gBattle_BackdropScenes lists each backdrop (a word with bit 31 set) followed by the scenes that use it, ended by 0; a scene takes the backdrop listed last before it, and a scene not listed takes the last backdrop. Called by Encounter_SelectSceneZones; sets gGameState.special.

Definition at line 382 of file encounter.c.

Referenced by Battle_SelectSceneBackdrop(), and Encounter_SelectSceneZones().

◆ Battle_SelectTerrainBackdrop()

void Battle_SelectTerrainBackdrop ( s32 behavior)

Chooses the battle backdrop for a world map terrain behavior (1 to 7; any other gives Sol Sanctum's) and sets gGameState.special.

Called by Encounter_ResolveWorldMapZoneAndBackdrop.

Definition at line 404 of file encounter.c.

Referenced by Battle_SelectTerrainBackdrop(), and Encounter_ResolveWorldMapZoneAndBackdrop().

◆ BattleFx_ShrinkObjectAndDestroySlow()

void BattleFx_ShrinkObjectAndDestroySlow ( union FieldObject * object)

Spins and shrinks an object by 0x1c0 a frame, then releases it.

Definition at line 110 of file jupiter.c.

Referenced by BattleFx_ShrinkObjectAndDestroySlow(), and Djinn_RunMarsJoinEffect().

◆ BattleFx_ShrinkObjectAndDestroyFast()

void BattleFx_ShrinkObjectAndDestroyFast ( union FieldObject * object)

Spins and shrinks an object by 0x400 a frame, then releases it.

Definition at line 137 of file mars.c.

Referenced by BattleFx_RunVenusDjinnCapture(), and BattleFx_ShrinkObjectAndDestroyFast().

◆ FieldFx_RunLift()

void FieldFx_RunLift ( void )

Lift cast with no target: objects appear above the caster and to either side, move apart and scatter into shards.

Abilities: Lift (field kind 7), cast with no target. Called by BattleFx_Run.

Definition at line 81 of file lift.c.

Referenced by BattleFx_Run(), and FieldFx_RunLift().

◆ FieldFx_RunCarry()

void FieldFx_RunCarry ( void )

Carry cast with no target: objects appear above the caster and to either side, move apart and scatter into shards.

Abilities: Carry (field kind 11), cast with no target.

Definition at line 285 of file carry.c.

Referenced by BattleFx_Run(), and FieldFx_RunCarry().

◆ Party_RemapCharacterIdByFlags()

s32 Party_RemapCharacterIdByFlags ( s32 character)

Returns the sprite of character, which is the character itself except that FLAG_CHILDHOOD gives characters 0 and 1 sprites 0x12 and 0x13, and FLAG_ISAAC_WEARS_TUNIC gives grown Isaac sprite 0x11.

Called by Event_SpawnObjectTable for every placement, and by PsynergyMenu_InitializeEntryObjects (through Party_RemapCharacterIdByFlagsFar) for the party's figures.

Definition at line 19 of file actors.c.

Referenced by Event_SpawnObjectTable(), and Party_RemapCharacterIdByFlags().

◆ Party_RemapCharacterIdIfEnabled()

s32 Party_RemapCharacterIdIfEnabled ( s32 character,
s32 childhood )

Returns the sprite of character as Party_RemapCharacterIdByFlags would with FLAG_CHILDHOOD set to childhood (as recorded in a save file's summary).

Called by SaveMenu_ShowPartySprites through Party_RemapCharacterIdIfEnabledFar. Save summaries omit the tunic flag, so this never gives sprite 0x11.

Definition at line 45 of file actors.c.

Referenced by Party_RemapCharacterIdIfEnabled().

◆ Event_SpawnObjectTable()

void Event_SpawnObjectTable ( struct ScenePlacement * entry,
s32 slot )

Creates the actors of a scene's placement table (ended by sprite -1), and records the table among the scene's tables.

Sprites 0 to 7 are the party's characters and take their own actor slot; other placements take the actor slots from slot on, one each, up to slot 65. A placement whose condition does not hold is skipped, as is a Djinni hidden after a lost battle outside the world map. An existing actor is moved back to its place unless the party keeps its position.

Called by ObjectTable_ResetForObject (the leader, then the scene's table), BattleEffect_ClearAllObjects and Event_CallWithLastActiveObjectId. Records the table in work->tables and each actor in work->actors.

Definition at line 75 of file actors.c.

Referenced by BattleEffect_ClearAllObjects(), Event_CallWithLastActiveObjectId(), Event_SpawnObjectTable(), and ObjectTable_ResetForObject().

◆ ObjectTable_DestroyAtIndex()

void ObjectTable_DestroyAtIndex ( s32 actorIndex)

Destroys the actor in slot actorIndex, if there is one, and empties the slot.

No caller names it; its far-call veneer has no exported name.

Definition at line 186 of file actors.c.

Referenced by ObjectTable_DestroyAtIndex().

◆ ObjectTable_ResetForObject()

void ObjectTable_ResetForObject ( struct ScenePlacement * table)

Creates a scene's actors on entering it: the party leader where the game state puts it, then the scene's placement table from actor slot 8, and the camera that follows the leader.

A leader entering above ground where its cell and the cell north of it are climbing spots (collision code 0xfd) is raised by the ground height of the cell north of it less 32 pixels, and starts climbing (movement mode 1).

Called by Field_RunScene on entering a scene, and by Event_RunObjectHookAndWait. Empties every actor slot and table first; sets work->camera, the map's origin and gGameState.movementMode.

Definition at line 217 of file actors.c.

Referenced by Event_RunObjectHookAndWait(), Field_RunScene(), and ObjectTable_ResetForObject().

◆ ObjectTable_FindLastActiveId()

s32 ObjectTable_FindLastActiveId ( void )

Returns the slot after the last placed actor (8 when there is none), or -1 when slot 65 is occupied.

Earlier holes are not reused by this append scan.

Called by BattleEffect_ClearAllObjects and Event_CallWithLastActiveObjectId to choose where Event_SpawnObjectTable starts.

Definition at line 285 of file actors.c.

Referenced by BattleEffect_ClearAllObjects(), Event_CallWithLastActiveObjectId(), and ObjectTable_FindLastActiveId().

◆ ObjectTable_GetSlotAddress()

void * ObjectTable_GetSlotAddress ( u32 actorIndex)

Returns the address of actor slot index in the event work.

Definition at line 307 of file actors.c.

Referenced by ObjectTable_GetSlotAddress().

◆ Scene_AssignViewFlags()

void Scene_AssignViewFlags ( struct ScenePlacement * entry)

Gives each placement with condition 0 a condition saying whether it lies within the map's view bounds, so that only those inside appear.

Called by scene overlays through Scene_AssignViewFlagsFar, which they import under four local names (FieldScene_PrepareActors the most used). Writes the placements' condition, and clears FLAG_IN_VIEW and sets FLAG_OUT_OF_VIEW.

Definition at line 325 of file actors.c.

Referenced by Scene_AssignViewFlags().

◆ BattleEffect_ClearOutOfBoundsObjects()

void BattleEffect_ClearOutOfBoundsObjects ( void )

Destroys the placed actors far from the view's centre: more than 160 pixels to either side, 200 pixels north or 100 pixels south.

Actors at (0, 0) stay.

Called on the world map before an effect plays, by Field_UsePsynergy and Djinn_JoinParty; empties the slots it frees. BattleEffect_ClearAllObjects brings the actors back afterwards.

Definition at line 357 of file actors.c.

Referenced by BattleEffect_ClearOutOfBoundsObjects(), Djinn_JoinParty(), and Field_UsePsynergy().

◆ BattleEffect_ClearAllObjects()

void BattleEffect_ClearAllObjects ( void )

Destroys every placed actor and places the scene's actors again from its first placement table after the leader's.

Called on the world map after an effect, by Field_UsePsynergy and Djinn_JoinParty. Clears work->tables 1 to 3 before the table is spawned again.

Definition at line 417 of file actors.c.

Referenced by BattleEffect_ClearAllObjects(), Djinn_JoinParty(), and Field_UsePsynergy().

◆ ObjectTable_ClearAll()

void ObjectTable_ClearAll ( void )

Empties all 66 actor slots, without destroying the actors.

Called by ObjectTable_ResetForObject.

Definition at line 443 of file actors.c.

Referenced by ObjectTable_ClearAll(), and ObjectTable_ResetForObject().

◆ ObjectTable_Get()

void * ObjectTable_Get ( u32 actorIndex)

Returns the actor in slot index (0 to 65), or NULL.

Indices up to 191 read past the actor slots into the rest of the event work; larger ones give NULL.

The field's actor lookup: called across the object folder and, through ObjectTable_GetFar (Engine_ActorLookup), by scene overlays.

Definition at line 462 of file actors.c.

Referenced by Actor_WaitForAnimationEnd(), BattleEffect_PauseObject(), BattleFx_ConfigureLinkedObject(), BattleFx_FindMatchingEvent(), BattleFx_GetAnimationValue(), BattleFx_ResumeObject(), BattleFx_SetupObjectPair(), BattleFx_SpawnLinked(), BattleFx_StartEffectObject22(), BattleFx_StartFadeOverlay(), Camera_FollowActor(), DisplayTransition_UpdateScanlineTable(), EffectRuntime_RunRisingObjectSequence(), Event_RunObjectHookAndWait(), Event_ShowSpeakerMessage(), Event_SpawnObjectTable(), Field_FindItemEvent(), Field_FindNearbyPsynergyTarget(), Field_FindNearbyTalkTarget(), Field_RequestBattleFromEncounterTable(), Field_RequestDjinnBattle(), Field_RunPsynergyEvents(), Field_UpdateObjectVisibilityBounds(), Field_UsePsynergy(), FieldEffect_SpawnNearbyMarkers(), FieldEffect_WatchLeaderDistance(), FieldFx_BlinkAvoidCaster(), FieldFx_CheckCloakTile(), FieldFx_EndCloak(), FieldFx_RunReveal(), FieldFx_StartCloak(), FieldObject_PlaceSceneActors(), ItemDisplay_RaiseAboveLeader(), Leader_StopMoving(), Map_UpdateWorldMapMarkers(), Marker_MoveLeaderAway(), Motion_LaunchFromFocusedObject(), Object_GetById(), Object_GetScreenPosition(), Object_GetTriggerTileAheadOfCurrent(), Object_LinkObjectAndSetCallback(), Object_LinkPair(), Object_PlaceCurrentWithinCameraBounds(), Object_RefreshSelectorById(), Object_ResetTargetAndSetMode1(), Object_SetActionById(), Object_SetActionCallbackAndRefreshById(), Object_SetModeById(), Object_SetTargetAndCallback(), ObjectEffect_EndContextEffect(), ObjectEffect_PrepareContextEffect(), ObjectEffect_RunPendingFlagEvent(), ObjectGroup_ConfigureChildValue(), ObjectGroup_SetActionForOthers(), ObjectMotion_ArmCallback(), ObjectMotion_CenterOnColumn(), ObjectMotion_CommitCurrentPositionAndActivate(), ObjectMotion_CommitPositionAndActivate(), ObjectMotion_EnableActionAndResetMotion(), ObjectMotion_EnableActionAndSetCallback(), ObjectMotion_Launch(), ObjectMotion_OffsetPositionAndReset(), ObjectMotion_OffsetPositionAndResetMotion(), ObjectMotion_ResetAndSetPosition(), ObjectMotion_ResetAndSetPositionInMode2(), ObjectMotion_SetActionVariant(), ObjectMotion_SetAngleToward(), ObjectMotion_SetHorizontalPositionWithTerrain(), ObjectMotion_SetPositionAndCommit(), ObjectMotion_SetPositionAndReset(), ObjectMotion_SetPositionWithTerrain(), ObjectMotion_SetSpeedParameters(), ObjectMotion_SetVariantCallback(), ObjectMotion_WaitForAnimationChange(), ObjectTable_DestroyAtIndex(), ObjectTable_DestroyById(), ObjectTable_Get(), ObjectTable_Restore(), ObjectTable_Snapshot(), Scene_FindEvent(), and UiText_OpenMessageAtObject().

◆ ObjectTable_Snapshot()

void ObjectTable_Snapshot ( void )

Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots, with each one's slot, animation, sprite flags and priority, so that ObjectTable_Restore can put them back.

Called by Field_RunScene before a random battle, by the save menu through SaveState_CaptureObjectTableFar, and by two scenes (Tolbi's spring and the Venus Lighthouse aerie).

Definition at line 488 of file actors.c.

Referenced by Field_RunScene(), ObjectTable_Snapshot(), TolbiSpring_OfferLuckyDice(), TolbiSpring_OfferLuckyWheels(), and VenusLighthouseAerie_EruptBeacon().

◆ ObjectTable_Restore()

void ObjectTable_Restore ( void )

Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.

Called by Field_RunScene when the party keeps its position (FLAG_KEEP_PARTY_POSITION), and by the Venus Lighthouse aerie scene through ObjectTable_RestoreFar. Only actors whose slots are filled again are restored; the leader is set idle.

Definition at line 545 of file actors.c.

Referenced by Field_RunScene(), and ObjectTable_Restore().

◆ Field_ClearRequests()

void Field_ClearRequests ( void )

Clears the field's twelve pending requests (see struct FieldWork).

Called by Field_RunScene while it sets a scene up.

Definition at line 33 of file step.c.

Referenced by Field_ClearRequests(), and Field_RunScene().

◆ Field_CountRequests()

s32 Field_CountRequests ( void )

Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-zero while any request is pending.

Field_RunScene tests it to stop walking and to leave its request loop.

Definition at line 56 of file step.c.

Referenced by Field_CountRequests(), and Field_RunScene().

◆ Field_GetCollisionAheadOfLeader()

s32 Field_GetCollisionAheadOfLeader ( void )

Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on the world map), or 0 without a leader.

Called from items.c, where using an item looks at what the leader faces.

Definition at line 69 of file step.c.

Referenced by BattleFx_FindMatchingEvent(), Field_FindItemEvent(), and Field_GetCollisionAheadOfLeader().

◆ Field_CheckExitRegions()

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, y, z) and whose condition holds: records the region's exit value for Field_RunScene, plays the exit sound and starts leaving the scene.

Called by Field_ProcessStep when the leader steps on a cell with a non-zero collision code. Sets work->exit and stops the leader.

Definition at line 135 of file step.c.

Referenced by Field_CheckExitRegions(), and Field_ProcessStep().

◆ Field_ProcessStep()

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 push tiles, takes exits, and while walking advances the encounter counter, regenerates PP, hurts the party with poison and hazardous ground, and wears Avoid off.

When this hurts the party, the leader flinches and characters who fall are listed in the field work.

Called by Field_RunScene each frame while the party walks (in debug mode, flag 0x163 skips it). Sets work->action, input, battle, command and event (-1 when someone fell), work->currentTile and previousTile, walkingDistance, fallenOwners and survivorCount, and gGameState's hazard and Avoid counts.

Definition at line 193 of file step.c.

Referenced by Field_ProcessStep(), and Field_RunScene().

◆ BattleParty_ApplyDrain()

void BattleParty_ApplyDrain ( s32 amount,
s32 unused )

Gives each character in the party amount PP (PP regenerates as the party walks).

Called by Field_ProcessStep as the party walks, by Field_SearchTile for a Psynergy stone (999, all PP), and by the Vale home scene through BattleParty_ApplyDrainFar.

Definition at line 362 of file step.c.

Referenced by BattleParty_ApplyDrain(), Event_UsePsynergyStone(), Field_ProcessStep(), and Field_SearchTile().

◆ BattleParty_ApplyHealthDelta()

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 percentage that truncates to zero falls back to the positive magnitude of amount. Damage flashes and plays an impact sound; healing plays the recovery sound.

Called by Field_ProcessStep for hazardous ground.

Definition at line 376 of file step.c.

Referenced by BattleParty_ApplyHealthDelta(), and Field_ProcessStep().

◆ BattleParty_ApplyStatusDamage()

s32 BattleParty_ApplyStatusDamage ( void )

Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a tenth (at least 1).

Returns 0 when nobody was hurt, else the worst status found (1 poison, 2 venom), after a flash.

Called by Field_ProcessStep at each tick of the distance walked.

Definition at line 416 of file step.c.

Referenced by BattleParty_ApplyStatusDamage(), and Field_ProcessStep().

◆ WorldMap_BeginEvent()

void WorldMap_BeginEvent ( void )

Starts an event or menu on the world map: ends any colour ratio transition in progress, pauses camera movement and freezes the perspective view as a still picture.

Elsewhere it does nothing.

Called by Field_RunScene around the handling of most requests, by the Djinni effect and by the world map scene; each call is paired with WorldMap_EndEvent. Changes the display transition state in heap slot 31 (0x1F, HEAP_SLOT_TRANSITION) only when it is running.

Definition at line 464 of file step.c.

Referenced by Djinn_JoinParty(), Event_MeetFlint(), Event_SearchShipwreck(), Event_StopLeavingShip(), Event_UseBlackOrb(), Field_RunScene(), WorldMap_BeginEvent(), WorldMap_BoardBunzasWagon(), WorldMap_DepartWithTravelers(), WorldMap_RunBlackOrbScene(), WorldMap_ShowDjinnTutorial(), and WorldMap_ShowEndingScene().

◆ WorldMap_EndEvent()

void WorldMap_EndEvent ( void )

Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the camera's movement state back to 0.

Definition at line 484 of file step.c.

Referenced by Djinn_JoinParty(), Event_MeetFlint(), Event_SearchShipwreck(), Event_StopLeavingShip(), Event_UseBlackOrb(), Field_RunScene(), WorldMap_DepartWithTravelers(), WorldMap_EndEvent(), WorldMap_RunBlackOrbScene(), and WorldMap_ShowDjinnTutorial().

◆ Field_RunScene()

s32 Field_RunScene ( s32 entrance)

Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit kind it left by (for Scene_TakeExit), or 999 when the party fell outside battle.

Sets the scene up (map, actors, encounters, return points), runs its initialization, fades it in, then runs the field loop: the party walks (Field_ProcessStep each frame) until a request is made, and then the requests are handled until none is left.

Called from Game_ResetForNewGame's main loop for every field scene, which passes the result to Scene_TakeExit. Allocates the field work in heap slot 27 (HEAP_SLOT_EVENT) and frees it on the way out, sets gGameState's default, next and defeat destinations, and clears FLAG_IN_BATTLE and, once the scene has started, FLAG_KEEP_PARTY_POSITION.

Definition at line 26 of file run_scene.c.

Referenced by Field_RunScene(), and Game_ResetForNewGame().

◆ Object_GetTriggerTileAheadOfCurrent()

s32 Object_GetTriggerTileAheadOfCurrent ( void )

Returns the collision code of the map cell 16 pixels ahead of the party leader when there is something to search there: a tile code from 242 to 247 whose ground is no more than 64 pixels above the leader, or a code the scene has a search event for.

Returns 0 otherwise.

Called by Field_RunScene for the A button (a non-zero result becomes work->tile, for Field_SearchTile), and by Menu_RunTopSelection's search entry through Object_GetTriggerTileAheadOfCurrentFar. Changes nothing.

Definition at line 407 of file run_scene.c.

Referenced by Field_RunScene(), and Object_GetTriggerTileAheadOfCurrent().

◆ Scene_ApplyEntrance()

void Scene_ApplyEntrance ( void )

Places the party at the entrance it came in by (the first matching entry, or the scene's first one) unless it keeps its position, and sets the map's scroll bounds, at least a screen (240 x 160 pixels) wide and tall.

Called by Field_RunScene once the scene's events are set. Writes gGameState's position, heading and turn, and the map's minX to maxY.

Definition at line 461 of file run_scene.c.

Referenced by Field_RunScene(), and Scene_ApplyEntrance().

◆ Debug_RunPaletteEditor()

void Debug_RunPaletteEditor ( void )

The debug palette editor (L on the pause menu in debug mode).

Shows colours 1 to 15 of a palette with their red, green and blue values in hex. Left and right choose the colour, up and down the channel, L and R the palette (0 to 13); A raises the channel and B lowers it, Start makes the colour blink while held, and Select leaves. Called by Field_RunScene for the pause request when L is held in debug mode. Writes the edited colours straight to BG palette RAM and draws over screen block 4; on leaving it reloads the window graphics and clears the debug text.

Definition at line 21 of file palette_editor.c.

Referenced by Debug_RunPaletteEditor(), and Field_RunScene().

◆ Scene_FindActorPlacement()

struct ScenePlacement * Scene_FindActorPlacement ( s32 id)

Returns the placement of actor id in the scene's placement tables, or NULL: for a party character (0 to 7) the row with its sprite, and for a placed actor (8 on) the row it was created from, counting the placed rows in order.

Called by Scene_TalkToActor for the talk facing, and by the field Psynergy effects that read an actor's placement (Mind Read, the Djinni effect, the event messages and the view).

Definition at line 14 of file events.c.

Referenced by BattleFx_CopyLinkedObjectPosition(), Djinn_ResolvePendingEvent(), Event_AskYesNoWithActorAnimation(), FieldEvent_ShowMessageAndWait(), FieldFx_UpdateMindReadWave(), FieldObject_PlaceSceneActors(), Scene_FindActorPlacement(), and Scene_TalkToActor().

◆ GameFlag_IsConditionActive()

s32 GameFlag_IsConditionActive ( s32 condition)

Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while that flag is set, any other while its flag is clear.

Used for every condition column of a scene's tables: events (Scene_FindEvent, Field_SearchTile), placements (Event_SpawnObjectTable), exit regions (Field_CheckExitRegions) and item events.

Definition at line 65 of file events.c.

Referenced by BattleFx_FindMatchingEvent(), Event_SpawnObjectTable(), Field_CheckExitRegions(), Field_FindItemEvent(), Field_SearchTile(), GameFlag_IsConditionActive(), and Scene_FindEvent().

◆ Event_SearchIgnoresCondition()

u32 Event_SearchIgnoresCondition ( s32 flags,
s32 result )

Returns 1 for a search event (kind 3) that holds whatever its condition: one with more flags than its kind, unless its result is a mimic battle (type 0x005 in its top 12 bits).

Called by Scene_FindEvent. Field_SearchTile tests such an event's condition itself (a chest's flag is set once it is opened), so the event is found either way and the leader still checks the spot; a mimic is found only while its condition holds.

Definition at line 86 of file events.c.

Referenced by Event_SearchIgnoresCondition(), and Scene_FindEvent().

◆ Scene_FindEvent()

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.

Flag 0x200 also needs the leader to have pushed against it for more than 12 frames (2 with flag 0x800); flag 0x400 needs the leader to face within an eighth of a turn of the direction in the top four bits.

Called by every lookup of a scene's events in this part and by Object_GetTriggerTileAheadOfCurrent. Changes nothing.

Definition at line 111 of file events.c.

Referenced by Field_SearchTile(), Object_GetTriggerTileAheadOfCurrent(), Scene_FindActorTalkEvent(), Scene_FindEvent(), Scene_RunRaisedEvent(), Scene_RunTouchOrExit(), and Scene_TalkToActor().

◆ Runtime_CallWorkBlockEntry()

void Runtime_CallWorkBlockEntry ( void )

Nothing calls this.

Definition at line 168 of file events.c.

Referenced by Runtime_CallWorkBlockEntry().

◆ Scene_FindActorTalkEvent()

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 one.

Called by Field_RunScene for the A button, to choose between talking and searching, and by the field Psynergy dispatch.

Definition at line 175 of file events.c.

Referenced by BattleFx_Run(), Field_RunScene(), and Scene_FindActorTalkEvent().

◆ Scene_TalkToActor()

s32 Scene_TalkToActor ( s32 id)

Talks to actor id: shows its event's message or calls its event function, with the actor stopped and turned as its placement says.

For the actor the party has stopped, its kind 7 event comes first; without one, a talk event that is a function gives a random line from MsgPonderEllipsis ("...") instead. Returns 0 when an event ran, -1 when there was none.

Called by Field_RunScene for its talk request (work->descriptor). Resumes the stopped actor and sets gGameState.pausedObject back to -1 afterwards.

Definition at line 197 of file events.c.

Referenced by Field_RunScene(), and Scene_TalkToActor().

◆ Scene_RunRaisedEvent()

s32 Scene_RunRaisedEvent ( s32 value)

Runs the scene's raised event (kind 6) for value: its message or its function.

Returns 0 when an event ran, -1 when there was none.

Called by Field_RunScene for a positive event request (work->event).

Definition at line 301 of file events.c.

Referenced by Field_RunScene(), and Scene_RunRaisedEvent().

◆ Scene_RunTouchOrExit()

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 exit's sound (and effect) and records where it leads.

Returns 0 when something ran, -1 when there was nothing.

Called by Field_RunScene for its step request (work->action), which Field_ProcessStep raises for collision codes 1 to 239. Sets work->exit for an exit, and clears work->blockedSteps after a touch that needs pushing.

Definition at line 333 of file events.c.

Referenced by Field_RunScene(), and Scene_RunTouchOrExit().

◆ Field_RunPushTileEvent()

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 for more than 12 frames; the count then restarts.

Called by Field_RunScene for its push request (work->input), which Field_ProcessStep raises for codes 252 to 254; nothing raises 0xf9 there. Clears work->blockedSteps when it acts.

Definition at line 389 of file events.c.

Referenced by Field_RunPushTileEvent(), and Field_RunScene().

◆ Field_SearchTile()

s32 Field_SearchTile ( s32 tile)

Searches the tile ahead with the given collision code.

Codes 242 to 247 show their two messages. Otherwise the scene's search event for the tile runs: a function, a message, or a chest holding a Psynergy stone, a mimic, coins or an item; with no event, "checked the ground" and "found nothing".

Called by Field_RunScene for its search request (work->tile). Opening a chest sets its condition flag, and it may raise a mimic battle (work->battle), give coins or an item, or restore all PP.

Definition at line 429 of file events.c.

Referenced by Field_RunScene(), and Field_SearchTile().

◆ Field_GetPsynergyTargetRange()

s32 Field_GetPsynergyTargetRange ( s32 kind)

Returns how far, in pixels, a field Psynergy of the given kind reaches: gBattleFx_TargetRangeByMode pairs kinds with ranges, ended by -1, and a kind not listed reaches 16 pixels.

Called by Field_FindNearbyPsynergyTarget.

Definition at line 10 of file targets.c.

Referenced by Field_FindNearbyPsynergyTarget(), and Field_GetPsynergyTargetRange().

◆ Field_FindNearbyTalkTarget()

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 pixels of distance and, beyond 11 pixels, within 0x2fff of the direction it faces.

Actors with collision flag 8 are skipped, and those with flag 4 count as 10/13 as far. Called with the leader by Field_RunScene for the A button, and by the item code (items.c) to find whom an item is used on.

Definition at line 33 of file targets.c.

Referenced by Field_FindItemEvent(), Field_FindNearbyTalkTarget(), Field_RunScene(), and Field_UseItem().

◆ Field_FindNearbyPsynergyTarget()

s32 Field_FindNearbyPsynergyTarget ( s32 id,
s32 kind )

Returns the actor nearest in front of actor id that a field Psynergy of the given kind can reach, or -1.

The direction is rounded to a quarter turn and the distance measured on the ground; kind sets the range, the height allowed and the width of the cone. Actors with collision flag 0x10 count as 2/3 as far. Called with the leader by Field_UsePsynergy, by the item code (items.c) and by the Psynergy dispatch (psynergy_effects/dispatch.c).

Definition at line 110 of file targets.c.

Referenced by BattleFx_FindMatchingEvent(), BattleFx_Run(), Field_FindNearbyPsynergyTarget(), and Field_UsePsynergy().

◆ BattleFx_PlayCueAndStartEmitterOnTarget()

s32 BattleFx_PlayCueAndStartEmitterOnTarget ( s32 actor,
s32 target,
s32 itemId )

If actor target exists, plays SE_124, gives it animation 4 and, 12 frames later, shows itemId in front of actor with sparkles.

Returns the picture's encoded actor pointer, or 0 when the target or picture is absent. Called by two scene overlays: McCoy's palace, when a reward chest opens, and Vault's interiors, when Ivan finds the Shaman's Rod.

Definition at line 207 of file targets.c.

Referenced by BattleFx_PlayCueAndStartEmitterOnTarget(), McCoyPalace_ClaimReward(), and VaultInteriors_ReturnStolenGoods().

◆ Animation_ApplyChildPalette()

void Animation_ApplyChildPalette ( struct MotionObject * object,
s32 palette )

Gives every part of a motion object's sprite (but those at palette 15) palette - 1, or for palette 0 the next palette of a cycle that changes every 2 frames.

Sets the sprite's dirty flag so it is drawn again. Called by Mind Read's wave effect (psynergy_effects/mind_read.c) on the caster: each frame with 0 to cycle its colours, and with 1 (palette 0) when it ends.

Definition at line 227 of file targets.c.

Referenced by Animation_ApplyChildPalette(), BattleFx_FinishSceneAndReleaseHeapBlock(), and FieldFx_UpdateMindReadWave().

◆ Battle_ResetEffectCounter()

◆ Field_FindItemEvent()

s32 Field_FindItemEvent ( s32 item)

Returns the scene's item event (kind 4) for item that applies to what the leader faces, or 0 (item 0 matches any item).

The event's trigger names an actor (control flag 0x10) or a tile code, and may also require the leader to face within 0x17ff of a direction. Called by Field_UseItem, and by BattleFx_HasTrigger (psynergy.c) to test whether an item would do anything here.

Definition at line 16 of file items.c.

Referenced by BattleFx_HasTrigger(), Field_FindItemEvent(), and Field_UseItem().

◆ Field_UseItem()

s32 Field_UseItem ( s32 packedItem,
s32 slot )

Uses an item on the field.

packedItem holds the item (bits 0 to 9) and the character using it (bits 10 to 13; 15 for the character carrying most of it); slot is its inventory slot. The scene's item event for what the leader faces runs if there is one; otherwise an item with a field action uses it (Retreat asks first and leaves the scene). FLAG_NOTHING_HAPPENS still set afterwards says "But nothing happens."; FLAG_ITEM_USED_UP removes the item. Called by Field_RunScene for the item request (work->item and work->itemArgument). Retreat sets gGameState.scene and .entrance to the Retreat point and raises work->exit.

Definition at line 65 of file items.c.

Referenced by Field_RunScene(), and Field_UseItem().

◆ BattleFx_FindMatchingEvent()

void * BattleFx_FindMatchingEvent ( s32 eventFlags,
s32 group,
void * target )

Returns the scene's Psynergy event (kind 5) for Psynergy of the given group that applies to what the leader faces, or NULL; stores the actor the Psynergy would target in *target.

eventFlags gives the event's phase and kind (0x70000005 for any phase). The event may apply to any target (control flag 0x80), to an actor (0x10) or to a tile code. Called by Field_UsePsynergy for each phase, by Field_RunPsynergyEvents, and by the Force, Frost and Reveal effects (psynergy_effects/) for their own phases.

Definition at line 206 of file items.c.

Referenced by BattleFx_FindMatchingEvent(), BattleFx_HasMatchingEvent5(), Field_RunPsynergyEvents(), Field_UsePsynergy(), FieldFx_RunForce(), FieldFx_RunFrost(), FieldFx_RunReveal(), and ResetSceneTransitionEffect().

◆ Field_RunPsynergyEvents()

s32 Field_RunPsynergyEvents ( s32 packed)

Runs the scene's events for Psynergy without paying its PP or showing its usual effect (phases 3 and 2, around the event's own effect), as for a Psynergy that ends by itself: packed holds the Psynergy (bits 0 to 9) and its user (bits 10 to 13).

Called by Field_UsePsynergy for a use with ACT_PACKED, and by Battle_ResetEffectCounter to end Reveal.

Definition at line 253 of file items.c.

Referenced by Battle_ResetEffectCounter(), Field_RunPsynergyEvents(), and Field_UsePsynergy().

◆ Field_UsePsynergy()

s32 Field_UsePsynergy ( u32 code)

Uses Psynergy on the field.

code holds the Psynergy (bits 0 to 9), its user (bits 10 to 13; 15 for character 0) and ACT_PACKED to use it without paying PP. Checks it can be used here (Reveal not on the world map, Retreat where it is not blocked, after asking), pays its PP, then plays its effect between the scene's Psynergy events for what the leader faces: phase 1 before and phase 0 after. A phase 5 event is not run here; it only makes the effect aim at the actor ahead, and the effects that act on it (Force, Frost, Reveal) find it themselves. An after event whose trigger has flag 0x400 plays the effect itself. Called by Field_RunScene for the Psynergy request (work->command); sets work->resolvingAction while the effect plays.

Definition at line 17 of file psynergy.c.

Referenced by Field_RunScene(), and Field_UsePsynergy().

◆ BattleFx_HasMatchingEvent5()

s32 BattleFx_HasMatchingEvent5 ( s32 group)

Returns whether the scene has a Psynergy event, in any phase, for Psynergy of group and what the leader faces.

Exported as BattleFx_HasMatchingEvent5Far, which no ☀️ code names.

Definition at line 141 of file psynergy.c.

Referenced by BattleFx_HasMatchingEvent5().

◆ BattleFx_HasTrigger()

u32 BattleFx_HasTrigger ( u16 item)

Returns whether the scene has an event for item and what the leader faces.

Called by the item menu (menu/item.c) through BattleFx_HasTriggerFar: such an item closes the menu and is used on the field.

Definition at line 151 of file psynergy.c.

Referenced by BattleFx_HasTrigger().

◆ ObjectMotion_SnapToTerrain()

void ObjectMotion_SnapToTerrain ( void * object)

Sets an actor's y and terrainHeight to the map's height at its x and z.

Called by Field_PlaceMapMarkers for each marker it places.

Definition at line 9 of file markers.c.

Referenced by Field_PlaceMapMarkers(), and ObjectMotion_SnapToTerrain().

◆ Field_PlaceMapMarkers()

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, up to ten: a chest (actor 20) for a chest event, shown open once its flag is set and gone once its mimic was beaten, and a Psynergy stone (actor 28) for a search event giving one, until it is taken.

A marker with no such event takes no slot. Called by Field_RunScene on scene load; clears and fills work->markers.

Definition at line 30 of file markers.c.

Referenced by Field_PlaceMapMarkers(), and Field_RunScene().

◆ Marker_FindSlot()

s32 Marker_FindSlot ( s32 id)

Returns the marker slot (0 to 9) whose event trigger is id, or -1.

Called by the Marker_ functions below.

Definition at line 138 of file markers.c.

Referenced by Marker_FindSlot(), Marker_GetActor(), Marker_Hide(), Marker_LaunchMimic(), Marker_SetActorPosition(), Marker_ShowOpened(), and SetMarkerAnimationAndPlaySound().

◆ EffectRuntime_ReservedNoOp()

void EffectRuntime_ReservedNoOp ( void )

Definition at line 154 of file markers.c.

Referenced by EffectRuntime_ReservedNoOp().

◆ Marker_CloseChest()

void Marker_CloseChest ( s32 id)

Closes the chest of marker id again (its item could not be carried), with SE_125.

Called by Field_SearchTile.

Definition at line 176 of file markers.c.

Referenced by Field_SearchTile(), and Marker_CloseChest().

◆ Marker_LaunchMimic()

void Marker_LaunchMimic ( s32 id)

Makes the chest of marker id jump up as a mimic: after 18 frames it takes animation 7, plays SE_146 and gets an upward velocityY of 8 << 16.

Called by Field_SearchTile before the mimic's battle.

Definition at line 183 of file markers.c.

Referenced by Field_SearchTile(), and Marker_LaunchMimic().

◆ Marker_OpenChest()

void Marker_OpenChest ( s32 id)

Opens the chest of marker id (animation 4) with SE_124, and waits 12 frames.

Called by Field_SearchTile when a chest is searched.

Definition at line 205 of file markers.c.

Referenced by Field_SearchTile(), and Marker_OpenChest().

◆ Marker_ShowOpened()

void Marker_ShowOpened ( s32 id)

Shows the chest of marker id open (animation 2), with no sound.

Called by Field_SearchTile once a chest's contents are taken.

Definition at line 209 of file markers.c.

Referenced by Field_SearchTile(), and Marker_ShowOpened().

◆ Marker_GetActor()

struct ObjectRuntime * Marker_GetActor ( s32 id)

Returns the actor of marker id, or NULL when no slot has it.

Called by Field_SearchTile, and by the world map markers (field_fx.c) to skip a marker already placed.

Definition at line 226 of file markers.c.

Referenced by Field_SearchTile(), FieldEffect_SpawnNearbyMarkers(), and Marker_GetActor().

◆ Marker_Hide()

void Marker_Hide ( s32 id)

Hides the actor of marker id by clearing its animationKind.

Called by Field_SearchTile once a Psynergy stone is taken.

Definition at line 238 of file markers.c.

Referenced by Field_SearchTile(), and Marker_Hide().

◆ Marker_SetActorPosition()

void Marker_SetActorPosition ( s32 id,
s32 x,
s32 z )

Moves the actor of marker id to (x, z) on the ground; -1 keeps the centre of its cell on that axis.

Positions are 16.16. Scene overlays call it as Engine_MapObjectSetPosition.

Definition at line 255 of file markers.c.

Referenced by Marker_SetActorPosition().

◆ Marker_MoveLeaderAway()

void Marker_MoveLeaderAway ( void )

Keeps the party leader off the markers: a leader within 16 pixels of a marker cell's centre is moved 20 pixels from that centre, in the direction it stood, and loses its move target.

Only the first marker it stands on moves it. Called by two scene overlays (Suhalla Desert, Lamakan Desert).

Definition at line 43 of file field_fx.c.

Referenced by Event_RevealStarts(), Marker_MoveLeaderAway(), and Reveal_ShowSecrets().

◆ ItemDisplay_EmitSparkles()

void ItemDisplay_EmitSparkles ( union FieldObject * fieldObject)

Each frame of a found item's picture: one time in ten, a sparkle appears within 16 pixels of it.

Installed as the picture's updateHook by BattleFx_StartRandomParticleEmitter, EffectRuntime_RunRisingObjectSequence and BattleFx_StartEffectObject22.

Definition at line 99 of file field_fx.c.

Referenced by BattleFx_StartEffectObject22(), BattleFx_StartRandomParticleEmitter(), EffectRuntime_RunRisingObjectSequence(), and ItemDisplay_EmitSparkles().

◆ BattleFx_StartRandomParticleEmitter()

struct EffectObj * BattleFx_StartRandomParticleEmitter ( s32 actor,
s32 item )

Shows the picture of item (0 for none) at the centre of the cell 16 pixels in front of character actor, 16 pixels up, with sparkles.

While Reveal is active, its sparkles are cleared first. Returns the picture's actor, or 0. The picture is object 22, thrown up (velocityY 2 << 16, gravity 0x4000), its icon drawn through heap block 17 and loaded into VRAM. Called by Field_SearchTile for coins and items found, and by BattleFx_PlayCueAndStartEmitterOnTarget.

Definition at line 132 of file field_fx.c.

Referenced by BattleFx_PlayCueAndStartEmitterOnTarget(), BattleFx_StartRandomParticleEmitter(), and Field_SearchTile().

◆ Object_DestroyIfPresent()

void Object_DestroyIfPresent ( void * object)

Releases object unless it is NULL.

Called by Field_SearchTile to drop the picture of an item nobody could carry.

Definition at line 212 of file field_fx.c.

Referenced by Field_SearchTile(), and Object_DestroyIfPresent().

◆ ItemDisplay_RaiseAboveLeader()

void ItemDisplay_RaiseAboveLeader ( struct ObjectRuntime * object)

Raises a found item's picture to 36 pixels above the party leader, who holds it up (animation 28) facing the screen.

Called by Field_SearchTile for what a search finds, by EffectRuntime_RunRisingObjectSequence and by BattleFx_StartEffectObject22.

Definition at line 221 of file field_fx.c.

Referenced by BattleFx_StartEffectObject22(), EffectRuntime_RunRisingObjectSequence(), Field_SearchTile(), and ItemDisplay_RaiseAboveLeader().

◆ EffectRuntime_RunRisingObjectSequence()

void EffectRuntime_RunRisingObjectSequence ( void * object,
s32 flags )

Shows a found item's picture: flags bit 0 adds sparkles and bit 1 raises it above the leader, with waits of 60 and 80 frames around that when both are set.

The leader then returns to animation 1. Scene overlays call it as Engine_RunRisingObjectSequence (six of them).

Definition at line 244 of file field_fx.c.

Referenced by EffectRuntime_RunRisingObjectSequence().

◆ BattleFx_StartEffectObject22()

void BattleFx_StartEffectObject22 ( s32 item,
s32 flags )

Shows the picture of item 36 pixels above the party leader for 80 frames; flags bit 0 adds sparkles and bit 1 raises it as a found item.

Then it releases the picture and the leader returns to animation 1. Scene overlays call it as Engine_ItemShowFound (41 of them).

Definition at line 273 of file field_fx.c.

Referenced by BattleFx_StartEffectObject22().

◆ BattleFx_ClearRandomParticles()

void BattleFx_ClearRandomParticles ( void )

◆ RevealMarker_EmitSparkles()

void RevealMarker_EmitSparkles ( union FieldObject * fieldObject)

Each frame of a Reveal marker: one time in ten, a sparkle appears within 16 pixels of it.

Installed as the marker's updateHook by FieldEffect_SpawnNearbyMarkers.

Definition at line 336 of file field_fx.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_StartRandomParticleEmitter(), FieldEffect_SpawnNearbyMarkers(), and RevealMarker_EmitSparkles().

◆ Field_IsRevealActive()

s32 Field_IsRevealActive ( struct ScriptInterpreter * interpreter)

Returns 1 while Reveal is active, else 0.

Run by a Reveal marker's object script (gBattleFx_MarkerParticleScript) through SC_CALL.

Definition at line 361 of file field_fx.c.

Referenced by BattleFx_ClearRandomParticles(), and Field_IsRevealActive().

◆ FieldEffect_SpawnNearbyMarkers()

void FieldEffect_SpawnNearbyMarkers ( void )

Reveal: marks with sparkles the hidden things within 8 cells left or right and 5 up or down of the leader: map places 100 to 239 with no marker actor, whose search event (kind 3) gives an item, coins, a Psynergy stone or a mimic (types 0 to 3 and 5) and whose flag is not yet set.

Each mark is an object 22 running gBattleFx_MarkerParticleScript. Called by Reveal's effect (psynergy_effects/reveal.c).

Definition at line 380 of file field_fx.c.

Referenced by BattleFx_ClearRandomParticles(), FieldEffect_SpawnNearbyMarkers(), and FieldFx_RunReveal().

◆ BattleFx_StartWindowHBlankDma()

void BattleFx_StartWindowHBlankDma ( void )

Each frame, before drawing: turns windows 0 and 1 on, writes the first four values of the shown page into WININ, WINOUT, WIN0H and WIN1H, and has DMA 0 copy the rest into WIN0H and WIN1H one word each HBlank, so that every line of the screen gets its own window edges.

A scheduler callback (priority 0x480) that DisplayTransition_Start, DisplayTransition_Finish and DisplayTransition_InitializeBattleEffectState add for a window transition, and DisplayTransition_UpdateScanlineTable removes when it ends.

Definition at line 16 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_StartWindowHBlankDma(), DisplayTransition_Finish(), DisplayTransition_InitializeBattleEffectState(), DisplayTransition_Start(), DisplayTransition_SuspendCallbacks(), and DisplayTransition_UpdateScanlineTable().

◆ DisplayTransition_UpdateScanlineTable()

void DisplayTransition_UpdateScanlineTable ( void )

Each frame of a window transition: advances its value toward its end (and at the end turns the windows off, or moves to the next mode), then builds the next page of window edges, WININ and WINOUT first and then a (left << 8 | right) pair for each of the 160 lines.

Bit 5 of the value says whether the transition opens or closes; its low 5 bits are its progress. Modes: 0 random bars, 1 a shape from gDisplayTransition_Shapes, 2 random horizontal noise, 3 a circle at the screen's centre, 4 alternate lines wiping in from the left and the right, 7 and 9 an ellipse wider than tall around the party leader (7 flickers), 8 a wobbling ellipse around a point, 77 an ellipse a little taller than wide, centred 8 pixels lower on the leader.

A scheduler callback (priority 0xc80), added with BattleFx_StartWindowHBlankDma; it removes both and stops DMA 0 when a transition with no next mode ends. Writes the hidden page of the transition state (heap slot 31) and then flips state->page.

Definition at line 75 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_InitializeBattleEffectState(), DisplayTransition_Start(), DisplayTransition_SuspendCallbacks(), and DisplayTransition_UpdateScanlineTable().

◆ DisplayTransition_InitializeBattleEffectState()

void DisplayTransition_InitializeBattleEffectState ( s32 mode)

Starts window transition mode at value 0, with no duration: the caller moves it.

Called by Reveal's effect (mode 8) and, through DisplayTransition_InitializeBattleEffectStateFar, by three scenes (Altmiller Cave, Tret Tree's branch and Babi's palace). Allocates and clears the transition state in heap slot 31 and adds both window callbacks; mask 0x3f3f shows every layer in both windows.

Definition at line 559 of file transition.c.

Referenced by AltmillerCave_InitializeDarkness(), BabiPalace_WakeAfterFinals(), BattleFx_ClearRandomParticles(), DisplayTransition_InitializeBattleEffectState(), Event_CastReveal(), FieldFx_RunReveal(), and TretTreeBranch_Initialize().

◆ DisplayTransition_SuspendCallbacks()

void DisplayTransition_SuspendCallbacks ( void )

Suspends the window transition's two callbacks.

XXX: nothing in ☀️ names it and it has no far-call entry, yet it is not marked UNUSED; a caller through a table or ⚓️'s twin would settle it.

Definition at line 576 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), and DisplayTransition_SuspendCallbacks().

◆ DisplayTransition_AllocateAndClearState()

struct DisplayTransitionState * DisplayTransition_AllocateAndClearState ( void )

Allocates the display transition state (heap block 31) and clears it.

Called by DisplayTransition_Start and DisplayTransition_Finish for every kind but the two fades.

Definition at line 585 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_AllocateAndClearState(), DisplayTransition_Finish(), and DisplayTransition_Start().

◆ DisplayTransition_Start()

void DisplayTransition_Start ( s32 mode,
s32 frames )

Fades the screen in over frames frames.

mode's high byte chooses how: 0 from black, 1 from the backdrop colour, 2 a window transition (its low byte the mode), 3 a dissolve, 4 opening from the centre line (low byte 1 flickers).

Called by Field_RunScene to fade a scene in with work->transition and work->transitionFrames, and by Event_StartScreenTransition for scene scripts. Kinds 2 to 4 add a scheduler callback (and kind 4 the VCount handler, IRQ 1) that runs the transition; every kind ORs the map's display bits into DISPCNT through the I/O write queue.

Definition at line 603 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Start(), Event_StartScreenTransition(), and Field_RunScene().

◆ DisplayTransition_Finish()

void DisplayTransition_Finish ( s32 mode,
s32 frames )

Fades the screen out over frames frames, as DisplayTransition_Start fades it in.

Called by Field_RunScene as a scene ends, by Field_StartEncounterTransition before a battle (kinds 0x401 and 0x207), and by Event_FinishScreenTransition for scene scripts. The window and dissolve kinds run from value 32 to 64, the centre line from 0 to 80.

Definition at line 698 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), Event_FinishScreenTransition(), Field_RunScene(), and Field_StartEncounterTransition().

◆ DisplayState_ClearFlags()

void DisplayState_ClearFlags ( s32 clearBg3,
s32 clearBg2,
s32 clearBg1 )

Clears the map's display-control bits for backgrounds 3, 2 and 1 (0x0800, 0x0400 and 0x0200) for each argument that is set.

Reached only through its unnamed far-call veneer. DisplayTransition_Start ORs these bits into DISPCNT.

Definition at line 771 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), and DisplayState_ClearFlags().

◆ DisplayTransition_Update()

void DisplayTransition_Update ( void )

Each frame of the centre-line transition: moves the value toward its end and sets the two lines where the screen switches between shown and blank.

A scheduler callback added by DisplayTransition_Start and DisplayTransition_Finish for kind 4, variant 0; when its run ends it removes itself and the VCount handler.

Definition at line 794 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_Start(), and DisplayTransition_Update().

◆ DisplayTransition_UpdateFromCentre()

void DisplayTransition_UpdateFromCentre ( void )

As DisplayTransition_Update, but the lines flicker every other frame.

The kind 4 callback for a non-zero variant.

Definition at line 834 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_Start(), and DisplayTransition_UpdateFromCentre().

◆ DisplayTransition_UpdateScanline()

void DisplayTransition_UpdateScanline ( void )

The VCount interrupt of the centre-line transition: switches the display to mode 2 (nothing shown) at the first line and back to mode 0 at the second.

Installed as IRQ handler 1 by DisplayTransition_Start and DisplayTransition_Finish for kind 4. Phases: 0 waits for a line on screen, 1 for whichever edge line comes first, 2 and 3 for the other one; 9 is done.

Definition at line 879 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_Start(), and DisplayTransition_UpdateScanline().

◆ DisplayTransition_UpdateFrame()

void DisplayTransition_UpdateFrame ( void )

Each frame of the dissolve: moves the value toward its end and sets two more of the solid tile's 64 pixels, in the order of gDisplayTransition_DitherTable, to colour 15 (or 0 when closing).

The dissolve's scheduler callback (kind 3 of DisplayTransition_Start and DisplayTransition_Finish, and DisplayTransition_InitializeState). Queues the changed tile into character block 0 each frame.

Definition at line 930 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_Finish(), DisplayTransition_InitializeState(), DisplayTransition_Start(), and DisplayTransition_UpdateFrame().

◆ DisplayTransition_FillTilemapAndSolidTile()

void DisplayTransition_FillTilemapAndSolidTile ( s32 color)

Fills background screen block 4 with tile 0 in palette 15 and, unless color is -1, makes tile 0 solid color.

Sets up the dissolve for DisplayTransition_Start (colour 15), DisplayTransition_Finish and DisplayTransition_InitializeState (colour 0).

Definition at line 979 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), DisplayTransition_FillTilemapAndSolidTile(), DisplayTransition_Finish(), DisplayTransition_InitializeState(), and DisplayTransition_Start().

◆ DisplayTransition_InitializeState()

void DisplayTransition_InitializeState ( s32 value)

Starts a dissolve of the given mode and waits 120 frames.

It sets no duration, so the dissolve stays at value 0 until a caller moves it. Reached only through its unnamed far-call veneer.

Definition at line 1000 of file transition.c.

Referenced by BattleFx_ClearRandomParticles(), and DisplayTransition_InitializeState().

◆ BattleFx_InterpolateBuffers()

void BattleFx_InterpolateBuffers ( s16 * source,
s16 * target,
s16 * step,
s32 frames )

Sets each of the 1344 colour channels of step to the amount to add each frame for source to reach target in frames frames; with frames 0 or less step is left as it was.

Called by BattleFx_StartBufferInterpolation and by the weather effects (psynergy_effects/weather.c).

Definition at line 17 of file color.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_InterpolateBuffers(), BattleFx_StartBufferBlend(), BattleFx_StartBufferInterpolation(), and FieldFx_StartLightning().

◆ BattlePalette_UpdateBlend()

void BattlePalette_UpdateBlend ( void )

Each frame (unless flag 0x152 is set): moves the colour buffer one step toward its target, packs it into RGB555 and queues it for the BG and OBJ palettes.

The packed colours are double-buffered: work->page names the page the queued DMA reads, and the other is written. Registered by BattleEffect_InitializeBuffers as a scheduler callback; the menus clear and set flag 0x152 around it (menu/common.c).

Definition at line 43 of file color.c.

Referenced by BattleEffect_InitializeBuffers(), BattleFx_ClearRandomParticles(), BattlePalette_StopBlendAndReleaseBuffer(), and BattlePalette_UpdateBlend().

◆ BattleEffect_InitializeBuffers()

void BattleEffect_InitializeBuffers ( void )

Sets up the colour buffer (heap block 32) from the BG and OBJ palettes and starts updating the palettes from it each frame.

Called by Field_RunScene on scene load; allocates heap slot 32 (gPaletteBufferWork) and registers BattlePalette_UpdateBlend at priority 0xc8f.

Definition at line 373 of file color.c.

Referenced by BattleEffect_InitializeBuffers(), BattleFx_ClearRandomParticles(), and Field_RunScene().

◆ BattlePalette_StopBlendAndReleaseBuffer()

void BattlePalette_StopBlendAndReleaseBuffer ( void )

Stops the colour buffer and frees it: removes BattlePalette_UpdateBlend and releases heap slot 32.

Reached only through a bare far-call veneer; no ☀️ code names it.

Definition at line 389 of file color.c.

Referenced by BattleFx_ClearRandomParticles(), and BattlePalette_StopBlendAndReleaseBuffer().

◆ BattleFx_ApplyColorToTargetBuffer()

void BattleFx_ApplyColorToTargetBuffer ( s32 mode,
s32 half )

Sets the colours the buffer moves toward (see BattleFx_BuildBuffer); does nothing without a colour buffer.

Called by the field Psynergy effects, the scene transitions, the shop cursor, and scene overlays as Engine_ColorBufferApplyTarget.

Definition at line 398 of file color.c.

Referenced by BattleEffect_InitializeSharedScene(), BattleFx_ApplyColorToTargetBuffer(), BattleFx_ClearRandomParticles(), BattleFx_PrepareBufferInterpolation(), DisplayTransition_Finish(), Field_RunScene(), FieldFx_RunReveal(), FieldFx_UpdateLightning(), FieldFx_UpdateMindReadWave(), ResetSceneTransitionEffect(), and RunSceneTransitionEffect().

◆ BattleFx_ApplyColorToSourceBuffer()

void BattleFx_ApplyColorToSourceBuffer ( s32 mode,
s32 half )

Sets the colours the buffer shows now (see BattleFx_BuildBuffer).

Called by Reveal, the leader's steps (step.c), the transitions, and scene overlays as Engine_ColorBufferApplySource.

Definition at line 409 of file color.c.

Referenced by BattleFx_ApplyColorToSourceBuffer(), BattleFx_ClearRandomParticles(), BattleParty_ApplyHealthDelta(), BattleParty_ApplyStatusDamage(), DisplayTransition_Start(), FieldFx_RunReveal(), and ResetSceneTransitionEffect().

◆ BattleFx_SetPrimaryBufferValue()

void BattleFx_SetPrimaryBufferValue ( u32 color)

Sets the buffer's source backdrop colour (BG colour 0 of its palette copy).

Called by the transitions (transition.c).

Definition at line 419 of file color.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_SetPrimaryBufferValue(), and DisplayTransition_Start().

◆ BattleFx_StartBufferInterpolation()

void BattleFx_StartBufferInterpolation ( s32 frames)

Starts moving the shown colours to the target colours over frames frames: sets work->duration, clears work->step and fills work->delta.

Called after BattleFx_ApplyColorToTargetBuffer by the same callers, and by scene overlays as Engine_ColorBufferInterpolate.

Definition at line 431 of file color.c.

Referenced by BattleEffect_InitializeSharedScene(), BattleFx_ClearRandomParticles(), BattleFx_PrepareBufferInterpolation(), BattleFx_StartBufferInterpolation(), BattleParty_ApplyHealthDelta(), BattleParty_ApplyStatusDamage(), DisplayTransition_Finish(), DisplayTransition_Start(), FieldFx_RunReveal(), FieldFx_UpdateMindReadWave(), ResetSceneTransitionEffect(), and RunSceneTransitionEffect().

◆ BattleFx_ClampRgb555Channel()

s32 BattleFx_ClampRgb555Channel ( s32 value)

Clamps a 5-bit colour channel to 0 to 31.

Definition at line 443 of file color.c.

Referenced by BattleFx_BuildBuffer(), BattleFx_ClampRgb555Channel(), and BattleFx_ClearRandomParticles().

◆ BattleFx_ClampRgb555Component()

s32 BattleFx_ClampRgb555Component ( s32 value)

Clamps a colour channel shifted up 10 bits to at most 31 << 10.

Definition at line 452 of file color.c.

Referenced by BattleFx_BuildBuffer(), BattleFx_ClampRgb555Component(), and BattleFx_ClearRandomParticles().

◆ FadeOverlay_DrawMarks()

void FadeOverlay_DrawMarks ( void )

Each frame of the fade overlay: on each of the two cells beside the actor (left and right of it), where the ground one or two cells south rises above the actor's floor, draws a semi-transparent 16-pixel-wide sprite of colour 1 at the height of that ground.

Registered as a scheduler callback by BattleFx_StartFadeOverlay; reads the work in heap slot 36 and queues the marks with Runtime_PushSlotEntry.

Definition at line 22 of file fade_overlay.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_StartFadeOverlay(), FadeOverlay_DrawMarks(), FadeOverlay_Resume(), and FadeOverlay_Suspend().

◆ BattleFx_StartFadeOverlay()

void BattleFx_StartFadeOverlay ( void * object)

Starts the fade overlay on object (the party leader when NULL): loads its solid tiles, sets the blending and draws it each frame.

Allocates heap slot 36 for its work, borrows heap block 14 for the tiles (0x200 bytes of colour 1, VRAM cache block 94) and registers FadeOverlay_DrawMarks. Called by seven scene overlays (Venus and Mercury Lighthouses, Kalay, the tunnel ruins, Crossbone Isle, the ice room by Imil and Fuchin Falls); Crossbone Isle then switches it on and off by setting the work's actor.

Definition at line 113 of file fade_overlay.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_StartFadeOverlay(), ImilFuchinFalls_PrepareRoom(), Kalay_PrepareTunnel(), MercuryLighthouse_Initialize(), MercuryLighthouseEntrance_Initialize(), Scene_Initialize(), Scene_RunEntrySetup(), and TunnelRuins_Initialize().

◆ FadeOverlay_Suspend()

void FadeOverlay_Suspend ( void )

Stops drawing the fade overlay, keeping its work.

Reached only through a bare far-call veneer; no ☀️ code names it.

Definition at line 139 of file fade_overlay.c.

Referenced by BattleFx_ClearRandomParticles(), and FadeOverlay_Suspend().

◆ FadeOverlay_Resume()

void FadeOverlay_Resume ( void )

Draws the fade overlay again after FadeOverlay_Suspend.

Reached only through a bare far-call veneer.

Definition at line 145 of file fade_overlay.c.

Referenced by BattleFx_ClearRandomParticles(), and FadeOverlay_Resume().

◆ BattleFx_FindDefinition()

struct BattleEffectEntry * BattleFx_FindDefinition ( u32 id)

Returns the speaker definition of sprite id from gBattleFx_DefinitionTable, or its last entry when there is none.

The search stops after 0x82 entries, all but the table's last of its 131.

Definition at line 10 of file speakers.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_FindDefinition(), BattleFx_GetFlags(), and BattleFx_GetResourceId().

◆ BattleFx_GetAnimationValue()

s32 BattleFx_GetAnimationValue ( s32 id)

Returns the sprite id stored by a live actor's animated sprite, or 0 when that actor has no animated sprite or its sprite-id pointer is absent.

Definition at line 27 of file speakers.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_GetAnimationValue(), and BattleFx_GetFlags().

◆ BattleFx_GetResourceId()

s32 BattleFx_GetResourceId ( u32 id)

Returns the portrait shown beside the messages of sprite id (0x100 plus its definition's value), or 0 with no portrait or with gGameState.speech off.

Definition at line 40 of file speakers.c.

Referenced by Battle_ShowPairedUnitWorkAndWait(), BattleFx_ClearRandomParticles(), BattleFx_GetResourceId(), Ui_SetMessageVoiceFromActor(), and UiText_OpenMessageAtObject().

◆ BattleFx_GetFlags()

s32 BattleFx_GetFlags ( s32 id)

Returns the definition flags of actor id's sprite, which choose its line when it has nothing to say.

Definition at line 52 of file speakers.c.

Referenced by BattleFx_ClearRandomParticles(), BattleFx_FilterObjectIdByFlags(), BattleFx_GetFlags(), and Scene_TalkToActor().