15#define NULL ((void *)0)
33#include "text/msg_ids.h"
83 if (leader->
y.
part.pixel > 31) {
124 s32 distanceLimit,
s32 forceTracking) {
136 forceTracking != 0) {
139 s32 previousHeading = (angle - 0x1000) & 0xf000;
140 s32 nextHeading = (angle + 0x1000) & 0xf000;
141 s32 targetHeading = angle & 0xf000;
142 s32 currentHeading = actor->
facing & 0xf000;
144 if (targetHeading == currentHeading || nextHeading == currentHeading ||
145 previousHeading == currentHeading || forceTracking != 0) {
149 actor->
timer = isTracking;
183 if ((
u32)((leader->
x.
fixed >> 20) - 17) <= 1 && leader->
z.
fixed >> 20 == 14 &&
206#define XIAN_WATER_CARRIER_UPDATE Xian_WatchWaterCarrierPath
208#define XIAN_WATER_CARRIER_UPDATE ((void *)Xian_WatchWaterCarrierPath)
243 s32 leaderMustStepAside;
253 leaderMustStepAside = 0;
259 savedFacing = carrier->
facing;
268 carrier->
facing = savedFacing;
292 leaderMustStepAside = 1;
316 carrierX = carrier->
x.
fixed;
318 carrierCellZ = carrier->
z.
fixed >> 20;
320 (carrierCellZ << 20) +
PIXELS(8));
322 carrierColumnX = carrier->
x.
fixed;
335 }
while (
scaleX <= 0xffff);
347 leaderMustStepAside = 1;
350 if (leaderMustStepAside != 0) {
361 if ((carrier->
z.
fixed >> 20) != 14) {
375 if ((leader->
z.
fixed >> 20) <= 13)
383 s32 stationaryMotionFlags;
388 stationaryMotionFlags = 0;
391 puddleX = puddle->
x.
fixed;
404 s32 demonstrationSeen;
408 s32 stepBackOffset[3];
413 if (demonstrationSeen != 0) {
426 SET_VECTOR(stepBackOffset, demonstrationSeen, demonstrationSeen,
433 stepBackOffset[0] / 0x10000,
434 stepBackOffset[2] / 0x10000);
440 Effect_Spawn(
PIXELS(192), 0,
PIXELS(312), 0x1999, 0x3333, 0, 0x20001, 0);
441 Effect_Spawn(
PIXELS(192), 0,
PIXELS(312), 0x3333, 0x1999, 0, 0x20001, 0);
454 effectParams.
type = 0x11b;
465 Effect_Spawn(
PIXELS(144), 0,
PIXELS(312), 0, 0, 0, 0x20001, 0);
466 Effect_Spawn(
PIXELS(144), 0,
PIXELS(312), -0x3333, 0x1999, 0, 0x20001, 0);
467 reboundVelocity = -0x8000;
468 Effect_Spawn(
PIXELS(144), 0,
PIXELS(312), reboundVelocity, 0, 0, 0x20001,
503 s32 savedMotionFlags;
511 landing = &landingPosition;
558 switch (event->touchedTrigger) {
691 for (decorationIndex = 0; decorationIndex <= 2; decorationIndex++) {
694 actor->sprite->image.priority = 1;
725 actor->sprite->rotation = 0x8000;
848 {0,
CONDITION_ALWAYS, 172, 0, 149,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
849 {1,
CONDITION_ALWAYS, 376, 0, 504,
FACING_NORTH, 0, -1, -1, -1, -1, 0},
850 {5,
CONDITION_ALWAYS, 344, 0, 328,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
851 {6,
CONDITION_ALWAYS, 376, 0, 216,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
852 {7,
CONDITION_ALWAYS, 424, 0, 216,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
853 {8,
CONDITION_ALWAYS, 408, 0, 424,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
854 {9,
CONDITION_ALWAYS, 216, 0, 184,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
855 {10,
CONDITION_ALWAYS, 392, 0, 184,
FACING_SOUTH, 0, -1, -1, -1, -1, 0},
856 {11,
CONDITION_ALWAYS, 176, 0, 216,
FACING_SOUTH, 0, -1, -1, -1, -1, 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.
const s32 * gEffectScripts[]
Calls through a function pointer, by argument count.
void(*) SchedulerCallback(void)
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.
static s32 FieldObject_CheckMovementCollision(struct FieldActor *actor, struct FieldPosition *position)
@ EFFECT_USE_PALETTE
options.palette, as its group child value
@ EFFECT_USE_ROTATION
options.rotation, as the sprite's
@ EFFECT_USE_TYPE
options.type, else object type 222
@ EFFECT_USE_PRIORITY
options.priority, as the sprite's priority
@ EFFECT_USE_SCRIPT
options.script, run in mode 1
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
void Engine_ActorFaceActor(s32 actor, s32 target, s32 frames)
static void Actor_SetDestination(s32 actor, s32 x, s32 z)
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_MapCopyCellAttributes(s32 srcX, s32 srcY, s32 width, s32 height, s32 destX, s32 destY)
void Object_SetMode(struct FieldActor *object, s32 animation)
void Engine_ActorSetSpritePriority(s32 actor, s32 priority)
static void Event_ShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
static void Actor_SetBuiltinAction(s32 actor, s32 action)
void Engine_EventShowMessageAndWait(s32 speaker, s32 flags, s32 frames)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
#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)
static void Actor_FaceActor(s32 actor, s32 target, s32 frames)
static void Actor_WalkTo(s32 actor, s32 x, s32 z)
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
s32 Engine_EventAskYesNo(s32 speaker, s32 flags)
void Engine_GameFlagSet(s32 flag)
void Engine_GameFlagClear(s32 flag)
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_ActorRunRepeatedMotion(s32 actor, s32 repeats)
static void Event_ShowMessage(s32 speaker, s32 flags)
static void Event_PlayCue(s32 cue)
void Engine_ActorSetChildValue(s32 actor, s32 value)
#define MAP_CELL_STEPS_END
s32 Engine_GameFlagIsSet(s32 flag)
void Engine_MapAnimateCells(const u16 *steps, s32 destX, s32 destY)
void Engine_ActorStartRepeatedMotion(s32 actor, s32 repeats)
static void Actor_CenterAndWalk(s32 actor, s32 priority, s32 dz)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_ObjectMotionSetPositionAndCommit(s32 actor, s32 x, s32 z)
static void Actor_SetPosition(s32 actor, s32 fixed_x, s32 fixed_z)
void Engine_ActorSetDestinationOffset(s32 actor, s32 dx, s32 dz)
void Engine_EventWait(s32 frames)
static struct FieldActor * Actor_Get(s32 actor)
Field objects and actors, and the scene transition styles.
@ TRANSITION_BACKDROP_FADE
@ ACTOR_PRIORITY_UNDERFOOT
The depth sort treats it as 320 pixels higher on the screen.
#define ACTOR_NO_TARGET
A target coordinate that is not set: the object has no target.
#define SCENE_TRANSITION(style, variant)
@ ACTOR_FACES_MOTION
turns toward its velocity, 1/16 turn a frame
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 EVENT_TOUCH_WALKING
#define TOUCH_WALKING_INTO(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 s32 Task_AddCallback(void(*callback)(void), s32 priority)
Calls the main-image scheduler through engine_call.h.
static void FieldVector_AddPolarOffset(s32 radius, s32 heading, struct FieldPosition *probe)
Game flags, named where their meaning is shown.
#define FLAG_SHOW_LOCATION_NAME
#define FLAG_DJINNI_0
the flag of Djinni 0, set once it is caught
#define FLAG_SCENE_TEMP_03
#define FLAG_XIAN_HEARD_HSU_TRAPPED
#define FLAG_SCENE_TEMP_00
#define FLAG_SCENE_TEMP_02
#define FLAG_XIAN_LUCKY_MEDAL_JAR
Xian: set once the jar's Lucky Medal is taken.
#define FLAG_SCENE_TEMP_01
#define FLAG_FEIZHI_WENT_TO_HSU
#define FLAG_FEIZHI_SAW_ROCKSLIDE
Feizhi has found the road blocked and run ahead to look for Hsu.
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 screen blend's globals and the graphics routines.
The main-image routines scene overlays import.
Item numbers, named from the English release.
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
Small statement macros both games use for positions, velocities and bounds.
#define SET_VECTOR(v, x, y, z)
Sets the x, y and z of a three-part vector: a position about to be projected, a per-frame step,...
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
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.
#define ACTOR_ACTION_IDLE
void BattleFx_PlayQueuedSound(void)
Plays the sound BattleFx_SetQueuedSoundAndPlay remembered, if any.
void BattleFx_SetQueuedSoundAndPlay(s32 soundId)
Plays SE_298, then soundId (SE_289 for -1), and remembers soundId for BattleFx_PlayQueuedSound in the...
Declares nothing of its own: it only includes types.h.
Song and sound effect ids, indices into gSound_SongTable.
#define SE_JUMP
An actor jumps: ObjectMotion_Launch plays the high jump above 5 pixels a frame.
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_EventSetMessage()
void Engine_EventShowMessage()
#define offsetof(type, member)
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
u16 rotation
1/65536 turns
The options of a spawned field effect, each used when its EFFECT_USE_ flag (or EFFECT_SCALE_TO_TARGET...
s16 type
the object type to create; 222 without the flag
s32 palette
passed to ObjectGroup_SetChildValue
s32 priority
the sprite's priority
u16 rotation
1/65536 turns
const s32 * script
the object script, run in mode 1
The running scene's event work: its placement and event tables, its actors, the triggers and exit it ...
s16 raisedTrigger
a raised event for Scene_RunRaisedEvent
s32 startTransition
SCENE_TRANSITION(style, variant).
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
s32 targetX
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
u8 steeringFlags
ActorSteeringFlag bits.
u8 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
u8 riseCounter
not read by the engine; scene code's own counter
union FieldCoordinate x
16.16 fixed-point pixels
s32 targetZ
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
s32 velocityX
16.16 fixed-point pixels per frame
u8 paused
nonzero skips its script and motion, not its update
s32 bounce
The share of its falling speed kept as it bounces on landing, 16.16 fixed point (0x4000 when created)...
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
s32 gravity
Taken off the vertical velocity each frame while it is above the ground, in 16.16 fixed-point pixels ...
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 targetY
16.16 fixed-point pixels; ACTOR_NO_TARGET when unset
s32 scaleX
16.16 fixed point, 0x10000 full size
s32 scaleY
16.16 fixed point, 0x10000 full size
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
u8 collisionFlags
bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psyne...
s32 velocityZ
16.16 fixed-point pixels per frame
s32 z
16.16 fixed-point pixels
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
A scene's exit region: the box that, while its condition holds, takes the party leader out through it...
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
An object on the field, read as an actor or as an effect.
static void Xian_StrikeTrainingTreeWithForce(void)
Force on the training tree: it jumps, and the student cries out.
s32 gXian_TreeImpactScript[]
The effect at the tree's foot when the student strikes it: 18 frames.
s32 gXian_TrainingTreeJump[]
The struck tree jumps 32 pixels and drops back.
struct ScenePlacement gXian_Placements[]
static void Xian_RotateTrainingTree(void)
Rotates the training tree during the student's strike and Force animation.
static void Xian_TalkToFeizhi(void)
Talking to Feizhi.
@ ACTOR_KUNG_FU_STUDENT
Strikes the tree before him with a shout. "Hoo-whaaa... Hachaaa!".
@ ACTOR_FORCE_TARGET
Force's mark on the training tree.
@ ACTOR_FIRST_DECORATION
The first of three actors kept below the others.
@ ACTOR_WATER_CARRIER
Carries water along the street. "You made me spill my water!".
@ ACTOR_TRAINING_TREE
The tree the student strikes; it jumps when hit.
static s32 Xian_UpdateCarrierTracking(struct FieldActor *actor, struct FieldActor *target, s32 distanceLimit, s32 forceTracking)
Tracks a nearby target only within the actor's current facing sector.
static void Xian_RecruitVillageDjinni(void)
Talking to the Djinni: it joins the party (Mercury Djinni 2).
struct SceneEvent gXian_Events[]
const struct SceneEntrance * Xian_GetEntrances(void)
static void Xian_FreezeSpilledWater(void)
Frost freezes the spilled water: the puddle turns to ice the leader can stand on, and there is nothin...
static void Xian_OpenDoorAndLeave(void)
Walking into one of Xian's doors: it opens and the party goes in.
u16 gXian_DoorSteps1[]
The doors' opening frames, copied from map cells.
static void Xian_JumpOverSpilledWater(void)
Walking into the spilled water before it is frozen: the leader jumps two cells over it,...
s32 gXian_WaterCarrierRoute[]
The water carrier's round: from (280, 232) east to (424, 232), up to (424, 216) and back,...
const struct ScenePlacement * Xian_GetPlacements(void)
Once Xian has heard Hsu is trapped, actor 15 turns to face the party.
static void Xian_UpdateFrozenPuddleLayer(void)
Draws the frozen puddle under the leader while the leader stands on top of it.
s32 gXian_TrainingParticleScript[]
Each particle beside the leaping student, facing west: 16 frames.
static void Xian_AskAboutYoungWarriors(void)
Asks about the young warriors' way here.
static void Xian_MoveAsideForWaterCarrier(void)
The leader has stood in the water carrier's way for two seconds: both walk to the start of her route,...
#define XIAN_WATER_CARRIER_UPDATE
struct SceneEntrance gXian_Entrances[]
const u32 * Xian_GetExits(void)
static void Xian_SpawnTrainingParticles(void)
Emits particles beside the student every fourth frame.
const struct SceneEvent * Xian_GetEvents(void)
static void Xian_WalkThroughExit(s32 exitId)
Walks the leader through a doorway and leaves by its exit.
static void Xian_TalkToKungFuStudent(void)
The kung fu student.
static s32 Xian_WatchWaterCarrierPath(union FieldObject *fieldObject)
@ XIAN_CARRIER_BLOCKED_FRAMES
@ XIAN_TRIGGER_CARRIER_BLOCKED
static void Xian_UpdatePuddlePriority(void)
Frost on the spilled water, before it freezes: the puddle is drawn in front while the leader stands n...
static void Xian_TalkToWaterCarrier(void)
Talking to the water carrier.
s32 Xian_Initialize(void)
Queues sound 169 and sets up the village as the story and this visit left it.
const struct SceneRegion * Xian_GetRegions(void)