1#ifndef ALCHEMY_UNIT_FIELD_FIELD_H
2#define ALCHEMY_UNIT_FIELD_FIELD_H
107 s32 operation,
s32 value);
109 s32 operation,
s32 value);
111 s32 operation,
s32 value);
113 s32 operation,
s32 value);
119 s32 operation,
s32 value);
121 s32 operation,
s32 value);
125 s32 operation,
s32 value);
134 s32 *screenPosition);
152 s32 linkedObjectHandle);
159 s32 linkedObjectHandle);
229 s32 *secondPosition,
s32 radiusB);
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).
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 ...
s32 ResourceMetadata_Register(struct AnimationObject *sprite, s32 id)
Adds a layer of animation id to a sprite, in its first free layer of four.
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.
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 ...
void ObjectSystem_Configure(s32 mode)
Allocates and zeroes the 64 sprites and 64 animation layers (from the fixed blocks in mode 3,...
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),...
s32 AnimationObjects_SetActiveFrameTimers(struct AnimationObject *sprite, s32 frames)
Sets each animated layer's timer to the given duration in frames.
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...
s32 Animation_LookupValueByKey(s32 tag)
Returns the buffer loaded into the resource slot with this tag, or 0.
void ResourceObject_Release(struct AnimationObject *sprite)
Releases a sprite: its VRAM cache entry (unless retainCacheEntry is set), its four animation layers,...
s32 Animation_InitializeObjects(struct AnimationObject *sprite)
Resets each layer of a sprite from its animation's metadata: its facing kind, frames,...
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...
void Animation_SetWorkEntry(struct AnimationEntry *layer, s32 animation)
Starts the indexed animation on a layer when its metadata contains it.
void Animation_InitWorkFromMetadata(struct AnimationEntry *layer)
Resets one animation layer from its animation's metadata, as Animation_InitializeObjects does for eac...
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 t...
u8 * Resource_DecompressLz(const u8 *source, u8 *destination)
Decompresses an LZ stream from source into destination and returns destination.
void ObjectDispatch_StartMoveByKeys(struct DispatchObject *object)
Starts an object on the script that moves it by the keys (SC_KEYS).
void ObjectDispatch_SetChildRotation(struct DispatchObject *object, u32 rotation)
Sets the rotation of an object's sprite, when it has just one.
void ObjectDispatch_StartApproachLink(struct DispatchObject *object, s32 linkedObjectHandle)
Starts an object on the script that approaches its linked object (SC_APPROACH_LINK),...
void Animation_ApplyChildValues(struct DispatchObject *object, u32 param)
Sets the draw parameter of a one-sprite object's layers (see ObjectGroup_SetChildValueUnlessFifteen).
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...
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 Animation_SetIndexAndInitObjects(void *rawDispatchObject, s32 animationId)
Gives a one-sprite object's first layer animation id animationId and restarts its layers.
void Map_RenderAnimatedTileFramesForObject(u8 *sprite)
Dissolves a sprite pixel by pixel, four steps a frame, over 32 frames.
void ObjectDispatch_Initialize(struct DispatchObject *object, const s32 *script)
Gives an object a script and starts it from the top.
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 o...
void ObjectDispatch_RegisterChildMetadata(struct DispatchObject *object, s32 animationId)
Adds a layer of animation id animationId to a one-sprite object's sprite.
void ObjectDispatch_StartPlayerControl(struct DispatchObject *object)
Starts an object on the player control script (SC_PLAYER).
void ObjectDispatch_SetSingleChildFlags(struct DispatchObject *object, u32 flags)
Sets the flags of a one-sprite object's sprite (bit 0: draw its shadow).
UNUSED void ResourceTable_ReservedNoOpC0C4(void)
void ObjectDispatch_StartKeyCheck(struct DispatchObject *object)
Starts an object on the script that runs SC_KEY_COUNT every frame.
void ObjectDispatch_SetChildBlendMode(struct DispatchObject *object, u32 mode)
Sets the OAM blend mode of a one-sprite object's sprite.
void Map_RenderAllAnimatedTileFrames(u8 **sprites, s32 count)
Dissolves count sprites together, pixel by pixel, over 32 frames.
void ObjectDispatch_StartWorldMapControl(struct DispatchObject *object)
Starts an object on the world map control script (SC_WORLD).
UNUSED void ResourceTable_ReservedNoOp2(void)
void ObjectDispatch_Release(struct DispatchObject *object)
Releases an object's sprites and zeroes it, freeing it.
void * ObjectDispatch_FindFreeObject(void)
Returns the first of the 64 objects not in use (with no script), or 0.
UNUSED s32 ObjectDispatch_ReturnTrue(void)
void ObjectSystem_ResumeProjectionAndHideLayers(void)
Resumes the object camera updates and hides BG1-3 and the sprites.
void ObjectDispatch_SelectAnimation(void *rawObject, s32 value)
Switches all of an object's sprites to animation value.
void ObjectDispatch_StartCamera(struct DispatchObject *object, s32 linkedObjectHandle)
Starts an object on the camera script (SC_CAMERA).
void Map_RenderAnimatedTileFrame(u8 *obj, u32 pos)
One step of dissolving a sprite pixel by pixel.
void ObjectDispatch_SetAnimationSpeed(struct DispatchObject *rawObject, s32 value)
Sets the animation speed (timer step) of all of an object's sprites.
void ObjectSystem_Initialize(s32 controlMode)
Sets up the object system: allocates and zeroes the 64 objects and registers the per-frame updates.
void ObjectDispatch_StartIdle(struct DispatchObject *object)
Starts an object on the idle script (a lone SC_END).
void ObjectDispatch_WaitForValue16(void *rawObject)
Waits until the object's script reaches SC_END (0x10), at most 300 frames.
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 ObjectSystem_SuspendProjectionAndShowSprites(void)
Suspends the object camera updates, starts the palette back to normal and, a frame later,...
void TileMap_DrawRowsFromRam(const struct MapAffinePair *lines, u8 *pixels)
Draws the current affine page into the world map's still-view pixels.
void Map_WaitForShakeToSettle(void)
Waits until both shake amplitudes are below 1/256 pixel, with a 300-frame limit for a shake whose dec...
void Map_SetScreenShake(s32 shakeX, s32 shakeY, s32 shakeDecay)
Changes the shake without restarting an axis whose argument is negative.
void WorldMap_BuildScanlineTable(s32 pitchSlope, s32 *position, struct MapScanline *scanline)
Rebuilds the ground plane's scanline terms when the world map pitch changes.
void Map_ShowBg1FromBuffer(void)
VBlank: shows BG1 and copies the area's tiles back into VRAM.
void Map_RenderPaletteMappedColumn(u32 tileColumn)
Draws world map tileColumn into the BG map: 64 cells down.
s32 Map_InitializePerspectiveScene(void)
Sets up the world map's perspective view: BG2 and BG3 in affine mode, the camera work,...
void WorldMap_UpdateView(void)
Each frame on the world map: loads tiles as the view moves, shakes and follows the player,...
void Map_LoadAreaGraphics(void)
Reloads the world map area's palette and tiles after the still view, puts the default cells back and ...
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,...
void MapAnimation_ApplyAffineFrame(void)
HBlank setup each frame on the world map: copies the first scanline's BG2 and BG3 affine parameters,...
void Map_UpdateCurrentTileBlock(void)
Loads and draws the 2x2 world map tiles around the player in both layers.
void MapAnimation_PresentFrame(void)
VBlank: shows BG1 and copies the decoded frame's tiles into VRAM.
void Map_RenderPaletteMappedRow(u32 tileRow)
Draws world map tileRow into the BG map: 32 cells, then 32 more a screen block on.
void WorldMap_BeginStillView(void)
Freezes the world map's perspective view as a still picture on BG1: saves BG1's tiles,...
void Map_LoadDefaultCellsAndUpdateBlock(void)
Puts the default world map cells back after the still view and returns to the perspective 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...
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 fro...
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 fra...
void DisplayBlend_SuspendScript(void)
Suspends the blend script.
UNUSED void PaletteQueue_Initialize(void)
Allocates the palette cycling queue (heap slot 28) with its four entries cleared.
UNUSED s32 PaletteQueue_Add(s16 paletteBank, s16 firstColor, s16 delay, s16 colorCount)
Adds a palette cycle: colorCount colours of background palette paletteBank from firstColor,...
void Map_SetLayerEntryFlag(u32 channelIndex)
Pauses tile animation channel channelIndex by setting its paused byte.
void MapAnimation_Update(void)
Each frame: runs the 16 tile animation channels.
void DisplayBlend_StartScript(u16 *script)
Starts a map's blend script, unless it is empty.
UNUSED void PaletteQueue_Stop(void)
Stops the palette cycles and frees their queue (heap slot 28).
void MapAnimation_Resume(void)
Resumes the tile animations, unless the world map's still view is shown.
void Map_ClearLayerEntryFlag(u32 channelIndex)
Resumes tile animation channel channelIndex by clearing its paused byte.
void PaletteQueue_StepCycles(void)
Each frame: advances each palette cycle whose timer has run out by one colour, writing the rotated co...
void DisplayBlend_ResumeScript(void)
Resumes the blend script, through DisplayBlend_ResumeScriptFar.
UNUSED void PaletteQueue_Start(void)
Starts running the palette cycles each frame.
void DisplayBlend_RunScript(void)
Each frame: runs the map's blend script.
void MapAnimation_StartChannels(const u16 *script)
Starts the tile animation channels a map's animation script lists: each 0xfdNN marker starts channel ...
void MapAnimation_Suspend(void)
Suspends the tile animations, unless the world map's still view is shown.
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 la...
void Tilemap_DecodeStagedBuffer(s32 size)
Unpacks the staged block data into gMapBlocks.
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,...
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,...
void Tilemap_ConvertBuffer(void)
Converts the map's cells in place with Tile_ConvertMap, run from RAM, from a saved copy of the staged...
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),...
void Map_UpdateLayerScroll(void)
Each frame on a layered map: centres the view on the point the map follows (origin),...
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),...
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 (til...
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 r...
void Map_CenterOnFollowedPoint(void)
Centres the camera on the point the map follows (origin: x, height, z), or on (0, 0) when there is no...
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 layerFla...
s32 Map_LoadLayeredScene(s32 index)
Loads layered scene index from gMap_LayeredScenes: its blocks, collision, cells, tile animations,...
void Runtime_RemapBytesByTable(u8 *bytes, s32 byteCount)
Remaps byteCount bytes in place through gRuntime_ByteRemapTable.
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),...
UNUSED void Tilemap_NumberPlaceholderBlocks(void)
Gives each map cell whose block number is 0xfff (a placeholder) a number of its own,...
UNUSED s32 ObjectCamera_ReturnTrue(void)
void ObjectSystem_UpdateCamera(void)
Each frame, with the scrolling camera: places every object's sprite on the screen.
void ObjectSystem_UpdateCameraFixed(void)
Each frame, with the fixed camera: places every object's sprite, from the 64th object down,...
void Object_SetMoveTarget(struct ObjectRuntime *object, s32 x, s32 y, s32 z)
Sends an object towards (x, y, z), in 16.16 pixels.
UNUSED void Object_RunUpdateAllFromHeap(void)
Copies Object_UpdateAll (ARM code) to the heap, runs it once and frees it.
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 Object_IsTargetUnset(struct ObjectRuntime *object)
Returns 1 when the object has no movement target: none of its target coordinates set,...
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.
void Object_UpdateAllThumb(void)
Advances all 64 field objects by one frame, as Object_UpdateAll does for the eight script objects,...
void Object_UpdateAllMotion(void)
Advances the first 14 objects' motion by one frame, without running their scripts: steering towards a...
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.
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 radius...
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 heigh...
s32 Field_CheckConfiguredKeysAndCount(struct ScriptInterpreter *interpreter)
SC_KEY_COUNT: checks the configured keys (Field_CheckConfiguredKeys).
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,...
s32 FieldObject_UpdatePlayerControl(struct ScriptInterpreter *interpreter)
SC_PLAYER: moves the player on the field by the direction pad: walking or running,...
UNUSED 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,...
s32 Field_CheckConfiguredKeys(void)
Checks the keys the player has configured: Select, A and Start set their flag in the event work and r...
A sprite's screen position and scale.
void Script_SetOrCompareWord68(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareUnsignedHalfword(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Object_ApproachLinkedObject(struct ScriptInterpreter *interpreter)
SC_APPROACH_LINK: follows the linked object at its speed.
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_FOREVE...
void Script_SetOrCompareVerticalMotion(struct ScriptOperands *operands, s32 operation, s32 value)
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,...
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_JumpToLabel(struct ScriptInterpreter *interpreter)
SC_JUMP(to): jumps to label to.
s32 Script_Wait(struct ScriptInterpreter *interpreter)
SC_WAIT(n): waits n frames; this frame counts as the first.
s32 Script_ClearFlagAndTest(struct ScriptInterpreter *interpreter)
void Script_SetOrCompareGravity(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_PlaySound(struct ScriptInterpreter *interpreter)
SC_SE(n): sends sound command n (a sound effect).
s32 Camera_FollowLeaderInBounds(struct ScriptInterpreter *interpreter)
SC_CAMERA: keeps the camera object on its leader (linkedObject), clamped so the view stays on the map...
void Script_SetOrCompareRadius(struct ScriptOperands *state, s32 operation, s32 value)
Work value SW_RADIUS: sets, adds to or compares the object's radius.
struct ScriptObjectEntry * ScriptObject_FindOverlappingEntry(struct ScriptObjectEntry *object, s32 *values)
Returns the first solid object that an object at position values would overlap, as ScriptObject_Check...
s32 Script_ApplyOperandSet(struct ScriptInterpreter *interpreter)
SC_SET(w, v): sets work value w to v.
void Script_SetOrCompareSpeedLimit(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareSignedHalfword66(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrComparePaused(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_JumpIfTrue(struct ScriptInterpreter *interpreter)
SC_IF(to): jumps to label to when the last test was true.
void Script_SetOrCompareRepeatCount(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_ApplyOperandAdd(struct ScriptInterpreter *interpreter)
SC_ADD(w, v): adds v to work value w.
s32 Script_ToggleFlagAndTest(struct ScriptInterpreter *interpreter)
SC_FLAG_REV(f): tests game flag f, then flips it.
s32 Script_InvokeCallback(struct ScriptInterpreter *interpreter)
SC_CALL(fn): calls fn with the 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; th...
s32 Script_Nop(struct ScriptInterpreter *interpreter)
SC_NOP(v): does nothing with its operand.
void Script_SetOrCompareCollisionFlags(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareComparisonResult(struct ScriptOperands *operands, s32 operation, s32 value)
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),...
s32 Script_FreeObject(struct ScriptInterpreter *interpreter)
SC_FREE: releases the object through ObjectDispatch_Release, which releases its sprites and zeroes it...
void Script_SetOrCompareCursor(struct ScriptOperands *operands, s32 operation, s32 value)
Work value SW_CURSOR: sets, adds to or compares the script cursor.
void Script_SetOrCompareByte63(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_End(struct ScriptInterpreter *interpreter)
SC_END: hands the object back to the idle script, gScript_MainScript, whose lone SC_END runs again ea...
s32 Script_ApplyAbsolutePosition(struct ScriptInterpreter *interpreter)
SC_MOVE(x, y, z): sends the object towards (x, y, z).
void Script_SetOrCompareScaleX(struct ScriptOperands *operands, s32 operation, s32 value)
s32 ScriptObject_WanderNearHome(struct ScriptInterpreter *interpreter)
SC_WANDER_HOME(base, range, limit): wanders as SC_WANDER does, testing more ground around the point,...
void Script_SetOrCompareAddress50(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareVelocityX(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareArrivalAxis(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareTargetY(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareZ(struct ScriptOperands *operands, s32 operation, s32 value)
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 ...
s32 Object_Wander(struct ScriptInterpreter *interpreter)
SC_WANDER(base, range, limit): walks to a random point base to base + range away, within 90 degrees e...
void Script_SetOrCompareSnapToTarget(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareX(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareScaleY(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_TestFlag(struct ScriptInterpreter *interpreter)
SC_FLAG_CHECK(f): tests game flag f.
void Script_SetOrCompareY(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareTargetX(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareHalfword5e(struct ScriptOperands *work, s32 operation, s32 value)
Work value SW_WAIT: sets, adds to or compares the wait counter.
s32 Script_ApplyOperandCompare(struct ScriptInterpreter *interpreter)
SC_CMP(w, v): tests whether work value w equals v.
void Script_SetOrCompareByte54(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareWord4c(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareMotionFlags(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareSignedHalfword64(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_SetPositionAndResetMotion(struct ScriptInterpreter *interpreter)
SC_POS(x, y, z): places the object at (x, y, z) and stops it.
s32 Script_SetAnimation(struct ScriptInterpreter *interpreter)
SC_ARG(v): switches the object's sprites to animation v.
void Script_SetOrCompareVelocityY(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_ApplyLinkedObjectPosition(struct ScriptInterpreter *interpreter)
SC_MOVE_LINK: sends the object towards its linked object.
void Script_SetOrCompareByte62(struct ScriptOperands *operands, s32 operation, s32 value)
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 ...
void Script_SetOrCompareTerrainHeight(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareVelocityZ(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareTargetZ(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareAcceleration(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareSteeringFlags(struct ScriptOperands *operands, s32 operation, s32 value)
void Script_SetOrCompareAddress(struct ScriptOperands *operands, s32 operation, s32 value)
The work value handlers, one for each entry of enum ScriptWork (see gScript_OperandHandlerTable in op...
void Script_SetOrCompareUpdateAddress(struct ScriptOperands *operands, s32 operation, s32 value)
s32 Script_JumpIfFalse(struct ScriptInterpreter *interpreter)
SC_IFNOT(to): jumps to label to when the last test was false.
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,...
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_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 a...
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 a...
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,...
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,...
void Ui_SetGridColumnPriority(s32 layerIndex, s32 value)
void Ui_RunIconMonitor(void)
A debug sprite viewer, which never returns.
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 u...
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 ...
void Battle_PlaceActorsByFormationKind(void)
Each frame in the sprite viewer: places each copy of the sprite at its ring position,...
void Ui_SetGridColumnParameter(s32 layerIndex, s32 value)
Sets the draw parameter or the priority of one layer of the viewer's ten sprites.
void Ui_SetGridColumnNumber(s32 layerIndex, s32 spriteId)
Sets spriteId on layerIndex of each of the viewer's ten sprites.
One animation layer of a sprite: its animation id, frames, running script and timer.
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
u8 slot
VRAM cache entry holding its tiles.
u8 count
layers in use, up to the last one present
A field object as the object dispatcher's far calls take it.
One screen line's affine parameters for BG2 and BG3.
One screen line's ground-plane terms on the world map: its width scale and distance,...
One of the 64 field objects in the object pool (heap slot 5): its script, position,...
s32 z
16.16 fixed-point pixels
s32 * script
the object script it runs; null when the object is free
u8 flags
FieldActor.motionFlags: 3 when created, 4 for a placed actor above the ground; zero is free flight in...
void * animation
its sprite, or its list of four, by animationKind
s32 x
16.16 fixed-point pixels
s16 step
the script cursor, in words
s32 y
16.16 fixed-point pixels
The prefix that command handlers read from a field object's 0x70-byte slot.
A field object as the script commands' overlap checks see it.
A field object as its object script commands see it: the script and its place, position,...
The whole 0x70-byte slot as SC_SET, SC_ADD and SC_CMP see it: each field is one work value (enum Scri...
A sprite's screen position and its two vertical offsets, in 16.16 pixels.
Horizontal and vertical sprite scale; 0x10000 is the original size.
A position on the world map, as its walkability check reads it.
s32 height
16.16 fixed-point pixels
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 corner...
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_GetFirstSampleB(const u8 *heightBytes, s32 pixelX, s32 pixelY)
Flat, as Curve_GetFirstSampleA. Kind 14.
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)...
s32 Curve_LookupSampleByTableReversed(const u8 *heightBytes, s32 pixelX, s32 pixelY)
The same, with the table mirrored left to right.
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,...
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 tw...
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 Curve_GetFirstSampleC(const u8 *heightBytes, s32 pixelX, s32 pixelY)
Flat, as Curve_GetFirstSampleA. Kind 15.
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.
UNUSED s32 Map_GetCellHighFlags(s32 x, s32 y)
Returns the top two bits of the block word of the cell at pixel (x, y).
s32 GetWorldMapCollision(struct WorldPosition *position)
Returns the world map's collision value (1-15) at position: from the upper collision layer where it h...
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_LookupSampleByTable(const u8 *heightBytes, s32 pixelX, s32 pixelY)
The sample gCurve_SampleIndexTable picks for (x, y).
s32 Curve_GetFirstSampleA(const u8 *heightBytes, s32 pixelX, s32 pixelY)
The terrain height functions (gMap_TerrainHeightFunctions): each takes a cell's height samples after ...
s32 GetWorldMapTerrainBehavior(struct WorldPosition *position, s32 *terrainKind)
Returns the world map's terrain behaviour at position from gWorldMap_TerrainBehaviorTable,...
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...
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 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...
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 tw...
s32 GetMapCellCollision(s32 layer, s32 x, s32 y)
Returns the collision code of a layer's cell at (x, y) in 16.16 pixels.
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 di...
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 th...
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 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 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 ter...
The integer types, TRUE, UNUSED and the fixed-address macros.