Skip to Content
The Alchemy Project

src/scene/tret_tree_branch.c

Tret Tree's branches (SceneIdTretTreeBranch): the outside of Tret, the holy tree of Kolima Forest, high up under open sky, with clouds drifting past above and the green of the forest far below (places/tret-tree-branch/map-0.png). More…

Macros

NameDescription
#defineBG3_SPLIT_Y 192The map height at which the background splits: the clouds drift above it, and the forest far below lies under it.
#defineREVEAL_WININ (WININ_WIN0_ALL | WININ_WIN1_ALL)The oval round Isaac (WINDOW_TRANSITION_LEADER) in which the leaves in front of the branches are see-through: inside it BG1, the leaves, is blended over the rest, and outside it every layer shows without the colour effect.
#defineREVEAL_WINOUT (WINOUT_WIN01_ALL & ~WINOUT_WIN01_CLR)
#defineREVEAL_WINDOW_STEPS 10

Enumerations

NameDescription
enumanonymous enum { ACTOR_BREEZE }Breeze, a Jupiter Djinni (DJINNI_BREEZE), is the only placed actor.
enumTRET_TREE_BRANCH_METATILE_BEHAVIOR { METATILE_BEHAVIOR_TRET_JOIN_WEST_VINE, METATILE_BEHAVIOR_TRE … }The metatiles at the vines' tops that move Isaac between the branch he walks on and the hidden copy of it that joins the vine.

Functions

NameDescription
static voidscTretTreeBranchStartBg3Split (void)Starts the clouds drifting above the forest.
static voidscTretTreeBranchTalkToBreeze (void)Talking to Breeze, the Jupiter Djinni at the east end of Tret's highest branch, makes it hop and starts the battle with it.
const SCENE_ENTRANCE *scGetEntrances (void)The six rooms share one entrance table.
const SCENE_EXIT_REGION *scGetExitRegions (void)The scene has no exit regions: its regions entry returns none.
const Uint32 *scGetExits (void)Both scenes share one exit table.
const ACTOR_PLACE *scGetActorPlacements (void)Some villagers only turn back after talking once the flood is over or their family has gone home.
static voidscTretTreeBranchShiftLeaderAndCameraByMetatiles (Sint32 metatileOffsetX, Sint32 metatileOffsetZ)Moves the leader and the camera the same number of metatiles, each set on the ground of the metatile it lands on.
static voidscTretTreeBranchJoinWestVine (void)On the upper branch beside the west vine's top (metatile (7, 12)), moves Isaac onto the hidden copy that joins the vine, so that Down climbs him down it.
static voidscTretTreeBranchLeaveWestVine (void)Stepping east off the west vine's top (metatile (8, 17)) moves Isaac back onto the drawn branch, the one to the fifth floor's west door.
static voidscTretTreeBranchJoinNortheastVine (void)On the northeast vine's top (metatile (37, 11)), on the branch to the fifth floor's east door, moves Isaac onto the hidden copy that joins the vine.
static voidscTretTreeBranchLeaveNortheastVine (void)Stepping west off the northeast vine's top (metatile (36, 16)) moves Isaac back onto the drawn branch, the one to the fifth floor's east door and Breeze.
static voidscTretTreeBranchJoinSoutheastVine (void)At the southeast vine's top (metatile (41, 20)), on the branch from the third floor's east door, moves Isaac onto the hidden copy that joins the vine, down which he climbs to the second floor's east door.
static voidscTretTreeBranchLeaveSoutheastVine (void)Stepping west off the southeast vine's top (metatile (40, 26)) moves Isaac back onto the drawn branch to the third floor's east door.
static voidscTretTreeBranchEnterTretTreeRooms (void)Isaac walks into one of the arched doors in Tret's trunk, such as the second floor's west door at the end of the lowest branch (metatile (20, 26)), and goes back inside Tret Tree to the floor that door belongs to.
static inline voidscTretTreeBranchSetRevealWindow (SCREEN_TRANSITION_STATE *state)Opens the see-through oval round Isaac, as the scene starts and again after Reveal.
static voidscTretTreeBranchRevealFades (void)When Reveal wears off, the leaves round Isaac turn see-through again: Reveal drew its own rippling oval in place of the scene's, so the scene's oval and the leaves' blend are set back as scInit set them.
const CUE *scGetCues (void)Returns the scene's scripts: its eight doors, the six metatiles at the vines' tops, Breeze and Reveal.
static void UNUSEDscTretTreeBranchRunEmptyScript (void)Unused script hook: begins and immediately ends a script.
static void UNUSEDscTretTreeBranchUnusedHookFirst (void)Unused: an empty function nothing refers to, the first of two here.
static void UNUSEDscTretTreeBranchUnusedHookSecond (void)Unused: an empty function nothing refers to, the second of two here.
static void UNUSEDscTretTreeBranchExchangeInputPacket (void)Unused exchange callback: puts held/repeated keys in the transfer header.
Sint32scInit (void)Opens Tret's branches with a backdrop fade, opens the see-through oval in the leaves round Isaac and starts the clouds drifting.
static voidscTretTreeBranchApplyBg3ScrollAtScanline (void)At each scanline, picks the background's horizontal scroll: the drifting clouds' above the split, the map's below it.
static voidscTretTreeBranchUpdateBg3ScrollSplit (void)Each tick, moves the split with the map's vertical scroll, so that it stays at BG3_SPLIT_Y on the map.

