40 value |=
object->actionFlags;
41 object->actionFlags = value;
55 object->actionFlags = enabled |
object->actionFlags;
67 object->linkedObject =
91 value |=
object->actionFlags;
92 object->actionFlags = value;
104 if (
object !=
NULL) {
105 object->movementState = 0;
118 if (
object !=
NULL) {
119 object->movementState = 0;
132 if (
object !=
NULL) {
133 object->movementState = 0;
146 if (
object !=
NULL) {
147 object->movementState = 0;
167 if (
object !=
NULL) {
177 offsetInColumn = pixelX - columnX;
178 object->movementState = 0;
182 object->y, object->z);
186 object->z + (zOffset << 16));
198 if (
object !=
NULL) {
199 object->movementState = 0;
202 object->z + (zOffset << 16));
213 if (
object !=
NULL) {
214 object->movementState = 0;
218 object->z + (zOffset << 16));
230 if (
object !=
NULL) {
244 if (
object !=
NULL) {
252 object->movementState = 0;
268 if (
object !=
NULL) {
287 if (
object !=
NULL) {
297 if (1 & object->flags) {
310 object->y = (
object->y -
object->terrainHeight) +
terrainHeight;
326 if (
object !=
NULL) {
332 if (1 & object->flags) {
345 object->y = (
object->y -
object->terrainHeight) +
terrainHeight;
387 sprite =
object->animation;
389 for (elapsedFrames = 0; elapsedFrames <= 89; elapsedFrames++) {
391 if (saved != sprite->
lastNo) {
420 s32 verticalVelocity;
423 if (
object !=
NULL) {
424 objectFlags = &
object->flags;
425 updatedFlags = *objectFlags | 2;
426 verticalVelocity = speed << 16;
427 *objectFlags = updatedFlags;
428 object->velocityY = verticalVelocity;
446 if (
object !=
NULL && count > 0) {
510 child =
object->sprite;
529 object->motionFlags = 0;
531 object->acceleration = -0x1999 *
speed;
534 object->speed = 0x1999 *
speed;
563 objectFlags = &
object->flags;
567 flags |= *objectFlags;
568 *objectFlags =
flags;
570 object->velocityY = 0x40000;
581 nextY =
object->y + 0xFFFE0000;
583 object->targetY = nextY;
585 if ((param != -1) && (pose & 1)) {
589 }
while ((
u32)pose <= 0xD);
593 object->velocityY = 0x30000;
596 for (pose = 0; (
u32)pose <= 0xB3 &&
object->y >
object->terrainHeight;
615 if (first != 0 && second != 0) {
629 if (first !=
NULL && second !=
NULL) {
641 s32 firstTargetAngle;
642 s32 secondTargetAngle;
647 if (first ==
NULL || second ==
NULL)
649 firstTargetAngle = (
u16)
ArcTan2(second->
z - first->
z, second->
x - first->
x);
651 secondTargetAngle = firstTargetAngle + 0x8000;
652 for (frame = 0; frame < 60; frame++) {
656 angleDifference = (
s16)(firstTargetAngle - first->
angle);
657 if (angleDifference != 0) {
658 if (angleDifference > 0x1000)
659 angleDifference = 0x1000;
660 if (angleDifference < -0x1000)
661 angleDifference = -0x1000;
662 first->
angle += angleDifference;
666 angleDifference = (
s16)(secondTargetAngle - second->
angle);
667 if (angleDifference != 0) {
668 if (angleDifference > 0x1000)
669 angleDifference = 0x1000;
670 if (angleDifference < -0x1000)
671 angleDifference = -0x1000;
672 second->
angle += angleDifference;
676 if (actorsTurning == 0)
710 memcpy((
u8 *)table + 0x14 + index *
sizeof(
void *), &empty,
sizeof(empty));
712 table->slots[index] =
NULL;
729 if (
object !=
NULL) {
730 blink = 0x100 & param;
747 if ((object->
kind & 0xf) == 1) {
754 container =
object->target.child;
755 partCount = container->
count;
756 if (partCount != 0) {
758 s32 remaining = partCount;
761 if (entry != 0 && entry->
script != 0) {
765 }
while (remaining != 0);
767 container->
dirty = 1;
778 if ((object->
kind & 0xf) == 1) {
780 u8 partCount = container->
count;
782 if (partCount != 0) {
784 u32 count = partCount;
791 }
while (count != 0);
793 container->
dirty = 1;
807 if (follower !=
NULL && target !=
NULL) {
826 if (
object !=
NULL) {
828 s32 currentAngle =
object->angle;
829 delta = (
s16)(targetAngle - currentAngle);
835 object->angle = currentAngle + delta;
847 if (
object !=
NULL) {
864 if (
object !=
NULL) {
865 object->action =
angle;
899 sprite =
object->animation;
900 vramBlock = sprite->
slot;
904 sprite =
object->animation;
905 sprite->
slot = vramBlock;
955 for (index = 8; index <= 65; index++) {
void ObjectMotion_SetSpeedParameters(u32 objectId, s32 speedLimit, s32 acceleration)
The event command "set actor speed": its top speed and acceleration, 16.16 pixels per frame.
void ObjectVisual_CopyAttributes(u32 targetId, u32 sourceId)
Makes the target actor's sprite show the source actor's graphics (its VRAM block and tile).
void ObjectMotion_CommitCurrentPositionAndActivate(u32 objectId)
The event command "wait for actor": waits (at most 600 frames) for the actor to arrive and stands it ...
void ObjectMotion_ResetAndSetPositionInMode2(u32 objectId, s32 x, s32 z)
The event command "walk actor to": the actor walks (animation 2) toward (x, z), in pixels.
void Motion_SetVarCbAndRefresh(u32 objectId, s32 count)
The event command "run repeated motion": as ObjectMotion_SetVariantCallback, then waits for it to end...
void ObjectMotion_NoOp(void)
An empty function, reached only through an unnamed veneer in the object bank's far-call table; nothin...
void Object_LinkPair(s32 firstId, s32 secondId, s32 wait)
The event command "actors face each other": turns two actors toward each other, then waits wait frame...
s32 ObjectMotion_StepAngle(struct ObjectRuntime *object)
Script step that turns an actor toward the angle kept in its action: the whole way when within 1/16 t...
void ObjectMotion_Launch(u32 objectId, s32 speed, s32 frames)
The event command "actor jump": throws the actor upward at speed pixels per frame with a jump sound (...
void Object_ResetTargetAndSetMode1(u32 objectId)
Clears an actor's destination, puts it under event control and stands it still.
void ObjectTable_DestroyById(s32 index)
The event command "destroy actor": releases the actor and frees its slot, writing NULL to its place i...
s32 ObjectTable_ReadActiveValue(s32 actor)
Returns the sprite (the first animation's id) of the actor in the low 12 bits of actor,...
void FieldFx_UpdateParticleLinearMotion(union FieldObject *fieldObject)
Moves a dust puff of FieldFx_SpawnBurstParticle: it drifts with its x and z velocity (kept in speed a...
void ObjectMotion_CenterOnColumn(u32 objectId, s32 priority, s32 zOffset)
The event command "center actor and walk": walks the actor sideways to the middle of its 16-pixel col...
void ObjectGroup_SetChildValue(struct FieldActor *actor, s32 param)
Sets the param byte of every animated part of an actor's sprite.
void Object_SetActionCallbackAndRefreshById(u32 objectId, s32 action)
Starts a built-in action or supplied script, then waits up to 300 frames for its script to end.
void Object_RefreshSelectorById(u32 objectId)
Waits, at most 300 frames, for an actor's script to reach its end (command 0x10).
void ObjectMotion_SetHorizontalPositionWithTerrain(u32 objectId, s32 x, s32 z)
The event command "set actor position": puts the actor at (x, z), 16.16 pixels, at rest.
UNUSED void ObjectVisual_ReservedNoOp(void)
void ObjectMotion_ResetAndSetPosition(u32 objectId, s32 x, s32 z)
The event command "set actor destination": the actor heads for (x, z), in pixels, keeping its current...
void Motion_SetModeAndWaitAnimation(u32 objectId, s32 animation)
The event command "set actor animation and wait": plays the animation and waits for it to end.
void ObjectGroup_ApplyIndexedChildValue(union FieldObject *fieldObject)
Per-frame hook of a blinking actor: sets its sprite parts' param from gObjectGroup_BlinkChildValues (...
void ObjectMotion_EnableActionAndSetCallback(u32 objectId, s32 action)
Gives an actor an action script (ObjectMotion_SetActionCallback) and lets it run: sets bit 0 of its a...
void ObjectMotion_ArmCallback(s32 objectId, s32 angle, s32 wait)
The event command "actor face direction": the actor turns toward angle (0x10000 a full turn; ObjectMo...
void FieldFx_SpawnBurstParticle(struct FieldActor *source, s32 param)
Kicks up a dust puff (object 222) where source stands: it flies off toward the back at 0....
void Actor_JumpDownLedge(s32 actor, s32 pose, s32 param)
Makes an actor jump down off a ledge in front of it (the field runs it for the leader when the player...
void Object_SetTargetAndCallback(u32 objectId, s32 targetId, const void *script)
Links an actor to the actor in the low 8 bits of targetId and starts script on it.
void ObjectMotion_CommitPositionAndActivate(u32 objectId, s32 xOffset, s32 zOffset)
Walks the actor (xOffset, zOffset) pixels, waits for it to arrive and stands it still.
void ObjectMotion_OffsetPositionAndResetMotion(u32 objectId, s32 xOffset, s32 zOffset)
The event command "set actor destination offset": the actor heads (xOffset, zOffset) pixels from wher...
void Object_LinkObjectAndSetCallback(u32 objectId, u32 linkedObjectId)
Makes an actor follow another (the linked action script): writes its linkedObject.
void ObjectMotion_SetVariantCallback(u32 objectId, s32 count)
The event command "start repeated motion": the actor squashes and springs back count times (1 to 3),...
void Motion_LaunchFromFocusedObject(u32 objectId, s32 xOffset, s32 zOffset, s32 action)
Places an actor on the leader and sends it walking (xOffset, zOffset) pixels away at speed 0....
s32 ObjectTable_FindActiveByValue(s32 sprite)
Returns the first scene actor (8 to 65) showing sprite, or -1.
void ObjectMotion_SetPositionWithTerrain(u32 objectId, s32 x, s32 y, s32 z)
Puts the actor at (x, y, z), 16.16 pixels, at rest; an actor that follows the ground (flag 1) is rais...
void FacingObject_TurnPairToFaceEachOther(struct FacingObject *firstObject, struct FacingObject *secondObject)
Turns two actors to face each other, at most 1/16 turn a frame each, until both do (at most 60 frames...
void ObjectMotion_SetPositionAndReset(u32 objectId, s32 x, s32 z)
The event command "walk actor to and wait": walks the actor to (x, z), in pixels, waits for it to arr...
void Event_SetMessageId(s32 message)
The event command "set message": the number of the event's next message, written to work->message.
void ObjectMotion_WaitForAnimationChange(u32 objectId)
Waits, at most 90 frames, for an actor's animation to change.
void ObjectMotion_OffsetPositionAndReset(u32 objectId, s32 xOffset, s32 zOffset)
Walks the actor (animation 2) (xOffset, zOffset) pixels from where it stands.
void ObjectMotion_SetPositionAndCommit(u32 objectId, s32 x, s32 z)
The event command "move actor and wait": as ObjectMotion_ResetAndSetPosition, then waits (at most 600...
void ObjectMotion_EnableActionAndResetMotion(u32 objectId)
The event command "stop actor": stops its action and puts it back under event control (dispatch scrip...
void Object_SetActionById(u32 objectId, s32 steps)
Sets the animation timer steps of each of an actor's sprites (AnimationObjects_SetActiveTimerSteps).
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
void ObjectMotion_SetAngleToward(s32 firstId, s32 secondId, s32 wait)
The event command "actor face actor": turns the first actor at once to face the second,...
UNUSED void ObjectTable_DestroyNoOp(void)
void Object_SetModeById(u32 objectId, s32 animation)
The event command "set actor animation" (1 stands, 2 walks, 3 nods, 4 shakes the head and so on).
void ObjectGroup_ConfigureChildValue(s32 objectId, s32 param)
The event command "set actor sprite param": gives every sprite part of the actor param (ObjectGroup_S...
void ObjectMotion_SetActionVariant(s32 objectId, s32 priority)
The event command "set actor sprite priority": fixes the priority of the actor's sprite,...
void ObjectMotion_SetActionCallback(struct ObjectRuntime *object, s32 action)
Starts an actor's action script: 1 to 4 the fixed action scripts, 5 follow the linked object,...
void * ObjectTable_Get(u32 actorIndex)
Returns the actor in slot index (0 to 65), or NULL.
const u8 gObjectMotion_LinkedActionScript[]
struct ObjectRuntime * Object_CreateFar(s32 id, s32 x, s32 y, s32 z)
Far call to FieldObject_Create.
void ObjectDispatch_ReleaseFar(struct DispatchObject *obj)
s32 Map_GetTerrainHeightFar(s32 layer, s32 x, s32 y)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_InitializeFar(struct DispatchObject *obj, const s32 *script)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
void Object_SetMoveTargetFar(struct ObjectRuntime *object, s32 x, s32 y, s32 z)
void ObjectDispatch_WaitForValue16Far(void *raw)
void FieldObject_WaitForMoveFar(void *fieldObject)
void ObjectDispatch_StartIdleFar(struct DispatchObject *obj)
void AudioCommand_PlayFar(s32 id)
u8 gObjectMotion_LaunchScript
const u8 gObjectMotion_StepAngleScript[]
const u8 gBattleFx_BurstParticleScriptB[]
const u8 gBattleFx_BurstParticleScriptA[]
@ ACTOR_PRIORITY_AUTOMATIC
The sprite takes its priority from the map cell under it.
#define ACTOR_NO_TARGET
A target coordinate that is not set: the object has no target.
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
volatile u32 gFrameCount
Frames WaitFrames has finished.
const s32 gObjectMotion_VariantScripts[97]
Squashes as many times as the variant (1 to 3): variant v starts at word (3 - v) * 32 and runs to the...
const u8 gObjectGroup_BlinkChildValues[4]
A child value by frame ((gFrameCount >> 1) & 3).
struct GameState gGameState
#define SET_VELOCITY(p, vx, vy, vz)
#define SET_POSITION(p, px, py, pz)
Sets the position or the velocity of a particle, a piece of debris or an object in one statement.
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,...
void FieldEvent_WaitFrames(s32 frames)
The event command "wait": waits the requested frames, unless debug fast forward (Event_UpdateDebugSki...
What every part of psynergy_effects.c shares: its includes and the macros and types more than one par...
void BattleFx_PlayQueuedSound(void)
Plays the sound BattleFx_SetQueuedSoundAndPlay remembered, if any.
#define SE_JUMP
An actor jumps: ObjectMotion_Launch plays the high jump above 5 pixels a frame.
struct EventWork * gEventWork
#define STATIC_ASSERT(condition)
C89 permits repeated extern declarations of the same array.
#define offsetof(type, member)
One animation layer of a sprite: its animation id, frames, running script and timer.
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
u8 * script
the running script; null when stopped (ANIM_CMD_END)
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart shadow
struct AnimationSpritePart image
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
u8 lastNo
The animation number last selected, which selecting again skips.
u8 slot
VRAM cache entry holding its tiles.
struct AnimationEntry * entries[4]
its layers; empty ones null
u8 count
layers in use, up to the last one present
u8 dirty
nonzero redraws its pixels into VRAM when next drawn
u16 tile
first sprite tile in VRAM
u16 priority
2 when created
A field object as the object dispatcher's far calls take it.
u8 kind
low four bits: 0 no sprite, 1 one, 2 up to four
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,...
s32 speed
speed limit, 16.16 fixed-point pixels per frame
s32 targetX
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
union FieldCoordinate x
16.16 fixed-point pixels
s32 targetZ
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
s32 velocityX
16.16 fixed-point pixels per frame
union FieldCoordinate y
16.16 fixed-point pixels
union FieldCoordinate z
16.16 fixed-point pixels
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
s32 targetY
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
s32 velocityZ
16.16 fixed-point pixels per frame
Full event work allocated by Field_RunScene (heap slot 27).
s16 message
the next message, advanced as each window opens
struct FieldActor * actors[66]
The actors by id: 0 to 7 the party's characters, 8 on the placed actors.
s32 selectedActor
the leader: its unit and its actor
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 terrainHeight
16.16 fixed-point pixels
s32 z
16.16 fixed-point pixels
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
u8 collisionFlags
FieldActor.collisionFlags: bit 0 solid, bit 1 the player pushes it, bits 2 to 4 for talk and Psynergy...
s32 * script
the object script it runs; null when the object is free
u8 flags
FieldActor.motionFlags: 3 when created, 4 for a placed actor above the ground; zero is free flight in...
void * animation
its sprite, or its list of four, by animationKind
u16 wait
the object script's wait, in frames
s32 x
16.16 fixed-point pixels
s32 speedLimit
16.16 fixed-point pixels per frame
s32 y
16.16 fixed-point pixels
u8 animationKind
Low four bits: 0 no sprite, 1 one sprite, 2 a group of up to four.
struct ObjectRuntime * linkedObject
The object its action script follows or faces.
s16 action
The parameter its action script reads (a follow distance or an angle), or the player's frames to its ...
u8 terrainId
the map layer its ground height is read from
The event work seen as its actor slots, which the actor commands index by actor number.
struct ObjectRuntime * slots[0]
A field object as the motion code sees it: its script, position, motion toward a target,...
void(*) hook(union FieldObject *object)
Called each frame before its script.
A field coordinate, read whole or as its fraction and its whole pixels.
struct FieldCoordinate::@024321007066302143002254325121164243234242211074 part
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.
void * memcpy(void *destination, const void *source, unsigned long size)