field_fx.c
Showing a found item, and Reveal's sparkles on hidden things.
games/tbs/src/object/object/field_fx.c on GitHub
Showing a found item, and Reveal's sparkles on hidden things. Part of object.c, the field object, compiled only through it.
Functions
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).
Used by Reveal_ShowSecrets.
Object_InitializeSparkle
static inline void Object_InitializeSparkle(struct ObjectRuntime *obj)
Starts the particle script and its first child at priority 1, if the spawn succeeded. Allocation failure leaves the effect absent. The script sinks the sparkle a quarter pixel a frame for 60 frames, then frees it.
Used by ItemDisplay_EmitSparkles, RevealMarker_EmitSparkles.
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.
Used by BattleFx_StartEffectObject22, BattleFx_StartRandomParticleEmitter, EffectRuntime_RunRisingObjectSequence.
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, at a height of 16 pixels whatever the actor's, with sparkles. While Reveal is active, its marks and sparkles are cleared first. Returns the picture's actor, or 0 without the actor or a free object. The picture is object 22, thrown up (velocityY 2 << 16, gravity 0x4000: it rises for 8 frames) while it grows to full size, its icon drawn through heap block 17, which is released again, and loaded into VRAM. The caller owns the picture: Field_SearchTile releases it once the find is told. Called by Field_SearchTile for coins and items found, and by BattleFx_PlayCueAndStartEmitterOnTarget.
Used by BattleFx_PlayCueAndStartEmitterOnTarget, 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.
Used by Field_SearchTile.
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.
Used by BattleFx_StartEffectObject22, EffectRuntime_RunRisingObjectSequence, Field_SearchTile.
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).
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). When no object is free, heap block 17, taken for the icon, is not released (the scene change's heap reset frees it).
BattleFx_ClearRandomParticles
void BattleFx_ClearRandomParticles(void)
While Reveal is active, destroys all its sparkles, leaving its marks. Called by the field menu (Menu_RunTopSelection, window/selection.c) each time Menu_SelectTopEntry returns, a cancel included, while Reveal is active.
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.
Used by BattleFx_StartRandomParticleEmitter, FieldEffect_SpawnNearbyMarkers.
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: the marker stays while it returns 1 and frees itself once it returns 0.
Used by gBattleFx_MarkerParticleScript.
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).
Used by FieldFx_RunReveal.
Structures
EffectObj
struct EffectObj
An object of the 64-object pool (struct ObjectRuntime, 0x70 bytes), seen as the found item's picture, the sparkles and the Reveal marks use it.
| Field | Declared as | |
|---|---|---|
scriptWord | s32 scriptWord | The script pointer, as a word; 0 while the pool object is free. |
pad0 | u8 pad0[0x24] | |
velocityY | s32 velocityY | 16.16 fixed-point pixels a frame; up is positive |
pad1 | u8 pad1[0x1c] | |
gravity | s32 gravity | 16.16 fixed-point pixels taken off velocityY each frame while the object falls (motion bit 1); 0x10000 when created. |
pad2 | u8 pad2[4] | |
animation | struct AnimationObject *animation | |
pad3 | u8 pad3[24] | |
updateHook | void (*updateHook)(union FieldObject *object) | frame hook at offset 0x6c |
Used by BattleFx_ClearRandomParticles, BattleFx_StartEffectObject22, BattleFx_StartRandomParticleEmitter, EffectRuntime_RunRisingObjectSequence, FieldEffect_SpawnNearbyMarkers.
Macros
EFFECT_OBJECT_COUNT
#define EFFECT_OBJECT_COUNT 64
ObjectSystem_Initialize allocates 64 ObjectRuntime records in heap slot 5.
Used by BattleFx_ClearRandomParticles, BattleFx_StartRandomParticleEmitter.
MENU_OPEN_OFFSET
#define MENU_OPEN_OFFSET 0xcca
In gEventWork, the byte after queuedSound: Menu_RunTopSelection sets it once Menu_SelectTopEntry first returns, a cancel included, and clears it as it returns.
Used by RevealMarker_EmitSparkles.
Also, macros without a comment: EFFECT_OBJECT_POOL, EFFECT_OBJECT_POOL, SPARKLE_OBJECT_ID, PARTICLES_PAUSE_FOR_MENU.