The entrance table is used to create a means of linking between scenes. Each entrance record stores 4 bytes of data, and the table indexer is typically stored as a signed short, but the table lookup routine will ignore the sign bit, such that index 0x8000 equivalent to 0x0000 for example.
/*0x00*/ byte Scene; /*0x01*/ byte Spawn; /*0x02*/ short Variable //Bitpacked variable defined as below: // & 8000 = Continue playing background music when exiting. 0 stops it, 1 continues playing it. // & 4000 = Displays title card. (Also sets property in Link?) // & 3F80 = Fade In Transition Animation // & 007F = Fade Out Transition Animation
- Scene is the scene index used to reference what scene to load.
- Spawn sets what "entrance" within the scene to spawn at. Additionally, this value affects dynamic exits, and is used to determine which Fairy Fountain you've entered (see below). Entrances are defined by the Entrance List scene/room command. See Scenes and Rooms: Entrance List.
|02||Slow fade to/from black|
|03||Slow fade to/from white during the day, black during night|
|04||Fast fade to/from black during the day, slow fade to/from black during night|
|05||Fast fade to/from white during the day, slow fade to/from black during night|
|06||Very slow fade to/from white during the day, slow fade to/from black during night|
|07||Very slow fade to/from white during the day, slow fade to/from black during night|
|0E||Slow fade into sandstorm, sets sandstorm animation leaving, keeps animation running|
|0F||Fast fade to sandstorm, sets sandstorm animation on leaving, ends animation on entering|
|2C||Shortcut Transition Animation|
Both sandstorm transition effects are dependent on object gameplay_field_keep (0002, Shared assets for actors (Overworld)).
A somewhat confusing aspect of the entrance table is that the developers use a routine that indirectly looks up the entrance table based on 4 different variables: a "base" index, Link's age, the time of day, and variable used to load cutscene setups (we'll call it the cutscene number).
The base index can be thought of as being the starting point to an array of possible entrances.
- If the cutscene number's value is 0x0000, the look-up index = base index, +1 if night, +2 if Link is an adult
- If the cutscene number's value is 0xFFF0-0xFFFF, the look-up index = base index, +4, + the rightmost hex digit in the cutscene number.
This means that for every spawn location, you will need 4 sequential records on the entrance table. If you wish to trigger a cutscene stored within a scene setup, you will also need additional records for each cutscene you want to spawn at. Nintendo conserves space by using the same base index (which ends up being the entrance with the lowest index) for all cutscenes within a scene.
Day/Night, Child Adult Examples
If you touch the entrance to the Great Deku Tree, the base index is set to 0x0000, and the cutscene number should be 0x0000. The records at the following index will be looked up with the given time of day/age conditions.
- 0000 Day/Child
- 0001 Night/Child
- 0002 Day/Adult
- 0003 Night/Adult
Cutscene Setup Example
If you start an unmodified rom, the first cutscene that plays will be the title screen cutscene. This sets a base index of 0x00CD, with a cutscene number of 0xFFF3.
00CD 4 +0003 ===== 00D4
Certain index values are coded to have special functionality.
- The first time you are set to spawn at entrance index 0x05E0 (Kokiri Forest->Lost Woods Bridge), your entrance index will be converted to 0x011E (Kokiri Forest->Lost Woods entrance 0) in order to play the cutscene where Saria gives you the Fairy Ocarina without crashing.
- For every ovl_En_Holl (0023, Room Change Plane) spawned, the actor will run a check once per frame to see if the current entrance index is 00EE (Kokiri Forest's cutscene entrance), and the current scene setup is 8. If both conditions are true, the actor will force two rooms to load simultaneously when Link walks near one.
- On every frame, a check located within code is performed on the current entrance index to see if it's value is 00CD (Hyrule Field cutscene entrance)
- Whenever Link game overs, the game will check his current entrance index to determine whether to "death warp" him to a new destination, specifically for when warping him back to the start of a dungeon.
There exists a table in code which references various cutscenes that trigger when spawning with a specific entrance index. See Entrance Cutscenes for more details
Soft Reset Functionality
Setting an entrance index of -1 (0xFFFF or 0xFFFFFFFF, depending on the variable size) will "soft reset" the game, returning you to the title screen.
Indexes 0x7FF9 - 0x7FFE are used for dynamic scene exits, enabling the devs to reuse the same scenes. When Link touches an exit set to one of these index values, a table look-up is performed based on the index, plus the entrance id for the area spawned in.
- ovl_player_actor (Debug):
C23398 - Exit list for index 7FFE (Great Fairy Fountain, Upgrades) C2339E - Exit list for index 7FFB (Potion Shop? must have been only one scene at one time) C233A2 - Exit list for index 7FFC (Bazaar) C233AA - Exit list for index 7FFA (Shooting Gallery) C233AE - Exit list for index 7FF9 (Great Fairy Fountain, Magic Spells)
Index 0x7FFF is used to return a player to a previously saved grotto respawn point.
If you walk into the Great Fairy Fountain (Upgrades) from Death Mountain Trail, the following entrance look-up will occur.
|Index||Scene||Entrance||Variable||Scene Name||Spawn Info|
|04BE||3B||01||4102||Great Fairy's Fountain (Upgrades)||From Death Mountain Crater|
This sets the spawn entrance to (01). Then later when you touch the exit (which is set to 7FFE), The game will look at the two byte value at C2339A (2 * entrance + C2339A).