tolbi_ship_deck.c
The deck of the ship across the Karagol Sea, from Kalay to Tolbi: the wait at the Kalay dock while the replacement ship fails to come, setting sail with the passengers at the oars, the sea monsters and the Kraken, the arrival at Tolbi, and the stop at anchor off the island.
games/tbs/src/scene/tolbi_ship_deck.c on GitHub
The deck of the ship across the Karagol Sea, from Kalay to Tolbi: the wait at the Kalay dock while the replacement ship fails to come, setting sail with the passengers at the oars, the sea monsters and the Kraken, the arrival at Tolbi, and the stop at anchor off the island. Entrances 10 to 19 chain the voyage's cutscenes, each leaving by an exit that comes back to the next.
Functions
TolbiShipDeck_ShowSprite
static s32 TolbiShipDeck_ShowSprite(struct ScriptInterpreter *interpreter)
An action-script call: shows the actor's sprite. Returns 0 to end the call.
Used by gTolbiShipDeck_DeckEventActions.
TolbiShipDeck_HoverAndDiveAtOuranos
static s32 TolbiShipDeck_HoverAndDiveAtOuranos(struct ScriptInterpreter *interpreter)
The update of a sea monster hovering by Ouranos's side of the deck while the monsters attack. It drifts and bobs at random; one frame in a hundred it dives at Ouranos, who turns and jumps (sometimes with an emote), then it returns to its side. riseEnabled picks which side it returns to. Returns 1 to keep running.
Used by gTolbiShipDeck_CrewActionsA.
TolbiShipDeck_HoverAndDiveAtSean
static s32 TolbiShipDeck_HoverAndDiveAtSean(struct ScriptInterpreter *interpreter)
The same for the monster that dives at Sean.
Used by gTolbiShipDeck_CrewActionsB.
TolbiShipDeck_Bob
static s32 TolbiShipDeck_Bob(struct ScriptInterpreter *interpreter)
Bobs the actor between 4 and 12 pixels high by a random amount each frame; the actor's work halfword says which way it is going. Returns 1.
Used by gTolbiShipDeck_CrewActionsC.
TolbiShipDeck_LookAround
static s32 TolbiShipDeck_LookAround(struct ScriptInterpreter *interpreter)
Now and then (two chances in 32) turns the actor to look north-northeast or north-northwest. Returns 1.
Used by gTolbiShipDeck_CrewActionsD.
TolbiShipDeck_LeapAtOuranos
static s32 TolbiShipDeck_LeapAtOuranos(struct ScriptInterpreter *interpreter)
The update of a monster on deck that, at random, leaps at Ouranos: it jumps to him, he turns and jumps back (sometimes with an emote), and it lands on one of two spots chosen by riseEnabled. The actor's timer holds the step. Returns 1.
Used by gTolbiShipDeck_DeckActionsB.
TolbiShipDeck_LeapAtSean
static s32 TolbiShipDeck_LeapAtSean(struct ScriptInterpreter *interpreter)
The same for the monster that leaps at Sean.
Used by gTolbiShipDeck_DeckActionsA.
TolbiShipDeck_RandomlyStartActorHop
static s32 TolbiShipDeck_RandomlyStartActorHop(struct ScriptInterpreter *interpreter)
Makes the actor hop at random, one frame in 40 on average. Returns 1.
Used by gTolbiShipDeck_DeckActionsC.
TolbiShipDeck_ShrinkToNormalSize
static void TolbiShipDeck_ShrinkToNormalSize(union FieldObject *object)
The update that shrinks an enlarged actor by 1/32 a frame until it is back to normal size.
Used by TolbiShipDeck_JumpIntoKrakenBattle.
TolbiShipDeck_IdleTurn
static s32 TolbiShipDeck_IdleTurn(struct ScriptInterpreter *interpreter)
Turns the actor east, northeast-by-north or southeast-by-south at random intervals of 80 to 160 frames. riseCounter counts down the wait. Returns 1.
Used by gTolbiShipDeck_LeadActionsC.
TolbiShipDeck_TalkToWaitingPassenger21
static void TolbiShipDeck_TalkToWaitingPassenger21(void)
A passenger at Kalay. What he says follows the delay: impatient at first, alarmed once the warriors storm off to the captain, relieved once the party has agreed to protect the ship. While alarmed he paces at random intervals.
Used by gTolbiShipDeckEvents.
TolbiShipDeck_TalkToWaitingPassenger24
static void TolbiShipDeck_TalkToWaitingPassenger24(void)
Another waiting passenger, with the same three moods as actor 21.
Used by gTolbiShipDeckEvents.
TolbiShipDeck_AskHeadedForColosso
static void TolbiShipDeck_AskHeadedForColosso(void)
A passenger asks whether the party is headed for Colosso too.
Used by gTolbiShipDeckEventsArrived.
TolbiShipDeck_OpenFirstDoor
static void TolbiShipDeck_OpenFirstDoor(void)
Opens the first door to below deck, once a visit.
Used by TolbiShipDeck_AnnouncePreparationsReady, TolbiShipDeck_GoBelow, TolbiShipDeck_JumpIntoKrakenBattle, TolbiShipDeck_MonsterLandsOnDeck, TolbiShipDeck_MonstersAttackCrew, TolbiShipDeck_MonstersBoard, TolbiShipDeck_ReturnFromIsland, TolbiShipDeck_RowersDisembark, TolbiShipDeck_ThankForKraken.
TolbiShipDeck_OpenSecondDoor
static void TolbiShipDeck_OpenSecondDoor(void)
Opens the second door to below deck, once a visit.
Used by TolbiShipDeck_ConfrontCrewman, TolbiShipDeck_GoBelow, TolbiShipDeck_WatchCrewDecideToSail.
TolbiShipDeck_GoBelow
static void TolbiShipDeck_GoBelow(void)
Walking into one of the ways below deck (triggers 1 to 3). The doors at 1 and 3 open and the leader steps through; the hatch at 2 just plays its sound. Leaves by the exit numbered as the trigger.
Used by TolbiShipDeck_GoBelowWhileFacingWest, gTolbiShipDeckEvents, gTolbiShipDeckEventsArrived, gTolbiShipDeckEventsAtIsland, gTolbiShipDeckEventsAtSea.
TolbiShipDeck_GoBelowWhileFacingWest
static void TolbiShipDeck_GoBelowWhileFacingWest(void)
In the German, Spanish, French and Italian editions trigger 2 is a plain touch: the leader goes below only while facing west, after walking onto the hatch.
Used by gTolbiShipDeckEvents, gTolbiShipDeckEventsArrived, gTolbiShipDeckEventsAtIsland, gTolbiShipDeckEventsAtSea.
TolbiShipDeck_WatchCrewDecideToSail
static void TolbiShipDeck_WatchCrewDecideToSail(void)
At Kalay, once the party has heard of the delay (flag 0x911): the crew wonder what happened to the replacement ship and decide to set sail anyway; the crewman runs off through the second door. Plays once.
Used by gTolbiShipDeckEvents.
TolbiShipDeck_CatchCrewmanFromEast
static void TolbiShipDeck_CatchCrewmanFromEast(void)
Approaching from the east side of the door: the crewman comes out, protests and slips away round the party to the bow. "I didn't do anything..." Runs until the party has confronted the crewman.
Used by gTolbiShipDeckEvents.
TolbiShipDeck_CatchCrewmanFromWest
static void TolbiShipDeck_CatchCrewmanFromWest(void)
The same, approaching from the west side.
Used by gTolbiShipDeckEvents.
TolbiShipDeck_ConfrontCrewman
static void TolbiShipDeck_ConfrontCrewman(void)
The start both of those share: the camera pans to the door, which opens, and the crewman steps out and denies everything. Records the confrontation.
Used by TolbiShipDeck_CatchCrewmanFromEast, TolbiShipDeck_CatchCrewmanFromWest.
TolbiShipDeck_Initialize
s32 TolbiShipDeck_Initialize(void)
Sets up the scene on entry: clears FLAG_NOT_ON_MAP, sets the transition, starts the deck's sway at a random angle and stops the sea's scroll, redraws the map and applies the voyage's state.
TolbiShipDeck_ApplyEntryState
static void TolbiShipDeck_ApplyEntryState(void)
Applies the voyage's state: which cells and oars are drawn, whether the deck rocks and the sea scrolls, and which cutscene the entrance starts (entrances 10 to 19 are the voyage's cutscenes, chained by their exits).
Used by TolbiShipDeck_Initialize.
TolbiShipDeck_PlaceWaitingPassengers
static void TolbiShipDeck_PlaceWaitingPassengers(void)
At Kalay while the ship waits: places the passengers by what has happened so far.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_PlacePassengersAgreedToRow
static void TolbiShipDeck_PlacePassengersAgreedToRow(void)
At Kalay once the party has agreed to protect the ship: places the passengers who promised to row.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_SetUpUnderSail
static void TolbiShipDeck_SetUpUnderSail(void)
Under sail: the crew take their places, the two lookouts start their rounds and, when the party keeps its position, the leader stands on deck.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_SetUpAfterKraken
static void TolbiShipDeck_SetUpAfterKraken(void)
After the Kraken: as under sail, with Sean at the helm.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_SetUpAtAnchor
static void TolbiShipDeck_SetUpAtAnchor(void)
At anchor off the island: the crew stand where they were left, by whether the party has agreed to scout the island, and entering by entrance 6 means the party is back from it.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_DepartFromKalay
static void TolbiShipDeck_DepartFromKalay(void)
Entrance 10, setting sail before the party is on deck: actor 23 brings word to actor 21 that all is ready.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_DepartWithParty
static void TolbiShipDeck_DepartWithParty(void)
Entrance 10 with the party aboard: Kaja brings word to actor 23.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_AnnouncePreparationsReady
static void TolbiShipDeck_AnnouncePreparationsReady(s32 a0, s32 a1)
The messenger comes up through the first door to report, the officer calls the ship ready, and the scene moves on to the next stage of the voyage. "Preparations... Ready!"
Used by TolbiShipDeck_DepartFromKalay, TolbiShipDeck_DepartWithParty.
TolbiShipDeck_SightSeaMonsters
static void TolbiShipDeck_SightSeaMonsters(void)
Entrance 11: sea monsters are sighted. "Aye, Captain! Sea monsters!"
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_MonstersBoard
static void TolbiShipDeck_MonstersBoard(void)
Entrance 12: the monsters leap aboard and someone cries out. "It's no use. It's too late!"
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_MonstersAttackCrew
static void TolbiShipDeck_MonstersAttackCrew(void)
Entrance 13: the monsters harry the crew while more of them climb aboard.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_MonsterLandsOnDeck
static void TolbiShipDeck_MonsterLandsOnDeck(void)
Entrance 14: a great shape rises from the sea and a monster drops onto the deck.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_JumpIntoKrakenBattle
static void TolbiShipDeck_JumpIntoKrakenBattle(void)
Entrance 15: the party jumps down to the deck, gathers and charges; the battle with the Kraken begins (battle 62), returning to entrance 16.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_ThankForKraken
static void TolbiShipDeck_ThankForKraken(void)
Entrance 16: Isaac is thanked for the Kraken. "Thank you, Isaac. You did good against that Kraken."
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_SightLand
static void TolbiShipDeck_SightLand(void)
Entrance 17: land is sighted. "Hey, I can see land!"
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_RowersDisembark
static void TolbiShipDeck_RowersDisembark(void)
Entrance 18, at Tolbi: the four passengers who rowed come up from below in turn and each says something, then the leader comes up and is thanked for the hard work. Who rowed is read from the four seats' flag groups, the passengers (actors 23 to 31) in a fixed order of preference.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_GetRowerAtSeat
static s32 TolbiShipDeck_GetRowerAtSeat(u32 seat)
Returns the passenger (actor 23 to 31) who promised to row at a seat (0 to 3), or 0 if the seat is empty. Each seat has a group of nine flags, one for each passenger.
Used by TolbiShipDeck_ChooseOarStrokes, TolbiShipDeck_RowersDisembark.
TolbiShipDeck_RockDeck
static void TolbiShipDeck_RockDeck(void)
The callback that rocks the deck while under sail: sways the camera on two random-walking angles and offsets the BG3 sea pattern, wrapping at 32 pixels.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_SetUpOars
static void TolbiShipDeck_SetUpOars(void)
Under sail: shows the rowers (8 to 11) and the oars (12 to 19, the right-hand ones mirrored), records each oar's resting depth and chooses their strokes.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_ShowOar
static void TolbiShipDeck_ShowOar(s32 a)
Shows an oar or rower drawn under the deck, with no collision.
Used by TolbiShipDeck_RestOars, TolbiShipDeck_SetUpOars.
TolbiShipDeck_ChooseOarStrokes
static void TolbiShipDeck_ChooseOarStrokes(void)
Gives each oar the stroke of its seat's rower; empty seats take stroke 3. The first loop's stores are all overwritten below.
Used by TolbiShipDeck_SetUpOars.
TolbiShipDeck_GetSeatStroke
static s32 TolbiShipDeck_GetSeatStroke(u32 seat)
Returns the stroke (1 to 4) of the rower at a seat, or 0 if the seat is empty.
Used by TolbiShipDeck_ChooseOarStrokes.
TolbiShipDeck_RowOars
static void TolbiShipDeck_RowOars(void)
The task that rows: advances the four rowers' strokes and swings the eight oars, each following its rower's phase.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_AdvanceStroke
static void TolbiShipDeck_AdvanceStroke(s32 actor, s32 slot)
Advances one rower's stroke phase: slowly through the catch and the finish of the stroke, quicker through the drive, quickest on the return; the animation follows.
Used by TolbiShipDeck_RowOars.
TolbiShipDeck_SwingOar
static void TolbiShipDeck_SwingOar(s32 id, s32 slot, s32 flags)
Swings one oar to its angle: unless flags bit 1 is set, the angle follows the rower whose stroke the oar takes; bit 0 marks a right-hand oar. The oar's tilt (its sprite's rotation) and depth follow the angle.
Used by TolbiShipDeck_RestOars, TolbiShipDeck_RowOars.
TolbiShipDeck_RestOars
static void TolbiShipDeck_RestOars(void)
When not under sail: the oars lie at rest, all following the first rower's placeholder, which stands where the leader is.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_CopyUnderwayCells
static void TolbiShipDeck_CopyUnderwayCells(void)
Redraws a block of the deck's cells and attributes, as it is whenever the ship has left the Kalay dock.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_CopyAnchoredCells
static void TolbiShipDeck_CopyAnchoredCells(void)
Redraws two more blocks of cells, as they are at anchor.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_Say
static void TolbiShipDeck_Say(s32 a)
Shows the current message from a speaker and waits 10 frames.
Used by TolbiShipDeck_ArriveAtTolbi, TolbiShipDeck_CatchCrewmanFromEast, TolbiShipDeck_CatchCrewmanFromWest, TolbiShipDeck_MonstersBoard, TolbiShipDeck_OfferToScoutIsland, TolbiShipDeck_ReturnFromIsland, TolbiShipDeck_RowersDisembark, TolbiShipDeck_SightLand, TolbiShipDeck_ThankForKraken, TolbiShipDeck_WatchCrewDecideToSail.
TolbiShipDeck_Turn
static void TolbiShipDeck_Turn(s32 a, s32 b)
Turns an actor to a facing over 10 frames.
Used by TolbiShipDeck_AnnouncePreparationsReady, TolbiShipDeck_ArriveAtTolbi, TolbiShipDeck_JumpIntoKrakenBattle, TolbiShipDeck_MonsterLandsOnDeck, TolbiShipDeck_MonstersAttackCrew, TolbiShipDeck_OfferToScoutIsland, TolbiShipDeck_ReturnFromIsland, TolbiShipDeck_RowersDisembark, TolbiShipDeck_SightSeaMonsters, TolbiShipDeck_ThankForKraken, TolbiShipDeck_WatchCrewDecideToSail.
TolbiShipDeck_ArriveAtTolbi
static void TolbiShipDeck_ArriveAtTolbi(void)
Entrance 19: the ship reaches Tolbi and the crew talk it over before Kaja goes below.
Used by TolbiShipDeck_ApplyEntryState.
TolbiShipDeck_OfferToScoutIsland
static void TolbiShipDeck_OfferToScoutIsland(void)
At anchor: the party is asked to scout the island; Garet and Ivan may argue before the party agrees.
Used by gTolbiShipDeckEventsAtIsland.
TolbiShipDeck_ReturnFromIsland
static void TolbiShipDeck_ReturnFromIsland(void)
Back on deck from the island: on yes, the crew make ready to sail and the scene moves on. "How was it, Isaac? Did you explore the island thoroughly?"
Used by TolbiShipDeck_SetUpAtAnchor.
TolbiShipDeck_PlaceLeaderOnDeck
static void TolbiShipDeck_PlaceLeaderOnDeck(void)
Places the leader on the deck facing south, with the camera on them.
Used by TolbiShipDeck_SetUpAfterKraken, TolbiShipDeck_SetUpUnderSail.
Also, functions without a comment: TolbiShipDeck_GetEntrances, TolbiShipDeck_GetRegions, TolbiShipDeck_GetExits, TolbiShipDeck_GetPlacements, TolbiShipDeck_GetEvents.
Enumerations
TolbiShipDeckActor
enum TolbiShipDeckActor
Who is who on deck. At Kalay (gTolbiShipDeckPlacementsWaiting) the captain asks Kaja, the deck's fighter, how the oarsmen are ("Say, Kaja, how are the oarsmen doing?"). At sea gTolbiShipDeck_CrewScript places Kaja and the warriors Ouranos and Sean, who help him guard the deck ("That'll be me, Ouranos, and Sean on deck").
| Value | = | |
|---|---|---|
KALAY_CREWMAN | 20 | denies everything. "I didn't do anything..." |
KALAY_CAPTAIN | 22 | |
KALAY_KAJA | 23 | |
SEA_KAJA | 20 | |
SEA_OURANOS | 21 | |
SEA_SEAN | 22 |
Macros
FLAG_TOLBI_SHIP_KRAKEN_ABOARD
#define FLAG_TOLBI_SHIP_KRAKEN_ABOARD 0x302
"There's a huge sea monster on the ship!": the deck shakes until the Kraken is defeated (set in tolbi_ship_interiors.c).
Used by TolbiShipDeck_ThankForKraken, TolbiShipInteriors_ApplyEntryState, TolbiShipInteriors_NoticeShipRocking, TolbiShipInteriors_RunSceneCommand.
SPEAKER
#define SPEAKER(actor, window) ((window) << 12 | (actor))
A speaker: the actor, and in the top four bits where the message window opens beside them (4, SPEAKER_WINDOW_ABOVE, is above).
Used by Event_FightTret, TolbiShipDeck_ArriveAtTolbi, TolbiShipDeck_MonstersBoard, TolbiShipDeck_ReturnFromIsland, TolbiShipDeck_SightSeaMonsters, TolbiShipDeck_WatchCrewDecideToSail, TolbiShipInteriors_WatchWarriorsStormOff, TretTreeInteriors_PlayPostBattleConversation.
Also, macros without a comment: TOLBI_SHIP_DECK_SEA_WRAP.
Globals
sUnused0
UNUSED static s32 sUnused0
never used; keeps the statics' layout
sUnused1
UNUSED static s32 sUnused1
never used; keeps the statics' layout
gTolbiShipDeckRowerStrokes
const s32 gTolbiShipDeckRowerStrokes[]
How hard each passenger rows, for actors 23 to 31: 1 leaves the oar still, 2 to 4 row ever faster.
Used by TolbiShipDeck_GetSeatStroke.
Also, globals without a comment: sStrokePhase, sSwayAngleY, sOarAngle, sSeaScroll, sSwayAngleX, sSeaSpeed, sOarStroke, sOarDepth, gTolbiShipDeck_PresentationActionsA, gTolbiShipDeck_PresentationActionsB, gTolbiShipDeck_RandomActorActions, gTolbiShipDeck_DeckEventActions, gTolbiShipDeck_LeadActionsA, gTolbiShipDeck_LeadActionsB, gTolbiShipDeck_CrewActionsA, gTolbiShipDeck_CrewActionsB, gTolbiShipDeck_CrewActionsC, gTolbiShipDeck_CrewActionsD, gTolbiShipDeck_CrewActionsE, gTolbiShipDeck_SailorActions, gTolbiShipDeck_DeckActionsB, gTolbiShipDeck_DeckActionsA, gTolbiShipDeck_DeckActionsC, gTolbiShipDeck_RosterActions, gTolbiShipDeck_LeaveActions, gTolbiShipDeck_LeadActionsC, gTolbiShipDeckEntrances, gTolbiShipDeckRegions, gTolbiShipDeckExits, gTolbiShipDeckPlacements, gTolbiShipDeckPlacementsWaiting, gTolbiShipDeckPlacementsRowing, gTolbiShipDeckPlacementsAtSea, gTolbiShipDeck_CrewScript, gTolbiShipDeck_ClosingCrewScript, gTolbiShipDeck_CrewScriptB, gTolbiShipDeck_CrewScriptC, gTolbiShipDeck_CrewScriptD, gTolbiShipDeck_CrewScriptE, gTolbiShipDeckPlacementsArrived, gTolbiShipDeckEvents, gTolbiShipDeckEventsAtSea, gTolbiShipDeckEventsArrived, gTolbiShipDeckEventsAtIsland.