Alchemy
Loading...
Searching...
No Matches

field.h File Reference

Go to the source code of this file.

Functions

u8 * Resource_DecompressLz (const u8 *source, u8 *destination)
 Decompresses an LZ stream from source into destination and returns destination.
s32 Sprite_ComposeAnimationFrame (struct AnimationObject *obj, u16 dir)
 Advances a sprite's animation layers by one frame, picks each layer's frame for the facing dir, and when any frame changed redraws the sprite: the layers composed by priority into one pixel buffer, an optional outline, and the result uploaded to the sprite's VRAM tiles.
void Render_PlaceSpritePartPair (struct AnimationObject *sprite, s32 screenX, s32 height, s32 screenY, s32 groundHeight, s32 *scale)
 Positions a sprite's image (part 0) and shadow (part 1) on the screen: the image centred on screenX and raised height above screenY, the shadow at groundHeight.
void Render_ApplyProjectedPlacement (struct AnimationObject *sprite, const struct SpritePlacement *position, const struct SpriteScale *scale, s32 facing)
 Places a sprite for the scrolling camera and queues it for drawing.
void Render_PlaceProjectedSprite (struct AnimationObject *sprite, s32 *point, s32 *scale, s32 facing, s32 depth)
 Places a sprite at 3D point for the fixed camera and queues it for drawing: projected to the screen and scaled by its distance (unless useOwnScale keeps its own scale), with an affine matrix as needed and its shadow on the ground below.
void ObjectGroup_SetChildValueUnlessFifteen (void *rawSprite, u32 value)
 Sets the draw parameter of each of a sprite's layers to value, except layers whose parameter is 15, and marks the sprite for redrawing.
s32 ResourceSlot_Load (u32 slot, u32 *buffer, s32 number, u32 variant)
 Loads the frames of animation id number into resource slot slot's buffer: the resource listed for it in gResourceSlot_NumberTable, decoded, its frame offsets turned into pointers, and for variant 1-5 its pixel colours (those up to 0xdf) remapped through that variant's conversion table.
s32 Animation_LookupValueByKey (s32 tag)
 Returns the buffer loaded into the resource slot with this tag, or 0.
s32 Animation_InitializeObjects (struct AnimationObject *sprite)
 Resets each layer of a sprite from its animation's metadata: its facing kind, frames, scripts and codec, with no frame shown and no script running.
void Animation_InitWorkFromMetadata (struct AnimationEntry *layer)
 Resets one animation layer from its animation's metadata, as Animation_InitializeObjects does for each layer.
s32 ResourceMetadata_Register (struct AnimationObject *sprite, s32 id)
 Adds a layer of animation id to a sprite, in its first free layer of four.
void ResourceMetadata_Unregister (struct AnimationObject *sprite, s32 layer)
 Removes the layer handle from a sprite and clears it, trimming the sprite's layer count when no later layer remains.
void ResourceMetadata_ReleaseSlot (struct AnimationObject *sprite, u32 index)
 Removes and clears a sprite's layer number no (0-3), trimming the sprite's layer count when no later layer remains.
void Animation_SetWorkEntry (struct AnimationEntry *layer, s32 animation)
 Starts the indexed animation on a layer when its metadata contains it.
