VGFM Instrument Format
From ModdingWiki
The Vinyl Goddess From Mars Instrument Format is used to store the FM instruments used when playing the game's background music.
File format
The file begins with a header:
| Data type | Name | Description |
|---|---|---|
| UINT16LE | iVersion | File version? (always 0x0001) |
| UINT16LE | iNumInstruments | Number of instruments in the file |
| UINT16LE | iOffset | Offset where instrument data begins |
This is followed by a list of instrument names, repeated iNumInstruments times:
| Data type | Name | Description |
|---|---|---|
| BYTE[9] | cName | Instrument name - must be NULL-terminated |
At this point, the current position should be the same as iOffset. The actual instrument data follows, again repeated once for each instrument. The instrument data is in the following format, which is remarkably similar to the Adlib BNK format (only Vinyl uses two-byte words to store each field instead of a single byte as in the BNK format.)
| Data type | Name | Description |
|---|---|---|
| OPLREGS | oplModulator | Register values for the Modulator operator |
| OPLREGS | oplCarrier | Register values for the Carrier operator |
| UINT16LE | iModWaveSel | Modulator wave select (only bits 0-1 recognised, OPL register 0xE0) |
| UINT16LE | iCarWaveSel | Carrier wave select (only bits 0-1 recognised, OPL register 0xE0) |
The OPLREGS structure is defined as:
| Data type | Name | Description | OPL base register | Value range |
|---|---|---|---|---|
| UINT16LE | iKSL | Key scaling level | 0x40 (bits 6-7) | |
| UINT16LE | iMultiple | Frequency multiplier | 0x20 (bits 0-3) | iMultiple & 0x0F is sent to OPL register [verify this] |
| UINT16LE | iFeedback | Feedback | 0xC0 (bits 1-3) | Although only bits 1-3 are valid, Vinyl doesn't limit the output to three bits wide. |
| UINT16LE | iAttack | Attack rate | 0x80 (upper four bits) | [verify this] |
| UINT16LE | iSustain | Sustain level | 0x80 (upper four bits) | [verify this] |
| UINT16LE | iEG | Envelope gain (nonzero value is on) | 0x20 (bit 5) | [verify this] |
| UINT16LE | iDecay | Decay rate | 0x60 (lower four bits) | [verify this] |
| UINT16LE | iReleaseRate | Release rate | 0x80 (lower four bits) | [verify this] |
| UINT16LE | iTotalLevel | Total output level | 0x40 (bit 0-5) | [verify this] |
| UINT16LE | iAM | Amplitude modulation (Tremolo) | 0x20 (bit 7) | [verify this] |
| UINT16LE | iVIB | Frequency Vibrato | 0x20 (bit 6) | [verify this] |
| UINT16LE | iKSR | Key scaling/envelope rate | 0x20 (bit 4) | [verify this] |
| UINT16LE | iCONoff | Connector [OP0 only] | 0xC0 (bit 0, inverted) | 0: OPL bit set to 1 other: OPL bit set to 0 |
Credits
This file format was reverse engineered by Malvineous. If you find this information helpful in a project you're working on, please give credit where credit is due. (A link back to this wiki would be nice too!)
