field
games/tbs/include/field on GitHub
a9_motion.h
games/tbs/include/field/a9_motion.h
animspr.h
games/tbs/include/field/animspr.h
Structures
AnimationEntry
struct AnimationEntry
One animation layer of a sprite: its animation id, frames, running script and timer.
| Field | Declared as | |
|---|---|---|
animId | s16 animId | the sprite id whose metadata and frames it uses |
timer | u16 timer | Time left on the current frame in sixteenths of a frame, read signed: each timed command adds its argument times 16, each frame takes off step. |
kind | u8 kind | The facing table its frames follow (from the metadata, or ANIM_CMD_SET_KIND); zero marks a free layer record. |
param | u8 param | SpriteColorMode its pixels are drawn with; 0 when taken |
priority | u8 priority | drawing order 0 to 3 among the layers; above 3 not drawn |
mode | u8 mode | frame codec: 1 type-01, 3 LZ, anything else raw |
frames | void **frames | frame pointers, from the metadata or a resource slot |
scripts | u8 **scripts | the metadata's command scripts, one per animation number |
script | u8 *script | the running script; null when stopped (ANIM_CMD_END) |
pos | u8 pos | byte offset of the next command in script |
step | u8 step | taken off timer each frame; 16 is normal speed |
frame | u8 frame | frame shown, frameBase plus the facing offset; 255 none |
frameBase | u8 frameBase | frame the script chose, before facing; 255 blank |
Used by AnimationObject_Allocate, AnimationObjects_SelectAnimation, AnimationObjects_SetActiveFrameTimers, AnimationObjects_SetActiveTimerSteps, Animation_ApplyChildPalette, Animation_InitWorkFromMetadata, Animation_InitializeObjects, Animation_SetWorkEntry, BattleActor_SpawnObjectsForList, BattleEffect_PauseObject, BattleEvent_Playback, BattleMotion_SetMode5AndActivateSlot, BattleMotion_SetRecordChildValues, BattleMotion_ShowDowned, BattleMotion_SpawnSlotEffectAndWait, BattleStatusIcon_Cycle, FieldFx_BlinkAvoidCaster, FieldFx_EndCloak, FieldFx_RunAvoid, FieldFx_StartCloak, MercuryLighthouse_FollowLeader, ObjectDispatch_ApplyValueToKind200Children, ObjectGroup_ApplyIndexedChildValue, ObjectGroup_ApplyRandomChildValues, ObjectGroup_SetChildValue, ObjectGroup_SetChildValueUnlessFifteen, ObjectGroup_UpdateMembers, ObjectSystem_Configure, ObjectTable_ResetForObject, ResourceMetadata_ClearRecord, ResourceMetadata_Register, ResourceMetadata_ReleaseSlot, ResourceMetadata_Unregister, ResourceObject_Release, Sprite_ComposeAnimationFrame, Storm_SetActorFrameMode, TolbiSpring_SetActorAppearance, Ui_FillGridColumnFromMetadata, Ui_SetGridColumnNumber, gAnimationObjects.
ResourceSlot
struct ResourceSlot
A resource slot: the tag of the animation loaded into it (slot number and animation id) and the buffer holding its frames.
| Field | Declared as | |
|---|---|---|
tag | s32 tag | (slot << 12) | animation id |
buffer | void *buffer | the decoded frames, their offsets made pointers |
Used by Animation_LookupValueByKey, ResourceSlot_Load.
ObjectSystemWork
struct ObjectSystemWork
The object system's work: the flag that suspends sprite projection, the outline's edge and fill colours, and the resource slots. Heap slot 6.
| Field | Declared as | |
|---|---|---|
used | u16 used | sprite pixel bytes composed since the camera reset it |
unk02 | u8 unk02[2] | not named by TBS code |
suspended | s16 suspended | nonzero while a menu has suspended sprite projection |
edge | u8 edge | outline edge colour; 15 when the field sets up |
fill | u8 fill | outline fill colour; 0 when the field sets up |
unk08 | u8 unk08[0x10] | the sprite group tables, taken in turn by count |
count | s32 count | sprite group tables taken from unk08 |
slots | struct ResourceSlot slots[8] |
Used by Colosso_FadeInCompetitor, Colosso_RestoreCompetitor, ItemMenu_Run, Map_ShowWorldMap, ObjectSystem_Initialize, ObjectSystem_UpdateCamera, ObjectSystem_UpdateCameraFixed, PsynergyMenu_Run, ResourceSlot_Load, Sprite_ComposeAnimationFrame, StatusMenu_Run, gMenuCtrlWork.
AnimationSpritePart
struct AnimationSpritePart
The hardware sprite attributes one part of an animated sprite (its image or its shadow) is drawn with.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[4] | The link to the next part queued in the same depth slot this frame (Runtime_PushSlotEntry). |
y | u16 y : 8 | The OAM entry's attributes 0 to 2. @{ screen pixels |
affine | u16 affine : 2 | 0 plain, 1 affine, 3 affine at double size |
objectMode | u16 objectMode : 2 | |
mosaic | u16 mosaic : 1 | |
fullColor | u16 fullColor : 1 | 256 colours; set for both parts when created |
shape | u16 shape : 2 | |
x | u16 x : 9 | screen pixels |
affineIndex | u16 affineIndex : 5 | affine matrix, or 8 for a mirrored plain sprite |
size | u16 size : 2 | |
tile | u16 tile : 10 | first sprite tile in VRAM |
priority | u16 priority : 2 | 2 when created |
palette | u16 palette : 4 | |
unk0a | u8 unk0a[2] | @} zero when created; not named by TBS code |
Used by Colosso_UpdateLettering, Curtain_Close, FadeOverlay_DrawMarks, Map_UpdateWorldMapMarkers, Render_ApplyProjectedPlacement, Render_PlaceProjectedSprite, Render_PlaceSpritePartPair, ResourceObject_Create, SolSanctumStatue_UpdateScrollingSprites, sCurtainSprites.
AnimationObject
struct AnimationObject
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
| Field | Declared as | |
|---|---|---|
image | struct AnimationSpritePart image | |
shadow | struct AnimationSpritePart shadow | |
scale | s32 scale | 16.16 fixed point, 0x10000 full size |
slot | u8 slot | VRAM cache entry holding its tiles |
retainCacheEntry | u8 retainCacheEntry : 1 | Keeps the VRAM cache entry when it is released or off screen. |
useOwnScale | u8 useOwnScale : 1 | Drawn at its own scale, not scaled by distance (fixed camera). |
unk1d2 | u8 unk1d2 : 6 | not named by TBS code |
rotation | u16 rotation | 1/65536 turns |
width | u8 width | pixels; zero marks a free sprite |
height | u8 height | pixels |
offsetX | s8 offsetX | pixels |
offsetY | s8 offsetY | pixels |
lastNo | u8 lastNo | The animation number last selected, which selecting again skips. |
dirty | u8 dirty | nonzero redraws its pixels into VRAM when next drawn |
flags | u8 flags | bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created) |
count | u8 count | layers in use, up to the last one present |
entries | struct AnimationEntry *entries[4] | its layers; empty ones null |
Used by Actor_WaitForAnimationEnd, AnimationObjects_SelectAnimation, AnimationObjects_SetActiveFrameTimers, AnimationObjects_SetActiveTimerSteps, Animation_ApplyChildPalette, Animation_InitializeObjects, Animation_SetIndexAndInitObjects, BabiLighthouse_MatchLeaderPriority, BabiPalace_ApplyEntryState, BattleActor_SpawnObjectsForList, BattleActor_UpdateSpritePriorities, BattleEffect_UpdatePhasedRadialParticle, BattleEvent_Playback, BattleFx_DrawScaledObject, BattleFx_RunGaia, BattleFx_RunJudgment, BattleFx_RunKirin, BattleFx_RunMercuryDjinnCapture, BattleFx_RunParticleStreams, BattleFx_RunRamses, BattleFx_SetupObjectPair, BattleFx_SpawnDescendingArcParticles, BattleFx_SpawnItemBreakMode3, BattleFx_SpawnObjects, BattleFx_SpawnScaledArcObjects, BattleFx_StartEffectObject22, BattleFx_StartRandomParticleEmitter, BattleMotion_ProjectConditionalPosition, BattleMotion_ProjectPosition, BattleMotion_ProjectScaledPosition, BattleMotion_SetMode5AndActivateSlot, BattleMotion_SetRecordChildValues, BattleMotion_ShowDowned, BattlePres_RunAttack, BattlePres_RunItem, BattlePres_RunPlainAttack, BattlePres_RunPsynergyCast, BattlePres_RunUnitAction, BattlePresentation_RunUnitTransition, BattleStatusIcon_Cycle and 144 more.
Enumerations
SpriteColorMode
enum SpriteColorMode
AnimationEntry.param: how Render_DecodeFrame colours a layer's pixels. Modes 1 to 6 and 9 to 11 run them through a 256-byte table (the five gResourceSlot_ConversionTables, then the four gRuntime_ByteRemapTable ones); the solid modes paint every drawn pixel one colour of the basic sprite palette. Mode 8 is a second white and mode 12 reads past the tables.
| Value | = | |
|---|---|---|
SPRITE_COLOR_NORMAL | 0 | |
SPRITE_COLOR_GRB | 1 | red and green swapped |
SPRITE_COLOR_RBG | 2 | green and blue swapped |
SPRITE_COLOR_BGR | 3 | red and blue swapped |
SPRITE_COLOR_GBR | 4 | red to blue, green to red, blue to green |
SPRITE_COLOR_BRG | 5 | red to green, green to blue, blue to red |
SPRITE_COLOR_GREY | 6 | greyscale |
SPRITE_COLOR_WHITE | 7 | solid colour 15, white |
SPRITE_COLOR_BLUE_TINT | 9 | blue raised to full |
SPRITE_COLOR_RED_TINT | 10 | red raised to full |
SPRITE_COLOR_GREEN_TINT | 11 | green raised to full |
SPRITE_COLOR_FILL | 13 | solid gDecodeFillByte |
SPRITE_COLOR_BLACK | 14 | solid colour 1, black |
SPRITE_COLOR_HIDDEN | 15 | solid colour 0, transparent |
colosso_gauge.h
games/tbs/include/field/colosso_gauge.h
Structures
ColossoGaugeSprite
struct ColossoGaugeSprite
One sprite of the race gauge's list: a link word, its position and shape attributes, and its tile.
| Field | Declared as | |
|---|---|---|
link | s32 link | written 0; Runtime_PushSlotEntry links the queue through it |
attr | s32 attr | OAM attributes 0 and 1: y | x << 16 | shape and size bits |
tile | s32 tile | OAM attribute 2: the tile, with palette 14 and priority 1 |
Used by Colosso_DrawGauge.
ColossoGaugeWork
struct ColossoGaugeWork
The Colosso race gauge's work at the start of the race's heap slot (HEAP_SLOT_COLOSSO_RACE): its sprites, how far it has slid down, the racers and the finish.
| Field | Declared as | |
|---|---|---|
sprites | struct ColossoGaugeSprite sprites[18] | The bar, its ends and the racers' marks: 2 * segments + 6 sprites, all 18 for the Colosso Log's six segments. |
vramBlock | s16 vramBlock | The VRAM cache entry holding the gauge's tiles: released while the gauge is hidden, and loaded again when it slides back down. |
level | s16 level | 0 hidden to 2 fully down, stepping up while FLAG_MENU_OPEN is clear and down while it is set; the bar's y is level * 6 - 8. |
hold | s16 hold | Nonzero keeps the gauge down (level 2); only the unused Colosso_SetGaugeHold sets it. |
playerActor | s16 playerActor | the actor id drawn as the player's marker |
rivalActor | s16 rivalActor | The actor id drawn as the rival's marker, and the actor that runs the recorded path. |
finishItemActorA | u16 finishItemActorA | The first finisher's prize: the actor raised over that finisher, who stops at finishZ minus 16 pixels. |
finishItemActorB | u16 finishItemActorB | The second finisher's prize; that finisher stops at finishZ plus 16 pixels. |
segments | s16 segments | 16-pixel bar pieces either side of the centre: 6 in the Colosso Log, 4 in the River and 5 in the Wall. |
finishX | s32 finishX | 16.16 fixed-point pixels: the rival starts opposite Isaac across it and runs its path mirrored across it. |
finishZ | s32 finishZ | 16.16 fixed-point pixels |
Used by ColossoLog_CollectFinishEquipment, ColossoRiver_CollectFinishItem, ColossoWall_ApproachFinishAndTakeItem, Colosso_DrawGauge, Colosso_SetGaugeHold.
Macros
HEAP_SLOT_COLOSSO_RACE
#define HEAP_SLOT_COLOSSO_RACE 59
The heap slot of the Colosso finals' race work (struct ColossoRaceWork), which gColossoWork reads by its own name.
Used by ColossoWall_ApproachFinishAndTakeItem, ColossoWall_StartRivalPath, Colosso_SetGaugeHold, Colosso_StartRaceGauge, FieldScene_BuildDescriptorAndInstallTask.
effect_step.h
games/tbs/include/field/effect_step.h
Functions, without a comment: EffectStep_Coordinates, EffectPosition_Coordinates.
Structures
EffectStep
struct EffectStep
A moving point of an effect: its position, its velocity and a value each effect uses its own way (a size, a timer, -1 for idle).
| Field | Declared as | |
|---|---|---|
x, y, z, coordinates | union { struct { s32 x; ///< 16.16 fixed-point pixels s32 y; ///< 16.16 fixed-point pixels s32 z; ///< 16.16 fixed-point pixels }; s32 coordinates[3]; } | |
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | |
velocityX | s32 velocityX | 16.16 fixed-point pixels per frame |
velocityY | s32 velocityY | 16.16 fixed-point pixels per frame |
velocityZ | s32 velocityZ | 16.16 fixed-point pixels per frame |
variant | s32 variant | each effect's own: a size, a countdown, -1 for idle |
Used by BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunAtalanta, BattleFx_RunBeamSequence, BattleFx_RunBind, BattleFx_RunBladeRain, BattleFx_RunBolt, BattleFx_RunBoreas, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunBurstShower, BattleFx_RunCastingImpact, BattleFx_RunCybele, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDouse, BattleFx_RunDragonCloud, BattleFx_RunDrain, BattleFx_RunElementBurst, BattleFx_RunElementPillar, BattleFx_RunEruption, BattleFx_RunFire, BattleFx_RunFlare, BattleFx_RunFrost, BattleFx_RunFroth, BattleFx_RunGaia, BattleFx_RunGatheringLights, BattleFx_RunGround, BattleFx_RunGrowingColumns, BattleFx_RunHail, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunHelmSplitter, BattleFx_RunIce, BattleFx_RunImpactBurst, BattleFx_RunJudgment, BattleFx_RunJupiter, BattleFx_RunKirin, BattleFx_RunLobbedShells and 47 more.
EffectPosition
struct EffectPosition
A point projected onto the screen, with its depth.
| Field | Declared as | |
|---|---|---|
x, y, depth, coordinates | union { struct { s32 x; ///< screen pixels s32 y; ///< screen pixels s32 depth; ///< projected depth, larger further away }; s32 coordinates[3]; } | Projection writes three coordinates; effects read their named components. |
x | s32 x | screen pixels |
y | s32 y | screen pixels |
depth | s32 depth |
Used by BattleFx_DrawStreaks, BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunAtalanta, BattleFx_RunBeamSequence, BattleFx_RunBind, BattleFx_RunBladeRain, BattleFx_RunBolt, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunBurstShower, BattleFx_RunCastingImpact, BattleFx_RunCondemn, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDragonCloud, BattleFx_RunDrain, BattleFx_RunElementBurst, BattleFx_RunElementPillar, BattleFx_RunEruption, BattleFx_RunFire, BattleFx_RunFrost, BattleFx_RunFroth, BattleFx_RunGatheringLights, BattleFx_RunGround, BattleFx_RunHail, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunHelmSplitter, BattleFx_RunJudgment, BattleFx_RunKirin, BattleFx_RunLobbedShells, BattleFx_RunMirroredWall, BattleFx_RunMoteFountain, BattleFx_RunNeptune, BattleFx_RunOrbitingSkulls, BattleFx_RunOrbitingSpirals and 36 more.
event_work.h
games/tbs/include/field/event_work.h
Structures
EventWork
struct EventWork
The running scene's event work: its placement and event tables, its actors, the triggers and exit it has hit, encounters, transitions and the message on show. It is struct FieldWork (heap slot 27) as the scenes see it, through gEventWork; each field is the FieldWork field at its offset.
| Field | Declared as | |
|---|---|---|
tables | struct ScenePlacement *tables[4] | the placement tables placed so far |
events | struct SceneEvent *events | the scene's event table |
actors | struct FieldActor *actors[8] | the party's characters, ids 0 to 7 |
placedActors | struct FieldActor *placedActors[58] | the placed actors, from id 8 |
unk11c | u8 unk11c[0x50] | FieldWork's markers; not named by TBS code |
touchedTrigger | s16 touchedTrigger | the step event a touch or exit event answers |
unk16e | u8 unk16e[2] | FieldWork's input request; not named by TBS code |
requestedExit | u16 requestedExit | the exit kind taken, which ends the scene |
unk172 | u16 unk172 | FieldWork's menu request; scenes set it to 1 |
unk174 | u8 unk174[6] | FieldWork's examine, start and descriptor |
facingTrigger | s16 facingTrigger | the collision code ahead, which a search answers |
encounterEnemyGroup | u16 encounterEnemyGroup | the next battle's enemy group, 0 for none |
psynergyRequest | s16 psynergyRequest | a field Psynergy to use, as owner << 10 | Psynergy |
unk180 | u8 unk180[2] | FieldWork's item request; not named by TBS code |
raisedTrigger | s16 raisedTrigger | a raised event for Scene_RunRaisedEvent |
unk184 | u8 unk184[0x18] | FieldWork's fallen characters and item slot |
blockedSteps | s16 blockedSteps | frames the leader has pushed against something |
mode | s16 mode | MODE_WORLD_MAP (3) on the world map |
encounterGroups | u8 encounterGroups[8] | encounter zone for each kind of ground |
encounterBias | s32 encounterBias | randomized distance adjustment between battles |
encounterThreshold | s32 encounterThreshold | encounter steps before a battle |
unk1b0 | u8 unk1b0[0x10] | FieldWork's walking distance and tiles |
startTransition | s32 startTransition | SCENE_TRANSITION(style, variant) |
unk1c4 | u8 unk1c4[4] | FieldWork's unk1c4 and transitionActive |
transitionFrames | s32 transitionFrames | frames |
unk1cc | u8 unk1cc[0x0c] | FieldWork's fastForward and unk1d0 |
message | u16 message | the next message, advanced as each window opens |
unk1da | u8 unk1da[6] | FieldWork's unk1da to unk1de |
viewCenter | struct FieldActor *viewCenter | the object the map view follows |
unk1e4 | u8 unk1e4[0xade] | not named by TBS code through this view |
choiceMessage | u16 choiceMessage | Message containing the choices. |
unkcc4 | u16 unkcc4 | FieldWork's nameWidth; Colosso sets it to 4 |
Used by AltmillerCave_InitializeDarkness, BabiPalace_LeaveThroughDoor, BabiPalace_WakeAfterFinals, ColossoLogRollingStage_SceneTask, ColossoLog_RunCompetitorTalk, ColossoWall_RollLogToCell, Colosso_AskDoneCheering, Colosso_RaiseTakePlaceOnPsynergy, Colosso_TakePlaceForMatch, Event_AskAboutJourney, Event_AskWhetherMaskedManWasFelix, Event_DepartForQuest, Event_DoraWakesIsaac, Event_EnterDoor, Event_EnterSparklingPassage, Event_EnterWideDoor, Event_FightFirstMonster, Event_FightFourthMonster, Event_FightSecondMonster, Event_FightThirdMonster, Event_HurryToThePlaza, Event_InspectSecondMinotaurRelief, Event_LeaveByExit, Event_LeaveThroughDoor, Event_LeaveThroughEntrance, Event_MeetCorona, Event_MeetHail, Event_MeetVine, Event_OpenDoorAndLeave, Event_PushPipeworksBlock, Event_PushWestPillar, Event_ReadCorneredSuspectsMinds, Event_ReadRelief, Event_ReturnFromMtAleph, Event_RideMovingSidewalk, Event_RollLongLog, Event_TakeTouchedExit, Event_TalkToWallWedgeAttendant, Event_TravelersLeaveAfterBattle, Event_UnlockColumnRoomDoor and 68 more.
facing_object.h
games/tbs/include/field/facing_object.h
Structures
FacingObject
struct FacingObject
A field object seen as one that turns toward its facing target: its facing, its ground position and the target.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[6] | |
facing | u16 facing | 1/65536 turns |
positionX | s32 positionX | 16.16 fixed-point pixels |
unk0c | u8 unk0c[4] | |
positionZ | s32 positionZ | 16.16 fixed-point pixels |
unk14 | u8 unk14[0x46] | |
facingFlags | u8 facingFlags | The steering flags (SW_STEERING); bit 0, turning toward its velocity, is cleared while it turns toward its target. |
unk5b | u8 unk5b[9] | |
unk64 | s16 unk64 | work value 0x23 (actionParameter); not read through this view |
facingTarget | struct FacingObject *facingTarget | The linked object (work value 0x25), or null. |
Used by FacingObject_TurnPairToFaceEachOther, Scene_TurnTowardTarget.
field.h
games/tbs/include/field/field.h
Structures
Flags35
struct Flags35
An actor seen only as its priority flags at 0x23 (enum ActorPriorityFlag).
| Field | Declared as | |
|---|---|---|
pad | u8 pad[35] | |
flags | u8 flags |
OverlayActorPosition
struct OverlayActorPosition
An actor seen only as the coordinate at 0x08, which Goma Cave's stump reads in 16-pixel map cells.
| Field | Declared as | |
|---|---|---|
pad00 | u8 pad00[8] | |
depthFixed | s32 depthFixed | 16.16 fixed-point pixels |
OverlayActorState
struct OverlayActorState
An actor seen only as its priority flags at 0x23 (enum ActorPriorityFlag).
| Field | Declared as | |
|---|---|---|
pad00 | u8 pad00[35] | |
flags | u8 flags |
PathRecorder
struct PathRecorder
The Colosso rival's path player in the scene state: its mode (1 playing, 2 recording, 9 finished), whether it mirrors the path, the actor, its place in the path and how long the actor has stood still.
| Field | Declared as | |
|---|---|---|
mode | s16 mode | |
mirror | s16 mirror | |
actor | s16 actor | |
pos | u16 pos | |
still | s16 still | frames |
Used by ColossoLog_MarkRivalFinished, ColossoLog_WaitForRivalToFinish, ColossoWall_MarkRivalFinished, ColossoWall_StartRivalPath, ColossoWall_WaitForRivalFinish, Colosso_StartRival, Colosso_UpdatePathRival.
SwitchCell
struct SwitchCell
A Venus Lighthouse switch or pillar socket's map cell.
| Field | Declared as | |
|---|---|---|
x | u32 x | 16-pixel map cells |
z | u32 z | 16-pixel map cells |
Used by gVenusPillarCells, gVenusSwitchCells.
TileRun
struct TileRun
A log in Kolima Forest lying across four map cells, from its first cell across or, when vertical, down.
| Field | Declared as | |
|---|---|---|
id | s16 id | |
x | s16 x | map cells |
y | s16 y | map cells |
vertical | s16 vertical | |
unused08 | s16 unused08 | |
unused0a | s16 unused0a |
Also, structures without a comment: Slot, T.
Globals, without a comment: gIwram_Data1, gIwram_Data2, gObjectDispatch_DefaultScript, gWorldMap_TerrainBehaviorTable, Render_DecodeFrameCodeSize, gRuntime_ByteRemapTable, gAltinPeak_PaletteHold, gAltinPeak_PaletteStep, gBattleFx_BurstParticleScriptA, gBattleFx_BurstParticleScriptB, gWorldMap_GraphicsResources, gObjectMotion_WaitScript, gFieldFx_SparkleTiles, gField_TileMessageOffsets, gFieldFx_MoteTiles, gFourObjectMotion_ResourceIds, gTolbiShipInteriors_ShakeTimer, gKolimaForestBendLayout, gKolimaForestBendRecords, gKolimaForestBendReturned, gObjectSlots, gScanlineAngle, gScanlinePitch, gBabiPalace_Events2AfterColosso, gWorldMapPackedFrames, gWorldMapPackedTiles, gWorldMapPalettes, gKalay_DanceStep, gKolimaForestBend_ShakeChance, gKolimaForestBend_ShakeScroll, gKolimaPalette_First, gKolimaPalette_Second, gColosso_CompetitorStartAngle, gColosso_CompetitorStartX, gColosso_CompetitorStartZ, gColosso_GaugePalette, gColosso_MarkerOam, gColosso_ModeBlendDuration, gColosso_ModeBlendStart, gColosso_ModeBlendStep, gColosso_ModeBlendTarget, gColosso_ModeMoveStart, gColosso_ModeMoveStep, gColosso_ModeScaleDuration, gColosso_ModeScaleStart, gColosso_ModeScaleStep, gColosso_ModeScaleTarget, gColosso_LetteringSprites, gVaultInteriors_StopTimer, Object_UpdateAllCodeSize, gObjectGroup_BlinkChildValues, gObjectMotion_ActionKind1Script, gObjectMotion_ActionKind2Script, gObjectMotion_ActionKind3Script, gObjectMotion_ActionKind4Script, gObjectMotion_LaunchScript, gObjectMotion_MoveTowardTargetScript, gObjectMotion_ResetActionScript, gObjectMotion_StepAngleScript, gObjectMotion_TurnTowardLinkedScript, gObjectMotion_VariantScripts, gLamakanDesert_SandEffectTiles, gLamakanDesert_SandPalette, gLamakanDesert_SandPhase, gLamakanDesert_SandTileBuffer, gLamakanDesert_SandVramSlot, gLamakanDesert_SandWork, Render_DecodeFrame, gSolSanctumStatue_SpriteRowsGfx, gStagedActor_FootprintKinds, TileMap_DrawRows, TileMap_DrawRowsCodeSize, Transform_UpdateVerticesSize, gWorldMap_FootprintActions, gWorldMap_KeyHeadings.
Declarations, without a comment: CalculateFacingAngle, Engine_ActorFollow, Engine_EventClearInvalidPackedValues, Engine_PartyRemoveItem, FarCall_BlankLoadTable, FarCall_BlankRunTable, FieldScene_PrepareActors, GameFlag_IsSet, WorldMap_BeginStillView, Math_Atan2, Object_Destroy, ScenePlacement_ClipToView, SceneTable_Prepare.
field_coordinate.h
games/tbs/include/field/field_coordinate.h
Unions
FieldCoordinate
union FieldCoordinate
A field coordinate, read whole or as its fraction and its whole pixels.
| Field | Declared as | |
|---|---|---|
fixed | s32 fixed | 16.16 fixed-point pixels |
fraction, pixel, part | struct { u16 fraction; ///< 1/65536 pixels s16 pixel; ///< pixels } part |
Used by AltmillerCave_HopSelectedActor, Field_ClimbDown, Field_ClimbUp, Field_TryJumpForward, Map_CheckObjectStep, MercuryLighthouseAerie_FlickerBeacon, MercuryLighthouse_HopAcrossPool, ObjectMotion_CenterOnColumn, StagedActor_RunStepEffect, VaultInteriors_TryJumpTo, offsetof.
Globals, without a comment: offsetof.
mapcopy.h
games/tbs/include/field/mapcopy.h
objdisp.h
games/tbs/include/field/objdisp.h
perspective.h
games/tbs/include/field/perspective.h
Structures
PerspectiveWork
struct PerspectiveWork
The world map's perspective view: the followed position, screen shake, view position, window, pitch and yaw, tile ids and zoom. Heap slot 8.
| Field | Declared as | |
|---|---|---|
origin | s32 *origin | the followed point, as in MapScrollWork |
shakeX, shakeY, shakeDecay | s32 shakeX, shakeY, shakeDecay | the screen shake, as in MapScrollWork |
script | u8 *script | NULL at load |
fade | u16 fade | MapScrollWork's flags: REG_DISPCNT bits, 0x1f00 at load |
fadeStep | u8 fadeStep | MapScrollWork's wideTiles, 0x80 at load |
unk017 | u8 unk017[0xe4 - 0x17] | as MapScrollWork: tile animations, blend script |
viewX | s32 viewX | 16.16 fixed-point pixels |
viewY | s32 viewY | 16.16 fixed-point pixels |
scaleX | s32 scaleX | 0x200000 at load |
scaleY | s32 scaleY | 0x400000 at load |
limitX | s32 limitX | 0x1fe00000 at load |
limitY | s32 limitY | 0x1fe00000 at load |
animationActive | s8 animationActive | Set by WorldMap_BeginStillView while BG1 shows the drawn map; the tile animations are then neither suspended nor resumed. |
unk0fd | u8 unk0fd[3] | not named by TBS code |
windowTop | u16 windowTop | Screen rows, 0 and 159 at load and 200 and 255 from WorldMap_BeginStillView; each frame copies them to shownTop and shownBottom and picks BG mode 2 or 0 from them. @{ |
windowBottom | u16 windowBottom | |
shownTop | u16 shownTop | @} windowTop as the frame update last applied it |
shownBottom | u16 shownBottom | windowBottom as the frame update last applied it |
windowPending | u16 windowPending | cleared by the frame update; not set by name |
unk10a | u8 unk10a[6] | not named by TBS code |
tiles | void *tiles | The world map's tile offsets (ResourceId_PerspectiveDataA), each tile LZ-compressed. |
unk114 | u8 unk114[4] | not named by TBS code |
pitch | u16 pitch | 1/65536 turns |
yaw | u16 yaw | 1/65536 turns |
resources | u32 *resources | a row of gWorldMap_GraphicsResources, by terrain |
unk120 | u8 unk120[0x18] | not named by TBS code |
tileIds | u16 tileIds[256] | the world map tile in each of 16 by 16 cells |
quarterTiles | u16 quarterTiles[8] | The tile each quarter of each layer's block buffer shows, so an unchanged quarter is not decoded again. |
farPlane | s32 farPlane | 0x1fe0000 at load |
distance | s32 distance | farPlane scaled by the zoom |
previousZoom | s32 previousZoom | the zoom a transition starts from |
zoom | s32 zoom | 16.16 fixed point, 0x10000 full size |
zoomTransitionFrames | u16 zoomTransitionFrames | a zoom transition's length; 0 when none |
zoomTransitionStep | s16 zoomTransitionStep | frames of the transition done |
Used by Map_WriteLayerCellTile, Object_MoveOnWorldMap.
script.h
games/tbs/include/field/script.h
Structures
ScriptInterpreter
struct ScriptInterpreter
The prefix that command handlers read from a field object's 0x70-byte slot.
| Field | Declared as | |
|---|---|---|
script | const s32 *script | the running script; SC_END sets gScript_MainScript |
cursor | s16 cursor | the word index of the next command in script |
padding06 | u8 padding06[0x4e] | the object's own fields; not read by the commands |
spriteStorageKind | u8 spriteStorageKind | FieldActor's spriteStorageKind: SC_B54_ON sets 1, one sprite drawn, and SC_B54_OFF sets 0, which hides the object's sprites. |
padding55 | u8 padding55[2] | the object's own fields; not read by the commands |
conditionResult | u8 conditionResult | the last flag test, read by SC_IF and SC_IFNOT |
padding58 | u8 padding58[5] | the object's own fields; not read by the commands |
repeatCount | u8 repeatCount | SC_LOOP's count of jumps so far |
wait | s16 wait | Frames left of SC_WAIT (n - 1 when it starts); the update loops count it down, and Script_FindLabel clears it. |
refused | u8 refused | Frames in a row a solid object has refused the object's move (ScriptMotionObject.refused); SC_SYNC stops waiting after 60 and clears it. |
Used by Actor_DrawBehindScenery, BilibinCave_ClearScriptedActorSpriteFlags, Camera_FollowLeaderInBounds, ColossoLogRollingStage_AdvanceParticleMotion, ColossoLogRollingStage_RaiseLinkedSceneEffect, ColossoLog_ShowActivatedSidewalkLayer, ColossoRiver_PlaceFinishItemAboveActor, ColossoWall_RaiseLinkedSceneEffect, CrossboneIslePillarRooms_SetChildValueFromTimer, Event_MovePillarSwitchBlock, Event_MoveSwitchBlock, FieldObject_UpdatePlayerControl, Field_CheckConfiguredKeysAndCount, Field_IsRevealActive, FuchinTemple_ClearScriptedActorSpriteFlags, Fuchin_SetDustPalette, Garet_StepOnDeck, GomaCavePillar_FinishFragment, Imil_UpdateShiver, Ivan_StepOnDeck, Kalay_UpdateTouristFidget, KolimaForestBridge_BurstOnBarrier, KolimaForestBridge_FlashHitBarriers, KolimaForestBridge_TwinkleGroundSparkle, Kolima_ApplyPendingPose, Kolima_FlickerCurseDust, Kolima_TriggerRegionScript, Kolima_UpdateFallingDebris, Kolima_UpdateTimedAppearance, Leader_StepOnDeck, Maid_Sigh, MercuryLighthouseEntrance_PlayStepSound, MercuryLighthouse_FollowLeader, MercuryLighthouse_StartStatueSpray, Mia_StepOnDeck, MogallForest_ClearActorSpriteFlags, MogallForest_CopyTimerToChild, ObjectDispatch_WaitForValue16, Object_ApproachLinkedObject, Object_MoveByKeys and 75 more.
ScriptOperands
struct ScriptOperands
The whole 0x70-byte slot as SC_SET, SC_ADD and SC_CMP see it: each field is one work value (enum ScriptWork in objcmd.h), reached through gScript_OperandHandlerTable, and named for what the engine keeps there. The types are the widths the handlers read, not the engine's own.
| Field | Declared as | |
|---|---|---|
scriptAddress | u32 scriptAddress | SW_SCRIPT; an add steps it by whole words |
cursor | u16 cursor | SW_CURSOR, compared as signed |
facing | u16 facing | SW_FACING, and work values 2 and 4 |
x | u32 x | SW_X, 16.16 fixed-point pixels |
y | u32 y | SW_Y |
z | u32 z | SW_Z |
terrainHeight | u32 terrainHeight | SW_GROUND |
scaleX | u32 scaleX | SW_SCALE_X, 16.16 fixed point |
scaleY | u32 scaleY | SW_SCALE_Y, and work value 0x0b |
radius | u16 radius | SW_RADIUS, in pixels; compared as signed |
padding22 | u8 padding22[2] | the layer and priority flags; no work value |
velocityX | u32 velocityX | SW_VELOCITY_X, 16.16 fixed-point pixels per frame |
velocityY | u32 velocityY | SW_VELOCITY_Y |
velocityZ | u32 velocityZ | SW_VELOCITY_Z |
speedLimit | u32 speedLimit | SW_SPEED |
acceleration | u32 acceleration | SW_ACCEL |
targetX | u32 targetX | SW_TARGET_X; 0x80000000 when unset |
targetY | u32 targetY | SW_TARGET_Y |
targetZ | u32 targetZ | SW_TARGET_Z |
bounce | u32 bounce | SW_BOUNCE, or a floating object's phase |
gravity | u32 gravity | SW_GRAVITY |
sceneWord | u32 sceneWord | Work value 0x17: the word FieldObject_Create zeroes and only scene code reads. |
sprite | u32 sprite | work value 0x18: the sprite, or its list of four |
spriteStorageKind | u8 spriteStorageKind | work value 0x19: 0 hidden, 1 one, 2 a group |
motionFlags | u8 motionFlags | SW_MOTION, ActorMotionFlag bits |
arrivalAxis | u8 arrivalAxis | SW_ARRIVAL |
conditionResult | u8 conditionResult | SW_RESULT, the last test; every compare sets it |
snapToTarget | u8 snapToTarget | SW_SNAP |
collisionFlags | u8 collisionFlags | SW_COLLISION |
steeringFlags | u8 steeringFlags | SW_STEERING |
paused | u8 paused | SW_PAUSED |
byte5c | u8 byte5c | keeps the sprite's VRAM; no work value |
repeatCount | u8 repeatCount | SW_REPEAT, SC_LOOP's count |
wait | u16 wait | SW_WAIT, compared as signed |
refused | u8 refused | ScriptInterpreter.refused; no work value |
frozen | u8 frozen | ScriptMotionObject.frozen; no work value |
sceneByte62 | u8 sceneByte62 | work value 0x27, kept by scene code |
sceneByte63 | u8 sceneByte63 | work value 0x28, kept by scene code |
actionParameter | s16 actionParameter | work value 0x23, what its action script reads |
footprintSide | s16 footprintSide | work value 0x24, or scene scratch |
linkedObject | u32 linkedObject | work value 0x25, the object it follows or faces |
hook | u32 hook | SW_HOOK, the routine run each frame |
Used by Script_ApplyOperandAdd, Script_ApplyOperandCommand, Script_ApplyOperandCompare, Script_ApplyOperandSet, Script_SetOrCompareCursor, Script_SetOrCompareHalfword5e, Script_SetOrCompareRadius.
Types, without a comment: ScriptCommand.
script_object_runtime.h
games/tbs/include/field/script_object_runtime.h
Structures
ScriptObjectRuntime
struct ScriptObjectRuntime
A field object as its object script commands see it: the script and its place, position, motion toward a target, and the home it wanders around.
| Field | Declared as | |
|---|---|---|
script | const s32 *script | null when the object is free |
scriptCursor | u16 scriptCursor | in words |
scriptValue | u16 scriptValue | The object's facing, 1/65536 turns: the heading SC_WANDER and SC_WANDER_HOME wander around, and where SC_FACE_LINK stores the angle to the linked object. |
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | 16.16 fixed-point pixels |
terrainHeight | s32 terrainHeight | 16.16 fixed-point pixels |
unk18 | u8 unk18[0x0a] | the x and y scales and the radius; not named here |
terrainId | u8 terrainId | the map layer its ground height is read from |
unk23 | u8 unk23 | FieldActor.priorityFlags; not named here |
velocityX | s32 velocityX | 16.16 fixed-point pixels per frame |
velocityY | s32 velocityY | 16.16 fixed-point pixels per frame |
velocityZ | s32 velocityZ | 16.16 fixed-point pixels per frame |
speedLimit | s32 speedLimit | 16.16 fixed-point pixels per frame |
acceleration | s32 acceleration | 16.16 fixed-point pixels per frame, per frame |
targetX | s32 targetX | 16.16 fixed-point pixels; 0x80000000 when unset |
targetY | s32 targetY | 16.16 fixed-point pixels; 0x80000000 when unset |
targetZ | s32 targetZ | 16.16 fixed-point pixels; 0x80000000 when unset |
unk44 | u8 unk44[0x0c] | bounce, gravity and a spare word; not named here |
animation | void *animation | its sprite, or its list of four, by animationKind |
animationKind | u8 animationKind | low four bits: 0 no sprite, 1 one, 2 up to four |
flags | u8 flags | FieldActor.motionFlags |
unk56 | u8 unk56[0x03] | The arrival axis, the last flag test and the snap flag; not named here. |
flags59 | u8 flags59 | FieldActor.collisionFlags. SC_WANDER_HOME sets bit 1 while it roams inside its home radius and clears it on heading home. |
actionFlags | u8 actionFlags | FieldActor.steeringFlags |
movementState | u8 movementState | nonzero skips its script and motion (paused) |
unk5c | u8 unk5c[0x02] | The flag that keeps its sprite's VRAM, and the object script's SC_LOOP count; not named here. |
turnedBack | u16 turnedBack | The object script's wait, in frames (ScriptMotionObject.wait). SC_WANDER sets 1 when it turns back, to wait a frame. |
callback | void *callback | Not named by TBS code through this struct: the refusal count, the frozen flag and two bytes scene code uses. |
homeX | s16 homeX | Its home, in pixels: where it was created or placed. The bytes are ObjectRuntime's action and footprintSide too. @{ |
homeZ | s16 homeZ | |
linkedObject | struct ScriptObjectRuntime *linkedObject | @} The object SC_FACE_LINK and SC_MOVE_LINK aim at. |
unk6c | u8 unk6c[0x04] | the update hook (FieldActor.update); not named here |
Used by Event_SpawnObjectTable, FieldObject_Create, Field_PlaceMapMarkers, Object_ClearChildAndCollisionFlags, Object_Wander, ScriptObject_WanderNearHome, Script_ApplyLinkedObjectPosition, Script_ApplyLocalOffsetPosition, Script_ApplyRelativePosition, Script_StoreAngleToLinkedObject.