Variables

NameDescription
extern SCENE_ENTRANCETretTreeBranchEntrances []
extern Uint32TretTreeBranchExits []
extern ACTOR_PLACETretTreeBranchActorPlacements []
extern CUETretTreeBranchCues []
static Uint16TransferHeader [16]The header and data of the unused input exchange (scTretTreeBranchExchangeInputPacket).
static Uint8TransferData [96]
static Sint32SplitLineThe screen line where BG3 splits, and its horizontal scroll below the split (the forest) and above it (the drifting clouds).
static Uint16HofsAtOrAfterSplit
static Uint16HofsBeforeSplit
Uint16TretTreeBranchUnusedMetatileSteps []Unused: the two steps of a door opening, as Vale's doors have them (ValePrologueSanctumDoorOpens).

Description

Tret Tree's branches (SceneIdTretTreeBranch): the outside of Tret, the holy tree of Kolima Forest, high up under open sky, with clouds drifting past above and the green of the forest far below (places/tret-tree-branch/map-0.png). Isaac climbs Tret from the inside (SceneIdTreeRooms, tree_rooms.c), where the story is told; out here there is no story script, and nothing tests a story flag.

Arched doors in Tret's trunk lead out onto the branches, two from each of the
second to fifth floors. Walking into one goes back inside:
- the second floor's west door (metatile (20, 26)) opens onto a branch
that  leads nowhere, and its east door (metatile (26, 27)) onto the branch
below  the southeast vine; - the third floor's south door (metatile (23,
22)) opens onto a branch that  runs west, and its east door (metatile (26,
20)) onto the branch above the  southeast vine; - the fourth floor's south
door (metatile (23, 16)) opens onto the branch below  the northeast vine,
and its west door (metatile (20, 15)) onto the branch  below the west
vine; - the fifth floor's west door (metatile (20, 9)) opens onto the
branch above the  west vine, and its east door (metatile (26, 8)) onto the
branch above the  northeast vine.

So the way up Tret goes out of the second floor's east door, up the southeast vine and in at the third floor's east door; then out of the fourth floor's south door, east and up the northeast vine to the fifth floor's east door, where the Nut's chest is; and out of the fourth floor's west door, along the branch and up the west vine to the fifth floor's west door, which leads to the leaf that drops Isaac to Tret.

Breeze, a Jupiter Djinni, waits at the east end of the highest branch, above the fifth floor's east door, until it has joined the party.

