43#include "text/msg_ids.h"
57#define LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES 30
59#define LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES 80
77#define ACTOR_SPRITE(actor) \
78 ((struct AnimationObject *)*(s32 *)((u8 *)(actor) + 0x50))
81#define SET_PRIORITY(actor, n) \
82 ((n) == 9 ? (void)(ACTOR_SPRITE(actor)->image.priority = 1) \
83 : (void)(ACTOR_SPRITE(actor)->shadow.priority = 1))
135 Dma_Set((
const void *)(((
u32)(paletteIndex << 16) >> 15) +
147 u8 *obj = (
u8 *)fieldObject;
163 u16 *p = (
u16 *)(obj + 94);
271 actor->sprite->image.priority = 2;
544 ship->
speed = 0x20000;
558 event->transitionFrames = 96;
614 for (i = 0; i <= 15; i++) {
626 for (flash = 0; flash < 3; flash++) {
657 }
while (sunk <= 0x59ffff);
669 for (white = 0; white <= 16; white++) {
678 for (dark = 16; dark >= 0; dark--) {
753 layer->
y += -0x5a0000;
755 layer->
y += -0x5a0000;
770 volatile u32 *destination;
781 *destination = *source++;
783 (
volatile u32 *)dma0);
806 for (i = 0; i != 160; i++) {
815 for (i = 0; i != 160; i++) {
864 for (i = 0; i < 8; i++) {
870 *entry++ = (left & 0xff) | (i << 21) | 0x80004000;
873 x = (step / 2 + 136) & 0xff;
874 for (i = 0; i < 8; i++) {
876 *entry++ = (i << 21) | x | 0x80004000;
883 *entry++ = (i << 21) | x | 0x80004000;
886 for (i = 0; i < 24; i++)
908 0x5860, 0x69c0, 0x7f20, 0x69c0, 0x5860, 0x4800,
909 0x5860, 0x69c0, 0x7f20, 0x69c0, 0x5860, 0x0000,
919 0, 100, 200, 301, 401, 501, 601, 700,
920 799, 897, 995, 1092, 1189, 1284, 1379, 1474,
921 1567, 1659, 1751, 1841, 1930, 2018, 2105, 2191,
922 2275, 2358, 2439, 2519, 2598, 2675, 2750, 2824,
923 2896, 2966, 3034, 3101, 3166, 3229, 3289, 3348,
924 3405, 3460, 3513, 3563, 3612, 3658, 3702, 3744,
925 3784, 3821, 3856, 3889, 3919, 3947, 3973, 3996,
926 4017, 4035, 4051, 4065, 4076, 4084, 4091, 4094,
927 4096, 4094, 4091, 4084, 4076, 4065, 4051, 4035,
928 4017, 3996, 3973, 3947, 3919, 3889, 3856, 3821,
929 3784, 3744, 3702, 3658, 3612, 3563, 3513, 3460,
930 3405, 3348, 3289, 3229, 3166, 3101, 3034, 2966,
931 2896, 2824, 2750, 2675, 2598, 2519, 2439, 2358,
932 2275, 2191, 2105, 2018, 1930, 1841, 1751, 1659,
933 1567, 1474, 1379, 1284, 1189, 1092, 995, 897,
934 799, 700, 601, 501, 401, 301, 200, 100,
935 0, -100, -200, -301, -401, -501, -601, -700,
936 -799, -897, -995, -1092, -1189, -1284, -1379, -1474,
937 -1567, -1659, -1751, -1841, -1930, -2018, -2105, -2191,
938 -2275, -2358, -2439, -2519, -2598, -2675, -2750, -2824,
939 -2896, -2966, -3034, -3101, -3166, -3229, -3289, -3348,
940 -3405, -3460, -3513, -3563, -3612, -3658, -3702, -3744,
941 -3784, -3821, -3856, -3889, -3919, -3947, -3973, -3996,
942 -4017, -4035, -4051, -4065, -4076, -4084, -4091, -4094,
943 -4096, -4094, -4091, -4084, -4076, -4065, -4051, -4035,
944 -4017, -3996, -3973, -3947, -3919, -3889, -3856, -3821,
945 -3784, -3744, -3702, -3658, -3612, -3563, -3513, -3460,
946 -3405, -3348, -3289, -3229, -3166, -3101, -3034, -2966,
947 -2896, -2824, -2750, -2675, -2598, -2519, -2439, -2358,
948 -2275, -2191, -2105, -2018, -1930, -1841, -1751, -1659,
949 -1567, -1474, -1379, -1284, -1189, -1092, -995, -897,
950 -799, -700, -601, -501, -401, -301, -200, -100,
955 {0,
CONDITION_ALWAYS, 408, 0, 200,
FACING_NORTH, 0, -1, -1, -1, -1, 0},
956 {1,
CONDITION_ALWAYS, 312, 0, 296,
FACING_NORTH, 0, -1, -1, -1, 328, 0},
Ability numbers, named from the English release.
void Object_RefreshSelectorById(u32 objectId)
Waits, at most 300 frames, for an actor's script to reach its end (command 0x10).
void ObjectMotion_CommitPositionAndActivate(u32 objectId, s32 xOffset, s32 zOffset)
Walks the actor (xOffset, zOffset) pixels, waits for it to arrive and stands it still.
void Motion_LaunchFromFocusedObject(u32 objectId, s32 xOffset, s32 zOffset, s32 action)
Places an actor on the leader and sends it walking (xOffset, zOffset) pixels away at speed 0....
struct FieldActor * Object_GetById(s32 actor)
Returns an actor, or NULL if it does not exist.
s32 Math_DivideUnsigned(s32 value, s32 divisor)
Divides the nonnegative random value for wall-fragment scaling.
The task scheduler: tasks, their order and the scheduler's state.
The engine calls the debug menus import, and their palette swatch tiles.
DMA channel registers, and the DMA and CPU fills.
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
#define Dma_Fill32(value, destination, size)
Fills size bytes at destination with the word value by DMA3.
static s32 FieldScheduler_AddCallback(SchedulerCallback callback, s32 priority)
Registers a main-image scheduler callback.
The scene script layer: the engine services a scene's events call, declared once (Engine_EventBegin,...
static void Actor_FaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_ActorSetAnimationAndWait(s32 actor, s32 animation)
void Object_SetMode(struct FieldActor *object, s32 animation)
s32 Engine_EventChooseYesNo(s32 actor, s32 flags)
void Engine_CameraSetSpeed(s32 speed, s32 acceleration)
static void Actor_WalkToAndWait(s32 actor, s32 x, s32 z)
void Engine_CameraMoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
s32 Engine_TaskRemoveCallback(void(*callback)(void))
s32 Engine_MathSin(s32 angle)
void Engine_ActorFaceDirection(s32 actor, s32 facing, s32 frames)
void Engine_EventCloseScreen(void)
s32 Engine_VramLoad(s32 block, s32 size, const void *data)
void Engine_EventWaitForScreen(void)
static void Actor_ShowEmote(s32 actor, s32 emote, s32 frames)
void Engine_ObjectSetScript(struct FieldActor *object, const s32 *script)
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_ActorRunRepeatedMotion(s32 actor, s32 repeats)
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.
static struct FieldActor * Object_Create(s32 type, s32 fixed_x, s32 fixed_y, s32 fixed_z)
static void Actor_SetSpeed(s32 actor, s32 speed, s32 acceleration)
void Engine_MapRedraw(void)
static s32 Random_Next(void)
static void Camera_MoveTo(s32 fixed_x, s32 fixed_y, s32 fixed_z, s32 pan)
void Engine_EventWait(s32 frames)
Field objects and actors, and the scene transition styles.
@ TRANSITION_BACKDROP_FADE
#define SCENE_TRANSITION(style, variant)
The scene table formats: entrances, exits, placements and events, and the macros that write them.
#define SCENE_EXITS(scene)
#define PSYNERGY_IN_AREA(ability, phase)
#define SCENE_EXIT(exit, scene, entrance)
#define EVENT_SCRIPT(script)
The scene service layer: one typed inline for each engine service a scene calls by its own name,...
static void Event_End(void)
static void Task_Wait(s32 frames)
static void Event_Begin(void)
static void FieldObjectMotion_CommitPositionAndActivate(s32 a0, s32 a1, s32 a2)
static void FieldMotion_LaunchFromFocusedObject(s32 actor, s32 dx, s32 dz, s32 facing)
static void Event_Wait(s32 frames)
FixedPointPosition, a position in 16.16 fixed point.
Game flags, named where their meaning is shown.
#define FLAG_KEEP_MUSIC
The next scene keeps the music that is playing; scene.c clears FLAG_KEEP_MUSIC as it does,...
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.
void * Runtime_BumpAllocateAlternatePool(s32 size)
As MemAlloc, but tries EWRAM first.
s32 Inventory_AddItem(s32 owner, s32 itemId)
Gives a unit one item, joining its first matching stack (up to 30) or taking the first free slot.
The hardware's I/O registers and their bits, as pret names them.
#define DMA_HBLANK_WORD_PER_LINE
#define DMA_START_TIMING_DRQ_REPEAT
A DMA control's start timing (bits 12 and 13), cartridge request (bit 11) and repeat (bit 9): the bit...
Io_Write16, a 16-bit write to a register or memory.
#define Io_Write16(v, reg)
Writes a value to a 16-bit register or memory location.
Item numbers, named from the English release.
The IWRAM call layer: the routines the game keeps resident in IWRAM, each at its fixed address,...
#define Iwram_MulQ16(left, right)
static void OrbGlow_Fade(void)
Every 40 frames, the Black Orb's glow fades a step, down to 4.
static void ShipGlow_CyclePalette(void)
Slides a window of six colours along gShipGlowPalettes into palette 7's colours 4 to 9,...
static __inline__ s32 Wave_Offset(s32 angle, s32 amplitude, u16 base)
One line's ripple offset.
const struct SceneEntrance * LemurianShip_GetEntrances(void)
const u32 * LemurianShip_GetExits(void)
static void Ripple_Stop(void)
Takes the ripple's callbacks off and stops DMA 0.
@ SHIP_NORTH
the ship, in two pieces of sprite 0x1f6
static void Curtain_Close(void)
Moves the curtains a step closer and queues their 24 sprites.
const struct ScenePlacement * LemurianShip_GetPlacements(void)
The ship's two pieces; the party's own actors fill the first three rows.
s32 gSprayFallScript[]
A drop of spray, at the end of its rise: freed.
static void Ship_UpdateSwell(void)
The Black Orb's glow pulses in the blend, the ship (layers 6 and 7) and everyone on deck bob with the...
static struct CurtainSprite sCurtainSprites[24]
const struct SceneRegion * LemurianShip_GetRegions(void)
u16 gShipGlowPalettes[]
The ship's glow: ShipGlow_CyclePalette shows six of these colours at a time, from a start that moves ...
struct SceneEvent gLemurianShipEvents[]
s32 LemurianShip_SetupScene(void)
Sets the harbor up: the ship sunk 90 pixels, its pieces and the party drawn behind the water layers,...
struct SceneEntrance gLemurianShipEntrances[]
static void RaiseTheShip(void)
The Black Orb glows, the water lights up, spray rises and the ship comes up out of the sea 90 pixels;...
struct ScenePlacement gLemurianShipPlacements[]
#define SET_PRIORITY(actor, n)
Sets one of the sprite's two priority bits of a ship piece or a party actor: 9 sets the first,...
#define LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES
static void SetSail(void)
The others step out and talk over the journey while three questions shape their replies,...
static s32 Ivan_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Ivan's boarding height for the swell callback.
static void Curtain_Start(void)
Fills a 256-byte tile with colour 1 and starts the curtains 48 pixels open.
static s32 Leader_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers the leader's height on deck, so that from then on he bobs with the ship.
static s16 sCurtainVramSlot
static void LeaveTheShip(void)
The way out, back into Lalivero's interiors: leaves and clears the backdrop colour.
static void Spray_Update(union FieldObject *fieldObject)
A drop of spray rises and wobbles for its timer, then falls back by gSprayFallScript,...
const struct SceneEvent * LemurianShip_GetEvents(void)
The exit, Reveal and the Black Orb at the water's edge (cell code 10).
static s32 Garet_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Garet's boarding height for the swell callback.
static void Ripple_Start(void)
Starts the two-axis ripple with its original frequencies and amplitudes.
static s32 Mia_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Mia's boarding height for the swell callback.
static void Ripple_StopForReveal(void)
Stops the water's ripple while Reveal shows the scene.
The heaps: allocating and freeing blocks.
static __inline__ void * Runtime_CallAlternatePool(void *(*allocate)(s32), s32 size)
The reel game's title lettering.
Field object scripts: one s32 command word, then its operands, as gScriptObject_CommandTable runs the...
#define SC_SET(w, v)
Write a work value.
#define SC_SYNC
Wait for arrival.
#define SC_SE(n)
Sound effect.
#define SC_WAIT(n)
Wait n frames.
#define SC_END
Return to the main script.
#define SC_MOVE_BY(x, y, z)
Move by a relative offset.
void Battle_ResetEffectCounter(void)
Clears the field's busy flag and, while Reveal is active, ends it: Reveal used with ACT_PACKED runs i...
void Event_SetDestination(s32 scene, s32 entrance)
Makes the event leave for the given entrance of the given scene: raises the exit request 999 and writ...
struct UiWindow * UiText_OpenMessageAtObject(s32 actor, s32 unused)
The event command "open message": opens the event's current message in a speech window next to the sp...
void Runtime_PushSlotEntry(void *slotEntry, s32 slot)
Links a sprite entry into depth slot slot (clamped to 0..255) for this frame.
void AudioCommand_WaitForStateByteClear(void)
Waits one frame at a time until the sound driver has finished the last command.
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.
#define MUS_PUZZLE_SOLVED
void MusicCommand_SetPitchAndUpdateFrequency(u16 tempoScale)
Sets the BGM tempo scale directly; 0x100 preserves its native tempo.
void Engine_ActorSetAnimation()
struct EventWork * gEventWork
void Engine_EventRequestExit()
void Engine_AudioPlayCue()
void Engine_EventBegin(void)
void Engine_ActorShowEmote()
void Engine_EventSetMessage()
void Engine_EventShowMessage()
The curtains: three columns of eight 32 by 8 sprites that close in from the sides as the ship sails.
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
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 motionFlags
ActorMotionFlag bits; zero is free flight in 3D, and 3 is set on creation.
union FieldCoordinate x
16.16 fixed-point pixels
union FieldCoordinate y
16.16 fixed-point pixels
u8 priorityFlags
ActorPriorityFlag bits, read by the scrolling camera.
s32 terrainHeight
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....
void(*) update(union FieldObject *object)
Called each frame before the object's script, while the object is live.
u16 wait
the object script's wait, in frames (ScriptMotionObject)
u16 work
The side of the player's next footprint (2 after a stop), or scene scratch.
u8 collisionFlags
bits: 7 refuses to move into a solid object | 4 nearer for Psynergy targets | 3 never a talk or Psyne...
A position in three coordinates, each in 16.16 fixed point.
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,...
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.
u16 offset
bytes from the start of OBJ VRAM
The map's scrolling layers, as the swell moves them.
s32 y
16.16 pixels; layers 6 and 7 are the ship's hull and deck
s32 unk10[8]
Layer 4's unk10[0] and [1], whole pixels in 16.16, are the corner of the screen-sized box (240 by 160...
The map work, seen for the scrolling layers the swell moves.
struct WaveMapLayer layers[8]
The system's routines and globals: interrupts, BIOS sound bias, random numbers and sleep.
Values that differ by patch level or language, chosen once for their code.
The integer types, TRUE, UNUSED and the fixed-address macros.
s32 fixed
16.16 fixed-point pixels
An object on the field, read as an actor or as an effect.
The patch levels: our groups of the measured changes from the Japanese release.
Declares nothing of its own: it only includes the window, battle command, resource and VRAM table hea...
s32 Resource_FindFreeEntry(void)
Returns the number of the first free cache entry, or VRAM_CACHE_ENTRY_COUNT when all are taken.
The sprite VRAM block cache and its owners.
struct VramBlockCacheEntry gVramBlockCache[]