1#ifndef ALCHEMY_UNIT_OBJECT_OBJECT_H
2#define ALCHEMY_UNIT_OBJECT_OBJECT_H
78#define MODE_WORLD_MAP 3
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
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_ResetForObject(struct ScenePlacement *table)
Creates a scene's actors on entering it: the party leader where the game state puts it,...
void Scene_AssignViewFlags(struct ScenePlacement *entry)
Gives each placement with condition 0 a condition saying whether it lies within the map's view bounds...
void ObjectTable_Snapshot(void)
Saves up to 32 actors (only the party's 8 on the world map) into gObjectSnapshots,...
void ObjectTable_ClearAll(void)
Empties all 66 actor slots, without destroying the actors.
void ObjectTable_DestroyAtIndex(s32 actorIndex)
Destroys the actor in slot actorIndex, if there is one, and empties the slot.
void ObjectTable_Restore(void)
Puts back the actors ObjectTable_Snapshot saved, and moves the camera to the party leader's height.
UNUSED void * ObjectTable_GetSlotAddress(u32 actorIndex)
Returns the address of actor slot index in the event work.
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...
s32 Party_RemapCharacterIdByFlags(s32 character)
Returns the sprite of character, which is the character itself except that FLAG_CHILDHOOD gives chara...
void BattleEffect_ClearOutOfBoundsObjects(void)
Destroys the placed actors far from the view's centre: more than 160 pixels to either side,...
void BattleEffect_ClearAllObjects(void)
Destroys every placed actor and places the scene's actors again from its first placement table after ...
s32 Party_RemapCharacterIdIfEnabled(s32 character, s32 childhood)
Returns the sprite of character as Party_RemapCharacterIdByFlags would with FLAG_CHILDHOOD set to chi...
void FieldFx_RunCarry(void)
Carry cast with no target: objects appear above the caster and to either side, move apart and scatter...
void BattlePalette_StopBlendAndReleaseBuffer(void)
Stops the colour buffer and frees it: removes BattlePalette_UpdateBlend and releases heap slot 32.
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 tar...
void BattleFx_ApplyColorToTargetBuffer(s32 mode, s32 half)
Sets the colours the buffer moves toward (see BattleFx_BuildBuffer); does nothing without a colour bu...
void BattlePalette_UpdateBlend(void)
Each frame (unless flag 0x152 is set): moves the colour buffer one step toward its target,...
s32 BattleFx_ClampRgb555Component(s32 value)
Clamps a colour channel shifted up 10 bits to at most 31 << 10.
void BattleEffect_InitializeBuffers(void)
Sets up the colour buffer (heap block 32) from the BG and OBJ palettes and starts updating the palett...
void BattleFx_SetPrimaryBufferValue(u32 color)
Sets the buffer's source backdrop colour (BG colour 0 of its palette copy).
void BattleFx_BuildBuffer(u32 mode, u16 *src, u16 *dst, s32 half)
Builds colours for the colour buffer from the palette src into dst, which holds each colour as B,...
s32 BattleFx_ClampRgb555Channel(s32 value)
Clamps a 5-bit colour channel to 0 to 31.
void BattleFx_StartBufferInterpolation(s32 frames)
Starts moving the shown colours to the target colours over frames frames: sets work->duration,...
void BattleFx_ApplyColorToSourceBuffer(s32 mode, s32 half)
Sets the colours the buffer shows now (see BattleFx_BuildBuffer).
Effect slots: the particles Psynergy effects move and draw.
void FadeOverlay_Suspend(void)
Stops drawing the fade overlay, keeping its work.
void FadeOverlay_DrawMarks(void)
Each frame of the fade overlay: on each of the two cells beside the actor (left and right of it),...
void BattleFx_StartFadeOverlay(void *object)
Starts the fade overlay on object (the party leader when NULL): loads its solid tiles,...
void FadeOverlay_Resume(void)
Draws the fade overlay again after FadeOverlay_Suspend.
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.
void Object_DestroyIfPresent(void *object)
Releases object unless it is NULL.
void Marker_MoveLeaderAway(void)
Keeps the party leader off the markers: a leader within 16 pixels of a marker cell's centre is moved ...
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 acto...
void FieldEffect_SpawnNearbyMarkers(void)
Reveal: marks with sparkles the hidden things within 8 cells left or right and 5 up or down of the le...
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,...
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 a...
void RevealMarker_EmitSparkles(union FieldObject *fieldObject)
Each frame of a Reveal marker: one time in ten, a sparkle appears within 16 pixels of it.
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) fac...
s32 Field_IsRevealActive(struct ScriptInterpreter *interpreter)
Returns 1 while Reveal is active, else 0.
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 ...
s32 Field_FindItemEvent(s32 item)
Returns the scene's item event (kind 4) for item that applies to what the leader faces,...
s32 Field_RunPsynergyEvents(s32 packed)
Runs the scene's events for Psynergy without paying its PP or showing its usual effect (phases 3 and ...
s32 Field_UseItem(s32 packedItem, s32 slot)
Uses an item on the field.
void BattleFx_ShrinkObjectAndDestroySlow(union FieldObject *fieldObject)
Spins and shrinks an object by 0x1c0 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 ...
void Field_PlaceMapMarkers(void)
Places an actor at each of the map's markers (ids 100 to 239) that the scene has an event for,...
void 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.
s32 Marker_FindSlot(s32 id)
Returns the marker slot (0 to 9) whose event trigger is id, or -1.
struct ObjectRuntime * Marker_GetActor(s32 id)
Returns the actor of marker id, or NULL when no slot has it.
UNUSED void EffectRuntime_ReservedNoOp(void)
void ObjectMotion_SnapToTerrain(void *object)
Sets an actor's y and terrainHeight to the map's height at its x and z.
void Marker_CloseChest(s32 id)
Closes the chest of marker id again (its item could not be carried), with SE_125.
void Marker_ShowOpened(s32 id)
Shows the chest of marker id open (animation 2), with no sound.
void Marker_OpenChest(s32 id)
Opens the chest of marker id (animation 4) with SE_124, and waits 12 frames.
void Marker_LaunchMimic(s32 id)
Makes the chest of marker id jump up as a mimic: after 18 frames it takes animation 7,...
void Marker_Hide(s32 id)
Hides the actor of marker id by clearing its animationKind.
void BattleFx_ShrinkObjectAndDestroyFast(union FieldObject *fieldObject)
Spins and shrinks an object by 0x400 a frame, then releases it.
void Battle_SelectTerrainBackdrop(s32 behavior)
Chooses the battle backdrop for a world map terrain behavior (1 to 7; any other gives Sol Sanctum's) ...
void Scene_ResolveInteractionResult(void)
Chooses the current scene's field music (gGameState.cue) from the first rule matching the scene or it...
s32 Encounter_ResolveWorldMapZoneAndBackdrop(void *pos)
Returns the world map encounter zone for the terrain at pos (0 for none), and chooses the battle back...
u16 Encounter_GetEnemyGroupAtSlot(s32 zone, s32 slot)
Returns the enemy group in slot (0 to 7) of zone; 14 halfwords make a zone.
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.
s16 Event_GetSpecialValue(void)
Returns the battle backdrop chosen for the current scene.
s32 Encounter_RollWorldMap(s32 pos, s32 steps)
Rolls a random battle on the world map, taking the zone from the tile at pos.
void BattleFx_SelectBattleCue(s32 zone, s32 slot)
Chooses the battle music for slot of zone (gGameState.sceneCue).
void Encounter_SelectSceneZones(s32 useRules)
Chooses the current scene's encounter zones, one for each kind of ground the party can stand on (gEve...
s32 Encounter_RollTerrain(u32 terrain, s32 steps)
Rolls a random battle on the encounter zone of the ground underfoot.
void Battle_SelectSceneBackdrop(void)
Chooses the battle backdrop for the current scene.
s16 Encounter_GetDjinnEnemyGroup(s32 djinni)
Returns the enemy group of Djinni battle djinni, which the table gives as a zone and slot.
void Scene_SetDefeatReturnPoint(void)
Sets the scene the party returns to after a defeat (gGameState.savedScene and savedEntrance),...
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 ...
s32 GameFlag_IsConditionActive(s32 condition)
Returns whether an event condition holds: -1 always holds; a condition with bit 0x1000 holds while th...
struct EffectDescriptor * Scene_FindEvent(s32 kind, s32 target)
Returns the first of the scene's events of kind for target whose condition holds, or NULL.
s32 Scene_TalkToActor(s32 id)
Talks to actor id: shows its event's message or calls its event function, with the actor stopped and ...
s32 Scene_RunTouchOrExit(s32 value)
Runs the touch event (kind 2) of what the leader touched, or else takes its exit (kind 1): plays the ...
s32 Scene_FindActorTalkEvent(s32 id)
Returns the talk event of actor id: for the actor the party has stopped, its kind 7 event if it has o...
s32 Field_SearchTile(s32 tile)
Searches the tile ahead with the given collision code.
UNUSED void Runtime_CallWorkBlockEntry(void)
Nothing calls this.
s32 Scene_RunRaisedEvent(s32 value)
Runs the scene's raised event (kind 6) for value: its message or its function.
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 ...
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 ...
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...
s32 Field_UsePsynergy(u32 code)
Uses Psynergy on the field.
u32 BattleFx_HasTrigger(u16 item)
Returns whether the scene has an event for item and what the leader faces.
s32 BattleFx_HasMatchingEvent5(s32 group)
Returns whether the scene has a Psynergy event, in any phase, for Psynergy of group and what the lead...
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,...
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
s32 Field_FindNearbyTalkTarget(s32 id)
Returns the actor nearest to actor id that it could talk to, or -1: within 48 pixels of height and 32...
s32 Field_GetPsynergyTargetRange(s32 kind)
Returns how far, in pixels, a field Psynergy of the given kind reaches: gBattleFx_TargetRangeByMode p...
void Animation_ApplyChildPalette(struct MotionObject *object, s32 palette)
Gives every part of a motion object's sprite (but those at palette 15) palette - 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 fron...
void DisplayTransition_InitializeBattleEffectState(s32 mode)
Starts window transition mode at value 0, with no duration: the caller moves it.
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...
void DisplayTransition_FillTilemapAndSolidTile(s32 color)
Fills background screen block 4 with tile 0 in palette 15 and, unless color is -1,...
void DisplayTransition_UpdateScanline(void)
The VCount interrupt of the centre-line transition: switches the display to mode 2 (nothing shown) at...
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 DisplayTransition_UpdateScanlineTable(void)
Each frame of a window transition: advances its value toward its end (and at the end turns the window...
void BattleFx_StartWindowHBlankDma(void)
Each frame, before drawing: turns windows 0 and 1 on, writes the first four values of the shown page ...
void DisplayTransition_SuspendCallbacks(void)
Suspends the window transition's two callbacks.
void DisplayTransition_InitializeState(s32 value)
Starts a dissolve of the given mode and waits 120 frames.
void DisplayTransition_Update(void)
Each frame of the centre-line transition: moves the value toward its end and sets the two lines where...
struct DisplayTransitionState * DisplayTransition_AllocateAndClearState(void)
Allocates the display transition state (heap block 31) and clears it.
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 p...
void DisplayTransition_UpdateFromCentre(void)
As DisplayTransition_Update, but the lines flicker every other frame.
void Debug_RunPaletteEditor(void)
The debug palette editor (L on the pause menu in debug mode).
void Scene_ApplyEntrance(void)
Places the party at the entrance it came in by (the first matching entry, or the scene's first one) u...
s32 Object_GetTriggerTileAheadOfCurrent(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader when there is somethin...
s32 Field_RunScene(s32 entrance)
Runs the current field scene, which the party entered by entrance, until it leaves; returns the exit ...
void Audio_PlayCueFromEventWork(void)
Starts the current scene's field music, chosen by Scene_ResolveInteractionResult.
s32 BattleFx_GetResourceGroup(s32 scene)
Returns the group scene belongs to.
void Scene_TakeExit(s32 exitKind)
Chooses the scene and entrance to go to when the party leaves the current scene.
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 s...
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_ReturnFromBattle(s32 result)
Chooses where the game continues after a battle or another scene that is not a field map (see Game_Re...
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 ...
s32 BattleFx_GetResourceId(u32 id)
Returns the portrait shown beside the messages of sprite id (0x100 plus its definition's value),...
struct BattleEffectEntry * BattleFx_FindDefinition(u32 id)
Returns the speaker definition of sprite id from gBattleFx_DefinitionTable, or its last entry when th...
s32 BattleFx_GetFlags(s32 id)
Returns the definition flags of actor id's sprite, which choose its line when it has nothing to say.
void WorldMap_EndEvent(void)
Ends what WorldMap_BeginEvent started: on the world map, reloads the area's graphics and sets the cam...
void BattleParty_ApplyDrain(s32 amount, s32 unused)
Gives each character in the party amount PP (PP regenerates as the party walks).
s32 BattleParty_ApplyStatusDamage(void)
Hurts each poisoned character in the party: poison takes a twentieth of their maximum HP and venom a ...
void WorldMap_BeginEvent(void)
Starts an event or menu on the world map: ends any colour ratio transition in progress,...
void Field_ClearRequests(void)
Clears the field's twelve pending requests (see struct FieldWork).
void Field_ProcessStep(s32 layer, s32 x, s32 y, s32 z)
Handles one step of the party leader onto the cell at (x, y, z) of map layer: records step events and...
s32 Field_GetCollisionAheadOfLeader(void)
Returns the collision code of the map cell 16 pixels ahead of the party leader (a world map block on ...
s32 Field_CountRequests(void)
Returns the sum of the field's twelve pending requests (counting the actor event request twice): non-...
void Field_CheckExitRegions(s32 positionX, s32 positionY, s32 positionZ)
Takes the exit of the first of the scene's exit regions that contains the position (x,...
void BattleParty_ApplyHealthDelta(s32 amount, s32 percent)
Changes each party member's HP by amount, or by that percentage of maximum HP when percent is set.
A field object as Avoid's caster: its facing, its animation records and the phase and frame count of ...
A speaker definition, a row of gBattleFx_DefinitionTable: a sprite, its portrait (0xff for none) and ...
A FieldActor seen with the halfword at 0x64 unsigned and the one at 0x66 signed, as the bytes read th...
A field object as the object dispatcher's far calls take it.
The display transition state (heap block 31): two pages of window edges for every line,...
u16 value
The progress, moved from start to end over duration frames: bit 5 says whether the transition opens o...
u16 mode
The window transition's shape: modes are listed at DisplayTransition_UpdateScanlineTable.
A FieldActor seen with the halfword at 0x5e (here its phase), which FieldActor does not name.
One of the scene's events (the same 12 bytes as struct SceneEvent).
u8 value
the target (an actor or a tile code)
s32 result
below 0x10000 a message, else a function to call
s16 condition
as for GameFlag_IsConditionActive
s32 flags
the low 4 bits are the kind (SceneEventKind; 7 talks to the actor the party stopped)
An actor as these effects see it.
A particle a Psynergy effect moves and draws: its sprite, its position and target,...
A world position, as Camera_WorldToScreen converts it to the screen.
A field object seen as one that turns toward its facing target: its facing, its ground position and t...
A field actor: a person or thing on the field with a position, motion toward a target,...
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 z
16.16 fixed-point pixels
s32 x
16.16 fixed-point pixels
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
u8 flags
PLACEMENT_SHARE_PREVIOUS_SPRITE.
s16 condition
-1 always, a flag | 0x1000 set, else the flag clear; off the world map, 48 to 127 also need condition...
The prefix that command handlers read from a field object's 0x70-byte slot.
A FieldActor seen with the halfword at 0x5e (its lifetime), which FieldActor does not name.
A window: a framed rectangle of the tilemap with its sprite outputs, its opening or closing animation...
The integer types, TRUE, UNUSED and the fixed-address macros.
An object on the field, read as an actor or as an effect.
void BattleFx_ClearRandomParticles(void)