Open main menu

Difference between revisions of "SCUMM/Technical Reference/Room resources"

m
Small text tweaks
(Typos)
m (Small text tweaks)
 
Line 14: Line 14:
<tr><td>0x06</td><td>UInt16LE</td><td>Room height in tiles (always <code>0x10</code> on NES)</td></tr>
<tr><td>0x06</td><td>UInt16LE</td><td>Room height in tiles (always <code>0x10</code> on NES)</td></tr>
<tr><td>0x08</td><td>???</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x08</td><td>???</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x0a</td><td>UInt16LE</td><td>Offset to 1 byte for the tileset index, followed by 16 bytes of palette data, and then the RLE encoded nametable data (NES)</td></tr>
<tr><td>0x0a</td><td>UInt16LE</td><td>Offset to 1 byte for the tileset index, followed by 16 bytes of palette data, and then the [https://www.nesdev.org/wiki/Tile_compression RLE encoded] nametable data (NES)</td></tr>
<tr><td>0x0c</td><td>UInt16LE</td><td>Offset to the RLE encoded attribute table (NES)</td></tr>
<tr><td>0x0c</td><td>UInt16LE</td><td>Offset to the RLE encoded attribute table (NES)</td></tr>
<tr><td>0x0e</td><td>UInt16LE</td><td>Offset to the mask flag location, which if 1 is followed by the RLE encoded mask data</td></tr>
<tr><td>0x0e</td><td>UInt16LE</td><td>Offset to the mask flag location. A value of <code>0x01</code> is followed by the RLE encoded mask data, otherwise <code>0x01</code>.</td></tr>
<tr><td>0x10</td><td>???</td><td>Unknown (On NES both these values are equal)</td></tr>
<tr><td>0x10</td><td>???</td><td>Unknown (On NES both these values are equal)</td></tr>
<tr><td>0x12</td><td>???</td><td>Unknown</td></tr>
<tr><td>0x12</td><td>???</td><td>Unknown</td></tr>
Line 31: Line 31:
'''Note:''' Because of the following constraints:
'''Note:''' Because of the following constraints:


* Offset to box number location is stored as an UInt8, thus must be within the first 255 bytes of the chunk
* Offset to box number location is stored as an <code>UInt8</code>, thus must be within the first 255 bytes of the chunk
* The header takes 28 bytes
* The header takes 28 bytes
* The combined size of object image and object code offsets is 4 bytes per object
* The combined size of object image and object code offsets is 4 bytes per object
Line 76: Line 76:
</table>
</table>


'''Note:''' Some LFL files have unknown data between the last object code offset and the boxes number offset location. For most files however, both data are contiguous.
'''Note:''' Some <code>LFL</code> files have unknown data between the last object code offset and the boxes number offset location. For most files however, the data is contiguous.


=== Boxes ===
=== Boxes ===
Line 113: Line 113:
Immediately following the last box's data is the box matrix which determines how the boxes are connected.
Immediately following the last box's data is the box matrix which determines how the boxes are connected.


There are a minimum of <code>boxNum * boxNum</code> entries read as UInt8. Each entry has at least 2 pairs of 3 byte sets which determine connecting boxes. The table allows more values to be used in each entry if necessary. Example pseudo code:
There are a minimum of <code>boxNum * boxNum</code> entries read as <code>UInt8</code>. Each entry consists of at least two pairs of three bytes which determine how the boxes connect. The table allows more values to be used in each entry if necessary. Example pseudo code:


<pre>boxMatrix = [
<pre>boxMatrix = [
Line 126: Line 126:
function nextBox (from, to)
function nextBox (from, to)
{
{
   var boxm = boxMatrix[from];
   var box = boxMatrix[from];
   if (boxm[0] <= to && to <= boxm[1])
   if (box[0] <= to && to <= box[1])
     return boxm[2];
     return box[2];
   if (boxm[3] <= to && to <= boxm[4])
   if (box[3] <= to && to <= box[4])
     return boxm[5];
     return box[5];
   return -1;
   return -1;
}</pre>
}</pre>
Line 136: Line 136:
=== Tileset index ===
=== Tileset index ===


The two bytes at <code>0x0a</code> of the room data point to the tileset index which is used to look up the tileset in a separate table. The tileset table provides the bank and memory offset for the given tileset.
The two bytes of room data at <code>0x0a</code> point to the tileset index which is used to look up the tileset details in a separate table. The tileset table provides the bank and memory offset for the given tileset.


=== Palettes ===
=== Palettes ===
Line 148: Line 148:
=== Attribute table data ===
=== Attribute table data ===


The two bytes at <code>0x0c</code> of the room data point to the RLE encoded attribute table (NES). The amount of data is decoded according to the rom height and width.
The two bytes at <code>0x0c</code> of the room data point to the RLE encoded attribute table (NES). The amount of data is decoded according to the room height and width.


=== Mask Flag ===
=== Mask Flag ===
Line 156: Line 156:
=== Mask data ===
=== Mask data ===


If the mask flag is <code>0x01</code> then the RLE encoded mask data follows. This is bitmap data where each bit corresponds to a single tile, so a single byte covers a row of 8 tiles. A bit value of 1 = masked (background priority), and 0 = unmasked (sprite priority). The bits in each byte are reversed (or read right to left) before they are applied.
If the mask flag is <code>0x01</code> then the RLE encoded mask data is next. This is bitmap data where each bit corresponds to a single tile, so a single byte covers a row of 8 tiles. A bit value of 1 = masked (background priority), and 0 = unmasked (sprite priority). The bits in each byte are reversed (or read right to left) before they are applied.


=== Object image data ===
=== Object image data ===


Next starts the data that is pointed to by the object image offsets beginning at byte 0x1c in the room data. This is RLE encoded nametable and attribute table data for each. The amount of data for each object is based on the height and width of the object. The data is RLE encoded per row. These graphical updates are triggered in SCUMM by `setState08` and `clearState08`.
Next starts the data that is pointed to by the object image offsets beginning at byte <code>0x1c</code> in the room data. This is RLE encoded nametable and attribute table data for each object. The amount of data for each object is based on the height and width of the object. The data is RLE encoded per row. These graphical updates are triggered in SCUMM by <code>setState08</code> and <code>clearState08</code>.


=== Object code ===
=== Object code ===


The object code section has the following structure starting from its corresponding object code offset:
The object code section has the following structure starting at its corresponding object code offset:


==== Object code header ====
==== Object code header ====
Line 172: Line 172:
<tr><td>0x02</td><td>???</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x02</td><td>???</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x03</td><td>???</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x03</td><td>???</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x04</td><td>UInt16LE</td><td>The object number (used to reference object in scripts). The object number must be 255 (0xFF) or less to be able to be picked up.</td></tr>
<tr><td>0x04</td><td>UInt16LE</td><td>The object number (used to reference object in scripts). Because of the way the data is stored in-game, the object number must be 255 (<code>0xFF</code>) or less in order to be picked up.</td></tr>
<tr><td>0x06</td><td>??</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x06</td><td>??</td><td>Unknown (Always 0 on NES)</td></tr>
<tr><td>0x07</td><td>UInt8</td><td>X position of object</td></tr>
<tr><td>0x07</td><td>UInt8</td><td>X position of object</td></tr>
<tr><td>0x08</td><td>UInt8</td><td>Object parent state + Y position of object (<code>0xSSSYYYYY</code>). Parent state is always <code>0x04</code> if present and is used in combination with the Object parent value at <code>0x0a</code> to hide objects behind doors (think the refrigerator).</td></tr>
<tr><td>0x08</td><td>UInt8</td><td>Object parent state + Y position of object (<code>0xSSSYYYYY</code>). Parent state is always <code>0x04</code> if present and is used in combination with the Object parent value at <code>0x0a</code> to hide objects behind doors (e.g. items in the refrigerator).</td></tr>
<tr><td>0x09</td><td>UInt8</td><td>Object width in tiles</td></tr>
<tr><td>0x09</td><td>UInt8</td><td>Object width in tiles</td></tr>
<tr><td>0x0a</td><td>UInt8</td><td>Object parent</td></tr>
<tr><td>0x0a</td><td>UInt8</td><td>Object parent</td></tr>
<tr><td>0x0b</td><td>UInt8</td><td>Walk to X position</td></tr>
<tr><td>0x0b</td><td>UInt8</td><td>Walk to X position</td></tr>
<tr><td>0x0c</td><td>UInt8</td><td>Preposition + Walk to Y position (<code>0xPPPYYYYY</code>). Possible preposition values are: <code>0x001</code> = in, <code>0x010</code> = with, <code>0x011</code> = on.</td></tr>
<tr><td>0x0c</td><td>UInt8</td><td>Preposition + Walk to Y position (<code>0xPPPYYYYY</code>). Possible preposition values are: <code>0x001</code> = in, <code>0x010</code> = with, and <code>0x011</code> = on.</td></tr>
<tr><td>0x0d</td><td>UInt8</td><td>Object height in tiles + Actor facing direction (<code>0xHHHHHDDD</code>). Possible facing values are: <code>0x100</code> = left, <code>0x101</code> = right, <code>0x110</code> = front (facing player), <code>0x111</code> = back (facing away from player).</td></tr>
<tr><td>0x0d</td><td>UInt8</td><td>Object height in tiles + Actor facing direction (<code>0xHHHHHDDD</code>). Possible facing values are: <code>0x100</code> = left, <code>0x101</code> = right, <code>0x110</code> = front (facing the player), and <code>0x111</code> = back (facing away from the player).</td></tr>
<tr><td>0x0e</td><td>UInt8</td><td>Offset to object name</td></tr>
<tr><td>0x0e</td><td>UInt8</td><td>Offset to object name</td></tr>
</table>
</table>


'''Note:''' The object code data starts at byte 15. The verb-script pairs terminate with a null byte (0x00). This means that the object name offset value is always an even number 16 or above.
'''Note:''' The object code data starts at byte 15. The verb-script pairs terminate with a null byte (<code>0x00</code>). This means that the object name offset value is always an even number, 16 or above.


==== Object code content ====
==== Object code content ====
Line 195: Line 195:
===== Object script offsets =====
===== Object script offsets =====


Starting at byte 15, two UInt8 values are read at a time.
Starting at byte 15, two <code>UInt8</code> values are read at a time.


The first value is a the verb ID and the second value is an offset to the beginning of the object script. Multiple verbs can have the same offset. The verb IDs are as follows:
The first value is a the verb ID and the second value is an offset to the beginning of the object script. Multiple verbs can have the same offset. The verb IDs are as follows:
3

edits