s32 AnimationObjects_SelectAnimation (struct AnimationObject *sprite, s32 animation)
 Starts animation flags & 0x7f on every layer of a sprite (bit 7 keeps each layer's place and timer), unless the sprite plays it already.
s32 AnimationObjects_SetActiveFrameTimers (struct AnimationObject *sprite, s32 frames)
 Sets each animated layer's timer to the given duration in frames.
void AnimationObjects_SetActiveTimerSteps (struct AnimationObject *sprite, s32 step)
 Sets the timer step, the animation speed, of each animated layer of a sprite (16 is normal speed).
void ObjectSystem_Configure (s32 mode)
 Allocates and zeroes the 64 sprites and 64 animation layers (from the fixed blocks in mode 3, the heap otherwise), sets up the palette DMA, loads the shadow tiles into VRAM cache entry 93 and puts the sprite tile uploader in RAM.
struct AnimationEntry * AnimationObject_Allocate (s32 id)
 Takes a free animation layer record and starts it on animation id's first animation.
void ResourceMetadata_ClearRecord (struct AnimationEntry *record)
 Zeroes one animation layer (struct AnimationEntry); does nothing for NULL.
struct AnimationObject * ResourceObject_Create (s32 id)
 Creates a sprite for animation id, taking one of the 64 free sprites and a VRAM cache entry for its tiles.
void ResourceObject_Release (struct AnimationObject *sprite)
 Releases a sprite: its VRAM cache entry (unless retainCacheEntry is set), its four animation layers, and then zeroes its 56 bytes.
s32 ResourceMetadata_SumCommandLengths (s32 id, u32 animation, s32 frameCount)
 Returns how long the first frameCount frames of animation number animation of id last: the sum of the arguments of its frame, wait and blank commands, up to frameCount of them or the first play, hold, jump or end command.
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.
void ObjectDispatch_SelectAnimation (void *raw, s32 no)
 Switches all of an object's sprites to animation value.
void ObjectDispatch_SetAnimationSpeed (struct DispatchObject *obj, s32 val)
 Sets the animation speed (timer step) of all of an object's sprites.
s32 Script_SetFlagAndTest (struct ScriptInterpreter *interpreter)
 SC_FLAG_ON(f) and SC_FLAG_OFF(f): test game flag f, then set or clear it.
s32 Script_ClearFlagAndTest (struct ScriptInterpreter *interpreter)
void Script_SetOrCompareAddress (struct ScriptOperands *state, s32 operation, s32 value)
 The work value handlers, one for each entry of enum ScriptWork (see gScript_OperandHandlerTable in operand.c); each names the object field it sets, adds to or compares.
void Script_SetOrCompareUnsignedHalfword (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareX (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareY (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareZ (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareScaleX (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareScaleY (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareVelocityX (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareVelocityY (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareVelocityZ (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareSpeedLimit (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareAcceleration (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareTargetX (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareTargetY (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareTargetZ (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareVerticalMotion (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareGravity (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareTerrainHeight (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareWord4c (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareAddress50 (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareByte54 (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareMotionFlags (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareArrivalAxis (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareComparisonResult (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareSnapToTarget (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareCollisionFlags (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareSteeringFlags (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrComparePaused (struct ScriptOperands *state, s32 operation, s32 value)
void Script_SetOrCompareRepeatCount (struct ScriptOperands *work, s32 operation, s32 value)
void Script_SetOrCompareSignedHalfword64 (struct ScriptOperands *work, s32 operation, s32 value)
void Script_SetOrCompareSignedHalfword66 (struct ScriptOperands *work, s32 operation, s32 value)
void Script_SetOrCompareWord68 (struct ScriptOperands *work, s32 operation, s32 value)
void Script_SetOrCompareUpdateAddress (struct ScriptOperands *work, s32 operation, s32 value)
void Script_SetOrCompareByte62 (struct ScriptOperands *work, s32 operation, s32 value)
void Script_SetOrCompareByte63 (struct ScriptOperands *work, s32 operation, s32 value)
void Ui_SetGridColumnParameter (s32 slot, s32 value)
 Sets the draw parameter or the priority of one layer of the viewer's ten sprites.
void Ui_SetGridColumnPriority (s32 slot, s32 value)
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.
void ResourceTable_ReservedNoOpC0C4 (void)
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_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.
s32 ObjectDispatch_ReturnTrue (void)
void ObjectSystem_UpdateCamera (void)
 Each frame, with the scrolling camera: places every object's sprite on the screen.
s32 ObjectCamera_ReturnTrue (void)
void ObjectSystem_UpdateCameraFixed (void)
 Each frame, with the fixed camera: places every object's sprite, from the 64th object down, facing them by the angle from the eye to the target.
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.
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.
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.
s32 Script_Wait (struct ScriptInterpreter *interpreter)
 SC_WAIT(n): waits n frames; this frame counts as the first.
s32 Script_WaitForArrival (struct ScriptInterpreter *interpreter)
 SC_SYNC: waits until the object arrives at its target, or until a solid object has blocked it for 60 frames (refused is the blocked count, which Object_UpdateAllThumb raises).
s32 Script_InvokeCallback (struct ScriptInterpreter *interpreter)
 SC_CALL(fn): calls fn with the object.
s32 Script_FindLabel (struct ScriptInterpreter *interpreter, u32 labelKey)
 Returns the cursor just past the script's label key (SC_LABEL or SC_TO, matched without the bit that tells them apart), searching its first 1024 words, or 0 (the start) when key is 0 or not found.
s32 Script_RepeatOrJump (struct ScriptInterpreter *interpreter)
 SC_LOOP(n, to): jumps to label to until it has done so n - 1 times, then moves on; with n = SC_FOREVER it always jumps.
s32 Script_JumpToLabel (struct ScriptInterpreter *interpreter)
 SC_JUMP(to): jumps to label to.
s32 Script_JumpIfTrue (struct ScriptInterpreter *interpreter)
 SC_IF(to): jumps to label to when the last test was true.
s32 Script_JumpIfFalse (struct ScriptInterpreter *interpreter)
 SC_IFNOT(to): jumps to label to when the last test was false.
s32 Script_End (struct ScriptInterpreter *interpreter)
 SC_END: hands the object back to the idle script, gScript_MainScript, whose lone SC_END runs again each frame.
s32 Script_TestFlag (struct ScriptInterpreter *interpreter)
 SC_FLAG_CHECK(f): tests game flag f.
s32 Script_ToggleFlagAndTest (struct ScriptInterpreter *interpreter)
 SC_FLAG_REV(f): tests game flag f, then flips it.
s32 Script_SetAnimation (struct ScriptInterpreter *interpreter)
 SC_ARG(v): switches the object's sprites to animation v.
s32 Script_FreeObject (struct ScriptInterpreter *interpreter)
 SC_FREE: releases the object through ObjectDispatch_Release, which releases its sprites and zeroes its slot.
s32 Script_Nop (struct ScriptInterpreter *interpreter)
 SC_NOP(v): does nothing with its operand.
s32 Script_PlaySound (struct ScriptInterpreter *interpreter)
 SC_SE(n): sends sound command n (a sound effect).
s32 ScriptObject_CheckOverlap (struct ScriptObjectEntry *object, s32 *values)
 Returns -1 when an object at position values would overlap a solid object (bit 0 of collisionFlags), each radius less 2 pixels; otherwise 0.
struct ScriptObjectEntry * ScriptObject_FindOverlappingEntry (struct ScriptObjectEntry *object, s32 *values)
 Returns the first solid object that an object at position values would overlap, as ScriptObject_CheckOverlap tests, or NULL.
s32 Script_SetPositionAndResetMotion (struct ScriptInterpreter *interpreter)
 SC_POS(x, y, z): places the object at (x, y, z) and stops it.
s32 Script_ApplyAbsolutePosition (struct ScriptInterpreter *interpreter)
 SC_MOVE(x, y, z): sends the object towards (x, y, z).
s32 Script_ApplyRelativePosition (struct ScriptInterpreter *interpreter)
 SC_MOVE_BY(x, y, z): sends the object towards its position plus (x, y, z).
s32 Script_StoreAngleToLinkedObject (struct ScriptInterpreter *interpreter)
 SC_FACE_LINK: stores the angle from the object to its linked object in scriptValue, measured on the ground plane (x and z).
s32 Script_ApplyLinkedObjectPosition (struct ScriptInterpreter *interpreter)
 SC_MOVE_LINK: sends the object towards its linked object.
s32 Script_ApplyLocalOffsetPosition (struct ScriptInterpreter *interpreter)
 SC_MOVE_LOCAL(a, b): sends the object towards its position plus an offset that is never filled in; the operands are skipped unread.
s32 Camera_FollowLeaderInBounds (struct ScriptInterpreter *interpreter)
 SC_CAMERA: keeps the camera object on its leader (linkedObject), clamped so the view stays on the map.
s32 Object_ApproachLinkedObject (struct ScriptInterpreter *interpreter)
 SC_APPROACH_LINK: follows the linked object at its speed.
s32 Object_Wander (struct ScriptInterpreter *interpreter)
 SC_WANDER(base, range, limit): walks to a random point base to base + range away, within 90 degrees either side of its heading (scriptValue), that no solid object or wall blocks, with clear ground 8 pixels further at 45 degrees either side, and within limit pixels of home.
s32 ScriptObject_WanderNearHome (struct ScriptInterpreter *interpreter)
 SC_WANDER_HOME(base, range, limit): wanders as SC_WANDER does, testing more ground around the point, while it is within limit pixels of home; outside that, or when no point works, it heads back towards home.
void Script_SetOrCompareCursor (struct ScriptOperands *operands, s32 operation, s32 value)
 Work value SW_CURSOR: sets, adds to or compares the script cursor.
void Script_SetOrCompareRadius (struct ScriptOperands *state, s32 operation, s32 value)
 Work value SW_RADIUS: sets, adds to or compares the object's radius.
void Script_SetOrCompareHalfword5e (struct ScriptOperands *work, s32 operation, s32 value)
 Work value SW_WAIT: sets, adds to or compares the wait counter.
s32 Script_ApplyOperandSet (struct ScriptInterpreter *interpreter)
 SC_SET(w, v): sets work value w to v.
s32 Script_ApplyOperandAdd (struct ScriptInterpreter *interpreter)
 SC_ADD(w, v): adds v to work value w.
s32 Script_ApplyOperandCompare (struct ScriptInterpreter *interpreter)
 SC_CMP(w, v): tests whether work value w equals v.
void ObjectDispatch_SetUpdateValue (void *rawObject, s32 value)
 Stores value as a word at the object's unk6c.
u32 Field_RequestShortcut (u32 encodedAssignment)
 Handles a shortcut key's assignment: its top two bits choose what it requests (0 Psynergy, 1 an item) and the low 14 bits which one.
s32 Field_CheckConfiguredKeys (void)
 Checks the keys the player has configured: Select, A and Start set their flag in the event work and return 1; the two shortcut keys pass on their assignment (Field_RequestShortcut).
s32 Runtime_CheckRadiusOverlap (s32 *firstPosition, s32 radiusA, s32 *secondPosition, s32 radiusB)
 Returns 0 when two spheres overlap: at positions a and b (16.16 pixels) with radii radiusA and radiusB (pixels); -1 otherwise.
s32 FieldObject_UpdatePlayerControl (struct ScriptInterpreter *interpreter)
 SC_PLAYER: moves the player on the field by the direction pad: walking or running, sliding around walls, pushing movable objects, turning, playing the matching animation and leaving footprints.
s32 Object_MoveOnWorldMap (struct ScriptInterpreter *interpreter)
 SC_WORLD: moves the player on the world map by the direction pad, as SC_PLAYER does on the field, and turns the world map camera with the pad.
s32 Field_CheckConfiguredKeysAndCount (struct ScriptInterpreter *interpreter)
 SC_KEY_COUNT: checks the configured keys (Field_CheckConfiguredKeys).
s32 Object_MoveByKeys (struct ScriptInterpreter *interpreter)
 SC_KEYS: moves an object 8 pixels at a time by the direction pad, with up and down changing its height (y) rather than its depth.
void Runtime_RemapBytesByTable (u8 *bytes, s32 byteCount)
 Remaps byteCount bytes in place through gRuntime_ByteRemapTable.
void Tilemap_DecodeStagedBuffer (s32 size)
 Unpacks the staged block data into gMapBlocks.
void Tilemap_NumberPlaceholderBlocks (void)
 Gives each map cell whose block number is 0xfff (a placeholder) a number of its own, counting up from 0 in map order.
void Tilemap_ConvertBuffer (void)
 Converts the map's cells in place with Tile_ConvertMap, run from RAM, from a saved copy of the staged buffer.
s32 Map_LoadLayeredScene (s32 index)
 Loads layered scene index from gMap_LayeredScenes: its blocks, collision, cells, tile animations, blend script and marker list; sets up the three background layers' origins, parallax and wrap from the scene header; loads the palette and tile graphics unless FLAG_KEEP_LAYER_GRAPHICS says they are loaded; and starts the layer scrolling.
void Map_CenterOnFollowedPoint (void)
 Centres the camera on the point the map follows (origin: x, height, z), or on (0, 0) when there is none, and scrolls the layers there.
void Map_RenderMetatileRow (u32 layer, s32 tileX, s32 tileY)
 Draws a row of 16 blocks (32 tiles) of a layer's cells into its BG map (screen block 5 + layer), starting at tile (tileX, tileY); the BG map wraps every 32 tiles.
void Map_RenderMetatileColumn (u32 layer, s32 tileX, s32 tileY)
 Draws a column of 11 blocks of a layer's cells, one tile wide, into its BG map, starting at tile (tileX, tileY).
void Map_UpdateLayerScroll (void)
 Each frame on a layered map: centres the view on the point the map follows (origin), clamped to the map's bounds and shaken by any decaying screen shake; then scrolls each of the three layers by its parallax scale and automatic scroll (wrapping at its period), draws the block column or row that scrolls into view, and sets its BG scroll.
void Map_SetCameraCenter (s32 x, s32 y)
 Centres the view on (x, y) in 16.16 pixels, clamped to the map's bounds, and redraws every enabled layer's BG map around it.
void Map_CopyMetatileIndicesRect (s32 srcX, s32 srcY, u32 dstX, u32 dstY, u32 width, u32 height)
 Copies the block numbers of a rectangle of cells from (srcX, srcY) to (dstX, dstY), width by height cells, keeping each destination's attributes, and redraws the copied cells that are on screen.
void Map_PlayMetatileCopySequence (u16 *sequence, s32 destinationX, u32 destinationY)
 Plays a map edit sequence (struct MapCopyCommand records, ended by a source of 0xffff): copies each record's rectangle of block numbers to (destinationX, destinationY) and waits its delay in frames.
void Map_CopyMetatileCellsRect (s32 srcX, s32 srcY, s32 width, s32 height, s32 dstX, s32 dstY)
 Copies a rectangle of cells (16x16 pixels each) as they are, from (srcX, srcY) to (dstX, dstY), width by height cells.
void Map_CopyCellAttributeRect (s32 srcX, s32 srcY, s32 width, s32 height, s32 dstX, s32 dstY)
 Copies only the attributes of a rectangle of cells, from (srcX, srcY) to (dstX, dstY), width by height cells, keeping each destination cell's block number.
void Map_CopyCellIndexRect (s32 srcX, s32 srcY, s32 width, s32 height, s32 dstX, s32 dstY)
 Copies only the block numbers of a rectangle of cells, from (srcX, srcY) to (dstX, dstY), width by height cells, keeping each destination cell's attributes; cells in a visible area update the BG maps too.
void Map_SetShownLayers (u32 layerFlags)
 Sets which of BG1-BG3 the map shows (bits 9-11 of its display flags, as in REG_DISPCNT) from layerFlags, keeping its other flags.
s32 Map_WriteLayerCellTile (s32 layer, s32 x, s32 y, s32 tile, s32 update)
 Loads world map tile tile into quarter (x & 1, y & 1) of a layer's block buffer, decompressing it from the area's graphics, and with update set also draws it into the layer's BG map.
s32 Map_InitializePerspectiveScene (void)
 Sets up the world map's perspective view: BG2 and BG3 in affine mode, the camera work, the projection, the per-scanline ground plane routine in RAM (Transform_UpdateVertices) and its first frame, and the per-frame view and HBlank updates.
void Map_SetWindowCellTile (s32 x, s32 y, s32 px, s32 py)
 Puts world map tile (x / 16, y / 16) at cell (px / 16, py / 16) of the tile id grid, and draws it at once when it is next to the view.
void WorldMap_LoadGraphics (s32 x, s32 z)
 Loads the world map's palette and tiles for the area at (x, z): the second set where the ground there is terrain kind 21.
void MapAnimation_ApplyAffineFrame (void)
 HBlank setup each frame on the world map: copies the first scanline's BG2 and BG3 affine parameters, starts the HBlank DMA for the rest, and picks the BG mode from the window's top and bottom.
void Map_RenderPaletteMappedRow (u32 tileRow)
 Draws world map tileRow into the BG map: 32 cells, then 32 more a screen block on.
void Map_RenderPaletteMappedColumn (u32 tileColumn)
 Draws world map tileColumn into the BG map: 64 cells down.
void WorldMap_UpdateView (void)
 Each frame on the world map: loads tiles as the view moves, shakes and follows the player, draws the BG row or column that scrolls into view, moves the camera, and builds the ground plane's scanline table.
void Map_UpdateCurrentTileBlock (void)
 Loads and draws the 2x2 world map tiles around the player in both layers.
void Map_PreloadCurrentTileBlock (void)
 Loads the first of the 2x2 world map tiles around the player that is not shown yet (at most one a frame), without drawing it.
void MapAnimation_PresentFrame (void)
 VBlank: shows BG1 and copies the decoded frame's tiles into VRAM.
void WorldMap_BeginStillView (void)
 Freezes the world map's perspective view as a still picture on BG1: saves BG1's tiles, draws the current affine frame into pixels and hands the window and VBlank to it.
void Map_ShowBg1FromBuffer (void)
 VBlank: shows BG1 and copies the area's tiles back into VRAM.
void Map_LoadAreaGraphics (void)
 Reloads the world map area's palette and tiles after the still view, puts the default cells back and returns to the perspective view.
void Map_LoadDefaultCellsAndUpdateBlock (void)
 Puts the default world map cells back after the still view and returns to the perspective view, without reloading the area's palette or tiles.
void MapAnimation_Update (void)
 Each frame: runs the 16 tile animation channels.
void Map_ClearLayerEntryFlag (u32 channelIndex)
 Resumes tile animation channel channelIndex by clearing its paused byte.
void Map_SetLayerEntryFlag (u32 channelIndex)
 Pauses tile animation channel channelIndex by setting its paused byte.
void MapAnimation_StartChannels (const u16 *script)
 Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel NN & 15 there (paused when bit 7 is set).
void MapAnimation_Suspend (void)
 Suspends the tile animations, unless the world map's still view is shown.
void MapAnimation_Resume (void)
 Resumes the tile animations, unless the world map's still view is shown.
void DisplayBlend_RunScript (void)
 Each frame: runs the map's blend script.
void DisplayBlend_StartScript (u16 *script)
 Starts a map's blend script, unless it is empty.
void DisplayBlend_SuspendScript (void)
 Suspends the blend script.
void DisplayBlend_ResumeScript (void)
 Resumes the blend script, through DisplayBlend_ResumeScriptFar.
void PaletteQueue_Initialize (void)
 Allocates the palette cycling queue (heap slot 28) with its four entries cleared.
s32 PaletteQueue_Add (s16 paletteBank, s16 firstColor, s16 delay, s16 colorCount)
 Adds a palette cycle: colorCount colours of background palette paletteBank from firstColor, rotated by one every delay + 1 frames.
void PaletteQueue_Stop (void)
 Stops the palette cycles and frees their queue (heap slot 28).
void PaletteQueue_Start (void)
 Starts running the palette cycles each frame.
void PaletteQueue_StepCycles (void)
 Each frame: advances each palette cycle whose timer has run out by one colour, writing the rotated colours back to the palette.
s32 Curve_GetFirstSampleA (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 The terrain height functions (gMap_TerrainHeightFunctions): each takes a cell's height samples after its kind byte and a pixel (x, y) within the 16x16 cell, and returns the ground height there in 16.16 pixels.
s32 Curve_LerpTwoSamples (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 A slope along x: from sample 0 at x = 0 towards sample 1 at x = 16.
s32 Curve_LerpTwoSamplesB (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 A slope along y: from sample 0 at y = 0 towards sample 1 at y = 16.
s32 Curve_StepAtSummedPosition (const u8 *heightBytes, s32 x, s32 y)
 A step across the diagonal x + y = 15: sample 0 before it, sample 1 after it and the higher of the two on it.
s32 Curve_StepAtDifferencePosition (const u8 *heightBytes, s32 x, s32 y)
 A step across the diagonal x = y: sample 0 where y < x, sample 1 where y > x and the higher of the two on it.
s32 Curve_LerpThreeSamplesByRatio (const u8 *heightBytes, s32 x, s32 y)
 A slope that bends on the diagonal x + y = 15: from sample 0 at the top left corner to sample 1 on the diagonal to sample 2 at the bottom right.
s32 Curve_LerpThreeSamplesAtDifference (const u8 *heightBytes, s32 x, s32 y)
 A slope that bends on the diagonal x = y: from sample 0 at the top right corner to sample 1 on the diagonal to sample 2 at the bottom left.
s32 Curve_LerpTwoSamplesByTable (const u8 *heightBytes, s32 x, s32 y)
 A raised or sunken rounded square: sample 1 where gCurve_LerpWeightTable is 1, sample 0 in the corners.
s32 Curve_StepAtHalf (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 A step along x: sample 0 for x < 8, sample 1 from x = 8.
s32 Curve_StepAtHalfB (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 A step along y: sample 0 for y < 8, sample 1 from y = 8.
s32 Curve_LerpThreeSamplesAtHalf (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 A slope along x that bends at the middle: sample 0 at x = 0, sample 1 at x = 8, towards sample 2 at x = 16.
s32 Curve_LerpThreeSamplesAtHalfB (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 A slope along y that bends at the middle, as kind 10 does along x.
s32 Curve_LookupSampleByTable (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 The sample gCurve_SampleIndexTable picks for (x, y).
s32 Curve_LookupSampleByTableReversed (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 The same, with the table mirrored left to right.
s32 Curve_GetFirstSampleB (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 Flat, as Curve_GetFirstSampleA. Kind 14.
s32 Curve_GetFirstSampleC (const u8 *heightBytes, s32 pixelX, s32 pixelY)
 Flat, as Curve_GetFirstSampleA. Kind 15.
s32 Map_GetTerrainHeight (s32 layer, s32 x, s32 y)
 Returns the ground height of a layer at (x, y) in 16.16 pixels: the height function of the cell's terrain kind applied to its samples.
s32 Map_GetCellAttributeLowNibble (s32 layer, s32 x, s32 y)
 Returns the terrain kind (the low four bits of the first collision byte) of a layer's cell at (x, y) in 16.16 pixels.
s32 GetMapCellCollision (s32 layer, s32 x, s32 y)
 Returns the collision code of a layer's cell at (x, y) in 16.16 pixels.
void SetMapCellCollision (u32 layer, s32 x, s32 y, u32 collisionCode)
 Sets the collision code of a layer's cell at (x, y) in 16.16 pixels.
s32 Map_GetCellHighFlags (s32 x, s32 y)
 Returns the top two bits of the block word of the cell at pixel (x, y).
s32 Map_CheckObjectStep (struct ObjectRuntime *object, struct FieldPosition *position)
 Returns whether an object can step to position: 2 when the cell there is a wall (collision code 0xff), 1 when the ground is more than 8 pixels higher than the object's, -1 when it is more than 12 pixels lower, else 0.
s32 CheckMapPositionCellOccupied (struct WorldPosition *position)
 Returns 0 when the cell under position (its x, and y less its height) in layer 2 is a wall (collision code 0xff), else -1.
s32 GetWorldMapCollision (struct WorldPosition *position)
 Returns the world map's collision value (1-15) at position: from the upper collision layer where it has one, else the lower, else 7.
s32 CheckWorldMapWalkable (s32 unused, struct WorldPosition *position)
 Returns 0 when the world map at position can be walked on (collision 5 to 12), else -1.
s32 GetWorldMapTerrainBehavior (struct WorldPosition *position, s32 *terrainKind)
 Returns the world map's terrain behaviour at position from gWorldMap_TerrainBehaviorTable, and stores the block's terrain kind in terrainKind.
void Map_SetScreenShake (s32 shakeX, s32 shakeY, s32 shakeDecay)
 Changes the shake without restarting an axis whose argument is negative.
void Map_WaitForShakeToSettle (void)
 Waits until both shake amplitudes are below 1/256 pixel, with a 300-frame limit for a shake whose decay never settles.
void TileMap_DrawRowsFromRam (const struct MapAffinePair *lines, u8 *pixels)
 Draws the current affine page into the world map's still-view pixels.
void WorldMap_BuildScanlineTable (s32 depth, s32 *position, struct MapScanline *scanline)
 Rebuilds the ground plane's scanline terms when the world map pitch changes.
void Ui_RunIconMonitor (void)
 A debug sprite viewer, which never returns.
s32 Ui_FindNextSpriteWithImage (s32 spriteId, s32 direction)
 Returns the next sprite id after spriteId, stepping by direction (1 or -1) and wrapping within 0-511, whose metadata has an image (a nonzero width).
void Map_BuildProbeRing (s32 centerX, s32 centerY, struct SpritePlacement *positions)
 Lays out the sprite viewer's ring around pixel (x, z): one position per facing of the first sprite's facing kind (6, 8, 10 or 4, or two opposite pairs for kind 20), 56 pixels out (40 for kind 20).
void Ui_FillGridColumnFromMetadata (s32 layerIndex, s32 animationIndex)
 Starts animationIndex on layerIndex of each of the viewer's ten sprites, each one a frame (16 timer units) behind the last, so the copies are staggered.
void Ui_SetGridColumnNumber (s32 layerIndex, s32 spriteId)
 Sets spriteId on layerIndex of each of the viewer's ten sprites.
void Battle_PlaceActorsByFormationKind (void)
 Each frame in the sprite viewer: places each copy of the sprite at its ring position, facing the way that position stands for.

Function Documentation

◆ Resource_DecompressLz()

u8 * Resource_DecompressLz ( const u8 * source,
u8 * destination )

Decompresses an LZ stream from source into destination and returns destination.

The stream starts with a little-endian halfword: the offset of its command bytes, or 0 for an uncompressed block, whose data (source + 2) is returned as it is. The literal bytes follow that halfword. Each command byte gives eight flags, low bit first: 1 copies the next literal byte; 0 reads a big-endian halfword whose low 12 bits are a distance and high 4 bits a length - 2 (or, when 0, the next byte + 16 + 2), and copies that many bytes from the literals' start minus the distance. A zero halfword ends the stream. Called only by Sprite_ComposeAnimationFrame, for a codec 3 (LZ) layer that has a draw parameter, into a 0x400-byte scratch buffer.

Definition at line 17 of file decompress.c.

Referenced by Resource_DecompressLz(), and Sprite_ComposeAnimationFrame().

◆ Sprite_ComposeAnimationFrame()

s32 Sprite_ComposeAnimationFrame ( struct AnimationObject * obj,
u16 dir )

Advances a sprite's animation layers by one frame, picks each layer's frame for the facing dir, and when any frame changed redraws the sprite: the layers composed by priority into one pixel buffer, an optional outline, and the result uploaded to the sprite's VRAM tiles.

Returns 1 when layer 0's frame for this facing is drawn mirrored.

Called for each sprite drawn, every frame, by Render_ApplyProjectedPlacement and Render_PlaceProjectedSprite. Writes the layers' script position, timer and frame, the sprite's dirty flag and tile, its tiles in OBJ VRAM, and the ObjectSystemWork's count of bytes composed; takes heap slot HEAP_SLOT_FRAME_SCRATCH for the decoder when no caller holds it, and frees it again.

Definition at line 25 of file sprite_draw.c.

Referenced by Render_ApplyProjectedPlacement(), Render_PlaceProjectedSprite(), and Sprite_ComposeAnimationFrame().

◆ Render_PlaceSpritePartPair()

void Render_PlaceSpritePartPair ( struct AnimationObject * sprite,
s32 screenX,
s32 height,
s32 screenY,
s32 groundHeight,
s32 * scale )

Positions a sprite's image (part 0) and shadow (part 1) on the screen: the image centred on screenX and raised height above screenY, the shadow at groundHeight.

scale is the sprite's (x, y) scale (16.16); above 1.0 both parts use the double-size affine mode. It has a bare veneer in the field far-call table, and no caller names it.

Definition at line 337 of file sprite_draw.c.

Referenced by Render_PlaceSpritePartPair().

◆ Render_ApplyProjectedPlacement()

void Render_ApplyProjectedPlacement ( struct AnimationObject * sprite,
const struct SpritePlacement * position,
const struct SpriteScale * scale,
s32 facing )

Places a sprite for the scrolling camera and queues it for drawing.

Position holds screen x, height, screen y and ground height in 16.16 pixels; scale holds its x/y factors and facing its angle. Builds an affine matrix when the sprite is mirrored, scaled or rotated, queues the shadow (when the sprite has one) and then the image in a draw slot by depth; an object 100 pixels or more below the ground takes slot 1 instead, its shadow slot 0.

Called by ObjectSystem_UpdateCamera for each one-sprite object on a layered map, by the sprite viewer, and as Object_ApplyProjectedPlacementFar by the battle effects, the Psynergy effects and the menus.

Definition at line 384 of file sprite_draw.c.

Referenced by Battle_PlaceActorsByFormationKind(), ObjectSystem_UpdateCamera(), and Render_ApplyProjectedPlacement().

◆ Render_PlaceProjectedSprite()

void Render_PlaceProjectedSprite ( struct AnimationObject * sprite,
s32 * point,
s32 * scale,
s32 facing,
s32 depth )

Places a sprite at 3D point for the fixed camera and queues it for drawing: projected to the screen and scaled by its distance (unless useOwnScale keeps its own scale), with an affine matrix as needed and its shadow on the ground below.

depth 0 sorts it by distance; any other value is its draw slot. A sprite off screen gives up its VRAM cache entry unless retainCacheEntry holds it.

Called by ObjectSystem_UpdateCameraFixed for each object on the world map and in the battle; while a menu suspends projection (ObjectSystemWork.suspended) every sprite is treated as off screen.

Definition at line 481 of file sprite_draw.c.

Referenced by ObjectSystem_UpdateCameraFixed(), and Render_PlaceProjectedSprite().

◆ ObjectGroup_SetChildValueUnlessFifteen()

void ObjectGroup_SetChildValueUnlessFifteen ( void * rawSprite,
u32 value )

Sets the draw parameter of each of a sprite's layers to value, except layers whose parameter is 15, and marks the sprite for redrawing.

Called by Animation_ApplyChildValues and, as ObjectGroup_SetChildValueUnlessFifteenFar, by the Psynergy effects, the Sanctum and the Altmiller Cave scene.

Definition at line 599 of file sprite_draw.c.

Referenced by AltmillerCave_ReleaseWallBurst(), Animation_ApplyChildValues(), and ObjectGroup_SetChildValueUnlessFifteen().

◆ ResourceSlot_Load()

s32 ResourceSlot_Load ( u32 slot,
u32 * buffer,
s32 number,
u32 variant )

Loads the frames of animation id number into resource slot slot's buffer: the resource listed for it in gResourceSlot_NumberTable, decoded, its frame offsets turned into pointers, and for variant 1-5 its pixel colours (those up to 0xdf) remapped through that variant's conversion table.

Returns the image's size in pixels (width * height), or 0 when the slot or id is not known. Sets the slot's tag to (slot << 12) | number and its buffer; with a null buffer and number 0 it does only that, which is how the battle frees a slot. Called by the sprite viewer and, as ResourceSlot_LoadFar, by the battle for its enemy sprites (variant is the class's palette).

Definition at line 34 of file animation.c.

Referenced by ResourceSlot_Load(), and Ui_RunIconMonitor().

◆ Animation_LookupValueByKey()

s32 Animation_LookupValueByKey ( s32 tag)

Returns the buffer loaded into the resource slot with this tag, or 0.

An animation id that carries its slot in bits 12 and up finds its frames here; called by the layer set-up functions below.

Definition at line 103 of file animation.c.

Referenced by Animation_InitializeObjects(), Animation_InitWorkFromMetadata(), Animation_LookupValueByKey(), and AnimationObject_Allocate().

◆ Animation_InitializeObjects()

s32 Animation_InitializeObjects ( struct AnimationObject * sprite)

Resets each layer of a sprite from its animation's metadata: its facing kind, frames, scripts and codec, with no frame shown and no script running.

The first layer also sets the sprite's size, scale and offsets. Returns 0. Called by Animation_SetIndexAndInitObjects.

Definition at line 118 of file animation.c.

Referenced by Animation_InitializeObjects(), and Animation_SetIndexAndInitObjects().

◆ Animation_InitWorkFromMetadata()

void Animation_InitWorkFromMetadata ( struct AnimationEntry * layer)

Resets one animation layer from its animation's metadata, as Animation_InitializeObjects does for each layer.

Called by the sprite viewer.

Definition at line 160 of file animation.c.

Referenced by Animation_InitWorkFromMetadata(), and Ui_SetGridColumnNumber().

◆ ResourceMetadata_Register()

s32 ResourceMetadata_Register ( struct AnimationObject * sprite,
s32 id )

Adds a layer of animation id to a sprite, in its first free layer of four.

The first layer also sets the sprite's size, scale and offsets. Returns the layer, 0 when no layer record is free, or -1 when the sprite has four layers already. Called by ResourceObject_Create for a sprite's first layer, by ObjectDispatch_RegisterChildMetadata and the sprite viewer, and as ResourceMetadata_RegisterFar by the battle, the Psynergy effects and the field scene's actors.

Definition at line 191 of file animation.c.

Referenced by AltinPeak_RollLog(), ObjectDispatch_RegisterChildMetadata(), ResourceMetadata_Register(), ResourceObject_Create(), and Ui_RunIconMonitor().

◆ ResourceMetadata_Unregister()

void ResourceMetadata_Unregister ( struct AnimationObject * sprite,
s32 layer )

Removes the layer handle from a sprite and clears it, trimming the sprite's layer count when no later layer remains.

Called through ResourceMetadata_UnregisterFar by the battle's objects.

Definition at line 231 of file animation.c.

Referenced by ResourceMetadata_Unregister().

◆ ResourceMetadata_ReleaseSlot()

void ResourceMetadata_ReleaseSlot ( struct AnimationObject * sprite,
u32 index )

Removes and clears a sprite's layer number no (0-3), trimming the sprite's layer count when no later layer remains.

Definition at line 258 of file animation.c.

Referenced by ResourceMetadata_ReleaseSlot().

◆ Animation_SetWorkEntry()

void Animation_SetWorkEntry ( struct AnimationEntry * layer,
s32 animation )

Starts the indexed animation on a layer when its metadata contains it.

Bit 7 preserves the command cursor and timer; it remains part of the index. Reached through the animation script's play command (Sprite_ComposeAnimationFrame) and, as Animation_SetWorkEntryFar, from the battle's motion and objects. XXX: unlike AnimationObjects_SelectAnimation it does not mask bit 7 off, so with bit 7 set the index passes animationCount only in a set of more than 128 animations; a script that plays with bit 7 would show whether that is an original bug.

Definition at line 289 of file animation.c.

Referenced by Animation_SetWorkEntry(), and Sprite_ComposeAnimationFrame().

◆ AnimationObjects_SelectAnimation()

s32 AnimationObjects_SelectAnimation ( struct AnimationObject * sprite,
s32 animation )

Starts animation flags & 0x7f on every layer of a sprite (bit 7 keeps each layer's place and timer), unless the sprite plays it already.

The first layer's animation also sets the sprite's offsets. Returns 0. The engine's usual way to change what a sprite plays: called by the object dispatch and the player control, and as AnimationObjects_SelectAnimationFar by the battle, the shops, the menus, the battle and Psynergy effects and the scene scripts.

Definition at line 317 of file animation.c.

Referenced by AnimationObjects_SelectAnimation(), Bilibin_SpawnRiverEffect(), FieldObject_UpdatePlayerControl(), MercuryLighthouse_HopAcrossPool(), MercuryLighthouse_RestoreLights(), MercuryLighthouse_SpawnSparkPair(), Object_MoveOnWorldMap(), ObjectDispatch_SelectAnimation(), ObjectDispatch_SetAnimationAndSpeed(), OverlayObject_SpawnKind24AtObject(), OverlayObject_SpawnKind24AtObject(), SolSanctumEruption_SpawnEffectPair(), ValeHome_SpawnEffectPair(), VenusLighthouseAerie_SpawnLinkedPairEffects(), and WorldMap_CreateLinkedEffects().

◆ AnimationObjects_SetActiveFrameTimers()

s32 AnimationObjects_SetActiveFrameTimers ( struct AnimationObject * sprite,
s32 frames )

Sets each animated layer's timer to the given duration in frames.

Returns 0.

Definition at line 367 of file animation.c.

Referenced by AnimationObjects_SetActiveFrameTimers().

◆ AnimationObjects_SetActiveTimerSteps()

void AnimationObjects_SetActiveTimerSteps ( struct AnimationObject * sprite,
s32 step )

Sets the timer step, the animation speed, of each animated layer of a sprite (16 is normal speed).

Called by the object dispatch and, as AnimationObjects_SetActiveTimerStepsFar, by the Sanctum, which stops a party member's icon with 0 and restarts it with 16.

Definition at line 392 of file animation.c.

Referenced by AnimationObjects_SetActiveTimerSteps(), ObjectDispatch_SetAnimationAndSpeed(), and ObjectDispatch_SetAnimationSpeed().

◆ ObjectSystem_Configure()

void ObjectSystem_Configure ( s32 mode)

Allocates and zeroes the 64 sprites and 64 animation layers (from the fixed blocks in mode 3, the heap otherwise), sets up the palette DMA, loads the shadow tiles into VRAM cache entry 93 and puts the sprite tile uploader in RAM.

Called by ObjectSystem_Initialize.

Definition at line 411 of file animation.c.

Referenced by ObjectSystem_Configure(), and ObjectSystem_Initialize().

◆ AnimationObject_Allocate()

struct AnimationEntry * AnimationObject_Allocate ( s32 id)

Takes a free animation layer record and starts it on animation id's first animation.

Returns the layer, or NULL when none is free or the id has no image. Called by ResourceMetadata_Register.

Definition at line 445 of file animation.c.

Referenced by AnimationObject_Allocate(), and ResourceMetadata_Register().

◆ ResourceMetadata_ClearRecord()

void ResourceMetadata_ClearRecord ( struct AnimationEntry * record)

Zeroes one animation layer (struct AnimationEntry); does nothing for NULL.

Zeroing kind frees the record for AnimationObject_Allocate. Called by the layer release functions here and, as ResourceMetadata_ClearRecordFar, by the Psynergy effects and scene scripts.

Definition at line 499 of file animation.c.

Referenced by AltinPeak_StopLogAndJumpOff(), Colosso_ShowItemIcon(), ResourceMetadata_ClearRecord(), ResourceMetadata_ReleaseSlot(), ResourceMetadata_Unregister(), and ResourceObject_Release().

◆ ResourceObject_Create()

struct AnimationObject * ResourceObject_Create ( s32 id)

Creates a sprite for animation id, taking one of the 64 free sprites and a VRAM cache entry for its tiles.

Returns the sprite, or NULL when there is no room or the id has no image. Called by FieldObject_Create and the sprite viewer, and as ResourceObject_CreateFar by the battle, the battle effects, the Psynergy effects and the menus.

Definition at line 512 of file animation.c.

Referenced by FieldObject_Create(), ResourceObject_Create(), and Ui_RunIconMonitor().

◆ ResourceObject_Release()

void ResourceObject_Release ( struct AnimationObject * sprite)

Releases a sprite: its VRAM cache entry (unless retainCacheEntry is set), its four animation layers, and then zeroes its 56 bytes.

Called by ObjectDispatch_Release and, as ResourceObject_ReleaseFar, by the battle and its effects, the Psynergy effects and the menus.

Definition at line 624 of file animation.c.

Referenced by ObjectDispatch_Release(), and ResourceObject_Release().

◆ ResourceMetadata_SumCommandLengths()

s32 ResourceMetadata_SumCommandLengths ( s32 id,
u32 animation,
s32 frameCount )

Returns how long the first frameCount frames of animation number animation of id last: the sum of the arguments of its frame, wait and blank commands, up to frameCount of them or the first play, hold, jump or end command.

Called through ResourceMetadata_SumCommandLengthsFar by the battle's staging.

Definition at line 646 of file animation.c.

Referenced by ResourceMetadata_SumCommandLengths().

◆ Map_RenderAnimatedTileFrame()

void Map_RenderAnimatedTileFrame ( u8 * obj,
u32 pos )

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().

◆ 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().

◆ Map_RenderAllAnimatedTileFrames()

void Map_RenderAllAnimatedTileFrames ( u8 ** sprites,
s32 count )

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().

◆ ObjectDispatch_SelectAnimation()

void ObjectDispatch_SelectAnimation ( void * raw,
s32 no )

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().

◆ ObjectDispatch_SetAnimationSpeed()

void ObjectDispatch_SetAnimationSpeed ( struct DispatchObject * obj,
s32 val )

◆ Script_SetFlagAndTest()

s32 Script_SetFlagAndTest ( struct ScriptInterpreter * interpreter)

SC_FLAG_ON(f) and SC_FLAG_OFF(f): test game flag f, then set or clear it.

Definition at line 199 of file script_commands.c.

Referenced by Script_SetFlagAndTest().

◆ Script_ClearFlagAndTest()

s32 Script_ClearFlagAndTest ( struct ScriptInterpreter * interpreter)

Definition at line 200 of file script_commands.c.

Referenced by Script_ClearFlagAndTest().

◆ Script_SetOrCompareAddress()

void Script_SetOrCompareAddress ( struct ScriptOperands * state,
s32 operation,
s32 value )

The work value handlers, one for each entry of enum ScriptWork (see gScript_OperandHandlerTable in operand.c); each names the object field it sets, adds to or compares.

Definition at line 826 of file script_commands.c.

Referenced by Script_SetOrCompareAddress().

◆ Script_SetOrCompareUnsignedHalfword()

void Script_SetOrCompareUnsignedHalfword ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 840 of file script_commands.c.

Referenced by Script_SetOrCompareUnsignedHalfword().

◆ Script_SetOrCompareX()

void Script_SetOrCompareX ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 841 of file script_commands.c.

Referenced by Script_SetOrCompareX().

◆ Script_SetOrCompareY()

void Script_SetOrCompareY ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 842 of file script_commands.c.

Referenced by Script_SetOrCompareY().

◆ Script_SetOrCompareZ()

void Script_SetOrCompareZ ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 843 of file script_commands.c.

Referenced by Script_SetOrCompareZ().

◆ Script_SetOrCompareScaleX()

void Script_SetOrCompareScaleX ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 859 of file script_commands.c.

Referenced by Script_SetOrCompareScaleX().

◆ Script_SetOrCompareScaleY()

void Script_SetOrCompareScaleY ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 860 of file script_commands.c.

Referenced by Script_SetOrCompareScaleY().

◆ Script_SetOrCompareVelocityX()

void Script_SetOrCompareVelocityX ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 861 of file script_commands.c.

Referenced by Script_SetOrCompareVelocityX().

◆ Script_SetOrCompareVelocityY()

void Script_SetOrCompareVelocityY ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 862 of file script_commands.c.

Referenced by Script_SetOrCompareVelocityY().

◆ Script_SetOrCompareVelocityZ()

void Script_SetOrCompareVelocityZ ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 863 of file script_commands.c.

Referenced by Script_SetOrCompareVelocityZ().

◆ Script_SetOrCompareSpeedLimit()

void Script_SetOrCompareSpeedLimit ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 864 of file script_commands.c.

Referenced by Script_SetOrCompareSpeedLimit().

◆ Script_SetOrCompareAcceleration()

void Script_SetOrCompareAcceleration ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 865 of file script_commands.c.

Referenced by Script_SetOrCompareAcceleration().

◆ Script_SetOrCompareTargetX()

void Script_SetOrCompareTargetX ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 866 of file script_commands.c.

Referenced by Script_SetOrCompareTargetX().

◆ Script_SetOrCompareTargetY()

void Script_SetOrCompareTargetY ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 867 of file script_commands.c.

Referenced by Script_SetOrCompareTargetY().

◆ Script_SetOrCompareTargetZ()

void Script_SetOrCompareTargetZ ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 868 of file script_commands.c.

Referenced by Script_SetOrCompareTargetZ().

◆ Script_SetOrCompareVerticalMotion()

void Script_SetOrCompareVerticalMotion ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 869 of file script_commands.c.

Referenced by Script_SetOrCompareVerticalMotion().

◆ Script_SetOrCompareGravity()

void Script_SetOrCompareGravity ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 870 of file script_commands.c.

Referenced by Script_SetOrCompareGravity().

◆ Script_SetOrCompareTerrainHeight()

void Script_SetOrCompareTerrainHeight ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 871 of file script_commands.c.

Referenced by Script_SetOrCompareTerrainHeight().

◆ Script_SetOrCompareWord4c()

void Script_SetOrCompareWord4c ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 872 of file script_commands.c.

Referenced by Script_SetOrCompareWord4c().

◆ Script_SetOrCompareAddress50()

void Script_SetOrCompareAddress50 ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 873 of file script_commands.c.

Referenced by Script_SetOrCompareAddress50().

◆ Script_SetOrCompareByte54()

void Script_SetOrCompareByte54 ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 874 of file script_commands.c.

Referenced by Script_SetOrCompareByte54().

◆ Script_SetOrCompareMotionFlags()

void Script_SetOrCompareMotionFlags ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 875 of file script_commands.c.

Referenced by Script_SetOrCompareMotionFlags().

◆ Script_SetOrCompareArrivalAxis()

void Script_SetOrCompareArrivalAxis ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 876 of file script_commands.c.

Referenced by Script_SetOrCompareArrivalAxis().

◆ Script_SetOrCompareComparisonResult()

void Script_SetOrCompareComparisonResult ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 878 of file script_commands.c.

Referenced by Script_SetOrCompareArrivalAxis().

◆ Script_SetOrCompareSnapToTarget()

void Script_SetOrCompareSnapToTarget ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 879 of file script_commands.c.

Referenced by Script_SetOrCompareSnapToTarget().

◆ Script_SetOrCompareCollisionFlags()

void Script_SetOrCompareCollisionFlags ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 881 of file script_commands.c.

Referenced by Script_SetOrCompareSnapToTarget().

◆ Script_SetOrCompareSteeringFlags()

void Script_SetOrCompareSteeringFlags ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 883 of file script_commands.c.

Referenced by Script_SetOrCompareCollisionFlags().

◆ Script_SetOrComparePaused()

void Script_SetOrComparePaused ( struct ScriptOperands * state,
s32 operation,
s32 value )

Definition at line 884 of file script_commands.c.

Referenced by Script_SetOrComparePaused().

◆ Script_SetOrCompareRepeatCount()

void Script_SetOrCompareRepeatCount ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 885 of file script_commands.c.

Referenced by Script_SetOrCompareRepeatCount().

◆ Script_SetOrCompareSignedHalfword64()

void Script_SetOrCompareSignedHalfword64 ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 902 of file script_commands.c.

◆ Script_SetOrCompareSignedHalfword66()

void Script_SetOrCompareSignedHalfword66 ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 904 of file script_commands.c.

Referenced by Script_SetOrCompareSignedHalfword64().

◆ Script_SetOrCompareWord68()

void Script_SetOrCompareWord68 ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 905 of file script_commands.c.

Referenced by Script_SetOrCompareWord68().

◆ Script_SetOrCompareUpdateAddress()

void Script_SetOrCompareUpdateAddress ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 906 of file script_commands.c.

Referenced by Script_SetOrCompareUpdateAddress().

◆ Script_SetOrCompareByte62()

void Script_SetOrCompareByte62 ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 907 of file script_commands.c.

Referenced by Script_SetOrCompareByte62().

◆ Script_SetOrCompareByte63()

void Script_SetOrCompareByte63 ( struct ScriptOperands * work,
s32 operation,
s32 value )

Definition at line 908 of file script_commands.c.

Referenced by Script_SetOrCompareByte63().

◆ Ui_SetGridColumnParameter()

void Ui_SetGridColumnParameter ( s32 slot,
s32 value )

Sets the draw parameter or the priority of one layer of the viewer's ten sprites.

Definition at line 548 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor(), and Ui_SetGridColumnParameter().

◆ Ui_SetGridColumnPriority()

void Ui_SetGridColumnPriority ( s32 slot,
s32 value )

Definition at line 549 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor(), and Ui_SetGridColumnPriority().

◆ Map_GetScreenRelativePosition()

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().

◆ ObjectSystem_Initialize()

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().

◆ ResourceTable_ReservedNoOpC0C4()

void ResourceTable_ReservedNoOpC0C4 ( void )

Definition at line 185 of file objects.c.

Referenced by ResourceTable_ReservedNoOpC0C4().

◆ ResourceTable_ReservedNoOp2()

void ResourceTable_ReservedNoOp2 ( void )

Definition at line 187 of file objects.c.

Referenced by ResourceTable_ReservedNoOp2().

◆ ObjectDispatch_FindFreeObject()

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().

◆ ObjectDispatch_Release()

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().

◆ FieldObject_Create()

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().

◆ ObjectDispatch_Initialize()

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().

◆ ObjectDispatch_SetAnimationAndSpeed()

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().

◆ ObjectDispatch_SetChildRotation()

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().

◆ Animation_SetIndexAndInitObjects()

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().

◆ ObjectDispatch_RegisterChildMetadata()

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().

◆ ObjectDispatch_StartApproachLink()

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().

◆ ObjectDispatch_StartKeyCheck()

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().

◆ ObjectDispatch_StartMoveByKeys()

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().

◆ ObjectDispatch_StartPlayerControl()

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().

◆ ObjectDispatch_StartWorldMapControl()

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().

◆ ObjectDispatch_StartIdle()

void ObjectDispatch_StartIdle ( struct DispatchObject * object)

◆ ObjectDispatch_StartCamera()

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().

◆ ObjectDispatch_WaitForValue16()

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().

◆ ObjectDispatch_SetSingleChildFlags()

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().

◆ ObjectDispatch_SetChildBlendMode()

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().

◆ ObjectDispatch_SetChildFixedScale()

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().

◆ Animation_ApplyChildValues()

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().

◆ ObjectSystem_SuspendProjectionAndShowSprites()

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().

◆ ObjectSystem_ResumeProjectionAndHideLayers()

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().

◆ ObjectDispatch_ReturnTrue()

s32 ObjectDispatch_ReturnTrue ( void )

Definition at line 573 of file objects.c.

Referenced by ObjectDispatch_ReturnTrue().

◆ ObjectSystem_UpdateCamera()

void ObjectSystem_UpdateCamera ( void )

Each frame, with the scrolling camera: places every object's sprite on the screen.

An object on or near the screen takes its layer and priority from the cell under it; one off screen gives up its VRAM cache entry. ObjectSystem_Initialize schedules it (order 0xc80, after the objects move) for every mode but 3 and 4; ObjectSystem_SuspendProjectionAndShowSprites suspends it. Resets the system's used count, may change an object's layer and its sprite's priorities, and holds the frame decoder in heap slot HEAP_SLOT_FRAME_SCRATCH only while it runs.

Definition at line 59 of file object_camera.c.

Referenced by ObjectSystem_Initialize(), ObjectSystem_ResumeProjectionAndHideLayers(), ObjectSystem_SuspendProjectionAndShowSprites(), and ObjectSystem_UpdateCamera().

◆ ObjectCamera_ReturnTrue()

s32 ObjectCamera_ReturnTrue ( void )

Definition at line 197 of file object_camera.c.

Referenced by ObjectCamera_ReturnTrue().

◆ ObjectSystem_UpdateCameraFixed()

void ObjectSystem_UpdateCameraFixed ( void )

Each frame, with the fixed camera: places every object's sprite, from the 64th object down, facing them by the angle from the eye to the target.

While battle commands are chosen (flag 363, set by BattlePresentation_BuildActions) it uses the fixed view matrix and 1.0 scale. ObjectSystem_Initialize schedules it (order 0xc80) for modes 3 (the world map) and 4 (battle); ObjectSystem_SuspendProjectionAndShowSprites suspends it. Resets the system's used count.

Definition at line 206 of file object_camera.c.

Referenced by ObjectSystem_Initialize(), ObjectSystem_ResumeProjectionAndHideLayers(), ObjectSystem_SuspendProjectionAndShowSprites(), and ObjectSystem_UpdateCameraFixed().

◆ 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().

◆ 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()

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().

◆ Script_Wait()

s32 Script_Wait ( struct ScriptInterpreter * interpreter)

SC_WAIT(n): waits n frames; this frame counts as the first.

Sets interpreter->wait to n - 1, which the update loops count down, and moves past its operand. Returns 0 to end the object's commands for this frame.

Definition at line 32 of file script_commands.c.

Referenced by Script_Wait().

◆ Script_WaitForArrival()

s32 Script_WaitForArrival ( struct ScriptInterpreter * interpreter)

SC_SYNC: waits until the object arrives at its target, or until a solid object has blocked it for 60 frames (refused is the blocked count, which Object_UpdateAllThumb raises).

Returns 1 (run on) once it has, clearing refused when it gave up, and 0 (wait) until then.

Definition at line 44 of file script_commands.c.

Referenced by Script_WaitForArrival().

◆ Script_InvokeCallback()

s32 Script_InvokeCallback ( struct ScriptInterpreter * interpreter)

SC_CALL(fn): calls fn with the object.

A non-zero result waits and calls it again next frame; zero moves on, past the command unless fn moved the cursor itself. Scene scripts and the field effect scripts of fxdata.c use it to run their own per-object steps.

Definition at line 61 of file script_commands.c.

Referenced by Script_InvokeCallback().

◆ Script_FindLabel()

s32 Script_FindLabel ( struct ScriptInterpreter * interpreter,
u32 labelKey )

Returns the cursor just past the script's label key (SC_LABEL or SC_TO, matched without the bit that tells them apart), searching its first 1024 words, or 0 (the start) when key is 0 or not found.

Clears the wait. Called by the jumps: SC_JUMP, SC_LOOP, SC_IF and SC_IFNOT.

Definition at line 77 of file script_commands.c.

Referenced by Script_FindLabel(), Script_JumpIfFalse(), Script_JumpIfTrue(), Script_JumpToLabel(), and Script_RepeatOrJump().

◆ Script_RepeatOrJump()

s32 Script_RepeatOrJump ( struct ScriptInterpreter * interpreter)

SC_LOOP(n, to): jumps to label to until it has done so n - 1 times, then moves on; with n = SC_FOREVER it always jumps.

Counts in interpreter->repeatCount and clears it when the loop ends, so loops do not nest. The engine's own scripts (object_script.c) end with SC_LOOP(SC_FOREVER, SC_TOP).

Definition at line 105 of file script_commands.c.

Referenced by Script_RepeatOrJump().

◆ Script_JumpToLabel()

s32 Script_JumpToLabel ( struct ScriptInterpreter * interpreter)

SC_JUMP(to): jumps to label to.

Definition at line 132 of file script_commands.c.

Referenced by Script_JumpToLabel().

◆ Script_JumpIfTrue()

s32 Script_JumpIfTrue ( struct ScriptInterpreter * interpreter)

SC_IF(to): jumps to label to when the last test was true.

Definition at line 139 of file script_commands.c.

Referenced by Script_JumpIfTrue().

◆ Script_JumpIfFalse()

s32 Script_JumpIfFalse ( struct ScriptInterpreter * interpreter)

SC_IFNOT(to): jumps to label to when the last test was false.

Definition at line 153 of file script_commands.c.

Referenced by Script_JumpIfFalse().

◆ Script_End()

s32 Script_End ( struct ScriptInterpreter * interpreter)

SC_END: hands the object back to the idle script, gScript_MainScript, whose lone SC_END runs again each frame.

Returns 0. The table's unused command numbers from 0x24 also point here.

Definition at line 169 of file script_commands.c.

Referenced by Script_End().

◆ Script_TestFlag()

s32 Script_TestFlag ( struct ScriptInterpreter * interpreter)

SC_FLAG_CHECK(f): tests game flag f.

Definition at line 178 of file script_commands.c.

Referenced by Script_TestFlag().

◆ Script_ToggleFlagAndTest()

s32 Script_ToggleFlagAndTest ( struct ScriptInterpreter * interpreter)

SC_FLAG_REV(f): tests game flag f, then flips it.

Definition at line 203 of file script_commands.c.

Referenced by Script_ToggleFlagAndTest().

◆ Script_SetAnimation()

s32 Script_SetAnimation ( struct ScriptInterpreter * interpreter)

SC_ARG(v): switches the object's sprites to animation v.

Definition at line 221 of file script_commands.c.

Referenced by Script_SetAnimation().

◆ Script_FreeObject()

s32 Script_FreeObject ( struct ScriptInterpreter * interpreter)

SC_FREE: releases the object through ObjectDispatch_Release, which releases its sprites and zeroes its slot.

Returns 0.

Definition at line 230 of file script_commands.c.

Referenced by Script_FreeObject().

◆ Script_Nop()

s32 Script_Nop ( struct ScriptInterpreter * interpreter)

SC_NOP(v): does nothing with its operand.

Definition at line 236 of file script_commands.c.

Referenced by Script_Nop().

◆ Script_PlaySound()

s32 Script_PlaySound ( struct ScriptInterpreter * interpreter)

SC_SE(n): sends sound command n (a sound effect).

Definition at line 242 of file script_commands.c.

Referenced by Script_PlaySound().

◆ ScriptObject_CheckOverlap()

s32 ScriptObject_CheckOverlap ( struct ScriptObjectEntry * object,
s32 * values )

Returns -1 when an object at position values would overlap a solid object (bit 0 of collisionFlags), each radius less 2 pixels; otherwise 0.

The object itself is skipped. Called by SC_WANDER and SC_WANDER_HOME, the player's control (player_control.c), the motion loop's solid test (object_motion.c), and the carry and Force effects through ScriptObject_CheckOverlapFar.

Definition at line 254 of file script_commands.c.

Referenced by FieldObject_UpdatePlayerControl(), Object_UpdateAllThumb(), Object_Wander(), ScriptObject_CheckOverlap(), and ScriptObject_WanderNearHome().

◆ ScriptObject_FindOverlappingEntry()

struct ScriptObjectEntry * ScriptObject_FindOverlappingEntry ( struct ScriptObjectEntry * object,
s32 * values )

Returns the first solid object that an object at position values would overlap, as ScriptObject_CheckOverlap tests, or NULL.

Called by the Move effect (move.c) through ScriptObject_FindOverlappingEntryFar.

Definition at line 277 of file script_commands.c.

Referenced by ScriptObject_FindOverlappingEntry().

◆ Script_SetPositionAndResetMotion()

s32 Script_SetPositionAndResetMotion ( struct ScriptInterpreter * interpreter)

SC_POS(x, y, z): places the object at (x, y, z) and stops it.

Definition at line 319 of file script_commands.c.

Referenced by Script_SetPositionAndResetMotion().

◆ Script_ApplyAbsolutePosition()

s32 Script_ApplyAbsolutePosition ( struct ScriptInterpreter * interpreter)

SC_MOVE(x, y, z): sends the object towards (x, y, z).

Definition at line 325 of file script_commands.c.

Referenced by Script_ApplyAbsolutePosition().

◆ Script_ApplyRelativePosition()

s32 Script_ApplyRelativePosition ( struct ScriptInterpreter * interpreter)

SC_MOVE_BY(x, y, z): sends the object towards its position plus (x, y, z).

Definition at line 330 of file script_commands.c.

Referenced by Script_ApplyRelativePosition().

◆ Script_StoreAngleToLinkedObject()

s32 Script_StoreAngleToLinkedObject ( struct ScriptInterpreter * interpreter)

SC_FACE_LINK: stores the angle from the object to its linked object in scriptValue, measured on the ground plane (x and z).

Definition at line 348 of file script_commands.c.

Referenced by Script_StoreAngleToLinkedObject().

◆ Script_ApplyLinkedObjectPosition()

s32 Script_ApplyLinkedObjectPosition ( struct ScriptInterpreter * interpreter)

SC_MOVE_LINK: sends the object towards its linked object.

Definition at line 362 of file script_commands.c.

Referenced by Script_ApplyLinkedObjectPosition().

◆ Script_ApplyLocalOffsetPosition()

s32 Script_ApplyLocalOffsetPosition ( struct ScriptInterpreter * interpreter)

SC_MOVE_LOCAL(a, b): sends the object towards its position plus an offset that is never filled in; the operands are skipped unread.

Definition at line 377 of file script_commands.c.

Referenced by Script_ApplyLocalOffsetPosition().

◆ Camera_FollowLeaderInBounds()

s32 Camera_FollowLeaderInBounds ( struct ScriptInterpreter * interpreter)

SC_CAMERA: keeps the camera object on its leader (linkedObject), clamped so the view stays on the map.

It closes an eighth of the distance a frame, at most its speed limit, and a quarter of a large height difference; when action is set it jumps there at once.

Run each frame by gObjectDispatch_CameraScript, which ObjectDispatch_StartCamera starts. Clears the camera's flags and target, moves its position, and counts its step.

Definition at line 403 of file script_commands.c.

Referenced by Camera_FollowLeaderInBounds().

◆ Object_ApproachLinkedObject()

s32 Object_ApproachLinkedObject ( struct ScriptInterpreter * interpreter)

SC_APPROACH_LINK: follows the linked object at its speed.

More than 16 pixels away it walks to 16 pixels short of it (animation 2) and runs on; within 16 it stands (animation 1) and waits for the next frame.

Run each frame by gObjectDispatch_ApproachLinkScript, which ObjectDispatch_StartApproachLink starts. Copies the linked object's speed limit and acceleration, and sets the move target.

Definition at line 506 of file script_commands.c.

Referenced by Object_ApproachLinkedObject().

◆ Object_Wander()

s32 Object_Wander ( struct ScriptInterpreter * interpreter)

SC_WANDER(base, range, limit): walks to a random point base to base + range away, within 90 degrees either side of its heading (scriptValue), that no solid object or wall blocks, with clear ground 8 pixels further at 45 degrees either side, and within limit pixels of home.

After seven failed tries it turns around (turnedBack) and waits for the next frame. No script in games/tbs names SC_WANDER; scenes use SC_WANDER_HOME.

Definition at line 555 of file script_commands.c.

Referenced by Object_Wander().

◆ ScriptObject_WanderNearHome()

s32 ScriptObject_WanderNearHome ( struct ScriptInterpreter * interpreter)

SC_WANDER_HOME(base, range, limit): wanders as SC_WANDER does, testing more ground around the point, while it is within limit pixels of home; outside that, or when no point works, it heads back towards home.

Used by scripts in Vault and Vale (vault.c, vale_home.c). Sets bit 1 of flags59 while it roams and clears it on the way home, sets the move target, and always moves on to the next command.

Definition at line 654 of file script_commands.c.

Referenced by ScriptObject_WanderNearHome().

◆ Script_SetOrCompareCursor()

void Script_SetOrCompareCursor ( struct ScriptOperands * operands,
s32 operation,
s32 value )

Work value SW_CURSOR: sets, adds to or compares the script cursor.

Definition at line 829 of file script_commands.c.

Referenced by Script_SetOrCompareCursor().

◆ Script_SetOrCompareRadius()

void Script_SetOrCompareRadius ( struct ScriptOperands * state,
s32 operation,
s32 value )

Work value SW_RADIUS: sets, adds to or compares the object's radius.

Definition at line 846 of file script_commands.c.

Referenced by Script_SetOrCompareRadius().

◆ Script_SetOrCompareHalfword5e()

void Script_SetOrCompareHalfword5e ( struct ScriptOperands * work,
s32 operation,
s32 value )

Work value SW_WAIT: sets, adds to or compares the wait counter.

Definition at line 888 of file script_commands.c.

Referenced by Script_SetOrCompareHalfword5e().

◆ Script_ApplyOperandSet()

s32 Script_ApplyOperandSet ( struct ScriptInterpreter * interpreter)

SC_SET(w, v): sets work value w to v.

Definition at line 926 of file script_commands.c.

Referenced by Script_ApplyOperandSet().

◆ Script_ApplyOperandAdd()

s32 Script_ApplyOperandAdd ( struct ScriptInterpreter * interpreter)

SC_ADD(w, v): adds v to work value w.

Definition at line 933 of file script_commands.c.

Referenced by Script_ApplyOperandAdd().

◆ Script_ApplyOperandCompare()

s32 Script_ApplyOperandCompare ( struct ScriptInterpreter * interpreter)

SC_CMP(w, v): tests whether work value w equals v.

Definition at line 940 of file script_commands.c.

Referenced by Script_ApplyOperandCompare().

◆ ObjectDispatch_SetUpdateValue()

void ObjectDispatch_SetUpdateValue ( void * rawObject,
s32 value )

Stores value as a word at the object's unk6c.

Definition at line 28 of file player_control.c.

Referenced by ObjectDispatch_SetUpdateValue().

◆ Field_RequestShortcut()

u32 Field_RequestShortcut ( u32 encodedAssignment)

Handles a shortcut key's assignment: its top two bits choose what it requests (0 Psynergy, 1 an item) and the low 14 bits which one.

With flag 0x107 set it raises event 250 instead, as the menu key does then; on the world map (mode 3) R raises event -888 (0xfc88), the world map picture, and L -889 (0xfc87), the visibility transition. Returns the request.

Called by Field_CheckConfiguredKeys. Sets fieldWork->command, fieldWork->item or fieldWork->event, which the scene loop (run_scene.c) acts on.

Definition at line 44 of file player_control.c.

Referenced by Field_CheckConfiguredKeys(), and Field_RequestShortcut().

◆ Field_CheckConfiguredKeys()

s32 Field_CheckConfiguredKeys ( void )

Checks the keys the player has configured: Select, A and Start set their flag in the event work and return 1; the two shortcut keys pass on their assignment (Field_RequestShortcut).

Returns 0 when none is pressed. Only the first configured key pressed this frame counts, in that order.

Called each frame by the leader's control commands: SC_PLAYER, SC_WORLD and SC_KEY_COUNT. Sets fieldWork->menu, examine or start.

Definition at line 78 of file player_control.c.

Referenced by Field_CheckConfiguredKeys(), Field_CheckConfiguredKeysAndCount(), FieldObject_UpdatePlayerControl(), and Object_MoveOnWorldMap().

◆ Runtime_CheckRadiusOverlap()

s32 Runtime_CheckRadiusOverlap ( s32 * firstPosition,
s32 radiusA,
s32 * secondPosition,
s32 radiusB )

Returns 0 when two spheres overlap: at positions a and b (16.16 pixels) with radii radiusA and radiusB (pixels); -1 otherwise.

Called by SC_PLAYER's push test, ScriptObject_CheckOverlap and ScriptObject_FindOverlappingEntry.

Definition at line 105 of file player_control.c.

Referenced by FieldObject_UpdatePlayerControl(), Runtime_CheckRadiusOverlap(), ScriptObject_CheckOverlap(), and ScriptObject_FindOverlappingEntry().

◆ FieldObject_UpdatePlayerControl()

s32 FieldObject_UpdatePlayerControl ( struct ScriptInterpreter * interpreter)

SC_PLAYER: moves the player on the field by the direction pad: walking or running, sliding around walls, pushing movable objects, turning, playing the matching animation and leaving footprints.

Also checks the configured keys. Returns 1.

Run each frame by gObjectDispatch_PlayerScript, which the scene loop (run_scene.c) starts on the leader through ObjectDispatch_StartPlayerControl when it hands control back on the field. Sets the leader's speed, target, velocity, angle and action, moves the objects it pushes, counts gEventWork->blockedSteps and creates the footprint objects.

Definition at line 139 of file player_control.c.

Referenced by FieldObject_UpdatePlayerControl().

◆ Object_MoveOnWorldMap()

s32 Object_MoveOnWorldMap ( struct ScriptInterpreter * interpreter)

SC_WORLD: moves the player on the world map by the direction pad, as SC_PLAYER does on the field, and turns the world map camera with the pad.

Shallow water (terrain 6) leaves a ripple and terrain 9 hides the shadow.

Run each frame by gObjectDispatch_WorldMapScript, which the scene loop (run_scene.c) starts on the leader through ObjectDispatch_StartWorldMapControl on the world map. Sets the leader's speed, target, velocity, angle and action, turns the perspective work's yaw, counts gEventWork->blockedSteps and creates the ripple objects.

Definition at line 505 of file player_control.c.

Referenced by Object_MoveOnWorldMap().

◆ Field_CheckConfiguredKeysAndCount()

s32 Field_CheckConfiguredKeysAndCount ( struct ScriptInterpreter * interpreter)

SC_KEY_COUNT: checks the configured keys (Field_CheckConfiguredKeys).

Returns 1. Run each frame by gObjectDispatch_KeyCheckScript, which the scene loop starts on the leader in movement mode 2, where the pad does not move it.

Definition at line 807 of file player_control.c.

Referenced by Field_CheckConfiguredKeysAndCount().

◆ Object_MoveByKeys()

s32 Object_MoveByKeys ( struct ScriptInterpreter * interpreter)

SC_KEYS: moves an object 8 pixels at a time by the direction pad, with up and down changing its height (y) rather than its depth.

Refuses steps into an occupied cell, across a change of collision code, or onto ground too high (up) or too low (down). Returns 1.

Run each frame by gObjectDispatch_KeysScript, which the scene loop starts on the leader in movement mode 1 (climbing). Sets the leader's speed, angle, target or velocity, and counts gEventWork->blockedSteps.

Definition at line 823 of file player_control.c.

Referenced by Object_MoveByKeys().

◆ Runtime_RemapBytesByTable()

void Runtime_RemapBytesByTable ( u8 * bytes,
s32 byteCount )

Remaps byteCount bytes in place through gRuntime_ByteRemapTable.

Called through Runtime_RemapBytesByTableFar by RenderResource_LoadFrame, which remaps the colours of a command icon's first 768 bytes.

Definition at line 10 of file map_layers.c.

Referenced by Runtime_RemapBytesByTable().

◆ Tilemap_DecodeStagedBuffer()

void Tilemap_DecodeStagedBuffer ( s32 size)

Unpacks the staged block data into gMapBlocks.

Byte 1 of the staged buffer (Ram_MapCellBuffer) is the method, and the 16-bit data follows from byte 2. size counts the method byte too (an even size means no data). Methods: 0: copy as it is 1: all the high bytes, then all the low bytes; each value is XORed with the one before 2: each value is XORed with the one before

Called by Map_LoadLayeredScene with the size Resource_DecodeType01 returns; the packed stream is decoded to Ram_MapCellBuffer + 1 so that its method byte lands at byte 1 and the halfwords at byte 2 are aligned.

Definition at line 39 of file map_layers.c.

Referenced by Map_LoadLayeredScene(), and Tilemap_DecodeStagedBuffer().

◆ Tilemap_NumberPlaceholderBlocks()

void Tilemap_NumberPlaceholderBlocks ( void )

Gives each map cell whose block number is 0xfff (a placeholder) a number of its own, counting up from 0 in map order.

Definition at line 84 of file map_layers.c.

Referenced by Tilemap_NumberPlaceholderBlocks().

◆ Tilemap_ConvertBuffer()

void Tilemap_ConvertBuffer ( void )

Converts the map's cells in place with Tile_ConvertMap, run from RAM, from a saved copy of the staged buffer.

Called by Map_LoadLayeredScene once the cell planes are decoded. Copies the first 32 KB of Ram_MapCellBuffer to a block from the alternate pool and loads the routine into RAM; frees both when done.

Definition at line 110 of file map_layers.c.

Referenced by Map_LoadLayeredScene(), and Tilemap_ConvertBuffer().

◆ Map_LoadLayeredScene()

s32 Map_LoadLayeredScene ( s32 index)

Loads layered scene index from gMap_LayeredScenes: its blocks, collision, cells, tile animations, blend script and marker list; sets up the three background layers' origins, parallax and wrap from the scene header; loads the palette and tile graphics unless FLAG_KEEP_LAYER_GRAPHICS says they are loaded; and starts the layer scrolling.

Returns 2.

Called through Map_LoadLayeredSceneFar when a scene with a layered map starts (index is gGameState.map). Allocates and clears the map work in HEAP_SLOT_MAP; writes the BG palette (keeping the backdrop colour), char blocks 1 to 3, gMapLayerData, BG1CNT to BG3CNT, REG_MOSAIC, REG_BLDCNT and REG_DISPCNT; and registers Map_UpdateLayerScroll with the scheduler.

Definition at line 211 of file map_layers.c.

Referenced by Map_LoadLayeredScene().

◆ Map_CenterOnFollowedPoint()

void Map_CenterOnFollowedPoint ( void )

Centres the camera on the point the map follows (origin: x, height, z), or on (0, 0) when there is none, and scrolls the layers there.

Called through Map_CenterOnFollowedPointFar when a layered scene starts, by the camera event commands after they move the camera, and by about 35 scene scripts through Engine_MapRedraw.

Definition at line 387 of file map_layers.c.

Referenced by Map_CenterOnFollowedPoint().

◆ Map_RenderMetatileRow()

void Map_RenderMetatileRow ( u32 layer,
s32 tileX,
s32 tileY )

Draws a row of 16 blocks (32 tiles) of a layer's cells into its BG map (screen block 5 + layer), starting at tile (tileX, tileY); the BG map wraps every 32 tiles.

Called by Map_UpdateLayerScroll when a layer scrolls onto a new row of blocks.

Definition at line 411 of file map_layers.c.

Referenced by Map_RenderMetatileRow(), and Map_UpdateLayerScroll().

◆ Map_RenderMetatileColumn()

void Map_RenderMetatileColumn ( u32 layer,
s32 tileX,
s32 tileY )

Draws a column of 11 blocks of a layer's cells, one tile wide, into its BG map, starting at tile (tileX, tileY).

Called by Map_UpdateLayerScroll when a layer scrolls onto a new column of tiles; tileX's low bit picks the block's left or right half.

Definition at line 443 of file map_layers.c.

Referenced by Map_RenderMetatileColumn(), and Map_UpdateLayerScroll().

◆ Map_UpdateLayerScroll()

void Map_UpdateLayerScroll ( void )

Each frame on a layered map: centres the view on the point the map follows (origin), clamped to the map's bounds and shaken by any decaying screen shake; then scrolls each of the three layers by its parallax scale and automatic scroll (wrapping at its period), draws the block column or row that scrolls into view, and sets its BG scroll.

Registered with the scheduler by Map_LoadLayeredScene (priority 0xc85), and called by Map_CenterOnFollowedPoint. Sets work->viewX and viewY, decays work->shakeX and shakeY, advances each drifting layer's phase, and writes each layer's position and gBgScroll entry.

Definition at line 474 of file map_layers.c.

Referenced by Map_CenterOnFollowedPoint(), Map_LoadLayeredScene(), and Map_UpdateLayerScroll().

◆ Map_SetCameraCenter()

void Map_SetCameraCenter ( s32 x,
s32 y )

Centres the view on (x, y) in 16.16 pixels, clamped to the map's bounds, and redraws every enabled layer's BG map around it.

Called by Map_CenterOnFollowedPoint. Sets work->viewX and viewY, and advances each drifting layer's phase by one frame.

Definition at line 572 of file map_layers.c.

Referenced by Map_CenterOnFollowedPoint(), and Map_SetCameraCenter().

◆ Map_CopyMetatileIndicesRect()

void Map_CopyMetatileIndicesRect ( s32 srcX,
s32 srcY,
u32 dstX,
u32 dstY,
u32 width,
u32 height )

Copies the block numbers of a rectangle of cells from (srcX, srcY) to (dstX, dstY), width by height cells, keeping each destination's attributes, and redraws the copied cells that are on screen.

It does what Map_CopyCellIndexRect does, with the destination before the size.

Called by Map_PlayMetatileCopySequence, and by about 40 scene scripts through Map_CopyMetatileIndicesRectFar (Engine_MapCopyCellsTo).

Definition at line 644 of file map_layers.c.

Referenced by Map_CopyMetatileIndicesRect(), and Map_PlayMetatileCopySequence().

◆ Map_PlayMetatileCopySequence()

void Map_PlayMetatileCopySequence ( u16 * sequence,
s32 destinationX,
u32 destinationY )

Plays a map edit sequence (struct MapCopyCommand records, ended by a source of 0xffff): copies each record's rectangle of block numbers to (destinationX, destinationY) and waits its delay in frames.

Doors and other changing scenery are drawn this way.

Called by about 30 scene scripts through Map_PlayMetatileCopySequenceFar (Engine_MapAnimateCells); it returns only when the sequence ends, so it blocks the script that calls it.

Definition at line 748 of file map_layers.c.

Referenced by Map_PlayMetatileCopySequence().

◆ Map_CopyMetatileCellsRect()

void Map_CopyMetatileCellsRect ( s32 srcX,
s32 srcY,
s32 width,
s32 height,
s32 dstX,
s32 dstY )

Copies a rectangle of cells (16x16 pixels each) as they are, from (srcX, srcY) to (dstX, dstY), width by height cells.

Where a copied cell lies in a layer's visible area (16x12 cells), its block's 2x2 tiles go to that layer's BG map in VRAM too. Called by about 15 scene scripts through Map_CopyMetatileCellsRectFar (Engine_MapCopyCells).

Definition at line 803 of file map_layers.c.

Referenced by Map_CopyMetatileCellsRect().

◆ Map_CopyCellAttributeRect()

void Map_CopyCellAttributeRect ( s32 srcX,
s32 srcY,
s32 width,
s32 height,
s32 dstX,
s32 dstY )

Copies only the attributes of a rectangle of cells, from (srcX, srcY) to (dstX, dstY), width by height cells, keeping each destination cell's block number.

Nothing is redrawn: the attributes (flags, collision code and shape) do not show. Called by about 65 scene scripts through Map_CopyCellAttributeRectFar (Engine_MapCopyCellAttributes).

Definition at line 923 of file map_layers.c.

Referenced by Map_CopyCellAttributeRect().

◆ Map_CopyCellIndexRect()

void Map_CopyCellIndexRect ( s32 srcX,
s32 srcY,
s32 width,
s32 height,
s32 dstX,
s32 dstY )

Copies only the block numbers of a rectangle of cells, from (srcX, srcY) to (dstX, dstY), width by height cells, keeping each destination cell's attributes; cells in a visible area update the BG maps too.

Called by seven scene scripts through Map_CopyCellIndexRectFar (Engine_MapCopyCellsLayered).

Definition at line 950 of file map_layers.c.

Referenced by Map_CopyCellIndexRect().

◆ Map_SetShownLayers()

void Map_SetShownLayers ( u32 layerFlags)

Sets which of BG1-BG3 the map shows (bits 9-11 of its display flags, as in REG_DISPCNT) from layerFlags, keeping its other flags.

Called by Lunpa Fortress's scene through Map_SetShownLayersFar (Engine_MapSetWorkFlagBits9To11).

Definition at line 1050 of file map_layers.c.

Referenced by Map_SetShownLayers().

◆ Map_WriteLayerCellTile()

s32 Map_WriteLayerCellTile ( s32 layer,
s32 x,
s32 y,
s32 tile,
s32 update )

Loads world map tile tile into quarter (x & 1, y & 1) of a layer's block buffer, decompressing it from the area's graphics, and with update set also draws it into the layer's BG map.

Returns 0 when that quarter already shows the tile (and update is 0), else 1.

Called by Map_UpdateCurrentTileBlock and Map_SetWindowCellTile (update 1) and by Map_PreloadCurrentTileBlock (update 0). Sets the quarter's entry in perspective->quarterTiles, and borrows heap slot 14 for the decoded tile.

Definition at line 38 of file world_map.c.

Referenced by Map_PreloadCurrentTileBlock(), Map_SetWindowCellTile(), Map_UpdateCurrentTileBlock(), and Map_WriteLayerCellTile().

◆ Map_InitializePerspectiveScene()

s32 Map_InitializePerspectiveScene ( void )

Sets up the world map's perspective view: BG2 and BG3 in affine mode, the camera work, the projection, the per-scanline ground plane routine in RAM (Transform_UpdateVertices) and its first frame, and the per-frame view and HBlank updates.

Called through Map_InitializePerspectiveSceneFar when the world map scene starts (run_scene.c). Allocates and clears the perspective work in HEAP_SLOT_MAP, the camera in HEAP_SLOT_CAMERA and the affine pages in heap slot 7; loads the default cells, block attributes and tile animations; writes the blend, BG and affine registers and REG_DISPCNT (mode 2); and registers WorldMap_UpdateView and MapAnimation_ApplyAffineFrame with the scheduler.

Definition at line 114 of file world_map.c.

Referenced by Map_InitializePerspectiveScene().

◆ Map_SetWindowCellTile()

void Map_SetWindowCellTile ( s32 x,
s32 y,
s32 px,
s32 py )

Puts world map tile (x / 16, y / 16) at cell (px / 16, py / 16) of the tile id grid, and draws it at once when it is next to the view.

Layer 1 takes the tile 0x140 (320) further on. Called by the world map scene (FieldMap_SetWindowCellTile, through Map_SetWindowCellTileFar). Sets perspective->tileIds.

Definition at line 271 of file world_map.c.

Referenced by FieldMap_SetWindowCellTile(), and Map_SetWindowCellTile().

◆ WorldMap_LoadGraphics()

void WorldMap_LoadGraphics ( s32 x,
s32 z )

Loads the world map's palette and tiles for the area at (x, z): the second set where the ground there is terrain kind 21.

Fills the BG maps, and for the second set swaps in its own tiles at ids 10-12 and 26-28.

Called through WorldMap_LoadGraphicsFar when the world map scene starts, with the party's position (run_scene.c). Sets perspective->resources, which Map_LoadAreaGraphics reloads from; writes BG palette colours 1 to 223 (keeping the backdrop), char blocks 2 and 3, gMapLayerData and screen blocks 5 and 6.

Definition at line 311 of file world_map.c.

Referenced by WorldMap_LoadGraphics().

◆ MapAnimation_ApplyAffineFrame()

void MapAnimation_ApplyAffineFrame ( void )

HBlank setup each frame on the world map: copies the first scanline's BG2 and BG3 affine parameters, starts the HBlank DMA for the rest, and picks the BG mode from the window's top and bottom.

Registered with the scheduler by Map_InitializePerspectiveScene (priority 0x480). Reads this frame's affine page (gFrameCount & 1), restarts DMA 0, sets shownTop and shownBottom, writes REG_DISPCNT's mode and clears windowPending.

Definition at line 386 of file world_map.c.

Referenced by Map_InitializePerspectiveScene(), and MapAnimation_ApplyAffineFrame().

◆ Map_RenderPaletteMappedRow()

void Map_RenderPaletteMappedRow ( u32 tileRow)

Draws world map tileRow into the BG map: 32 cells, then 32 more a screen block on.

Called by WorldMap_UpdateView when the view crosses a row.

Definition at line 456 of file world_map.c.

Referenced by Map_RenderPaletteMappedRow(), and WorldMap_UpdateView().

◆ Map_RenderPaletteMappedColumn()

void Map_RenderPaletteMappedColumn ( u32 tileColumn)

Draws world map tileColumn into the BG map: 64 cells down.

Called by WorldMap_UpdateView when the view crosses a column.

Definition at line 484 of file world_map.c.

Referenced by Map_RenderPaletteMappedColumn(), and WorldMap_UpdateView().

◆ WorldMap_UpdateView()

void WorldMap_UpdateView ( void )

Each frame on the world map: loads tiles as the view moves, shakes and follows the player, draws the BG row or column that scrolls into view, moves the camera, and builds the ground plane's scanline table.

Registered with the scheduler by Map_InitializePerspectiveScene (priority 0xc85, as Map_UpdateLayerScroll is on layered maps). Sets viewX and viewY, decays the shake, moves the camera and its eye, and runs Transform_UpdateVertices from heap slot 46 into this frame's affine page.

Definition at line 508 of file world_map.c.

Referenced by Map_InitializePerspectiveScene(), and WorldMap_UpdateView().

◆ Map_UpdateCurrentTileBlock()

void Map_UpdateCurrentTileBlock ( void )

Loads and draws the 2x2 world map tiles around the player in both layers.

Called through Map_UpdateCurrentTileBlockFar when the world map scene starts, by WorldMap_LoadGraphics for the second graphics set, and by Map_LoadAreaGraphics and Map_LoadDefaultCellsAndUpdateBlock after the still view.

Definition at line 607 of file world_map.c.

Referenced by Map_LoadAreaGraphics(), Map_LoadDefaultCellsAndUpdateBlock(), Map_UpdateCurrentTileBlock(), and WorldMap_LoadGraphics().

◆ Map_PreloadCurrentTileBlock()

void Map_PreloadCurrentTileBlock ( void )

Loads the first of the 2x2 world map tiles around the player that is not shown yet (at most one a frame), without drawing it.

Called at the start of each WorldMap_UpdateView, so tiles come in one a frame as the player walks.

Definition at line 648 of file world_map.c.

Referenced by Map_PreloadCurrentTileBlock(), and WorldMap_UpdateView().

◆ MapAnimation_PresentFrame()

void MapAnimation_PresentFrame ( void )

VBlank: shows BG1 and copies the decoded frame's tiles into VRAM.

The frame is the still view WorldMap_BeginStillView draws: 0x2580 words, 240 by 160 pixels at a byte each, shown as 256-colour tiles on screen block 6. Set as gVBlankHook by WorldMap_BeginStillView.

Definition at line 684 of file world_map.c.

Referenced by MapAnimation_PresentFrame(), and WorldMap_BeginStillView().

◆ WorldMap_BeginStillView()

void WorldMap_BeginStillView ( void )

Freezes the world map's perspective view as a still picture on BG1: saves BG1's tiles, draws the current affine frame into pixels and hands the window and VBlank to it.

Called through WorldMap_BeginStillViewFar by WorldMap_BeginEvent when a menu or event starts on the world map, and by the world map scene's lighthouse transition. Sets animationActive, suspends the tile animations (MapAnimation_Update), copies 8 KB of char block 1 to gDecodeBuffer, sets the window rows to 200 and 255 (BG mode 0) and sets gVBlankHook to MapAnimation_PresentFrame. Map_LoadAreaGraphics undoes it.

Definition at line 701 of file world_map.c.

Referenced by GameFlag_IsSet(), WorldMap_BeginStillView(), and WorldMap_PlayLighthouseTransition().

◆ Map_ShowBg1FromBuffer()

void Map_ShowBg1FromBuffer ( void )

VBlank: shows BG1 and copies the area's tiles back into VRAM.

Restores BG1CNT as Map_InitializePerspectiveScene set it, and the 32 KB of char blocks 2 and 3 the still view overwrote, from gBgTileBuffer. Set as gVBlankHook by Map_LoadAreaGraphics and Map_LoadDefaultCellsAndUpdateBlock.

Definition at line 722 of file world_map.c.

Referenced by Map_LoadAreaGraphics(), Map_LoadDefaultCellsAndUpdateBlock(), and Map_ShowBg1FromBuffer().

◆ Map_LoadAreaGraphics()

void Map_LoadAreaGraphics ( void )

Reloads the world map area's palette and tiles after the still view, puts the default cells back and returns to the perspective view.

Called through Map_LoadAreaGraphicsFar by WorldMap_EndEvent when a menu or event ends, by Map_ShowWorldMap, and by the world map scene's lighthouse transition. Decodes into gMapCellBuffer and gBgTileBuffer, sets gVBlankHook to Map_ShowBg1FromBuffer, sets the window rows back to 0 and 159, clears animationActive and resumes the tile animations. Waits two frames.

Definition at line 737 of file world_map.c.

Referenced by Map_LoadAreaGraphics(), and WorldMap_PlayLighthouseTransition().

◆ Map_LoadDefaultCellsAndUpdateBlock()

void Map_LoadDefaultCellsAndUpdateBlock ( void )

Puts the default world map cells back after the still view and returns to the perspective view, without reloading the area's palette or tiles.

Called three times by the world map scene's events. Unlike Map_LoadAreaGraphics it leaves animationActive set. XXX: whether leaving animationActive set is intended; a scene that calls it and then opens a menu would show the effect.

Definition at line 780 of file world_map.c.

Referenced by Map_LoadDefaultCellsAndUpdateBlock(), and WorldMap_ShowEndingScene().

◆ MapAnimation_Update()

void MapAnimation_Update ( void )

Each frame: runs the 16 tile animation channels.

A channel script is groups of four halfwords (source tile, count, destination tile, frames to wait) that copy tiles into VRAM; 0xfeNN jumps to halfword offset NN * 2, 0xfeff stops, and 0xffff loops to the start. MapAnimation_StartChannels schedules it (order 0xc80); the world map's still view (WorldMap_BeginStillView) suspends it. Moves each channel's cursor and timer in the map work. The retries stay gotos: as an inner for (;;) loop with continue and break, loop.c reshapes the channel loop.

Definition at line 15 of file map_animation.c.

Referenced by Map_LoadAreaGraphics(), Map_LoadDefaultCellsAndUpdateBlock(), MapAnimation_Resume(), MapAnimation_StartChannels(), MapAnimation_Suspend(), MapAnimation_Update(), and WorldMap_BeginStillView().

◆ Map_ClearLayerEntryFlag()

◆ Map_SetLayerEntryFlag()

◆ MapAnimation_StartChannels()

void MapAnimation_StartChannels ( const u16 * script)

Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel NN & 15 there (paused when bit 7 is set).

Clears all 16 channels first, and schedules MapAnimation_Update when any starts. Called by Map_LoadLayeredScene with the map's own script, and by Map_InitializePerspectiveScene with the world map's default one.

Definition at line 113 of file map_animation.c.

Referenced by Map_InitializePerspectiveScene(), Map_LoadLayeredScene(), and MapAnimation_StartChannels().

◆ MapAnimation_Suspend()

void MapAnimation_Suspend ( void )

Suspends the tile animations, unless the world map's still view is shown.

Menu_SuspendFieldTasks (menu/menu/common.c) calls it through MapAnimation_SuspendFar.

Definition at line 150 of file map_animation.c.

Referenced by MapAnimation_Suspend().

◆ MapAnimation_Resume()

void MapAnimation_Resume ( void )

Resumes the tile animations, unless the world map's still view is shown.

Menu_ResumeFieldTasks (menu/menu/common.c) calls it through MapAnimation_ResumeFar.

Definition at line 158 of file map_animation.c.

Referenced by MapAnimation_Resume().

◆ DisplayBlend_RunScript()

void DisplayBlend_RunScript ( void )

Each frame: runs the map's blend script.

A 0x3NNN command sets BLDCNT; any other sets BLDALPHA (or BLDY when not alpha blending) and waits the halfword after it in frames; 0xfeNN jumps, 0xfeff stops and 0xffff loops. DisplayBlend_StartScript schedules it (order 0xc80). Writes REG_BLDCNT, REG_BLDALPHA and REG_BLDY, and keeps the last BLDCNT in the map work's blendControl.

Definition at line 169 of file map_animation.c.

Referenced by DisplayBlend_ResumeScript(), DisplayBlend_RunScript(), DisplayBlend_StartScript(), and DisplayBlend_SuspendScript().

◆ DisplayBlend_StartScript()

void DisplayBlend_StartScript ( u16 * script)

Starts a map's blend script, unless it is empty.

Clears the map work's three-word blend state first, then schedules DisplayBlend_RunScript. Called by Map_LoadLayeredScene when the map's header has a blend script.

Definition at line 234 of file map_animation.c.

Referenced by DisplayBlend_StartScript(), and Map_LoadLayeredScene().

◆ DisplayBlend_SuspendScript()

void DisplayBlend_SuspendScript ( void )

Suspends the blend script.

The lighthouse scenes and Vale's Babi scene reach it through DisplayBlend_SuspendScriptFar.

Definition at line 259 of file map_animation.c.

Referenced by DisplayBlend_SuspendScript(), Event_HurryToThePlaza(), MercuryLighthouse_Initialize(), MercuryLighthouse_RideLift(), and Scene_RunEntrySetup().

◆ DisplayBlend_ResumeScript()

void DisplayBlend_ResumeScript ( void )

Resumes the blend script, through DisplayBlend_ResumeScriptFar.

Definition at line 264 of file map_animation.c.

Referenced by DisplayBlend_ResumeScript(), and MercuryLighthouse_Initialize().

◆ PaletteQueue_Initialize()

void PaletteQueue_Initialize ( void )

Allocates the palette cycling queue (heap slot 28) with its four entries cleared.

Definition at line 270 of file map_animation.c.

Referenced by PaletteQueue_Initialize().

◆ PaletteQueue_Add()

s32 PaletteQueue_Add ( s16 paletteBank,
s16 firstColor,
s16 delay,
s16 colorCount )

Adds a palette cycle: colorCount colours of background palette paletteBank from firstColor, rotated by one every delay + 1 frames.

Returns 0, or -1 when all four cycles are taken. The cycle keeps a copy of the colours as they were, which every step rotates from.

Definition at line 297 of file map_animation.c.

Referenced by PaletteQueue_Add().

◆ PaletteQueue_Stop()

void PaletteQueue_Stop ( void )

Stops the palette cycles and frees their queue (heap slot 28).

Definition at line 326 of file map_animation.c.

Referenced by PaletteQueue_Stop().

◆ PaletteQueue_Start()

void PaletteQueue_Start ( void )

Starts running the palette cycles each frame.

Definition at line 332 of file map_animation.c.

Referenced by PaletteQueue_Start().

◆ PaletteQueue_StepCycles()

void PaletteQueue_StepCycles ( void )

Each frame: advances each palette cycle whose timer has run out by one colour, writing the rotated colours back to the palette.

Only PaletteQueue_Start schedules it, and nothing calls that, so no palette cycle runs in the game.

Definition at line 340 of file map_animation.c.

Referenced by PaletteQueue_Start(), PaletteQueue_StepCycles(), and PaletteQueue_Stop().

◆ Curve_GetFirstSampleA()

s32 Curve_GetFirstSampleA ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

The terrain height functions (gMap_TerrainHeightFunctions): each takes a cell's height samples after its kind byte and a pixel (x, y) within the 16x16 cell, and returns the ground height there in 16.16 pixels.

This one is flat: the first sample everywhere. Each is reached only through that table, by the low four bits of the cell's kind byte: this one is kind 0, and the rest follow in order.

Definition at line 21 of file terrain.c.

Referenced by Curve_GetFirstSampleA().

◆ Curve_LerpTwoSamples()

s32 Curve_LerpTwoSamples ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

A slope along x: from sample 0 at x = 0 towards sample 1 at x = 16.

Kind 1.

Definition at line 28 of file terrain.c.

Referenced by Curve_LerpTwoSamples().

◆ Curve_LerpTwoSamplesB()

s32 Curve_LerpTwoSamplesB ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

A slope along y: from sample 0 at y = 0 towards sample 1 at y = 16.

Kind 2.

Definition at line 44 of file terrain.c.

Referenced by Curve_LerpTwoSamplesB().

◆ Curve_StepAtSummedPosition()

s32 Curve_StepAtSummedPosition ( const u8 * heightBytes,
s32 x,
s32 y )

A step across the diagonal x + y = 15: sample 0 before it, sample 1 after it and the higher of the two on it.

Kind 3.

Definition at line 61 of file terrain.c.

Referenced by Curve_StepAtSummedPosition().

◆ Curve_StepAtDifferencePosition()

s32 Curve_StepAtDifferencePosition ( const u8 * heightBytes,
s32 x,
s32 y )

A step across the diagonal x = y: sample 0 where y < x, sample 1 where y > x and the higher of the two on it.

Kind 4.

Definition at line 88 of file terrain.c.

Referenced by Curve_StepAtDifferencePosition().

◆ Curve_LerpThreeSamplesByRatio()

s32 Curve_LerpThreeSamplesByRatio ( const u8 * heightBytes,
s32 x,
s32 y )

A slope that bends on the diagonal x + y = 15: from sample 0 at the top left corner to sample 1 on the diagonal to sample 2 at the bottom right.

Kind 5.

Definition at line 118 of file terrain.c.

Referenced by Curve_LerpThreeSamplesByRatio().

◆ Curve_LerpThreeSamplesAtDifference()

s32 Curve_LerpThreeSamplesAtDifference ( const u8 * heightBytes,
s32 x,
s32 y )

A slope that bends on the diagonal x = y: from sample 0 at the top right corner to sample 1 on the diagonal to sample 2 at the bottom left.

Kind 6. It divides by 16 with a shift where kind 5 divides by 15, so its slopes are 15/16 as steep and it never reaches sample 2 exactly.

Definition at line 149 of file terrain.c.

Referenced by Curve_LerpThreeSamplesAtDifference().

◆ Curve_LerpTwoSamplesByTable()

s32 Curve_LerpTwoSamplesByTable ( const u8 * heightBytes,
s32 x,
s32 y )

A raised or sunken rounded square: sample 1 where gCurve_LerpWeightTable is 1, sample 0 in the corners.

Kind 7.

Definition at line 188 of file terrain.c.

Referenced by Curve_LerpTwoSamplesByTable().

◆ Curve_StepAtHalf()

s32 Curve_StepAtHalf ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

A step along x: sample 0 for x < 8, sample 1 from x = 8.

Kind 8.

Definition at line 201 of file terrain.c.

Referenced by Curve_StepAtHalf().

◆ Curve_StepAtHalfB()

s32 Curve_StepAtHalfB ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

A step along y: sample 0 for y < 8, sample 1 from y = 8.

Kind 9.

Definition at line 214 of file terrain.c.

Referenced by Curve_StepAtHalfB().

◆ Curve_LerpThreeSamplesAtHalf()

s32 Curve_LerpThreeSamplesAtHalf ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

A slope along x that bends at the middle: sample 0 at x = 0, sample 1 at x = 8, towards sample 2 at x = 16.

Kind 10.

Definition at line 228 of file terrain.c.

Referenced by Curve_LerpThreeSamplesAtHalf().

◆ Curve_LerpThreeSamplesAtHalfB()

s32 Curve_LerpThreeSamplesAtHalfB ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

A slope along y that bends at the middle, as kind 10 does along x.

Kind 11. Its samples are read unsigned: 128 to 255 are heights, where the other kinds read them as -128 to -1.

Definition at line 266 of file terrain.c.

Referenced by Curve_LerpThreeSamplesAtHalfB().

◆ Curve_LookupSampleByTable()

s32 Curve_LookupSampleByTable ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

The sample gCurve_SampleIndexTable picks for (x, y).

Kind 12.

Definition at line 300 of file terrain.c.

Referenced by Curve_LookupSampleByTable().

◆ Curve_LookupSampleByTableReversed()

s32 Curve_LookupSampleByTableReversed ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

The same, with the table mirrored left to right.

Kind 13.

Definition at line 311 of file terrain.c.

Referenced by Curve_LookupSampleByTableReversed().

◆ Curve_GetFirstSampleB()

s32 Curve_GetFirstSampleB ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

Flat, as Curve_GetFirstSampleA. Kind 14.

Definition at line 323 of file terrain.c.

Referenced by Curve_GetFirstSampleB().

◆ Curve_GetFirstSampleC()

s32 Curve_GetFirstSampleC ( const u8 * heightBytes,
s32 pixelX,
s32 pixelY )

Flat, as Curve_GetFirstSampleA. Kind 15.

Definition at line 329 of file terrain.c.

Referenced by Curve_GetFirstSampleC().

◆ Map_GetTerrainHeight()

s32 Map_GetTerrainHeight ( s32 layer,
s32 x,
s32 y )

Returns the ground height of a layer at (x, y) in 16.16 pixels: the height function of the cell's terrain kind applied to its samples.

y is the map's down axis, an object's z.

Called each frame by Object_UpdateAllThumb for objects that follow the terrain, by the player control, and as Map_GetTerrainHeightFar by the field scene's objects, the Psynergy effects and about ten scene overlays.

Definition at line 343 of file terrain.c.

Referenced by AltinPeak_AdvanceLog(), AltinPeak_RollLog(), BabiLighthouse_FindActorAhead(), ColossoLog_Initialize(), ColossoRiver_Initialize(), CrossboneIslePillarRooms_LowerActorToLedge(), Event_JumpOrPushRoom4Pillar(), Event_SettleRocks(), Event_SettleRocks(), Imil_RunIceSlide(), Imil_SlideActorAcrossIce(), KolimaForestBend_CreateLogs(), Map_GetTerrainHeight(), Object_MoveByKeys(), Object_UpdateAllThumb(), and TretTreeBranch_ShiftLeaderAndCameraByCells().

◆ Map_GetCellAttributeLowNibble()

s32 Map_GetCellAttributeLowNibble ( s32 layer,
s32 x,
s32 y )

Returns the terrain kind (the low four bits of the first collision byte) of a layer's cell at (x, y) in 16.16 pixels.

Called through Map_GetCellAttributeLowNibbleFar by the Psynergy Move effect.

Definition at line 376 of file terrain.c.

Referenced by Map_GetCellAttributeLowNibble().

◆ GetMapCellCollision()

s32 GetMapCellCollision ( s32 layer,
s32 x,
s32 y )

Returns the collision code of a layer's cell at (x, y) in 16.16 pixels.

The shift by 20 takes 16.16 pixels straight to 16-pixel cells. Called through GetMapCellCollisionFar by the Psynergy climbing and by scenes (Altin Peak, Colosso, Imil, Crossbone Isle).

Definition at line 401 of file terrain.c.

Referenced by AltinPeak_RollLog(), ColossoLogRollingStage_CheckObstacleDestination(), Event_MovePillar(), GetMapCellCollision(), Imil_RunIceSlide(), and Imil_SlideActorAcrossIce().

◆ SetMapCellCollision()

void SetMapCellCollision ( u32 layer,
s32 x,
s32 y,
u32 collisionCode )

Sets the collision code of a layer's cell at (x, y) in 16.16 pixels.

Writes the cell in the map's grid; does nothing before the map is set up. Called through SetMapCellCollisionFar by scenes (Colosso, Altin Peak, Crossbone Isle, Venus Lighthouse, Tolbi, Sol Sanctum).

Definition at line 422 of file terrain.c.

Referenced by AltinPeak_MarkActorTerrainCell(), ColossoLog_UpdateEastEndCollision(), Event_GrowPlant11(), Event_GrowPlant12(), Event_GrowPlant13(), Event_GrowPlant14(), Event_LiftCarryBlock(), Event_MoveCarryBlock(), Field_SetMapCellCollision(), and SetMapCellCollision().

◆ Map_GetCellHighFlags()

s32 Map_GetCellHighFlags ( s32 x,
s32 y )

Returns the top two bits of the block word of the cell at pixel (x, y).

Definition at line 437 of file terrain.c.

Referenced by Map_GetCellHighFlags().

◆ Map_CheckObjectStep()

s32 Map_CheckObjectStep ( struct ObjectRuntime * object,
struct FieldPosition * position )

Returns whether an object can step to position: 2 when the cell there is a wall (collision code 0xff), 1 when the ground is more than 8 pixels higher than the object's, -1 when it is more than 12 pixels lower, else 0.

Called by the player control and the script commands that pick a free step, and as Map_CheckObjectStepFar by the Psynergy effects (Move, Carry, Force, climbing). A terrainId above 2 reads the grid from its start.

Definition at line 454 of file terrain.c.

Referenced by FieldObject_UpdatePlayerControl(), Map_CheckObjectStep(), Object_Wander(), and ScriptObject_WanderNearHome().

◆ CheckMapPositionCellOccupied()

s32 CheckMapPositionCellOccupied ( struct WorldPosition * position)

Returns 0 when the cell under position (its x, and y less its height) in layer 2 is a wall (collision code 0xff), else -1.

The name says the opposite of what it returns: 0 is the blocked answer. Called by the player control and, as CheckMapPositionCellOccupiedFar, by the Psynergy climbing.

Definition at line 506 of file terrain.c.

Referenced by CheckMapPositionCellOccupied(), and Object_MoveByKeys().

◆ GetWorldMapCollision()

s32 GetWorldMapCollision ( struct WorldPosition * position)

Returns the world map's collision value (1-15) at position: from the upper collision layer where it has one, else the lower, else 7.

Each layer is a tile map of 4-bit collision pixels.

Called by the player control, CheckWorldMapWalkable and GetWorldMapTerrainBehavior.

Definition at line 535 of file terrain.c.

Referenced by CheckWorldMapWalkable(), GetWorldMapCollision(), GetWorldMapTerrainBehavior(), and Object_MoveOnWorldMap().

◆ CheckWorldMapWalkable()

s32 CheckWorldMapWalkable ( s32 unused,
struct WorldPosition * position )

Returns 0 when the world map at position can be walked on (collision 5 to 12), else -1.

The first argument is not read; the player control passes its object. Called by the player control as it probes the steps around the object it moves.

Definition at line 586 of file terrain.c.

Referenced by CheckWorldMapWalkable(), and Object_MoveOnWorldMap().

◆ GetWorldMapTerrainBehavior()

s32 GetWorldMapTerrainBehavior ( struct WorldPosition * position,
s32 * terrainKind )

Returns the world map's terrain behaviour at position from gWorldMap_TerrainBehaviorTable, and stores the block's terrain kind in terrainKind.

Called through GetWorldMapTerrainBehaviorFar by the world map's encounters (Encounter_ResolveWorldMapZoneAndBackdrop).

Definition at line 599 of file terrain.c.

Referenced by GetWorldMapTerrainBehavior().

◆ Map_SetScreenShake()

void Map_SetScreenShake ( s32 shakeX,
s32 shakeY,
s32 shakeDecay )

Changes the shake without restarting an axis whose argument is negative.

Amplitudes are 16.16 pixels and decay is a 16.16 multiplier per frame. Scene commands reach it through Map_SetShake and Map_SetScreenShakeFar.

Definition at line 15 of file view.c.

Referenced by Map_SetScreenShake().

◆ Map_WaitForShakeToSettle()

void Map_WaitForShakeToSettle ( void )

Waits until both shake amplitudes are below 1/256 pixel, with a 300-frame limit for a shake whose decay never settles.

Scene imports reach it as Map_WaitForShakeToSettleFar; it stops further shake after the wait.

Definition at line 36 of file view.c.

Referenced by GomaCaveWaterway_LeapStump(), GondowanCave_RunSpinningLeap(), and Map_WaitForShakeToSettle().

◆ TileMap_DrawRowsFromRam()

void TileMap_DrawRowsFromRam ( const struct MapAffinePair * lines,
u8 * pixels )

Draws the current affine page into the world map's still-view pixels.

WorldMap_BeginStillView supplies 160 pairs and a 240 by 160 byte output. The ARM kernel borrows HEAP_SLOT_TEMP_RENDERER for this synchronous call; it is released before returning, while both graphics buffers stay owned by the world map.

Definition at line 64 of file view.c.

Referenced by TileMap_DrawRowsFromRam(), and WorldMap_BeginStillView().

◆ WorldMap_BuildScanlineTable()

void WorldMap_BuildScanlineTable ( s32 pitchSlope,
s32 * position,
struct MapScanline * scanline )

Rebuilds the ground plane's scanline terms when the world map pitch changes.

Map_InitializePerspectiveScene and WorldMap_UpdateView supply the pitch's sine/cosine ratio and the followed position, both in 16.16. Each screen line gets a width scale and signed ground distance, or zeros above the horizon; Transform_UpdateVertices reads them to build the frame's affine page.

Definition at line 88 of file view.c.

Referenced by Map_InitializePerspectiveScene(), WorldMap_BuildScanlineTable(), and WorldMap_UpdateView().

◆ Ui_RunIconMonitor()

void Ui_RunIconMonitor ( void )

A debug sprite viewer, which never returns.

It shows a sprite (with up to three more animation layers) once for each of its facings, in a ring. Start with the direction pad moves the ring; otherwise up and down choose a layer and left and right what to edit: 0 the animation, 1 the sprite number (ten at a time with Start), 2 the priority, 3 the draw parameter, changed with L and R. A restarts the animation, or in the other modes turns a layer on or off. Pressing Start toggles the shadows; B turns the ring when it is rebuilt with Start held. Select starts over; it passes a far-call resource set (the alternate one unless B is held) to RuntimeDispatch_ReturnZero, a stub that ignores it.

It has a bare veneer in the field far-call table, and no caller names it. Takes heap slot 9 for the ring of ten positions and runs Battle_PlaceActorsByFormationKind each frame to draw the copies.

Definition at line 45 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor().

◆ Ui_FindNextSpriteWithImage()

s32 Ui_FindNextSpriteWithImage ( s32 spriteId,
s32 direction )

Returns the next sprite id after spriteId, stepping by direction (1 or -1) and wrapping within 0-511, whose metadata has an image (a nonzero width).

Called by Ui_RunIconMonitor.

Definition at line 386 of file sprite_viewer.c.

Referenced by Ui_FindNextSpriteWithImage(), and Ui_RunIconMonitor().

◆ Map_BuildProbeRing()

void Map_BuildProbeRing ( s32 centerX,
s32 centerY,
struct SpritePlacement * positions )

Lays out the sprite viewer's ring around pixel (x, z): one position per facing of the first sprite's facing kind (6, 8, 10 or 4, or two opposite pairs for kind 20), 56 pixels out (40 for kind 20).

B held turns the ring. Called by Ui_RunIconMonitor when it starts and while Start moves the ring.

Definition at line 415 of file sprite_viewer.c.

Referenced by Map_BuildProbeRing(), and Ui_RunIconMonitor().

◆ Ui_FillGridColumnFromMetadata()

void Ui_FillGridColumnFromMetadata ( s32 layerIndex,
s32 animationIndex )

Starts animationIndex on layerIndex of each of the viewer's ten sprites, each one a frame (16 timer units) behind the last, so the copies are staggered.

Also sets each copy's offsetY and clears its rotation. Called by Ui_RunIconMonitor.

Definition at line 555 of file sprite_viewer.c.

Referenced by Ui_FillGridColumnFromMetadata(), and Ui_RunIconMonitor().

◆ Ui_SetGridColumnNumber()

void Ui_SetGridColumnNumber ( s32 layerIndex,
s32 spriteId )

Sets spriteId on layerIndex of each of the viewer's ten sprites.

Resets each layer from its new metadata. Called by Ui_RunIconMonitor when a layer other than 0 gets a new sprite.

Definition at line 591 of file sprite_viewer.c.

Referenced by Ui_RunIconMonitor(), and Ui_SetGridColumnNumber().

◆ Battle_PlaceActorsByFormationKind()

void Battle_PlaceActorsByFormationKind ( void )

Each frame in the sprite viewer: places each copy of the sprite at its ring position, facing the way that position stands for.

Despite its name it belongs to the sprite viewer, which schedules it; its ring is the placements in heap slot 9 (HEAP_SLOT_BATTLE) and its sprites the pool in heap slot 4.

Definition at line 613 of file sprite_viewer.c.

Referenced by Battle_PlaceActorsByFormationKind(), and Ui_RunIconMonitor().