Scenes and Rooms

From z64 wiki
(Redirected from Maps and Scenes)
Jump to: navigation, search

Header Commands

The header commands are designed to define the bulk of the structure for Scene and Room files.

Command Description Variables Usage Found in
0x00 Defines the start positions list 00xx0000 yyyyyyyy x is the number of start positons
y is the offset of that list (including the bank). Follows the actors list format.
scenes
0x01 Defines the actor list 01xx0000 yyyyyyyy x is the number of actors
y is the offset of that list (including the bank). Follows the actors list format.
rooms
0x02 Cameras used by 0x1B command (MM only?) 02xx0000 yyyyyyyy x is the number of entries, y is the offset of the entries (including the bank). Follows #Camera Entries format Unknown
0x03 Defines the collision header 03000000 yyyyyyyy y is the offset of the collision header (including the bank). Follows the collision format. scenes
0x04 Defines the maps 04xx0000 yyyyyyyy x is the number of maps
y is the offset of the map list (including the bank). Follows the map list format.
scenes
0x05 Sets the wind (red cloth posts, rain) 05000000 wwzzssff ww will push the wind westward
zz affects the wind vertically
ss pushes the wind south
ff alters the strength of the cloth flapping
Documented by Strati and mzxrules
rooms
0x06 Defines the entrance list 06000000 yyyyyyyy The number of entrances is undefined, though it is usually equal to the number of start positions (see below) (that the entrance table accesses)
y is the offset of that list (including the bank). Follows the entrance list format.
scenes
0x07 Special objects 07??0000 0000xxxx x is the object to use for the room, either gameplay_field_keep (object 0x0002) or gameplay_dangeon_keep (object 0x0003)
Posted on z64 by xdaniel
scenes
0x08 Room behavior 08xx0000 0000yyzz x affects Sun's Song, backflipping with A

y is unknown

z affects Link's idle animation OR makes the room "Too Hot". See here.
rooms
0x09 Unused command 09000000 00000000 Has two instructions saving values to the stack, which aren't read before being overwritten.
Documented by Strati
rooms (Depth Test)
0x0A Defines the mesh 0A000000 yyyyyyyy y is the offset of the mesh header (including the bank). Follows the mesh header format. rooms
0x0B Defines the object list 0Bxx0000 yyyyyyyy x is the number of objects
y is the offset of the object list (including the bank). Follows the object list format.
rooms
0x0C Unused environment settings 0Cxx0000 yyyyyyyy x is the number of unused environment settings
y is the offset of the list (including the bank). Follows the unused environment list format.
Discovered by ChriisTiian
Unused (can be used in rooms)
0x0D Pathways 0D000000 yyyyyyyy y is the offset of the path list (including the bank). Follows the path list format.
Documented by xdaniel
scenes
0x0E Defines the transition actor list 0Exx0000 yyyyyyyy x is the number of transition actors
y is the offset of that list (including the bank). Follows the transition actors list format.
scenes
0x0F Defines the environment settings 0Fxx0000 yyyyyyyy x is the number of environment settings
y is the offset of that list (including the bank). Follows the environments list format.
scenes
0x10 Time settings 10000000 xxxxyy00 x = start time (0xFFFF = current game time)
y = time speed (signed), default 0xA.
rooms
0x11 Skybox settings 11000000 xx0y0z00 x = Skybox number (see the skybox list)
y = Cast. 0 = Sunny, 1 = Cloudy. Affects the sun's lens flare, and skybox 1 will load sky/clouds
z = Fog. 0 = minimal fog, 1+ = significant fog
scenes
0x12 Skybox modifier 12000000 xx000000 Allows skyboxes to be enabled in some rooms of a scene but disabled in others.
x = disable sky if not 0 (some backgrounds still appear)
rooms
0x13 Defines the exit list 13000000 yyyyyyyy y is the offset of the exit list (including the bank). Follows the exit list format. scenes
0x14 End marker 14000000 00000000 Signals the end of the header scenes and rooms
0x15 Sound settings 15xx0000 0000yyzz x = reverb
y = Nighttime SFX to play, 0x13 = always playing day track
z = track to play
Nighttime SFX documented by Strati
scenes
0x16 Sound settings 16000000 000000xx x = echo rooms
0x17 Cutscenes (OoT) 17000000 xxxxxxxx x = offset of cutscene data (including the bank). Follows the cutscene data format. scenes
(MM) 17xx0000 yyyyyyyy x = Number of cutscenes. y = offset of cutscene data (including the bank). Follows the MM cutscene format. scenes
0x18 Alternate headers 18000000 xxxxxxxx x = offset of alternate header list (including the bank). Follows the alternate header list format. scenes and rooms
0x19 Camera Settings and World Map 19xx0000 000000yy x = Affects camera movement
y = Sets what location of the world map to highlight.
See camera settings
scenes
Commands beyond 0x19 are used in Majora's Mask only.
Command Description Variables Usage Found in
0x1A Unknown 1A000000 xxxxxxxx Unknown scenes
0x1B Unknown 1Bxx0000 yyyyyyyy Unknown scenes
0x1C Unknown 1C000000 xxxxxxxx Unknown scenes
0x1D Unknown Unknown Unknown Unknown
0x1E Unknown 1Exx0000 yyyyyyyy Unknown scenes