The three vines climb like any vine: Isaac stands on the vine and holds Up or Down. Nothing visible happens at the vines' tops, but the game has work to do there. The stretch of upper branch at each vine's top is stored twice in the map: once as the branch Isaac walks on, and once as a hidden copy, 5 or 6 metatiles further south and as much higher, so that both are drawn on the same pixels. Only the hidden copy joins the vine. One metatile beside each vine moves Isaac onto the copy, and one on the copy moves him back (scTretTreeBranchJoinWestVine and the others).

Leaves hang in front of the branches, so the scene keeps an oval round Isaac in which they are see-through, from when he steps out until he goes back in. Reveal's own ripple takes its place while Reveal lasts, and the scene puts it back afterwards.

The clouds above the forest drift slowly right while the forest below moves only with the map (scTretTreeBranchUpdateBg3ScrollSplit).

The overlay also keeps three unused hooks and a link-cable input exchange no table reaches.

Macros in detail

BG3_SPLIT_Y

#define BG3_SPLIT_Y 192

The map height at which the background splits: the clouds drift above it, and the forest far below lies under it.

Referenced by scTretTreeBranchUpdateBg3ScrollSplit().

Definition at line 114 of file tret_tree_branch.c.

REVEAL_WININ

#define REVEAL_WININ (WININ_WIN0_ALL | WININ_WIN1_ALL)

The oval round Isaac (WINDOW_TRANSITION_LEADER) in which the leaves in front of the branches are see-through: inside it BG1, the leaves, is blended over the rest, and outside it every layer shows without the colour effect. REVEAL_WINDOW_STEPS is how far it is open.

Referenced by scTretTreeBranchSetRevealWindow().

Definition at line 252 of file tret_tree_branch.c.

REVEAL_WINOUT

#define REVEAL_WINOUT (WINOUT_WIN01_ALL & ~WINOUT_WIN01_CLR)

Referenced by scTretTreeBranchSetRevealWindow().

Definition at line 253 of file tret_tree_branch.c.

REVEAL_WINDOW_STEPS

#define REVEAL_WINDOW_STEPS 10

Referenced by scTretTreeBranchSetRevealWindow().

Definition at line 254 of file tret_tree_branch.c.

Enumerations in detail

anonymous enum

enum { ACTOR_BREEZE }

Breeze, a Jupiter Djinni (DJINNI_BREEZE), is the only placed actor. Its actor placement is gone once its flag (FLAG_DJINNI(DJINNI_BREEZE)) is set.

EnumeratorValueDescription
ACTOR_BREEZEACTOR_FIRST_PLACED

Definition at line 69 of file tret_tree_branch.c.

TRET_TREE_BRANCH_METATILE_BEHAVIOR

enum TRET_TREE_BRANCH_METATILE_BEHAVIOR

The metatiles at the vines' tops that move Isaac between the branch he walks on and the hidden copy of it that joins the vine. A door's metatiles carry its exit number (TRET_TREE_BRANCH_TREE_ROOMS_SOUTH_SOUTHWEST and the others).

EnumeratorValueDescription
METATILE_BEHAVIOR_TRET_JOIN_WEST_VINE10Beside the west vine's top, on the branch Isaac walks on: metatile (7, 12).
METATILE_BEHAVIOR_TRET_LEAVE_WEST_VINE11On the hidden copy, east of the west vine's top: metatile (8, 17).
METATILE_BEHAVIOR_TRET_JOIN_NORTHEAST_VINE12Above the northeast vine's top, on the branch: metatile (37, 11).
METATILE_BEHAVIOR_TRET_LEAVE_NORTHEAST_VINE13On the hidden copy, west of the northeast vine's top: metatile (36, 16).
METATILE_BEHAVIOR_TRET_JOIN_SOUTHEAST_VINE14West of the southeast vine's top, on the branch: metatile (41, 20).
METATILE_BEHAVIOR_TRET_LEAVE_SOUTHEAST_VINE15On the hidden copy, west of the southeast vine's top: metatile (40, 26).

Definition at line 78 of file tret_tree_branch.c.

Functions in detail

scTretTreeBranchStartBg3Split

static void scTretTreeBranchStartBg3Split(void)

Starts the clouds drifting above the forest.

