object_motion.c
Object motion, each frame, and the first object script commands.
games/tbs/src/field/field/object_motion.c on GitHub
Object motion, each frame, and the first object script commands. Part of field.c, the field object, compiled only through it.
Functions
Script_SetBase
s32 Script_SetBase(struct ScriptInterpreter *interpreter)
SC_BASE: restarts the script at the next word, and returns 1 to run on.
Used by gScriptObject_CommandTable.
Script_ClearByte54
s32 Script_ClearByte54(struct ScriptInterpreter *interpreter)
SC_B54_OFF: clears spriteStorageKind, hiding the sprites, and moves on to the next command.
Used by gScriptObject_CommandTable.
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.
Used by gScriptObject_CommandTable.
FieldObject_WaitForMove
void FieldObject_WaitForMove(void *fieldObject)
Waits a frame at a time until a field object has arrived at its target, at most 600 frames. It takes void * because callers pass every view of an object. Called through FieldObject_WaitForMoveFar by the Psynergy effects and by about 50 scene overlays.
Used by ColossoLogRollingStage_PositionAndActivateActor, ColossoLog_PushActorAhead, ColossoRiver_MoveActorPairByOffset, ColossoRiver_PushObjectAhead, ColossoWall_MovePusherAndLog, ColossoWall_PushAdjacentObstacle, ColossoWall_PushBlockToCell, ColossoWall_RollLogToCell, Colosso_WalkActorToAndStand, CrossboneIsle_MoveSelectedActorAndBlock, Event_DousePipe, Event_KnockDownObstacle, Event_PassNorthWallOpening, Event_PassSouthWallOpening, Event_PushActorAhead, Event_PushBlock, Event_PushPipeworksBlock, Event_RollLongLog, Event_TalkToFreeClimbAttendant, Event_TalkToPipeworksAttendant, Event_TalkToScalesAttendant, Event_UseBlackOrb, Imil_RunIceSlide, Imil_SlideActorAcrossIce, Kalay_PushTunnelBlock, KolimaForestBend_RollLog, SceneActor_PlacePairAtOffset, SlideDownDune, StagedActor_AdvancePair, TolbiShipMast_ShowMonsters, VenusLighthouseAerie_CombineSaturosAndMenardi, VenusLighthouse_PushAdjacentBlock, VenusLighthouse_StepActorWithDust.
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).
Used by FieldObject_WaitForMove, Script_WaitForArrival.
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.
Used by 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.
Used by FieldObject_Create, 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.
Used by FieldObject_UpdatePlayerControl, Object_ApproachLinkedObject, Object_MoveByKeys, Object_MoveOnWorldMap, Object_Wander, ScriptObject_WanderNearHome, Script_ApplyAbsolutePosition, Script_ApplyLinkedObjectPosition, Script_ApplyLocalOffsetPosition, Script_ApplyRelativePosition.
Object_RunUpdateAllFromHeap
UNUSED void Object_RunUpdateAllFromHeap(void)
Copies Object_UpdateAll (ARM code) to the heap, runs it once and frees it.
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.
Used by ObjectSystem_Initialize.
Also, functions without a comment: ObjectMotion_Square.