Entrance Table

From z64 wiki
Jump to: navigation, search
Code (File)
Entrance Table
Version VRom Size
Debug 0x00B9F360 0x00BA0BB0 0x1850
NTSC 1.0 0x00B6FBF0 0x00B71440 0x1850
NTSC 1.2 0x00B6FC00 0x00B71450 0x1850

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.

Entrance Table and Alternate Organization contain a listing of the contents of the entrance tables

Format

sseevvtt
  • s is the Scene number to load
  • e 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.
  • v is a variable used to control certain behaviors (ex. whether to cut the music short) when transitioning to a new entrance
  • t sets the transition animation that plays when transitioning to a new entrance. It's important to note that dust transition effect that plays in certain spots seems to rely on a specific object file, in order to work without throwing a graphic exception each frame.

Look-up Routine

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


Other Info

Certain index values are coded to have special functionality.

Hardcoded Events

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.


On-Entrance Cutscenes

There exists a table in code which references various cutscenes that trigger when spawning with a specific entrance index. See On Entrance Cutscenes for more details

Soft Reset Functionality

Index 0x7FFF will "soft reset" the game, returning you to the title screen

Dynamic Exits

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
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)

Example

If you walk into the Great Fairy Fountain (Upgrades) from Death Mountain Trail, the following entrance look-up will occur.

IndexSceneEntranceVariableTransitionScene NameSpawn Info
04BE3B014102Great 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).