Gods Music Format

From ModdingWiki
Jump to navigation Jump to search
Gods Music Format
Format typeMusic
Notation typeMIDI
InstrumentsOPL
Max channel countUnknown
Max track count1
Max pattern count0
Max order count0
Tags?None
Games

Music and sound effects in Gods are stored in .MUS and .RL files. Both use the same simple container, holding a list of Standard MIDI Files. The files are compressed with PKWARE DCL Compression; everything below describes the decompressed data. All files are played by the PPLAYER.BIN sound engine (by Sound Images), which can drive an AdLib/OPL2, a Sound Blaster or a Roland MPU-401.

File Entries Used by Contents
PGODS.MUS 73 GAME.EXE with AdLib, Sound Blaster, Tandy or PC speaker All in-game sound effects, plus three music tracks (entries 19, 20 and 40)
PGODSRLA.RL ... PGODSRLG.RL 63 GAME.EXE with a Roland Entry 0 is the music, entries 1-62 are the sound effects (identical in all seven files)
PMUSIC.MUS 1 Intro, AdLib Title music
PGODMUS2.MUS 1 Intro, Sound Blaster Title music (FM part; see also Gods Sample Music Format)
PTITLE.RL 1 Intro, Roland Title music, followed by an MT-32 instrument bank

The Roland files are chosen by the game as follows: A-D for worlds 1-4, E for the title menu and game over, F for guardian fights and G for the shop. According to the game's READ.ME, the Roland version contains seven pieces written by John Foxx, which (like the Sound Blaster title music) cannot be heard when running from low-density floppy disks.

File format

Container

Data type Name Description
UINT16LE count Number of entries
UINT32LE[count] offsets Offset of each entry from the start of the file
UINT16LE pad Always 0x0080
BYTE[] data The entries, one after another

There are no lengths: each entry ends where the next one begins, and the last ends at the end of the file.

PTITLE.RL has one extra UINT32LE after the pad word, giving the offset of an MT-32 instrument bank stored after the music. Its single entry therefore starts at offset 12 instead of 8.

Entries

Most entries are ordinary Standard MIDI Files, beginning with MThd. In PGODS.MUS they are all format 0, one track, 420 ticks per quarter note, with a single tempo event. Even the sound effects are short MIDI sequences: for example the treasure pickup is a rising arpeggio followed by a quieter echo.

For the AdLib, the OPL instrument for each channel is stored inside the MIDI data as a sequencer-specific meta event (FF 7F). The event is placed at the point in the track where the instrument changes. Its data starts with a short header that includes a tag byte and the MIDI channel; for tag 1 this is followed by 28 bytes of instrument data: 13 bytes for the modulator, 13 bytes for the carrier and 2 wave select bytes.

Compressed entries

A few entries (PGODS.MUS entries 19, 20 and 40, the single entry in PGODMUS2.MUS and entry 21 of every .RL file) do not start with MThd. These are MIDI files compressed with a word dictionary:

Data type Name Description
char tag C or c
UINT16LE[256] dict Dictionary of 256 two-byte pairs
UINT8[] codes One code per two bytes of output

To decompress, replace each code byte n with the two bytes of dict[n] (low byte first). With tag c, drop the first byte of the result; this lets the scheme store a file of odd length. The result is a normal Standard MIDI File.

Source code

From re-gods, the open-source HTML5 port:

Credits

This file format was reverse engineered by VorticonCmdr. 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!)