34#include "text/msg_ids.h"
64 s32 scaledRandom = randomValue * 100;
65 s32 appearanceTimer = (
u16)actor->
timer + ((
u32)scaledRandom >> 16);
66 actor->
timer = appearanceTimer;
67 if ((
s16)appearanceTimer > 1000) {
84 s32 alternateTreeSprite;
88 alternateTreeSprite = 110;
89 for (; villagerIndex <= 8; villagerIndex++) {
90 villager->
sprite = treeSprite;
91 if ((villagerIndex - 6) <= 1) {
92 villager->
sprite = alternateTreeSprite;
110 debris->
timer = framesLeft;
111 if ((
u16)framesLeft == 0) {
281 for (debrisIndex = 0; debrisIndex < 10; debrisIndex++) {
288 debris->sprite->image.priority = 0;
292 debris->
timer = delay;
296 if (debrisIndex & 1) {
297 debris->
velocityX = -((
s32)(((debrisIndex & 3) << 16) + 0x10000) >> 1);
349 for (actor = 8; actor <= 16; actor++) {
381 s32 visibleOnOddFrames) {
430 s32 motionFacingFlag;
433 const s32 *squashActions;
434 const s32 *restoreScaleActions;
435 u32 *firstCurtainState;
437 const s32 *growFieldActions;
438 const s32 *shrinkFieldActions;
439 u32 *secondCurtainState;
473 if (*partyLayout != 0) {
486 if (*partyLayout != 0) {
492 if (*partyLayout != 0) {
498 if (*partyLayout != 0) {
516 if (*partyLayout != 0) {
521 if (*partyLayout != 0) {
545 if (*partyLayout != 0) {
549 if (*partyLayout != 0) {
562 if (*partyLayout != 0) {
670 (stagingValue << 10));
705 *firstCurtainState = 1;
717 *firstCurtainState = 2;
773 if (*sceneState != 0) {
998 *secondCurtainState = 1;
1023 *secondCurtainState = 2;
1037 *secondCurtainState = 3;
1140 if (*sceneState != 0) {
1291 if (actor !=
NULL) {
1298 if (actor !=
NULL) {
1308 if (actor !=
NULL) {
1345 if (framePhase != 0) {
1355 sprite = sparkle->sprite;
1356 sprite->
flags = framePhase;
1510 SC_CALL(Scene_TurnTowardTarget),
1521 {0,
CONDITION_ALWAYS, 232, 0, 120,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1522 {1,
CONDITION_ALWAYS, 44, 0, 267,
FACING_EAST, 0, -1, -1, -1, -1, 0},
1523 {2,
CONDITION_ALWAYS, 418, 0, 285,
FACING_WEST, 0, -1, -1, -1, -1, 0},
1524 {3,
CONDITION_ALWAYS, 119, 0, 182,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1525 {4,
CONDITION_ALWAYS, 151, 0, 310,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1526 {5,
CONDITION_ALWAYS, 264, 0, 373,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1527 {6,
CONDITION_ALWAYS, 329, 0, 230,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1528 {7,
CONDITION_ALWAYS, 263, 0, 326,
FACING_NORTH, 0, -1, -1, -1, -1, 0},
1529 {8,
CONDITION_ALWAYS, 360, 0, 346,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1530 {10,
CONDITION_ALWAYS, 44, 0, 267,
FACING_EAST, 0, -1, -1, -1, -1, 0},
1531 {12,
CONDITION_ALWAYS, 232, 0, 176,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1536 {1,
CONDITION_ALWAYS, 170, 0, 386,
FACING_NORTH, 0, 0, 0, 288, 416, 0},
1537 {2,
CONDITION_ALWAYS, 168, 0, 50,
FACING_SOUTH, 0, 48, 0, 288, 416, 0},
1542 {1,
CONDITION_ALWAYS, 216, 0, 320,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1543 {2,
CONDITION_ALWAYS, 312, 0, 312,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
1549 {207, 31, 311, 225, 49, 329, -1, 1},
1550 {303, 31, 303, 321, 49, 321, -1, 2},
1551 {-1, 0, 0, 0, 0, 0, 0, 0},
Ability numbers, named from the English release.
void ObjectGroup_SetChildValue(struct FieldActor *actor, s32 param)
Sets the param byte of every animated part of an actor's sprite.
void Object_RefreshSelectorById(u32 objectId)
Waits, at most 300 frames, for an actor's script to reach its end (command 0x10).
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
Calls through a function pointer, by argument count.
Character numbers, with each character's Japanese name.
The engine calls the debug menus import, and their palette swatch tiles.
void Djinn_JoinParty(s32 slot, s32 element, s32 djinn)
A Djinni joins the party: djinn (0 to 19) of element goes to the member with the fewest Djinn,...
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
FacingObject, the view of an object that turns to face a target.
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
void Engine_ObjectSetPosition(struct FieldActor *object, s32 fixed_x, s32 fixed_y, s32 fixed_z)
static s32 Event_OpenMessage(s32 speaker, s32 flags)
static void Actor_SetDestination(s32 actor, s32 x, s32 z)
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Engine_SanctumOpen(s32 priest)
void Object_SetMode(struct FieldActor *object, s32 animation)
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
void Engine_PsynergyBegin(s32 ability, s32 flags)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_CameraSetSpeed(s32 speed, s32 acceleration)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
static void Camera_SetSpeed(s32 speed, s32 acceleration)
void Engine_PsynergyRaiseHands(void)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
void Engine_PsynergyLowerHands(void)
void Engine_ActorJump(s32 actor, s32 height, s32 frames)
#define MAP_CELL_STEP(srcX, srcY, width, height, frames)
static void Actor_SetDestinationOffset(s32 actor, s32 dx, s32 dz)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ObjectDispatchRelease(struct FieldActor *object)
static void Actor_RunActionScriptAndWait(s32 actor, const s32 *script)
Runs a script, waiting at most 300 frames for its final command.
static void Map_CopyCellsTo(s32 srcX, s32 srcY, s32 destX, s32 destY, s32 width, s32 height)
static void Actor_FaceActor(s32 actor, s32 target, s32 frames)
static void ColorBuffer_ApplyTarget(s32 value, s32 mode)
void Engine_EventWaitForScreen(void)
void Engine_ActorDestroy(s32 actor)
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
s32 Engine_EventAskYesNo(s32 speaker, s32 flags)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
void Engine_EventOpenScreen(void)
void Engine_GameFlagSet(s32 flag)
void Engine_CameraWaitForMove(void)
static void Actor_SetActionScript(s32 actor, const s32 *script)
The engine encodes either a built-in action or an action-script address.
void Engine_ActorWaitForMove(s32 actor)
static void Map_CopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Engine_ActorStop(s32 actor)
void Engine_ActorRunRepeatedMotion(s32 actor, s32 repeats)
static void Event_ShowMessage(s32 speaker, s32 flags)
static void Event_PlayCue(s32 cue)
static void Map_SetShake(s32 horizontal, s32 vertical, s32 decay)
Sets shake amplitudes in fixed-point pixels and the per-frame decay factor.
#define MAP_CELL_STEPS_END
s32 Engine_GameFlagIsSet(s32 flag)
void Engine_MapAnimateCells(const u16 *steps, s32 destX, s32 destY)
void Engine_PsynergyPlayEffect(s32 effect)
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_ObjectMotionSetPositionAndCommit(s32 actor, s32 x, s32 z)
void Engine_MapRedraw(void)
void Engine_ColorBufferInterpolate(s32 frames)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
void Engine_ActorSetDestinationOffset(s32 actor, s32 dx, s32 dz)
void Engine_ActorFaceEachOther(s32 actor, s32 other, s32 frames)
void Engine_EventWait(s32 frames)
static void Actor_SetAttachedEffect(s32 actor, s32 effect)
void Engine_PsynergySetTarget(s32 caster, s32 target)
@ ACTOR_PRIORITY_AUTOMATIC
The sprite takes its priority from the map cell under it.
#define SCENE_TRANSITION(style, variant)
@ ACTOR_FACES_MOTION
turns toward its velocity, 1/16 turn a frame
The field's runtime work: map cells, scene records and regions, map markers and FieldWork.
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EXITS(scene)
#define IF_FLAG_SET(flag)
#define SCENE_EXIT(exit, scene, entrance)
@ TALK_FACE_PARTY_AND_BACK
#define PSYNERGY_ON_ACTOR(ability)
#define EVENT_SCRIPT(script)
#define TOUCH_WALKING_INTO(facing)
#define FACING_IS_NORTH(facing)
#define PLACEMENT_SHARE_PREVIOUS_SPRITE
The scene service layer: one typed inline for each engine service a scene calls by its own name,...
static void FieldObject_SetTargetAndCallback(s32 object, s32 target, const s32 *actions)
16.16 fixed-point constants, sine and cosine, and the library division.
#define Q16_ONE
One in the engine's signed 16.16 fixed-point format.
Game flags, named where their meaning is shown.
#define FLAG_KOLIMA_BRIDGE_COLLAPSED
Kolima's bridge fell as the party crossed it.
#define FLAG_IN_PARTY(character)
Flags 0 to 7: the character with that id (character_ids.h) is in the party (Party_AddActiveOwner).
#define FLAG_KOLIMA_CURSE_WITNESSED
The party has seen the curse fall, in Kolima or on the forest bridge.
#define FLAG_KOLIMA_CURSE_LIFTED
volatile u32 gFrameCount
Frames WaitFrames has finished.
GameState, the game's state: play time, coins, the scene and the leader's position,...
struct GameState gGameState
The work slots of gWorkSlot, read through their own names.
The screen blend's globals and the graphics routines.
Item numbers, named from the English release.
static void Kolima_WalkThroughExit(s32 exitId)
Walks the leader northward through the selected exit.
s32 gFallingEffectScript[]
static s32 Kolima_ApplyPendingPose(struct ScriptInterpreter *interpreter)
Applies the deferred pose change requested by the falling-effect script.
s32 gKolima_RegionScript[]
const struct SceneEvent * Kolima_GetEvents(void)
Selects the village or bridge event table.
static void Kolima_RecruitDjinni(void)
Lets the village's Djinni join the party.
static void Kolima_TalkToHealer(void)
Offers sanctum services to a north-facing leader, or discusses the trees.
static void Kolima_RestoreBridgeState(void)
Restores the bridge's villagers and collision after its collapse.
struct SceneEvent gKolimaEvents[]
struct ScenePlacement gKolimaPlacements[]
s32 gKolima_PartyRestoreScaleActions[]
s32 gKolima_FaceLeaderScript[]
static void Kolima_ReadVillagerThoughts(s32 actorId, s32 targetId)
Begins Mind Read on one of the villagers transformed into a tree.
static s32 Kolima_UpdateFallingDebris(struct ScriptInterpreter *interpreter)
Moves, enlarges and releases one bridge fragment after its lifetime.
s32 gKolima_PartySquashActions[]
s32 gKolima_ProtectiveFieldGrowActions[]
const u32 * Kolima_GetExits(void)
Returns the shared packed exit table.
static void Kolima_FinishReadingThoughts(void)
Finishes Mind Read and releases its temporary scene objects.
static __inline__ void Kolima_SetProtectiveFieldHeight(s32 actorId, s32 visibleOnOddFrames)
Shows a protective field on its assigned alternating frame.
struct ScenePlacement gKolimaPlacements3[]
s32 gKolima_Object26Script[]
struct ScenePlacement gKolima_EntryScript[]
s32 gKolima_ActionTable3[]
static void Kolima_AnimateSwitchOrExit(void)
Animates the touched map cells or leaves through the southern exit.
const struct ScenePlacement * Kolima_GetPlacements(void)
Selects placements and applies tree sprites while the villagers are cursed.
s32 gKolima_ActionTable1[]
static void Kolima_InitializeCursedVillagers(struct ScenePlacement *placements)
Replaces the nine villagers' placement sprites with their cursed trees.
struct ScenePlacement gKolimaPlacements1[]
static s32 Kolima_UpdateTimedAppearance(struct ScriptInterpreter *interpreter)
Alternates an ambient actor's child appearance with a random timer.
s32 gKolima_EntryActions[]
struct SceneEntrance gKolimaEntrances3[]
static __inline__ void Kolima_NodTogether(void)
Gives the four companions the same nod, waiting on the final actor.
s32 gKolima_ProtectiveFieldShrinkActions[]
struct SceneEvent gKolimaEvents3[]
struct SceneEntrance gKolimaEntrances[]
const struct SceneEntrance * Kolima_GetEntrances(void)
Selects the entrance table for the village, interior or bridge.
struct SceneEntrance gKolimaEntrances2[]
static void Kolima_ShowBridgeCollapse(void)
Shows the villager's crossing and the bridge collapsing into debris.
static s32 Kolima_TriggerRegionScript(struct ScriptInterpreter *interpreter)
Triggers a temporary pose when an effect enters the party's occupied area.
static void Kolima_SpawnCurseSparkle(void)
Spawns a moving curse sparkle every eighth frame.
s32 gKolima_DebrisScript[]
u16 gKolima_SwitchCells[]
static void Kolima_WitnessForestCurse(void)
Shows the forest's curse, the party's protective Psynergy and the trees' appeal.
static void Kolima_FaceActorAndWait(s32 actorId, s32 facing, s32 waitFrames)
Turns an actor immediately, then leaves time for the next scene beat.
static void Kolima_ShowMessageAndWait(s32 actorId, s32 waitFrames)
Shows the selected dialogue through an actor, then holds for its reaction.
static void Kolima_AlternateProtectiveFieldHeights(void)
Alternates the four protective sprites between visible and hidden heights.
s32 gKolima_ActionTable2[]
const struct SceneRegion * Kolima_GetRegions(void)
Returns the interior's regions; the other maps have none.
struct SceneRegion gKolimaRegions2[]
s32 Kolima_Initialize(void)
Restores the current map and plays the first visit to cursed Kolima.
The globals Kolima's scenes share: the falling effect and the party's state.
Kolima and its forest bridge: the sparkling dust that falls when Tret's curse strikes.
static s32 Kolima_FlickerCurseDust(struct ScriptInterpreter *interpreter)
An object script call, each frame of the fall: the speck flickers between palettes 10 and 7,...
Kolima, its forest bridge and the forest's tree: an effect (object 26) that stretches as it travels.
static s32 SceneEffect_AdvanceAngleUntilIdle(struct ScriptInterpreter *interpreter)
An object script call: widen the object by 0x1eb8 (about 0.12) a frame, and release it once it has re...
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_LABEL(n)
Branch destination.
#define SC_SET(w, v)
Write a work value.
#define SC_LOOP(n, to)
Repeat up to n times.
#define SC_POS(x, y, z)
Set position.
#define SC_SYNC
Wait for arrival.
#define SC_MOVE(x, y, z)
Move toward the target.
#define SC_WAIT(n)
Wait n frames.
#define SC_TOP
Script start.
#define SC_END
Return to the main script.
void Event_CallWithLastActiveObjectId(struct ScenePlacement *table)
Spawns the actors of a placement table after the last actor in use.
void BattleEffect_CleanupSceneObjects(void)
Ends a Psynergy effect: frees the effect slots still in use and, unless another effect is being resol...
ObjectRuntime, a field object's runtime state, and the object snapshots.
Palette fades, the battle effect palette buffers and the colour channel curves.
@ PALETTE_TRANSFORM_PLAIN
each colour unchanged
void Audio_PlayCueFromEventWork(void)
Starts the current scene's field music, chosen by Scene_ResolveInteractionResult.
Scene numbers, named after their places.
The field object script interpreter and the operands its commands read.
Song and sound effect ids, indices into gSound_SongTable.
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_ActorSetPosition(u32 actor, s32 x, s32 z)
void Engine_EventEnd(void)
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_ActorShowEmote()
void Engine_EventSetMessage()
void Engine_EventShowMessage()
void Kolima_UpdateCurseDust(void)
A scene callback: every eighth frame a speck (object 285, its script gFallingEffectScript) starts 160...
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
struct AnimationSpritePart image
u8 flags
bits: 1 outlined in ObjectSystemWork's edge and fill colours | 0 shadow drawn (set when created)
u16 priority
2 when created
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
s32 startTransition
SCENE_TRANSITION(style, variant).
s16 touchedTrigger
the step event a touch or exit event answers
s32 transitionFrames
frames
u16 message
the next message, advanced as each window opens
A field actor: a person or thing on the field with a position, motion toward a target,...
s16 timer
The parameter its action script reads (a follow distance or an angle to face), the player's frames to...
s32 speed
speed limit, 16.16 fixed-point pixels per frame
u8 steeringFlags
ActorSteeringFlag bits.
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
union FieldCoordinate x
16.16 fixed-point pixels
s32 velocityX
16.16 fixed-point pixels per frame
union FieldCoordinate y
16.16 fixed-point pixels
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
s32 velocityY
16.16 fixed-point pixels per frame
union FieldCoordinate z
16.16 fixed-point pixels
s32 acceleration
Added toward the target each frame, or taken off the speed when there is none, in 16....
s32 scaleX
16.16 fixed point, 0x10000 full size
s32 scaleY
16.16 fixed point, 0x10000 full size
s32 velocityZ
16.16 fixed-point pixels per frame
A scene entrance: where and facing which way the party arrives, and the camera's bounds there (-1 for...
A scene event: its kind and detail, the trigger it answers, its condition and its value (a message or...
An actor a scene places: its sprite, the condition for placing it, how it behaves,...
u8 talkFacing
enum ActorTalkFacing; 3 follows the leader afterwards
s16 sprite
The actor's sprite; 0 to 7 are the party's characters, each in its own actor slot,...
s32 behavior
A built-in action (enum ActorBehavior, 1 to 7) or an action script, for ObjectMotion_SetActionCallbac...
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
The prefix that command handlers read from a field object's 0x70-byte slot.
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
The integer types, TRUE, UNUSED and the fixed-address macros.
struct FieldCoordinate::@024321007066302143002254325121164243234242211074 part
s32 fixed
16.16 fixed-point pixels