35 sprite =
object->object;
37 if (object->
flags & 4)
38 offset = 0x1fc0000 -
object->z;
41 position.
x =
object->x;
43 position.
y =
object->z + offset;
45 if (object->
x > -0x200000 && object->
x < 0x1100000 && object->
z > -0x200000 &&
67 deltaX = effect->
targetX - effect->
x;
68 deltaZ = effect->
targetZ - effect->
z;
70 pixelX = deltaX / 0x10000;
71 pixelZ = deltaZ / 0x10000;
72 distance =
Iwram_Sqrt(pixelX * pixelX + pixelZ * pixelZ) << 16;
73 if (distance < 0x800000)
76 if (distance <= 0x80000) {
81 angle =
ArcTan2(deltaZ, deltaX);
84 turn = angle - heading;
85 if ((turn >= 0 ? turn : -turn) >= effect->
maxTurnStep) {
92 angle = turn + heading;
101 effect->
speed = speed;
116 return ((0u - targetX) | targetX) >> 31;
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
u32 EffectSlot_HasPendingTarget(struct EffectSlot *effect)
Returns nonzero while an effect slot that stops at its target still has one (it has not arrived),...
void BattleFx_ClearOwnedSlot(struct EffectSlot *slot)
Frees an effect slot and its sprite.
void EffectSlot_UpdateMotion(struct EffectSlot *effect)
Moves an effect slot toward its target, turning at most maxTurnStep a frame when limitTurnStep is set...
void EffectSlot_SetPosition(struct EffectSlot *effect, s32 x, s32 z)
Places an effect slot at (x, z), at rest with no target.
void EffectSlot_Update(struct EffectSlot *effect)
Updates one effect slot: counts its age, runs its callback (after any delay), moves it and draws it.
void EffectSlot_Initialize(struct EffectSlot *effect, s32 kind, s32 x, s32 z)
Fills an effect slot with a new sprite of kind at (x, z): stopping at its target, top speed 2,...
void BattleFx_DrawScaledObject(struct EffectSlot *object)
Draws an effect slot's sprite at its screen position and scale, when it is near the screen.
void EffectSlot_SetCallback(struct EffectSlot *effect, EffectCallback callback)
Gives an effect slot its per-frame callback, starting at state 0.
void EffectSlot_SetObjectMode(struct EffectSlot *effect, s32 mode)
Sets the animation of an effect slot's sprite.
void(*) EffectCallback(struct EffectSlot *)
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
struct AnimationObject * ResourceObject_CreateFar(s32 id)
void Object_ApplyProjectedPlacementFar(struct AnimationObject *sprite, const struct SpritePlacement *position, const struct SpriteScale *scale, s32 facing)
Far call to Render_ApplyProjectedPlacement.
void ResourceObject_ReleaseFar(struct AnimationObject *sprite)
static s32 Iwram_Sqrt(s32 value)
#define Iwram_MulQ16(left, right)
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
s32 FixedSqrt(s32 value)
Square root of a 16.16 fixed-point value, in 16.16.
What every part of psynergy_effects.c shares: its includes and the macros and types more than one par...
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart image
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
u8 slot
VRAM cache entry holding its tiles.
s32 scale
16.16 fixed point, 0x10000 full size
u16 priority
2 when created
A particle a Psynergy effect moves and draws: its sprite, its position and target,...
s32 speed
16.16 fixed-point pixels per frame
s32 scaleY
16.16 fixed point, 0x10000 full size
EffectCallback callback
run each frame once callbackDelay is 0
s8 state
the callback's own step; 0 when it is given
void * object
the slot's sprite, released with the slot
s32 originX
16.16 fixed-point pixels; where the slot started
s32 z
16.16 fixed-point pixels
s32 x
16.16 fixed-point pixels
s16 maxTurnStep
1/65536 turns a frame
s8 limitTurnStep
Clamp steering to maxTurnStep; zero faces the target directly.
s32 originZ
16.16 fixed-point pixels; where the slot started
s32 targetZ
16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
s32 scaleX
16.16 fixed point, 0x10000 full size
s32 targetX
16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
s8 active
nonzero while the slot is in use
s8 updateMotion
nonzero: EffectSlot_UpdateMotion moves it each frame
u8 flags
bits: 2 z also lifts the sprite (set when the slot is filled)
s32 maxSpeed
16.16 fixed-point pixels per frame
u8 randomValue
random when filled; not read by name in TBS
s8 stopAtTarget
nonzero: lands on the target within 8 pixels
s32 acceleration
16.16 fixed-point pixels per frame, each frame
s8 render
nonzero: drawn each frame
A sprite's screen position and its two vertical offsets, in 16.16 pixels.
s32 x
screen x of the sprite's centre
s32 y
screen y at the ground; sets the depth slot
s32 groundHeight
how far the shadow is raised above y
s32 height
how far the image is raised above y
Horizontal and vertical sprite scale; 0x10000 is the original size.