From the data offset, a VGM file is one command after another, each a command byte with
operands. The stream ends at command 66. An unknown command stops processing;
a reserved command must be skipped by its operand count. Timing
comes from the wait commands, in samples at 44,100 per second. All codes on this page
are hexadecimal. The commands are those of the specification on the vgmrips wiki (revision
5875, 1.72 beta) and of the 1.71 text; the commands the wiki does not list yet but libvgm
reads (32, 41 to 44 and C9) are marked
“libvgm”. The viewer shows the chip, the instance, the port, the register and the value
of every one of them; what a register means is the chip’s own documentation, which the
specification does not repeat. The register writes of the SN76489, YM2413, YM2612, YM2151,
YM2203, YM2608, YM2610, YM3812, YM3526, Y8950, YMF262, AY8910, Game Boy and NES APU (and its
FDS add-on) are decoded into what they set (“Ch 0 Slot 1 Total Level: 0x7F = 0%”), in the words
of vgmtools, whose text the viewer’s was compared with for every register of each chip.
Two chips of one type
Dual chip support is switched on by bit 30 of the chip’s clock in the header. The second chip is reached in one of two ways (VGM specification, “Dual Chip Support”):
- Separate commands. The second SN76489 uses
30(3Ffor the Game Gear stereo write). For the chips that use5n, the second chip usesAn, n being the last digit of the main command:52becomesA2. - Bit 7 of the first operand byte for all other chips: 00 to 7F is the first chip, 80 to FF the second. The Sega PCM keeps the bit in the high byte of its address, which is its second operand byte (bit 15 of the 16-bit address).
For data blocks and PCM RAM writes the equivalent is bit 31 of the block size (ROM and RAM dumps) and bit 7 of the chip type of a PCM RAM write. The viewer applies these rules and writes “#2” after the chip name for the second chip.
Chip writes
Each writes to a chip register. aa is the register, dd the value.
| Command | Operands | Chip |
|---|---|---|
| 30 | dd | Second SN76489 |
| 3F | dd | Second Game Gear PSG stereo |
| 31 | dd | AY8910 stereo mask (also for the YM2203’s SSG part) |
| 32 | dd | MSM5205 (libvgm): bits 4–6 are the register, bits 0–3 the data, bit 7 the second chip |
| 40 | aa dd | Mikey (1.72 beta), the Atari Lynx sound chip |
| 41 | aa dd | K007232 (libvgm); register 1F performs a chip read, the value being the offset |
| 42 | ad dd | K005289 (libvgm): register a, value ddd, like the PWM |
| 43 | aa dd | MSM5232 (libvgm) |
| 44 | aa dd | ICS2115 (libvgm) |
| 4F | dd | Game Gear PSG stereo, port 06 |
| 50 | dd | SN76489/SN76496 |
| 51 | aa dd | YM2413 |
| 52, 53 | aa dd | YM2612 port 0, port 1 |
| 54 | aa dd | YM2151 |
| 55 | aa dd | YM2203 |
| 56, 57 | aa dd | YM2608 port 0, port 1 |
| 58, 59 | aa dd | YM2610 port 0, port 1 |
| 5A | aa dd | YM3812 |
| 5B | aa dd | YM3526 |
| 5C | aa dd | Y8950 |
| 5D | aa dd | YMZ280B |
| 5E, 5F | aa dd | YMF262 port 0, port 1 |
| A0 | aa dd | AY8910 |
| A1 | aa dd | YM2413, second chip |
| A2, A3 | aa dd | YM2612 port 0, port 1, second chip |
| A4 | aa dd | YM2151, second chip |
| A5 | aa dd | YM2203, second chip |
| A6, A7 | aa dd | YM2608 port 0, port 1, second chip |
| A8, A9 | aa dd | YM2610 port 0, port 1, second chip |
| AA | aa dd | YM3812, second chip |
| AB | aa dd | YM3526, second chip |
| AC | aa dd | Y8950, second chip |
| AD | aa dd | YMZ280B, second chip |
| AE, AF | aa dd | YMF262 port 0, port 1, second chip |
| B0 | aa dd | RF5C68 |
| B1 | aa dd | RF5C164 |
| B2 | ad dd | PWM: register a, value ddd (d is the top nibble) |
| B3 | aa dd | GameBoy DMG: register 00 is address FF10 |
| B4 | aa dd | NES APU: 00–1F map to 4000–401F, 20–3E to 4080–409E, 3F to 4023, 40–7F to 4040–407F |
| B5 | aa dd | MultiPCM |
| B6 | aa dd | uPD7759 |
| B7 | aa dd | OKIM6258 |
| B8 | aa dd | OKIM6295 |
| B9 | aa dd | HuC6280 |
| BA | aa dd | K053260 |
| BB | aa dd | Pokey |
| BC | aa dd | WonderSwan |
| BD | aa dd | SAA1099 |
| BE | aa dd | ES5506, 8-bit value |
| BF | aa dd | GA20 |
| D0 | pp aa dd | YMF278B, port pp |
| D1 | pp aa dd | YMF271, port pp |
| D2 | pp aa dd | SCC1, port pp |
| D3 | pp aa dd | K054539, register ppaa |
| D4 | pp aa dd | C140, register ppaa |
| D5 | pp aa dd | ES5503, register ppaa |
| D6 | aa dd ee | ES5506, 16-bit value ddee to register aa |
| E1 | aa bb dd ee | C352, 16-bit value ddee to register aabb |
The AY8910 stereo mask is command 31. A second chip that has no command of its own is addressed through bit 7 of the first operand. For Sega PCM, that bit is in the high byte of the memory address.
Memory writes
| Command | Operands | Meaning |
|---|---|---|
| C0 | bb aa dd | Sega PCM: write dd to memory offset aabb |
| C1 | bb aa dd | RF5C68: memory offset aabb |
| C2 | bb aa dd | RF5C164: memory offset aabb |
| C3 | cc bb aa | MultiPCM: set bank offset aabb for channel cc |
| C4 | mm ll rr | QSound: write value mmll to register rr |
| C5 | mm ll dd | SCSP: memory offset mmll |
| C6 | mm ll dd | WonderSwan: memory offset mmll |
| C7 | mm ll dd | VSU: register mmll |
| C8 | mm ll dd | X1-010: memory offset mmll |
| C9 | aa dd ee | BSMT2000 (libvgm): the 16-bit value ddee to register aa; register 7F is a special register (dd selects it, ee is the data) |
Waits and flow
| Command | Operands | Meaning |
|---|---|---|
| 00 | No operation. The 1.71 text: no file should contain it, and players should skip it (the wiki text of 1.72 does not list it). | |
| 61 | nn nn | Wait n samples, 0 to 65,535 (about 1.49 seconds); longer pauses are several wait commands. |
| 62 | Wait 735 samples: one 60 Hz frame. | |
| 63 | Wait 882 samples: one 50 Hz frame. | |
| 66 | End of the sound data. | |
| 67 | … | Data block. |
| 68 | … | PCM RAM write. |
| 70–7F | Wait n + 1 samples, n being the low nibble (0 to 15). | |
| 80–8F | YM2612 port 0 address 2A write from the data bank, then wait n samples (the low nibble, 0 to 15). First chip only. | |
| 90–95 | … | DAC stream control. |
| E0 | dd dd dd dd | Seek to offset dddddddd in the PCM data bank. |
AY8910 stereo mask (command 31)
Added in 1.71. One operand dd, which the 1.72 text writes as the bits
i y r3 l3 r2 l2 r1 l1 (bit 7 down to bit 0): i is the chip
instance, y selects the YM2203 SSG (1) or the AY8910 (0), and l and
r enable a channel on the left and right speaker. The 1.71 text gives the same
bits as two-bit channel fields:
| Bits | Meaning |
|---|---|
| 0–1 | Channel A: 00 off, 01 left, 10 right, 11 centre. |
| 2–3 | Channel B, the same. |
| 4–5 | Channel C, the same. |
| 6 | Chip type: 0 AY8910, 1 YM2203 SSG. |
| 7 | Chip number: 0 or 1. |
Reserved commands
| Commands | Operands to skip |
|---|---|
| 33–3E | 1 (the 1.72 text reserves 30 to 3F with one operand; 30, 31, 32 and 3F are used) |
| 45–4E | 2 (41 to 44 are used in libvgm; 1 operand until version 1.60) |
| CA–CF | 3 (C9 is used in libvgm) |
| D7–DF | 3 |
| E2–FF | 4 |
On meeting these, a player skips the right number of bytes. 01 to
2F, 60, 64, 65, 69 to
6F and 96 to 9F are undefined: the 1.71 text says
that when a player meets an undefined command it should stop processing the file at
once. Players differ here (VGMPlay skips 01 to 2F as one byte,
libvgm stops), and the explorer follows the specification: it stops, reports the byte,
and shows what is left of the data as unread bytes.
Not described
Known, not yet covered
- Reference and viewer: the meaning of each chip register for the GA20 and for the writes that vgmtools’
chiptext.cgives no text (the overview lists them). This page gives the operands of every command; the viewer words the register writes of every other chip as vgmtools does, and shows chip, instance, port, register and value for the writes without text. - Reference: the commands
32,41to44andC9are described from libvgm’s source, as the wiki text does not list them.
Sources that disagree: the 16-bit value of D6 is written “aadd” in the wiki; vgmtools and VGMPlay combine the bytes high byte first, libvgm’s player reads the value low byte first. Two of three players and the wiki agree, and the viewer shows it high byte first.