Starts the clouds drifting: the split is chosen at every scanline and moved every tick.

References scTretTreeBranchApplyBg3ScrollAtScanline(), scTretTreeBranchUpdateBg3ScrollSplit(), syIntFunction() and sySetTickEvent().

Referenced by scInit().

Definition at lines 106 and 368 of file tret_tree_branch.c.

scTretTreeBranchTalkToBreeze

static void scTretTreeBranchTalkToBreeze(void)

Talking to Breeze, the Jupiter Djinni at the east end of Tret's highest branch, makes it hop and starts the battle with it.

References fdRequestDjinnBattle().

Referenced by TretTreeBranchCues.

Definition at line 124 of file tret_tree_branch.c.

scGetEntrances

const SCENE_ENTRANCE *scGetEntrances(void)

References TretTreeBranchEntrances.

Definition at line 129 of file tret_tree_branch.c.

scGetExitRegions

const SCENE_EXIT_REGION *scGetExitRegions(void)

Definition at line 134 of file tret_tree_branch.c.

scGetExits

const Uint32 *scGetExits(void)

References TretTreeBranchExits.

Definition at line 139 of file tret_tree_branch.c.

scGetActorPlacements

const ACTOR_PLACE *scGetActorPlacements(void)

References TretTreeBranchActorPlacements.

Definition at line 144 of file tret_tree_branch.c.

scTretTreeBranchShiftLeaderAndCameraByMetatiles

static void scTretTreeBranchShiftLeaderAndCameraByMetatiles(Sint32 metatileOffsetX, Sint32 metatileOffsetZ)

Moves the leader and the camera the same number of metatiles, each set on the ground of the metatile it lands on. Between a branch and its hidden copy the metatiles south are as much higher, so the picture does not change.

References fdActorGet(), fdMapGridGetTerrainHeight(), MainRoutineStateWork, Sint32 and state.

Referenced by scTretTreeBranchJoinNortheastVine(), scTretTreeBranchJoinSoutheastVine(), scTretTreeBranchJoinWestVine(), scTretTreeBranchLeaveNortheastVine(), scTretTreeBranchLeaveSoutheastVine() and scTretTreeBranchLeaveWestVine().

Definition at line 152 of file tret_tree_branch.c.

scTretTreeBranchJoinWestVine

static void scTretTreeBranchJoinWestVine(void)

On the upper branch beside the west vine's top (metatile (7, 12)), moves Isaac onto the hidden copy that joins the vine, so that Down climbs him down it.

References scTretTreeBranchShiftLeaderAndCameraByMetatiles().

Referenced by TretTreeBranchCues.

Definition at line 191 of file tret_tree_branch.c.

scTretTreeBranchLeaveWestVine

static void scTretTreeBranchLeaveWestVine(void)

Stepping east off the west vine's top (metatile (8, 17)) moves Isaac back onto the drawn branch, the one to the fifth floor's west door.

References scTretTreeBranchShiftLeaderAndCameraByMetatiles().

Referenced by TretTreeBranchCues.

Definition at line 198 of file tret_tree_branch.c.

scTretTreeBranchJoinNortheastVine

static void scTretTreeBranchJoinNortheastVine(void)

On the northeast vine's top (metatile (37, 11)), on the branch to the fifth floor's east door, moves Isaac onto the hidden copy that joins the vine.

References scTretTreeBranchShiftLeaderAndCameraByMetatiles().

Referenced by TretTreeBranchCues.

Definition at line 205 of file tret_tree_branch.c.

scTretTreeBranchLeaveNortheastVine

static void scTretTreeBranchLeaveNortheastVine(void)

Stepping west off the northeast vine's top (metatile (36, 16)) moves Isaac back onto the drawn branch, the one to the fifth floor's east door and Breeze.

References scTretTreeBranchShiftLeaderAndCameraByMetatiles().

Referenced by TretTreeBranchCues.

Definition at line 213 of file tret_tree_branch.c.

scTretTreeBranchJoinSoutheastVine

static void scTretTreeBranchJoinSoutheastVine(void)

