Field objects: the object pool, dissolving sprites, starting scripts. More...
Go to the source code of this file.
Macros | |
| #define | OBJECT_DISPATCH_DEFINE_APPLY(name, object_type, apply) |
| Defines name(object, value), which calls apply(sprite, value) on an object's one sprite, or on each sprite of its group. | |
Functions | |
| void | Map_RenderAnimatedTileFrame (u8 *obj, u32 pos) |
| One step of dissolving a sprite pixel by pixel. | |
| void | Map_RenderAnimatedTileFramesForObject (u8 *sprite) |
| Dissolves a sprite pixel by pixel, four steps a frame, over 32 frames. | |
| void | Map_RenderAllAnimatedTileFrames (u8 **sprites, s32 count) |
| Dissolves count sprites together, pixel by pixel, over 32 frames. | |
| s32 | Map_GetScreenRelativePosition (struct ObjectRuntime *object, s32 *screenPosition) |
| Writes the object's screen position, in pixels, to screenPosition[0..1] and returns 0 when it is on or near the screen; otherwise writes 0, 0 and returns -1. | |
| void | ObjectSystem_Initialize (s32 controlMode) |
| Sets up the object system: allocates and zeroes the 64 objects and registers the per-frame updates. | |
| UNUSED void | ResourceTable_ReservedNoOpC0C4 (void) |
| UNUSED void | ResourceTable_ReservedNoOp2 (void) |
| void * | ObjectDispatch_FindFreeObject (void) |
| Returns the first of the 64 objects not in use (with no script), or 0. | |
| void | ObjectDispatch_Release (struct DispatchObject *object) |
| Releases an object's sprites and zeroes it, freeing it. | |
| struct ObjectRuntime * | FieldObject_Create (s32 encodedSprite, s32 x, s32 y, s32 z) |
| Creates a field object at (x, y, z), in 16.16 pixels, or returns 0 when none is free. | |
| void | ObjectDispatch_Initialize (struct DispatchObject *object, const s32 *script) |
| Gives an object a script and starts it from the top. | |
| void | ObjectDispatch_SelectAnimation (void *rawObject, s32 value) |
| Switches all of an object's sprites to animation value. | |
| void | ObjectDispatch_SetAnimationSpeed (struct DispatchObject *rawObject, s32 value) |
| Sets the animation speed (timer step) of all of an object's sprites. | |
| void | ObjectDispatch_SetAnimationAndSpeed (struct DispatchObject *object, s32 animation, s32 step) |
| Both of the above: switches all of an object's sprites to animation and sets their timer step to step. | |
| void | ObjectDispatch_SetChildRotation (struct DispatchObject *object, u32 rotation) |
| Sets the rotation of an object's sprite, when it has just one. | |
| void | Animation_SetIndexAndInitObjects (void *rawDispatchObject, s32 animationId) |
| Gives a one-sprite object's first layer animation id animationId and restarts its layers. | |
| void | ObjectDispatch_RegisterChildMetadata (struct DispatchObject *object, s32 animationId) |
| Adds a layer of animation id animationId to a one-sprite object's sprite. | |
| void | ObjectDispatch_StartApproachLink (struct DispatchObject *object, s32 linkedObjectHandle) |
| Starts an object on the script that approaches its linked object (SC_APPROACH_LINK), linked to linkedObjectHandle. | |
| void | ObjectDispatch_StartKeyCheck (struct DispatchObject *object) |
| Starts an object on the script that runs SC_KEY_COUNT every frame. | |
| void | ObjectDispatch_StartMoveByKeys (struct DispatchObject *object) |
| Starts an object on the script that moves it by the keys (SC_KEYS). | |
| void | ObjectDispatch_StartPlayerControl (struct DispatchObject *object) |
| Starts an object on the player control script (SC_PLAYER). | |
| void | ObjectDispatch_StartWorldMapControl (struct DispatchObject *object) |
| Starts an object on the world map control script (SC_WORLD). | |
| void | ObjectDispatch_StartIdle (struct DispatchObject *object) |
| Starts an object on the idle script (a lone SC_END). | |
| void | ObjectDispatch_StartCamera (struct DispatchObject *object, s32 linkedObjectHandle) |
| Starts an object on the camera script (SC_CAMERA). | |
| void | ObjectDispatch_WaitForValue16 (void *rawObject) |
| Waits until the object's script reaches SC_END (0x10), at most 300 frames. | |
| void | ObjectDispatch_SetSingleChildFlags (struct DispatchObject *object, u32 flags) |
| Sets the flags of a one-sprite object's sprite (bit 0: draw its shadow). | |
| void | ObjectDispatch_SetChildBlendMode (struct DispatchObject *object, u32 mode) |
| Sets the OAM blend mode of a one-sprite object's sprite. | |
| void | ObjectDispatch_SetChildFixedScale (struct DispatchObject *object, u32 fixedScale) |
| Makes the fixed camera draw a one-sprite object at its own scale instead of scaling it by distance. | |
| void | Animation_ApplyChildValues (struct DispatchObject *object, u32 param) |
| Sets the draw parameter of a one-sprite object's layers (see ObjectGroup_SetChildValueUnlessFifteen). | |
| void | ObjectSystem_SuspendProjectionAndShowSprites (void) |
| Suspends the object camera updates, starts the palette back to normal and, a frame later, shows the sprites with BG1-3 hidden, leaving BG0 unchanged. | |
| void | ObjectSystem_ResumeProjectionAndHideLayers (void) |
| Resumes the object camera updates and hides BG1-3 and the sprites. | |
| UNUSED s32 | ObjectDispatch_ReturnTrue (void) |
Field objects: the object pool, dissolving sprites, starting scripts.
Part of field.c, the field object, compiled only through it.
Definition in file objects.c.
| #define OBJECT_DISPATCH_DEFINE_APPLY | ( | name, | |
| object_type, | |||
| apply ) |
Defines name(object, value), which calls apply(sprite, value) on an object's one sprite, or on each sprite of its group.
Definition at line 336 of file objects.c.
Referenced by ObjectDispatch_SelectAnimation().
One step of dissolving a sprite pixel by pixel.
In each 8x8 tile (256 colours) one pixel is cleared, in gMap_TileDissolveOrder's order; each tile runs one step ahead of the last, and only tiles whose step is 64-127 clear a pixel. obj is the sprite (struct AnimationObject), pos the step (0-127). Writes the sprite's tiles in OBJ VRAM. Called by the two functions below and, as render_animated_tile_frameFar, by the battle's playback (battle/battle/playback.c).
Definition at line 14 of file objects.c.
Referenced by Map_RenderAllAnimatedTileFrames(), Map_RenderAnimatedTileFrame(), and Map_RenderAnimatedTileFramesForObject().
| void Map_RenderAnimatedTileFramesForObject | ( | u8 * | sprite | ) |
Dissolves a sprite pixel by pixel, four steps a frame, over 32 frames.
Called through Map_RenderAnimatedTileFramesForObjectFar by the auto battle (battle/battle/auto_battle.c).
Definition at line 62 of file objects.c.
Referenced by Map_RenderAnimatedTileFramesForObject().
Dissolves count sprites together, pixel by pixel, over 32 frames.
Called through Map_RenderAllAnimatedTileFramesFar by the battle's staging (battle/battle/staging.c), after the unit is taken off its lists.
Definition at line 80 of file objects.c.
Referenced by Map_RenderAllAnimatedTileFrames().
| s32 Map_GetScreenRelativePosition | ( | struct ObjectRuntime * | object, |
| s32 * | screenPosition ) |
Writes the object's screen position, in pixels, to screenPosition[0..1] and returns 0 when it is on or near the screen; otherwise writes 0, 0 and returns -1.
Definition at line 114 of file objects.c.
Referenced by Map_GetScreenRelativePosition().
| void ObjectSystem_Initialize | ( | s32 | controlMode | ) |
Sets up the object system: allocates and zeroes the 64 objects and registers the per-frame updates.
Mode 4 moves objects with Object_UpdateAllMotion; modes 3 and 4 use the fixed camera.
Called through ObjectSystem_InitializeFar by the field scene runner (object/object/run_scene.c: 2 for a layered map, MODE_WORLD_MAP for the world map) and the battle's encounter (4), and directly by the sprite viewer (2). Allocates heap slot 6 for the ObjectSystemWork and slot 5 for the objects, and sets the sprite outline colours.
Definition at line 157 of file objects.c.
Referenced by ObjectSystem_Initialize(), and Ui_RunIconMonitor().
| UNUSED void ResourceTable_ReservedNoOpC0C4 | ( | void | ) |
Definition at line 185 of file objects.c.
Referenced by ResourceTable_ReservedNoOpC0C4().
| UNUSED void ResourceTable_ReservedNoOp2 | ( | void | ) |
Definition at line 187 of file objects.c.
Referenced by ResourceTable_ReservedNoOp2().
| void * ObjectDispatch_FindFreeObject | ( | void | ) |
Returns the first of the 64 objects not in use (with no script), or 0.
Called by FieldObject_Create.
Definition at line 191 of file objects.c.
Referenced by FieldObject_Create(), and ObjectDispatch_FindFreeObject().
| void ObjectDispatch_Release | ( | struct DispatchObject * | object | ) |
Releases an object's sprites and zeroes it, freeing it.
Clearing the script lets ObjectDispatch_FindFreeObject hand the object out again. Reached through SC_FREE (Script_FreeObject) and, as ObjectDispatch_ReleaseFar, from the battle, the Psynergy effects and the field scene's objects.
Definition at line 212 of file objects.c.
Referenced by ObjectDispatch_Release(), and Script_FreeObject().
| struct ObjectRuntime * FieldObject_Create | ( | s32 | encodedSprite, |
| s32 | x, | ||
| s32 | y, | ||
| s32 | z ) |
Creates a field object at (x, y, z), in 16.16 pixels, or returns 0 when none is free.
id / 4096 is the kind (0: one sprite, 2: two sprites, id and id + 1) and the low 12 bits the sprite's animation id.
Called as Object_CreateFar by the battle's placement, the Psynergy effects, the field scene's actors and markers and the scene scripts, and directly by the player control for footprints (25) and ripples (24). Gives the object gObjectDispatch_DefaultScript (a lone SC_END), its home position and the default motion values; a group's sprite list is taken from the ObjectSystemWork's group tables.
Definition at line 245 of file objects.c.
Referenced by FieldObject_Create(), FieldObject_UpdatePlayerControl(), and Object_MoveOnWorldMap().
| void ObjectDispatch_Initialize | ( | struct DispatchObject * | object, |
| const s32 * | script ) |
Gives an object a script and starts it from the top.
Sets the script and clears the cursor, the pause, the loop count and the last flag test. Called by the Start functions below and the player control, and as ObjectDispatch_InitializeFar by the battle's placement, the Psynergy effects and the field scene's events.
Definition at line 323 of file objects.c.
Referenced by FieldObject_UpdatePlayerControl(), Object_MoveOnWorldMap(), ObjectDispatch_Initialize(), ObjectDispatch_StartApproachLink(), ObjectDispatch_StartCamera(), ObjectDispatch_StartIdle(), ObjectDispatch_StartKeyCheck(), ObjectDispatch_StartMoveByKeys(), ObjectDispatch_StartPlayerControl(), and ObjectDispatch_StartWorldMapControl().
| void ObjectDispatch_SelectAnimation | ( | void * | rawObject, |
| s32 | value ) |
Switches all of an object's sprites to animation value.
Definition at line 365 of file objects.c.
Referenced by FieldObject_UpdatePlayerControl(), Object_ApproachLinkedObject(), Object_MoveByKeys(), Object_MoveOnWorldMap(), and Script_SetAnimation().
| void ObjectDispatch_SetAnimationSpeed | ( | struct DispatchObject * | rawObject, |
| s32 | value ) |
Sets the animation speed (timer step) of all of an object's sprites.
Definition at line 370 of file objects.c.
Referenced by CrossboneIslePlatformRooms_InitializeScene3(), Event_BaneLastEscape(), Event_BaneSecondEscape(), Imil_RunIceSlide(), Imil_SlideActorAcrossIce(), Imil_TurnSkaterTowardHeldDirection(), Imil_TurnSlidingActor(), ObjectDispatch_SelectAnimation(), and TolbiSpring_SetActorAppearance().
| void ObjectDispatch_SetAnimationAndSpeed | ( | struct DispatchObject * | object, |
| s32 | animation, | ||
| s32 | step ) |
Both of the above: switches all of an object's sprites to animation and sets their timer step to step.
Definition at line 374 of file objects.c.
Referenced by ObjectDispatch_SetAnimationAndSpeed().
| void ObjectDispatch_SetChildRotation | ( | struct DispatchObject * | object, |
| u32 | rotation ) |
Sets the rotation of an object's sprite, when it has just one.
Definition at line 401 of file objects.c.
Referenced by ObjectDispatch_SetChildRotation().
| void Animation_SetIndexAndInitObjects | ( | void * | rawDispatchObject, |
| s32 | animationId ) |
Gives a one-sprite object's first layer animation id animationId and restarts its layers.
A negative animationId does nothing.
Definition at line 410 of file objects.c.
Referenced by Animation_SetIndexAndInitObjects().
| void ObjectDispatch_RegisterChildMetadata | ( | struct DispatchObject * | object, |
| s32 | animationId ) |
Adds a layer of animation id animationId to a one-sprite object's sprite.
A negative animationId does nothing.
Definition at line 426 of file objects.c.
Referenced by Event_DoraWakesIsaac(), and ObjectDispatch_RegisterChildMetadata().
| void ObjectDispatch_StartApproachLink | ( | struct DispatchObject * | object, |
| s32 | linkedObjectHandle ) |
Starts an object on the script that approaches its linked object (SC_APPROACH_LINK), linked to linkedObjectHandle.
The functions below start the engine's other scripts (object_script.c).
Definition at line 438 of file objects.c.
Referenced by ObjectDispatch_StartApproachLink().
| void ObjectDispatch_StartKeyCheck | ( | struct DispatchObject * | object | ) |
Starts an object on the script that runs SC_KEY_COUNT every frame.
The field scene runner (object/object/run_scene.c) gives it to the leader when gGameState.movementMode is 2.
Definition at line 447 of file objects.c.
Referenced by ObjectDispatch_StartKeyCheck().
| void ObjectDispatch_StartMoveByKeys | ( | struct DispatchObject * | object | ) |
Starts an object on the script that moves it by the keys (SC_KEYS).
The field scene runner gives it to the leader when gGameState.movementMode is 1.
Definition at line 454 of file objects.c.
Referenced by ObjectDispatch_StartMoveByKeys().
| void ObjectDispatch_StartPlayerControl | ( | struct DispatchObject * | object | ) |
Starts an object on the player control script (SC_PLAYER).
The field scene runner's usual choice for the leader on a layered map.
Definition at line 460 of file objects.c.
Referenced by ObjectDispatch_StartPlayerControl().
| void ObjectDispatch_StartWorldMapControl | ( | struct DispatchObject * | object | ) |
Starts an object on the world map control script (SC_WORLD).
The field scene runner gives it to the leader on the world map.
Definition at line 466 of file objects.c.
Referenced by ObjectDispatch_StartWorldMapControl().
| void ObjectDispatch_StartIdle | ( | struct DispatchObject * | object | ) |
Starts an object on the idle script (a lone SC_END).
Definition at line 471 of file objects.c.
Referenced by Colosso_WalkActorTo(), Colosso_WalkActorToAndStand(), ColossoLogRollingStage_PositionActor(), ColossoLogRollingStage_PositionAndActivateActor(), Event_UseBlackOrb(), ObjectDispatch_StartIdle(), and OverlayObject_ResetMotionFields().
| void ObjectDispatch_StartCamera | ( | struct DispatchObject * | object, |
| s32 | linkedObjectHandle ) |
Starts an object on the camera script (SC_CAMERA).
With a leader to follow, it also gets a speed limit of 4 pixels a frame and an acceleration of 0.5 (value30 and value34 are those fields). Called through ObjectDispatch_StartCameraFar by the field scene's actors, the Psynergy camera and the Colosso and Kolima Forest scenes.
Definition at line 480 of file objects.c.
Referenced by ColossoWall_RollLogToCell(), Event_PushPipeworksBlock(), Event_RollLongLog(), KolimaForestBend_RollLog(), and ObjectDispatch_StartCamera().
| void ObjectDispatch_WaitForValue16 | ( | void * | rawObject | ) |
Waits until the object's script reaches SC_END (0x10), at most 300 frames.
Called through ObjectDispatch_WaitForValue16Far by the Psynergy actor commands and by scenes that wait for a scripted move (Colosso, Venus Lighthouse, Vale).
Definition at line 495 of file objects.c.
Referenced by ColossoLog_CollectFinishEquipment(), ColossoRiver_CollectFinishItem(), ColossoWall_ApproachFinishAndTakeItem(), Event_MovePillarSwitchBlock(), Event_ShowMythrilBag(), and ObjectDispatch_WaitForValue16().
| void ObjectDispatch_SetSingleChildFlags | ( | struct DispatchObject * | object, |
| u32 | flags ) |
Sets the flags of a one-sprite object's sprite (bit 0: draw its shadow).
Definition at line 511 of file objects.c.
Referenced by ObjectDispatch_SetSingleChildFlags().
| void ObjectDispatch_SetChildBlendMode | ( | struct DispatchObject * | object, |
| u32 | mode ) |
Sets the OAM blend mode of a one-sprite object's sprite.
This one and the next two test the whole kind byte, not its low four bits, so an object with high kind bits set is left alone.
Definition at line 522 of file objects.c.
Referenced by ObjectDispatch_SetChildBlendMode().
| void ObjectDispatch_SetChildFixedScale | ( | struct DispatchObject * | object, |
| u32 | fixedScale ) |
Makes the fixed camera draw a one-sprite object at its own scale instead of scaling it by distance.
Definition at line 531 of file objects.c.
Referenced by ObjectDispatch_SetChildFixedScale().
| void Animation_ApplyChildValues | ( | struct DispatchObject * | object, |
| u32 | param ) |
Sets the draw parameter of a one-sprite object's layers (see ObjectGroup_SetChildValueUnlessFifteen).
Definition at line 541 of file objects.c.
Referenced by AltmillerCave_BeginRetreat(), and Animation_ApplyChildValues().
| void ObjectSystem_SuspendProjectionAndShowSprites | ( | void | ) |
Suspends the object camera updates, starts the palette back to normal and, a frame later, shows the sprites with BG1-3 hidden, leaving BG0 unchanged.
Called through ObjectSystem_SuspendProjectionAndShowSpritesFar by scenes (Colosso, the Tolbi ship, Vale, Venus Lighthouse). The scenes except Colosso pair it with ObjectSystem_ResumeProjectionAndHideLayers.
Definition at line 552 of file objects.c.
Referenced by ColossoLog_PlayPostBattleReunion(), Event_DoraWakesIsaac(), Event_MendingTheRoof(), ObjectSystem_SuspendProjectionAndShowSprites(), TolbiShipDeck_MonsterLandsOnDeck(), TolbiShipDeck_MonstersAttackCrew(), TolbiShipDeck_MonstersBoard(), and VenusLighthouseAerie_PlayShebasFall().
| void ObjectSystem_ResumeProjectionAndHideLayers | ( | void | ) |
Resumes the object camera updates and hides BG1-3 and the sprites.
Called through ObjectSystem_ResumeProjectionAndHideLayersFar by the same scenes except Colosso.
Definition at line 566 of file objects.c.
Referenced by Event_DoraWakesIsaac(), Event_MendingTheRoof(), ObjectSystem_ResumeProjectionAndHideLayers(), TolbiShipDeck_MonsterLandsOnDeck(), TolbiShipDeck_MonstersAttackCrew(), TolbiShipDeck_MonstersBoard(), and VenusLighthouseAerie_PlayShebasFall().
Definition at line 573 of file objects.c.
Referenced by ObjectDispatch_ReturnTrue().