Difference between revisions of "SCUMM/Technical Reference/Room resources"
Line 33: | Line 33: | ||
* 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 UInt8, 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 | * The combined size of object image and object code offsets is 4 bytes per object | ||
The total number of objects per room must be less than 57: | The total number of objects per room must be less than 57: | ||
Line 49: | Line 49: | ||
</table> | </table> | ||
=== Object | === Object code offsets === | ||
From there, there is the list of offsets to each object | From there, there is the list of offsets to each object code: | ||
<table border="2" cellspacing="0" cellpadding="4"> | <table border="2" cellspacing="0" cellpadding="4"> | ||
<tr><th>Location</th><th>Format</th><th>Data</th></tr> | <tr><th>Location</th><th>Format</th><th>Data</th></tr> | ||
Line 68: | Line 68: | ||
</table> | </table> | ||
'''Note:''' Some LFL files have unknown data between the last object | '''Note:''' Some LFL files have unknown data between the last object code offset and the boxes number offset location. For most file however, both data are contiguous. | ||
=== Boxes === | === Boxes === | ||
Line 92: | Line 92: | ||
There are <code>boxNum * boxNum</code> number of them read as UInt8. | There are <code>boxNum * boxNum</code> number of them read as UInt8. | ||
=== Object | === Object code === | ||
The object code section has the following structure starting from its corresponding object code offset: | |||
==== Object | ==== Object code header ==== | ||
<table border="2" cellspacing="0" cellpadding="4"> | <table border="2" cellspacing="0" cellpadding="4"> | ||
<tr><th>Relative location</th><th>Format</th><th>Data</th></tr> | <tr><th>Relative location</th><th>Format</th><th>Data</th></tr> | ||
<tr><td>0x00</td><td>UInt8</td><td>Size of the object | <tr><td>0x00</td><td>UInt8</td><td>Size of the object code chunk</td></tr> | ||
<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> | ||
Line 114: | Line 114: | ||
</table> | </table> | ||
'''Note:''' The object | '''Note:''' The object code data starts at byte 15, the verb-script pairs part ends with a 0x00 byte. This means that the object name offset value is always an even number between 16 and 254. | ||
==== Object | ==== Object code data ==== | ||
Object | Object code data contains 3 sections optional, in this order: | ||
* 0 or more pairs of verb ids and object script offsets | * 0 or more pairs of verb ids and object script offsets | ||
* The name of the object | * The name of the object |
Revision as of 14:53, 18 November 2021
SCUMM V1
A room resource is located as the first chunk in a LFL File.
Header
The room resource starts with a 28 bytes header containing the following information:
Location | Format | Data |
---|---|---|
0x00 | UInt16LE | Size of the room resource chunk |
0x02 | ??? | Unknown |
0x04 | UInt16LE | Room width in tiles |
0x06 | UInt16LE | Room height in tiles |
0x08 | ??? | Unknown (Always 0 on NES) |
0x0a | UInt16LE | Offset to gfx nametable location (NES) |
0x0c | UInt16LE | Offset to gfx attrtable location (NES) |
0x0e | UInt16LE | Offset to mask flag value location |
0x10 | ??? | Unknown (On NES both these values are equal) |
0x12 | ??? | Unknown |
0x14 | UInt8 | Number of objects in room |
0x15 | UInt8 | Offset to number of boxes location |
0x16 | UInt8 | Number of sounds in room (Always 0 on NES) |
0x17 | UInt8 | Number of scripts in room |
0x18 | UInt16LE | Offset to exit script location |
0x1a | UInt16LE | Offset to entry script location |
All offsets are relative to the start of the chunk.
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
- The header takes 28 bytes
- The combined size of object image and object code offsets is 4 bytes per object
The total number of objects per room must be less than 57:
(256 - 28) / 4 = 57
Data
Object image offsets
From byte 0x1c starts the offsets to object images:
Location | Format | Data |
---|---|---|
0x1c | UInt16LE | Offset to object 1 image location |
0x1e | UInt16LE | Offset to object 2 image location |
... | UInt16LE | Repeated objNum times |
Object code offsets
From there, there is the list of offsets to each object code:
Location | Format | Data |
---|---|---|
0x1c + objNum * 2 | UInt16LE | Offset to object 1 content location |
0x1e + objNum * 2 | UInt16LE | Offset to object 2 content location |
... | UInt16LE | Repeated objNum times |
Number of boxes
The boxes number in the room is located at the boxes number offset specified in the header.
Location | Format | Data |
---|---|---|
Offset to number of boxes | UInt8 | Number of boxes in room |
Note: Some LFL files have unknown data between the last object code offset and the boxes number offset location. For most file however, both data are contiguous.
Boxes
2 bytes after the offset to number of boxes starts the payload for the boxes. Each box takes 8 bytes described as follow:
Relative location | Format | Data |
---|---|---|
0x00 | UInt8 | uy |
0x01 | UInt8 | ly |
0x02 | UInt8 | ulx |
0x03 | UInt8 | urx |
0x04 | UInt8 | llx |
0x05 | UInt8 | lrx |
0x06 | UInt8 | mask |
0x07 | UInt8 | flags |
Box matrix
Immediately following the last box payload is the box matrix.
There are boxNum * boxNum
number of them read as UInt8.
Object code
The object code section has the following structure starting from its corresponding object code offset:
Object code header
Relative location | Format | Data |
---|---|---|
0x00 | UInt8 | Size of the object code chunk |
0x02 | ??? | Unknown (Always 0 on NES) |
0x03 | ??? | Unknown (Always 0 on NES) |
0x04 | UInt16LE | The object number (used to reference object in scripts) |
0x06 | ?? | Unknown (Always 0 on NES) |
0x07 | UInt8 | X position of object |
0x08 | UInt8 | Y position of object + Object parent state |
0x09 | UInt8 | Object width in tiles |
0x0a | UInt8 | Object parent |
0x0b | UInt8 | Walk to X position |
0x0c | UInt8 | Walk to Y position |
0x0d | UInt8 | Actor facing direction + Object height in tiles |
0x0e | UInt8 | Offset to object name |
Note: The object code data starts at byte 15, the verb-script pairs part ends with a 0x00 byte. This means that the object name offset value is always an even number between 16 and 254.
Object code data
Object code data contains 3 sections optional, in this order:
- 0 or more pairs of verb ids and object script offsets
- The name of the object
- 0 or more object scripts
Object script offsets
From byte 15, 2 UInt8 are read 2 by 2.
The first one is a reference to the verb ID and the second is an offset to the beginning of the object script.
This part ends with a 0x00.
Object name
The object name starts at specified offset. Each character is read until a 0x00 value is found.
Object script
Each object script ends with 0x00 (Opcode for stopObjectCode()
).