Unreferenced Assets

Some assets stored within scene and room files are only referenced by external files, or not at all.

  • Textures that are used by multiple rooms are typically stored in the Scene file to save space.
  • Cutscenes that trigger when spawning on a specific entrance are referenced by code (possibly Ocarina of Time only). See On Entrance Cutscenes
  • The Spirit Temple in Ocarina of Time has two unreferenced headers in every scene and room, due to the alternate scene header command being absent.

Actors List

Format:
aaaaxxxx yyyyzzzz ppppwwww rrrrvvvv (repeats for each actor)
Where:
a = Actor number
x = Position on x-axis
y = Position on y-axis
z = Position on z-axis
p = Rotation around x-axis
w = Rotation around y-axis
r = Rotation around z-axis
v = initialization variable sent to actor
If the actor is link, use 0 for a and 0xFFF for v

Rooms List

Each room is two pointers, start and end, which game searches for in the file system. Format:
ssssssss eeeeeeee (repeats for each room)
Where:
s = Room virtual address start.
e = Room virtual address end.

Room Behavior

08xx0000 0000yyzz

x

00 - No effect/restrictions
01 - Prevents the Sun's Song time effect.
02 - Disables jumping through the action button.
05 - ??? (Used only in boss rooms)

y - Unknown. 01 in Shadow Temple rooms 0, 2, 00 in room 1

z - Sets extra idle animation OR makes the room too hot without the Goron Tunic

00 - Link tends to stand in place and glance back at the player
01 - Link's cold sneeze
02 - Link wipes his head
03 - Triggers the Heat timer! Camera seems to move in and out rapidly, and ever so slightly for the "heat" effect
04 - Link stretches and yawns?
06 - ?
07 - Bends over and gasps for breath
09 - Brandishes sword even if not equipped
0A - Re-adjusts his tunic?
 
FF - Link hops on Epona (even as a child)

Entrance List

Contains a list of start position and room pairs. Indexed based off of the entrance called by the entrance table.
pprr (repeats for each entry)
p = Which start position to use, defined by the start positions list (command 0x00) for the scene
r = Which room to load for this entrance

Mesh Header

Format:
ttcc0000 ssssssss eeeeeeee
Where:
t = type (see below)
c = number of entries
s = start of the entries
e = end of the entries

Mesh type 0

Simple mesh format; render all display lists specified. Format:
xxxxxxxx yyyyyyyy (repeats for each entry)
Where:
x = display list with opaque geometry. Set to 0 if unused.
y = display list with translucent geometry. Set to 0 if unused.

Mesh type 1

This format uses the header slightly differently. e is not the end of the entries, but the ROM address of the JFIF image within the room. Following e are 0x14 unknown bytes, perhaps bounds of some sort. At the offset given by s are the display lists, in the same format as mesh type 0.

Mesh type 2

Mesh that clips if the player is not within certain bounds. Format:
aaaabbbb ccccdddd xxxxxxxx yyyyyyyy (repeats for each entry)
Where:
a and b = X and Z maximum player coordinates to render first display list from,
c and d = X and Z minimum player coordinates to render first display list from,
x = first (close) display list. Set to 0 if unused.
y = second (far) display list. Set to 0 if unused.

Object List

Each entry is a two-byte entry of the object number, of the game's object list. Objects are required to load any actors that are not object 1 or object 2 (if the area is not a dungeon) or object 3 (if the area is a dungeon).

Unused Environment list

tt00 xxxx xxxx xxxx xxxx xxxx xxxx
Where tt = environment type:
00 - Nothing
01 - Light coming from outside of the room
02 - Punctual light source

Type 01

Format:
0100 uu00 vvcc cccc 0000 0000 0000
Where:
u = noth-south direction the light is coming from (00 = no light from noth or south, 01-7E = light from north, 7F-FF light from south)
v = east-west direction the light is coming from (00 = no light from east or west, 01-7E = light from east, 7F-FF light from west)
c = RGB color of the light

Type 02

Format:
0200 xx00 yy00 zz00 cccc cc00 rr00
Where:
x = Position on x-axis of the light source
y = Position on y-axis of the light source
z = Position on z-axis of the light source
c = RGB color of the light
r = radius of the emitted light

Path List

