Difference between revisions of "Chunk"
(Created page with "Chunks are the highest level data containers in NSF files. Each chunk is 64kb (0x10000 bytes) in size, in congruence with the 64kb pages allocated to contain them. == Format ...") |
(→Chunk IDs/CIDs) |
||
Line 154: | Line 154: | ||
== Chunk IDs/CIDs == | == Chunk IDs/CIDs == | ||
− | Each chunk | + | Each chunk has a unique ID. A chunk ID has been assigned to each chunk according to its index in the NSF file. The formula for a chunk ID, or CID, is: '(index << 1) - 1', where chunk indices start at 1. This is equivalent to '(index << 1) | 1' when chunks are zero-indexed. Thus, a chunk's index is contained in the leftmost 31 bits of its CID. The rightmost bit or LSB in a CID is an indicator bit or tag, and is always 1. A CID is typically stored in a tagged union with its replacement entry pointer as the key in an entry hash table slot. Its replacement pointer locates an entry contained in the chunk with that CID. |
+ | |||
+ | Texture chunks do not have a CID field with precomputed value. The texture paging routines manually compute CIDs for texture chunks. |
Revision as of 23:14, 25 July 2015
Chunks are the highest level data containers in NSF files. Each chunk is 64kb (0x10000 bytes) in size, in congruence with the 64kb pages allocated to contain them.
Contents
Format
Uncompressed chunks
Non-texture chunks
Offset | Field | Size | Value |
---|---|---|---|
0x0 | Magic Number | 2 bytes | 0x1234 |
0x2 | Type | 2 bytes | !=1 |
0x4 | ID | 4 bytes | * |
0x8 | Entry Count | 4 bytes | c |
0xC | Checksum | 4 bytes | * |
0x10 | Entry Offsets | 4 x c bytes | * |
0x10 + (4 x c) | Entries | * x c bytes | * |
Texture chunks
Offset | Field | Size | Value |
---|---|---|---|
0x0 | Magic Number | 2 bytes | 0x1234 |
0x2 | Type | 2 bytes | 1 |
0x4 | Texture Page EID | 4 bytes | * |
0x8 | Tex. Page Entry Type | 4 bytes | 5 |
0xC | Checksum | 4 bytes | * |
0x10 | Texture data | 0xFFF0/65520 bytes | * |
Compressed chunks
Offset | Field | Size | Value |
---|---|---|---|
0x0 | Magic Number | 2 bytes | 0x1235 |
0x2 | Unused | 2 bytes | * |
0x4 | Length | 4 bytes | l |
0x8 | Skip | 4 bytes | s |
0xC | Compressed data | n bytes | * |
0xC+n | Skipped data | s bytes | * |
0xC+n+s | Uncompressed data | (0x10000 - l) bytes | * |
Types
Type | Name |
---|---|
0 | Normal Chunk |
1 | Texture Chunk |
2 | Prototype Sound Chunk |
3 | Sound Chunk |
4 | Wavebank Chunk |
5 | Speech Chunk |
Chunk IDs/CIDs
Each chunk has a unique ID. A chunk ID has been assigned to each chunk according to its index in the NSF file. The formula for a chunk ID, or CID, is: '(index << 1) - 1', where chunk indices start at 1. This is equivalent to '(index << 1) | 1' when chunks are zero-indexed. Thus, a chunk's index is contained in the leftmost 31 bits of its CID. The rightmost bit or LSB in a CID is an indicator bit or tag, and is always 1. A CID is typically stored in a tagged union with its replacement entry pointer as the key in an entry hash table slot. Its replacement pointer locates an entry contained in the chunk with that CID.
Texture chunks do not have a CID field with precomputed value. The texture paging routines manually compute CIDs for texture chunks.