lemurian_ship.c
The Lemurian ship's hidden harbor at Lalivero, and the end of the game.
games/tbs/src/scene/lemurian_ship.c on GitHub
The Lemurian ship's hidden harbor at Lalivero, and the end of the game.
The leader steps up with the Black Orb: it glows, spray rises and the ancient ship comes up out of the water. The party boards, talks over the journey so far and sails; curtains close and the game goes to the clear screen.
Functions
LemurianShip_GetPlacements
const struct ScenePlacement *LemurianShip_GetPlacements(void)
The ship's two pieces; the party's own actors fill the first three rows.
LeaveTheShip
static void LeaveTheShip(void)
The way out, back into Lalivero's interiors: leaves and clears the backdrop colour. Reached by stepping on cell code 1 (gLemurianShipEvents); takes exit 1.
Used by gLemurianShipEvents.
Ripple_StopForReveal
static void Ripple_StopForReveal(void)
Stops the water's ripple while Reveal shows the scene. Reached by Reveal's phase 5 anywhere in the scene; Ripple_Start, at phase 4, starts the ripple again.
Used by gLemurianShipEvents.
Ripple_Start
static void Ripple_Start(void)
Starts the two-axis ripple with its original frequencies and amplitudes. Called by LemurianShip_SetupScene, and reached by Reveal's phase 4 as the spell ends.
Used by LemurianShip_SetupScene, gLemurianShipEvents.
LemurianShip_GetEvents
const struct SceneEvent *LemurianShip_GetEvents(void)
The exit, Reveal and the Black Orb at the water's edge (cell code 10).
ShipGlow_CyclePalette
static void ShipGlow_CyclePalette(void)
Slides a window of six colours along gShipGlowPalettes into palette 7's colours 4 to 9, one step every 6 frames, so the ship's glow ripples. Run each frame once RaiseTheShip has brought the ship up.
Used by RaiseTheShip.
Spray_Update
static void Spray_Update(union FieldObject *fieldObject)
A drop of spray rises and wobbles for its timer, then falls back by gSprayFallScript, which frees it. The update hook Ship_UpdateSwell gives each drop it creates.
Used by Ship_UpdateSwell.
OrbGlow_Fade
static void OrbGlow_Fade(void)
Every 40 frames, the Black Orb's glow fades a step, down to 4. Run each frame while the ship rises; RaiseTheShip adds and removes it.
Used by RaiseTheShip.
Ship_UpdateSwell
static void Ship_UpdateSwell(void)
The Black Orb's glow pulses in the blend, the ship (the hull on BG2, the deck on BG1) and everyone on deck bob with the swell, and spray rises from the water in a screen-sized box (240 by 160) at the view. Run each frame from RaiseTheShip to the end of the game; each part runs while its flag (gOrbGlowActive, gSwellActive, gSprayActive) is set.
Used by RaiseTheShip.
Leader_StepOnDeck
static s32 Leader_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers the leader's height on deck, so that from then on he bobs with the ship. Called by gLeaderBoardsShip as he steps on deck; the other members' boarding scripts call their own copies below.
Used by gLeaderBoardsShip.
Garet_StepOnDeck
static s32 Garet_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Garet's boarding height for the swell callback.
Used by gGaretBoardsShip.
Mia_StepOnDeck
static s32 Mia_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Mia's boarding height for the swell callback.
Used by gMiaBoardsShip.
Ivan_StepOnDeck
static s32 Ivan_StepOnDeck(struct ScriptInterpreter *interpreter)
Remembers Ivan's boarding height for the swell callback.
Used by gIvanBoardsShip.
SetSail
static void SetSail(void)
The others step out and talk over the journey while three questions shape their replies, everyone boards, and the ship sails east as the curtains close and the game goes to the clear screen. Called by RaiseTheShip once the ship has risen. Sets FLAG_KEEP_MUSIC and sends the party to the clear screen (SceneId_Title, entrance 9).
Used by RaiseTheShip.
Wave_Offset
static __inline__ s32 Wave_Offset(s32 angle, s32 amplitude, u16 base)
One line's ripple offset.
Used by DisplayScroll_BuildAndSwapHBlankPage.
RaiseTheShip
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; then the party sets sail. Reached by using the Black Orb at the water's edge (cell code 10). Adds the swell and glow callbacks, which run to the end of the game, and calls SetSail.
Used by gLemurianShipEvents.
LemurianShip_SetupScene
s32 LemurianShip_SetupScene(void)
Sets the harbor up: the ship sunk 90 pixels, its pieces and the party drawn behind the water layers, and the ripple running. The scene's initialization; arriving by entrance 99, which the entrance table does not list, first gives the leader the Black Orb.
DisplayScroll_ArmHBlankDma
void DisplayScroll_ArmHBlankDma(void)
Arms DMA 0 to copy the shown ripple page, a line each HBlank, into background 3's scroll registers, writing the first line itself. Run each frame; DisplayScroll_InitializeHBlankDma adds it and Ripple_Stop removes it.
Used by DisplayScroll_DisarmHBlankDma, DisplayScroll_InitializeHBlankDma, Ripple_Stop.
DisplayScroll_BuildAndSwapHBlankPage
void DisplayScroll_BuildAndSwapHBlankPage(void)
Builds the other ripple page and swaps it in. Run each frame; DisplayScroll_InitializeHBlankDma adds it and Ripple_Stop removes it.
Used by DisplayScroll_DisarmHBlankDma, DisplayScroll_InitializeHBlankDma, Ripple_Stop.
Ripple_Stop
static void Ripple_Stop(void)
Takes the ripple's callbacks off and stops DMA 0. Called by Ripple_StopForReveal.
Used by Ripple_StopForReveal.
Curtain_Close
static void Curtain_Close(void)
Moves the curtains a step closer and queues their 24 sprites. Run each frame from Curtain_Start to the end of the game.
Used by Curtain_Start.
Curtain_Start
static void Curtain_Start(void)
Fills a 256-byte tile with colour 1 and starts the curtains 48 pixels open. Called by SetSail as the ship leaves; adds Curtain_Close.
Used by SetSail.
Also, functions without a comment: LemurianShip_GetEntrances, LemurianShip_GetRegions, LemurianShip_GetExits.
Structures
RippleScrollWork
struct RippleScrollWork
The water's ripple, this scene's view of the HBlank scroll work (gHBlankScrollWork, struct DisplayScrollWork): two pages of per-line scroll offsets, swapped each frame, built from a sine table. Here a line is one word, BG3's x and y, where DisplayScrollWork has three.
| Field | Declared as | |
|---|---|---|
pages | u16 pages[2][0x3c0] | per page: 160 lines of BG3 x, y; the rest unused |
page | u8 page | the page the HBlank DMA shows; the other is built |
mode | u8 mode | |
phase | u16 phase | frames built so far, added to BG3's y |
unkf04 | u8 unkf04[4] | |
frequency | s32 frequency[2] | x, y: 16.16 sine entries per frame and per row |
step | s32 step[2] | x, y: 16.16 sine entries a line |
amplitude | s32 amplitude[2] | x, y: 16.16 scale on the sine, then divided by 256 |
Used by DisplayScroll_ArmHBlankDma, DisplayScroll_BuildAndSwapHBlankPage.
Macros
SET_PRIORITY
#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, any other the second.
Used by LemurianShip_SetupScene.
Also, macros without a comment: LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES, LEMURIAN_SHIP_DEPARTURE_DELAY_FRAMES, ACTOR_SPRITE, ACTOR_SPRITE.
Globals
sCurtainSprites
static struct AnimationSpritePart sCurtainSprites[24]
The curtains: three columns of eight 32 by 8 sprites that close in from the sides as the ship sails.
Used by Curtain_Close.
gShipGlowPalettes
u16 gShipGlowPalettes[]
The ship's glow: ShipGlow_CyclePalette shows six of these colours at a time, from a start that moves one colour every 6 frames.
Used by ShipGlow_CyclePalette.
gSprayFallScript
s32 gSprayFallScript[]
A drop of spray, at the end of its rise: freed.
Used by Spray_Update.
Also, globals without a comment: sCurtainGap, sCurtainVramSlot, gRippleSine, gLemurianShipEntrances, gLemurianShipExits, gLemurianShipPlacements, gLemurianShipEvents, gOrbGlowActive, gOrbGlowPhase, gOrbGlowStrength, gOrbGlowFadeFrames, gSprayActive, gSwellActive, gSwellPhase, gShipHullY, gShipDeckY, gLeaderDeckY, gGaretDeckY, gMiaDeckY, gIvanDeckY, gShipGlowStep, gLeaderBoardsShip, gGaretBoardsShip, gIvanBoardsShip, gMiaBoardsShip.