Actors which have a "route" to follow, such as the carpenters or the graveyard boy, do not have the route hard-coded within them. Instead, the points which they make straight lines to are mapped out in a list. That is, a point is marked at every turning point, and they follow straight lines between the turning points. The data pointed to by the scene header is a list of:
aa000000 llllllll (repeats for each path)
Where:
a is the number of points for the given path, and
l is the location of the first point of the path
The path pointer list at offset l has a entries, each consisting of:
xxxx yyyy zzzz (repeats for each point of path)
x, y, and z are the (signed) coordinates of the specific point on the path.

xdaniel figured this out while working on SayakaGL, and the information was verified by spinout by reversal of a function which reads the data. (Graveyard boy @ func_809E1E90) (SayakaGL Implementation)

Transition Actors

Scene actors change the room that is loaded.  They usually don't have their own collision, it must be part of the collision specified by the collision command in the scene header. Format:
ffmmbbnn aaaaxxxx yyyyzzzz wwwwvvvv (repeats for each transition actor)
Where:
f = Room to switch to when triggered from the front of the object (for doors, the front has the knob on the right)
m = How the camera reacts during the front transition (effects depend on actor, best to experiment; recommended are 0, 0F, and FF)
b = Room to switch to when triggered from the back of the object
n = How the camera reacts during the back transition
a = Actor Number
x = Position along x-axis
y = Position along y-axis
z = Position along z-axis
w = Y rotation
v = actor variable

Environments list

aaaaaa bbbbbb cccccc dddddd eeeeee ffffff gggg hhhh (repeats for each environment type)
Where:
a = Ambient light color (format RRGGBB, usually 0x462D39)
b = First diffuse light direction (format XXYYZZ, usually 0x494949)
c = First diffuse light color [illumination of Link from upside] (format RRGGBB, usually 0xB49A8A)
d = Second diffuse light direction (format XXYYZZ, usually 0xB7B7B7)
e = Second diffuse light color [illumination of Link from downside] (format RRGGBB, usually 0x14143C)
f = Fog color (format RRGGBB)
g & 0x3FF = Fog start
h = Draw distance

Exit List

Each entry is a two-byte exit number, from the game's entrance table (for index values, click here). The length of the list is undefined, the engine assumes all indexes within the list which it asks for exist. This being said, there is no way for collision polygon types to reference an exit number higher than 16, as it is allotted only one nybble.
Check out the collision format for more information about exits.

Cutscenes

MM Cutscene Data

Entries
xxxxxxxx yyyyuutt
xx = Offset of cutscene data
yy = Exit
uu = Entrance cutscene activates at
tt = Event flag

Cutscene Header
xxxxxxxx yyyyyyyy
xx = Number of markers
yy = Length (Frames)

Small list of cutscene markers:

0000000A Text
0000005A Camera data
00000066 Zelda
00000070 Epona
00000078 Romani
00000082 Happy mask man
00000096 Sound effects?
00000097 ???
00000098 Screen Transition
00000099 Motion blur?
0000009B ???
0000009C ???
000000C8 Link
000000C9 Tatl
0000012C Play song
0000015E End Cutscene

The formats for these markers should be the same as they are in OoT, except for the camera data.

Alternate Header List

Each entry is the offset (including bank) of the alternate headers for the current scene/room. The number of alternate headers is undefined, but there must be a minimum of three alternate header records, one for all four combination of day/night child/adult when you add in the main header.

Camera Settings

19xx0000 000000yy

xx sets restrictions on both camera movement and c-up camera usage.

00 is used in scenes which don't rely on pre-rendered environments, and have free c-up camera control.
10 is used with shop scenes, which have a fixed camera that switch between two views, and no c-up option
20 is used in scenes which have pre-rendered backgrounds that can rotate, where pressing c-up gives you a bird eye view.
30 is used in scenes which have pre-rendered backgrounds that are fixed, no c-up option.
40 is used in scenes which have a pre-rendered backgrounds that rotate, but have no c-up option. 
50 is used in the shooting gallery.

For more details on skybox camera attributes, see collision camera data.

yy sets the scene's location on the world map.

00 Hyrule Field / not applicable
01 Kakariko
02 Grave
03 Zora River
04 Kokiri Forest
05 Sacred Forest Meadow
06 Lake Hylia
07 Zora's Domain
08 Zora's Fountain
09 Gerudo Valley
0A Lost woods
0B Desert Colossus
0C Gerudo Fortress
0D Haunted Wasteland
0E Market
0F Hyrule castle
10 Death Mountain Trail
11 Death Mountain Crater
12 Goron City
13 Lon Lon Ranch
14 ? (Windmill/Dampe's Grave)
15 Ganon's Castle
16+ Undefined

Credits

spinout, jsa, cendamos, MNGoldenEagle, xdaniel, fkualol probably others