DRO Format

From ModdingWiki

Jump to: navigation, search
Edge of map!

The DOSBox Raw OPL (DRO) format is used for storing captured OPL data from a game running in the cross-platform DOS emulator DOSBox.

Contents

File format

The file begins with a header:

Data typeNameDescription
BYTE[8]cSignature"DBRAWOPL" (not NULL-terminated)
UINT16LEiVersionMajorVersion number (high)
UINT16LEiVersionMinorVersion number (low)

The rest of the header depends on the version. If iVersionMajor is 5 and iVersionMinor is 6, then the version would be called "5.6" here.

Version 0.1

The first version of the DRO Format was used up to and including DOSBox version 0.72.

Header

The version 0.1 header follows on directly from the main file header.

Data typeNameDescription
UINT32LEiLengthMSLength of the song in milliseconds
UINT32LEiLengthBytesLength of the song data in bytes
UINT32LEiHardwareTypeFlag listing the hardware used in the song

iHardwareType is one of the following values:

iHardwareTypeDescription
0OPL2
1OPL3
2Dual OPL2

Song data

Directly following the header is iLengthBytes bytes of OPL data. The first byte in the song data will be the OPL register, followed by the byte to send to that register. The "register" can also be one of these control values:

Register valueData sizePurpose
0x001Delay. The single data byte following should be incremented by one, and is then the delay in milliseconds.
0x012Delay. Same as above only a UINT16LE integer.
0x020Switch to "low" OPL chip (#0)
0x030Switch to "high" OPL chip (#1)
0x042Escape - the next two bytes are normal register/value pairs even though the register might be 0x00-0x04
Other1Anything else should be treated as an OPL register, with the byte following being the data to send to that register.

The delays all need to be incremented by one, as having a delay of zero milliseconds would be a waste of space. Codes 0x02 and 0x03 switch between two OPL chips, and should only be used if the hardware flag in the header indicates the file is in dual-OPL format.

All delays are in milliseconds (which can be treated as 1000Hz if converting between other formats.)

Version 2.0

Version 2.0 of the DRO Format is currently (2009-04-10) only used by the CVS development version of DOSBox.

Header

The version 2.0 header also follows on directly from the main file header.

Data typeNameDescription
UINT32iLengthPairsLength of the song in register/value pairs (TODO: confirm - 1 == one register + one value, or two bytes)
UINT32iLengthMSLength of the song data ("chunk" -?) in milliseconds
UINT8iHardwareTypeFlag listing the hardware used in the song
UINT8iFormatData arrangement
UINT8iCompressionCompression type, zero means no compression (currently only zero is used)
UINT8iShortDelayCodeCommand code for short delay (1-256ms)
UINT8iLongDelayCodeCommand code for short delay (> 256ms)
UINT8iCodemapLengthNumber of entries in codemap table
UINT8[iCodemapLength]iCodemapCodemap table (see below)
  • UINT32 values appear to be host-endian, i.e. they could be either big or little endian, depending on the platform where the capture was taken. This is to be confirmed. If true, a possible method for endian detection would be to use the version number - 0x0002 would mean no endian change, 0x0200 would mean an endian change is required.

iHardwareType is one of the following values: (which are different in v1.0 and v2.0)

iHardwareTypeDescription
0OPL2
1Dual OPL2
2OPL3

iFormat is one of the following values:

iFormatDescription
0Commands and data are interleaved (default/as per v1.0)
1Maybe all commands, followed by all data (unused? - TODO: Confirm)

Notes:

  • iLengthMS is at a different offset in v1.0 and v2.0
  • The iShortDelayCode value must have one added to it, as per v1.0 (so a short delay of 2 == a 3ms delay)
  • The iLongDelayCode value must have one added to it, then be multiplied by 256 (or "<< 8"), so a long delay of 2 == a 768ms delay

Codemap table

The codemap table maps index numbers to OPL registers. As there are 256 possible OPL registers but only a subset of these actually used, the mapping table allows up to 128 OPL registers to be used in a song. The other 128 (with the high bit set) are used for the second OPL2 chip in a dual-OPL2 capture.

The table is a list of iCodemapLength bytes, with the index used later in the file. For example this code table:

01 04 05 08 BD

Means that when the song references register #0 the data should be sent to OPL register 0x01, when the song references register #4 the data should go to OPL register 0xBD.

Song data

Directly following the header is the song data in register index and value pairs.

Data typeNameDescription
UINT8iRegisterIndexRegister to write to. This is an index into the codemap table.
UINT8iValueValue to write to the OPL register

This structure is repeated iLengthPairs times. Note that while iRegisterIndex is normally an index into the codemap table, it can also match iShortDelayCode or iLongDelayCode if iValue is to be treated as a delay length (see above.) If the high bit is set (iRegisterIndex & 0x80) then it is a register on the second OPL chip in a dual-OPL2 song (so the high bit should be removed and the value looked up as normal, but then sent to the second OPL chip instead.)

Tools

Similar formats

  • Rdos' RAW format serves the same purpose, only it is created through the RAC (Rdos Adlib Capture) TSR.
  • The id Software Music Format (IMF) stores Adlib data in a similar manner in order to provide background music in many Apogee games.
Personal tools
programming