At the southeast vine's top (metatile (41, 20)), on the branch from the third floor's east door, moves Isaac onto the hidden copy that joins the vine, down which he climbs to the second floor's east door.

References scTretTreeBranchShiftLeaderAndCameraByMetatiles().

Referenced by TretTreeBranchCues.

Definition at line 221 of file tret_tree_branch.c.

scTretTreeBranchLeaveSoutheastVine

static void scTretTreeBranchLeaveSoutheastVine(void)

Stepping west off the southeast vine's top (metatile (40, 26)) moves Isaac back onto the drawn branch to the third floor's east door.

References scTretTreeBranchShiftLeaderAndCameraByMetatiles().

Referenced by TretTreeBranchCues.

Definition at line 228 of file tret_tree_branch.c.

scTretTreeBranchEnterTretTreeRooms

static void scTretTreeBranchEnterTretTreeRooms(void)

Isaac walks into one of the arched doors in Tret's trunk, such as the second floor's west door at the end of the lowest branch (metatile (20, 26)), and goes back inside Tret Tree to the floor that door belongs to.

A moment's push against the doorway is enough (STEP_CUE_FLAG_QUICK). The exit sound plays, and the door's metatile carries its own exit number, which the step cue hands on as the exit to take.

References state, syImportScriptSetExitRequest() and sySoundPlay().

Referenced by TretTreeBranchCues.

Definition at line 240 of file tret_tree_branch.c.

scTretTreeBranchSetRevealWindow

static inline void scTretTreeBranchSetRevealWindow(SCREEN_TRANSITION_STATE *state)

Opens the see-through oval round Isaac, as the scene starts and again after Reveal.

References state.

Referenced by scInit() and scTretTreeBranchRevealFades().

Definition at line 258 of file tret_tree_branch.c.

scTretTreeBranchRevealFades

static void scTretTreeBranchRevealFades(void)

When Reveal wears off, the leaves round Isaac turn see-through again: Reveal drew its own rippling oval in place of the scene's, so the scene's oval and the leaves' blend are set back as scInit set them.

References fdScreenTransitionStartHeldWindow() and scTretTreeBranchSetRevealWindow().

Referenced by TretTreeBranchCues.

Definition at line 269 of file tret_tree_branch.c.

scGetCues

const CUE *scGetCues(void)

Returns the scene's scripts: its eight doors, the six metatiles at the vines' tops, Breeze and Reveal.

References TretTreeBranchCues.

Definition at line 281 of file tret_tree_branch.c.

scTretTreeBranchRunEmptyScript

static void UNUSED scTretTreeBranchRunEmptyScript(void)

Unused script hook: begins and immediately ends a script.

References fdScriptEnd() and fdScriptStart().

Definition at line 287 of file tret_tree_branch.c.

scTretTreeBranchUnusedHookFirst

static void UNUSED scTretTreeBranchUnusedHookFirst(void)

Unused: an empty function nothing refers to, the first of two here.

Definition at line 294 of file tret_tree_branch.c.

scTretTreeBranchUnusedHookSecond

static void UNUSED scTretTreeBranchUnusedHookSecond(void)

Unused: an empty function nothing refers to, the second of two here.

Definition at line 299 of file tret_tree_branch.c.

scTretTreeBranchExchangeInputPacket

static void UNUSED scTretTreeBranchExchangeInputPacket(void)

Unused exchange callback: puts held/repeated keys in the transfer header.

References PerData, PerRepeat, sySerialPollAndTransfer(), TransferData and TransferHeader.

Definition at line 304 of file tret_tree_branch.c.

scInit

Sint32 scInit(void)

Opens Tret's branches with a backdrop fade, opens the see-through oval in the leaves round Isaac and starts the clouds drifting.

References fdScreenTransitionStartHeldWindow(), scTretTreeBranchSetRevealWindow(), scTretTreeBranchStartBg3Split(), Sint32 and state.

Definition at line 315 of file tret_tree_branch.c.

scTretTreeBranchApplyBg3ScrollAtScanline

