A data block carries sample data or a chip’s ROM or RAM contents inside the stream. Codes on this page are hexadecimal.
Format
67 66 tt ss ss ss ss (data)
| Field | Size | Meaning |
|---|---|---|
67 | 1 | The command. |
66 | 1 | A compatibility byte that makes older players stop parsing here. |
tt | 1 | The data type. |
ss ss ss ss | 4 | The data size in bytes. Bit 31 set means the ROM or RAM dump goes to the second chip (the 1.71 text, “Dual Chip Support #3”; libvgm takes the size as the low 31 bits for every type). |
Unknown ROM and RAM types must be skipped; data for blocks 00 to 7F must be stored by the player in any case. Data blocks of recorded streams, if present, should be at the very start of the VGM data, but because a block can occur anywhere in the stream, a player must parse data blocks anywhere. Several blocks of the same type are valid: the player consolidates them into one memory (the data bank) and keeps the start offset and length of each block for command 95.
The type list must be followed when commands 68 and 80 to 8F are used. The stream control system can use any of the 64 block types with any of the sound chips, so the types may be used arbitrarily there (VGM specification, notes under the type list).
Type codes
| Type | Meaning |
|---|---|
| 00 | YM2612 PCM data |
| 01 | RF5C68 PCM |
| 02 | RF5C164 PCM |
| 03 | PWM |
| 04 | OKIM6258 ADPCM |
| 05 | HuC6280 |
| 06 | SCSP |
| 07 | NES APU DPCM |
| 08 | Mikey PCM (1.72 text). vgmtools calls it “SN76489 PCM Database” and libvgm’s table sends bank 08 to chip 2B (K005289; its comment says MSM5205), so the sources differ here. |
| 09–3F | Uncompressed recorded-stream data of types the specification does not name; the data bank for the type holds it |
| 40–7E | Compressed versions of 00–3E (the text says “same as 00..3E, just compressed”) |
| 7F | Decompression table |
| 80 | Sega PCM ROM |
| 81 | YM2608 DELTA-T ROM |
| 82 | YM2610 ADPCM ROM |
| 83 | YM2610 DELTA-T ROM |
| 84 | YMF278B ROM |
| 85 | YMF271 ROM |
| 86 | YMZ280B ROM |
| 87 | YMF278B RAM |
| 88 | Y8950 DELTA-T ROM |
| 89 | MultiPCM ROM |
| 8A | uPD7759 ROM |
| 8B | OKIM6295 ROM |
| 8C | K054539 ROM |
| 8D | C140 ROM |
| 8E | K053260 ROM |
| 8F | Q-Sound ROM |
| 90 | ES5506 ROM |
| 91 | X1-010 ROM |
| 92 | C352 ROM |
| 93 | GA20 ROM |
| 94 | K007232 ROM (libvgm) |
| 95 | BSMT2000 ROM (libvgm) |
| 96 | ICS2115 ROM (libvgm) |
| C0 | RF5C68 RAM write |
| C1 | RF5C164 RAM write |
| C2 | NES APU RAM write |
| C3 | K005289 RAM write (libvgm) |
| E0 | SCSP RAM write |
| E1 | ES5503 RAM write |
ROM and RAM dumps
| Types | Fields, then data | Data size |
|---|---|---|
| 80–BF | rr rr rr rr total ROM size, ss ss ss ss start address | Block size − 8 |
| C0–DF | ss ss 16-bit start address | Block size − 2 |
| E0–FF | ss ss ss ss 32-bit start address | Block size − 4 |
Compressed blocks (40–7E)
The block starts with tt, the compression type, and ss ss ss ss,
the uncompressed size, used to allocate memory. Each decompressed value takes
ceil(bd ÷ 8) bytes. Attribute bytes follow, and the data size is the block
size − 0A − the attribute size.
| Compression | Attribute | Meaning |
|---|---|---|
| 00: n-bit | bd | Bits decompressed. |
| bc | Bits compressed. | |
| st | Sub-type: 00 copy (high bits unused), 01 shift left (low bits unused), 02 table lookup (the value is an index into table 7F). | |
| aa aa | Added to the result; ignored when a table is used. | |
| 01: DPCM | bd | Bits decompressed. |
| bc | Bits compressed. | |
| st | Reserved, 00. | |
| aa aa | Start value: the initial state. |
The data is a bitstream of bc bits per value: “the top bits in each byte are
read first”. For DPCM, each value indexes the delta table; the delta is added to the
state (which starts at aa aa), and the state is the output. The state wraps
at bd bits.
For a value of more than eight bits the specification does not say in which order the
bits come. libvgm’s dblk_compr.c reads such a value eight bits at a time,
each piece taking its bits from the top of the byte, and the first piece fills the
low end of the value. The explorer does the same, and its decompression was
compared with libvgm’s on 1,400 generated blocks (copy, shift left, table and DPCM, 8
and 16 bits, every bit count) with identical output. The compressed block holds a size
for the decompressed data; if the compressed bits give fewer values, the rest is left
zero and the explorer reports it.
Decompression table (7F)
| Field | Size | Meaning |
|---|---|---|
| tt | 1 | Compression type. |
| st | 1 | Sub-type. |
| bd | 1 | Bits decompressed. |
| bc | 1 | Bits compressed, used only to check against the matching block. |
| cc cc | 2 | Number of values. |
| data | Block size − 6 | cc values of ceil(bd ÷ 8) bytes. |
Keep one table per combination of type and sub-type. A new table of the same type replaces the old one for later blocks.
PCM RAM write (68)
68 66 cc oo oo oo dd dd dd ss ss ss
| Field | Size | Meaning |
|---|---|---|
| cc | 1 | Chip type, matching data block types 00–3F. (libvgm takes bit 7 as the second chip.) |
| oo oo oo | 3 | Read offset in the data block. |
| dd dd dd | 3 | Write offset in the chip’s RAM, affected by chip banking. |
| ss ss ss | 3 | Size in bytes. 0 means 01000000. |
Unknown types must be skipped.
Not described
Known, not yet covered
- Viewer: the PCM in data blocks is shown as bytes and opens as a file (compressed blocks decompressed), but only the YM2612 bank (type
00, read by commands80to8F) is played; the chips that would play the others have no emulation in the viewer. - Reference: types
94to96andC3come from libvgm; no specification text names them.
Unknown
- Reference: type
08: three open sources disagree. The wiki says Mikey PCM, vgmtools’vgm2txtprints “SN76489 PCM Database”, libvgm’s table sends it to chip2B(K005289; its comment says MSM5205). VGMPlay does not define it.