Alchemy
Loading...
Searching...
No Matches

object_motion.c File Reference

Object motion, each frame, and the first object script commands. More...

Go to the source code of this file.

Functions

s32 Script_SetBase (struct ScriptInterpreter *interpreter)
 SC_BASE: restarts the script at the next word, and returns 1 to run on.
s32 Script_ClearByte54 (struct ScriptInterpreter *interpreter)
 SC_B54_OFF: clears spriteStorageKind, hiding the sprites, and moves on to the next command.
s32 Script_SetByte54 (struct ScriptInterpreter *interpreter)
 SC_B54_ON: sets spriteStorageKind to 1, one sprite drawn, and moves on to the next command.
void FieldObject_WaitForMove (void *fieldObject)
 Waits a frame at a time until a field object has arrived at its target, at most 600 frames.
s32 Object_IsTargetUnset (struct ObjectRuntime *object)
 Returns 1 when the object has no movement target: none of its target coordinates set, or for an object moved by the ground (any motion flag) neither its target x nor z.
static __inline__ s32 ObjectMotion_Square (s32 value)
void Object_UpdateAllThumb (void)
 Advances all 64 field objects by one frame, as Object_UpdateAll does for the eight script objects, with the field's extras: free flight in 3D, terrain following, floating, and solid objects that refuse to overlap.
void Object_SetPositionAndResetMotion (struct ObjectRuntime *object, s32 x, s32 y, s32 z)
 Places the object at (x, y, z), in 16.16 pixels, clears its movement target and stops it.
void Object_SetMoveTarget (struct ObjectRuntime *object, s32 x, s32 y, s32 z)
 Sends an object towards (x, y, z), in 16.16 pixels.
UNUSED void Object_RunUpdateAllFromHeap (void)
 Copies Object_UpdateAll (ARM code) to the heap, runs it once and frees it.
void Object_UpdateAllMotion (void)
 Advances the first 14 objects' motion by one frame, without running their scripts: steering towards a target or braking, gravity and bouncing, arrival, and turning to face the direction of travel.

Detailed Description

Object motion, each frame, and the first object script commands.

Part of field.c, the field object, compiled only through it.

Definition in file object_motion.c.

Function Documentation

◆ Script_SetBase()

s32 Script_SetBase ( struct ScriptInterpreter * interpreter)

SC_BASE: restarts the script at the next word, and returns 1 to run on.

Definition at line 8 of file object_motion.c.

Referenced by Script_SetBase().

◆ Script_ClearByte54()

s32 Script_ClearByte54 ( struct ScriptInterpreter * interpreter)

SC_B54_OFF: clears spriteStorageKind, hiding the sprites, and moves on to the next command.

Definition at line 20 of file object_motion.c.

Referenced by Script_ClearByte54().

◆ Script_SetByte54()

s32 Script_SetByte54 ( struct ScriptInterpreter * interpreter)

SC_B54_ON: sets spriteStorageKind to 1, one sprite drawn, and moves on to the next command.

Definition at line 28 of file object_motion.c.

Referenced by Script_SetByte54().

◆ FieldObject_WaitForMove()

void FieldObject_WaitForMove ( void * fieldObject)

◆ Object_IsTargetUnset()

s32 Object_IsTargetUnset ( struct ObjectRuntime * object)

Returns 1 when the object has no movement target: none of its target coordinates set, or for an object moved by the ground (any motion flag) neither its target x nor z.

Called by FieldObject_WaitForMove and SC_SYNC (Script_WaitForArrival).

Definition at line 52 of file object_motion.c.

Referenced by FieldObject_WaitForMove(), Object_IsTargetUnset(), and Script_WaitForArrival().

◆ ObjectMotion_Square()

__inline__ s32 ObjectMotion_Square ( s32 value)
static

Definition at line 72 of file object_motion.c.

Referenced by Object_UpdateAllThumb(), and ObjectMotion_Square().

◆ Object_UpdateAllThumb()

void Object_UpdateAllThumb ( void )

Advances all 64 field objects by one frame, as Object_UpdateAll does for the eight script objects, with the field's extras: free flight in 3D, terrain following, floating, and solid objects that refuse to overlap.

ObjectSystem_Initialize schedules it as the per-frame object update in every mode but the battle's (4). Writes each live object's position, velocity, target, wait and facing.

Definition at line 80 of file object_motion.c.

Referenced by Object_UpdateAllThumb(), and ObjectSystem_Initialize().

◆ Object_SetPositionAndResetMotion()

void Object_SetPositionAndResetMotion ( struct ObjectRuntime * object,
s32 x,
s32 y,
s32 z )

Places the object at (x, y, z), in 16.16 pixels, clears its movement target and stops it.

Reached through SC_POS and FieldObject_Create, and as Object_SetPositionAndResetMotionFar from the Psynergy effects and the field scene's actors.

Definition at line 402 of file object_motion.c.

Referenced by FieldObject_Create(), Object_SetPositionAndResetMotion(), and Script_SetPositionAndResetMotion().

◆ Object_SetMoveTarget()

void Object_SetMoveTarget ( struct ObjectRuntime * object,
s32 x,
s32 y,
s32 z )

Sends an object towards (x, y, z), in 16.16 pixels.

Within a pixel it arrives at once. Unless it snaps to its target, the target is pulled in by half its braking distance (speed limit squared over acceleration), or to halfway when that is further, as the object coasts on. Picks the axis to watch for arrival: the one with the furthest to go (y only for a free-flying object).

Reached through SC_MOVE and the other move commands, the player control, and as Object_SetMoveTargetFar from the battle's motion, the battle effects and the Psynergy effects. Sets the target and arrivalAxis.

Definition at line 423 of file object_motion.c.

Referenced by FieldObject_UpdatePlayerControl(), Object_ApproachLinkedObject(), Object_MoveByKeys(), Object_MoveOnWorldMap(), Object_SetMoveTarget(), Object_Wander(), Script_ApplyAbsolutePosition(), Script_ApplyLinkedObjectPosition(), Script_ApplyLocalOffsetPosition(), Script_ApplyRelativePosition(), and ScriptObject_WanderNearHome().

◆ Object_RunUpdateAllFromHeap()

UNUSED void Object_RunUpdateAllFromHeap ( void )

Copies Object_UpdateAll (ARM code) to the heap, runs it once and frees it.

Definition at line 489 of file object_motion.c.

Referenced by Object_RunUpdateAllFromHeap().

◆ Object_UpdateAllMotion()

void Object_UpdateAllMotion ( void )

Advances the first 14 objects' motion by one frame, without running their scripts: steering towards a target or braking, gravity and bouncing, arrival, and turning to face the direction of travel.

ObjectSystem_Initialize schedules it in place of Object_UpdateAllThumb in mode 4, the battle's.

Definition at line 502 of file object_motion.c.

Referenced by Object_UpdateAllMotion(), and ObjectSystem_Initialize().