static void scTretTreeBranchApplyBg3ScrollAtScanline(void)

At each scanline, picks the background's horizontal scroll: the drifting clouds' above the split, the map's below it.

References HofsAtOrAfterSplit, HofsBeforeSplit and SplitLine.

Referenced by scTretTreeBranchStartBg3Split().

Definition at line 335 of file tret_tree_branch.c.

scTretTreeBranchUpdateBg3ScrollSplit

static void scTretTreeBranchUpdateBg3ScrollSplit(void)

Each tick, moves the split with the map's vertical scroll, so that it stays at BG3_SPLIT_Y on the map. The clouds above it lag the map by one more pixel every four ticks, so they drift slowly right.

References HofsAtOrAfterSplit, HofsBeforeSplit, Sint32, SplitLine and TickCount.

Referenced by scTretTreeBranchStartBg3Split().

Definition at line 355 of file tret_tree_branch.c.

Variables in detail

TretTreeBranchEntrances

extern SCENE_ENTRANCE TretTreeBranchEntrances[]

SCENE_ENTRANCE TretTreeBranchEntrances[]

Referenced by scGetEntrances().

Definition at lines 62 and 374 of file tret_tree_branch.c.

TretTreeBranchExits

extern Uint32 TretTreeBranchExits[]

Uint32 TretTreeBranchExits[]

Referenced by scGetExits().

Definition at lines 63 and 459 of file tret_tree_branch.c.

TretTreeBranchActorPlacements

extern ACTOR_PLACE TretTreeBranchActorPlacements[]

ACTOR_PLACE TretTreeBranchActorPlacements[]

Referenced by scGetActorPlacements().

Definition at lines 64 and 489 of file tret_tree_branch.c.

TretTreeBranchCues

extern CUE TretTreeBranchCues[]

CUE TretTreeBranchCues[]

References scTretTreeBranchEnterTretTreeRooms(), scTretTreeBranchJoinNortheastVine(), scTretTreeBranchJoinSoutheastVine(), scTretTreeBranchJoinWestVine(), scTretTreeBranchLeaveNortheastVine(), scTretTreeBranchLeaveSoutheastVine(), scTretTreeBranchLeaveWestVine(), scTretTreeBranchRevealFades() and scTretTreeBranchTalkToBreeze().

Referenced by scGetCues().

Definition at lines 65 and 496 of file tret_tree_branch.c.

TransferHeader

static Uint16 TransferHeader[16]

The header and data of the unused input exchange (scTretTreeBranchExchangeInputPacket).

Referenced by scTretTreeBranchExchangeInputPacket().

Definition at line 110 of file tret_tree_branch.c.

TransferData

static Uint8 TransferData[96]

Referenced by scTretTreeBranchExchangeInputPacket().

Definition at line 111 of file tret_tree_branch.c.

SplitLine

static Sint32 SplitLine

The screen line where BG3 splits, and its horizontal scroll below the split (the forest) and above it (the drifting clouds).

References Sint32.

Referenced by scTretTreeBranchApplyBg3ScrollAtScanline() and scTretTreeBranchUpdateBg3ScrollSplit().

Definition at line 118 of file tret_tree_branch.c.

HofsAtOrAfterSplit

static Uint16 HofsAtOrAfterSplit

Referenced by scTretTreeBranchApplyBg3ScrollAtScanline() and scTretTreeBranchUpdateBg3ScrollSplit().

Definition at line 119 of file tret_tree_branch.c.

HofsBeforeSplit

static Uint16 HofsBeforeSplit

Referenced by scTretTreeBranchApplyBg3ScrollAtScanline() and scTretTreeBranchUpdateBg3ScrollSplit().

Definition at line 120 of file tret_tree_branch.c.

TretTreeBranchUnusedMetatileSteps

Uint16 TretTreeBranchUnusedMetatileSteps[]

Unused: the two steps of a door opening, as Vale's doors have them (ValePrologueSanctumDoorOpens). Nothing on the branch plays them.

Definition at line 550 of file tret_tree_branch.c.