Micro Machines Sound Driver Format

From ModdingWiki
Jump to navigation Jump to search
Micro Machines Sound Driver Format
Format typeMusic
Notation typeCustom
InstrumentsOPL
Max channel count9
Max track count8
Max pattern countUnknown
Max order countUnknown
Tags?None
Games

All music and sound effects of Micro Machines are stored inside the sound driver modules DRIVER0.BIN, DRIVER1.BIN and DRIVER2.BIN. The game only passes tune and effect numbers to the driver. There are no digitised sounds; the "Blaster" option in the setup means AdLib (OPL2) music.

File Size Sound option Content
DRIVER0.BIN 8 None MOV AX,0 / RETF twice: every command does nothing
DRIVER1.BIN 28625 Blaster Sound Images Generation 2 OPL2 driver by Tony Williams: 8 tunes, 18 effects, 128 instruments
DRIVER2.BIN 11845 Speaker "Internal Beeper v1.08" PC speaker driver: 8 tunes, 15 effects

The driver is chosen by SETTINGS.DAT (see Micro Machines Settings Format).

Calling the driver

The file is loaded to offset 0 of a segment and called with a far call to offset 0. The command is passed in AH, the argument in AL (or CX/DX), the result is returned in AL. The game calls command 3 about 70 times per second from its timer interrupt.

AH Command
0 Initialise, DX = OPL port (0x388)
1 Shut down
2 Set timer rate, CX = PIT divisor of the calling timer
3 Timer tick
4 Play tune AL (1-8)
5 Play sound effect AL (1-18), or engine sound 0x40 + car
6 Stop everything
7 Stop music
8 Stop sound effect AL
9 Is tune AL playing? (0 = yes)
10 Is sound effect AL playing? (0 = yes)
11 Count playing sound effects
14-16 PC speaker only: engine voice on, set pitch, off

File format

The rest of this page describes DRIVER1.BIN. DRIVER2.BIN uses the same sequence format with its own offsets (banks at 0x074F, 0x2CBE and 0x2DE5, pointed to by words at 0x749), but only reads the transpose and length bytes of its instruments.

Offset Content
0x0000 Code. The four 16-byte engine sound sequences are at 0x0008-0x0047.
0x09D3 Frequency and volume tables
0x13F0 Three UINT16LE pointers to the music, sound effect and instrument banks
0x13F6 Music bank: 8 tunes, 47 tracks in total
0x65B4 Sound effect bank: 18 effects
0x6751 Instrument bank: a 128-byte percussion map (all zero), then 128 instruments of 16 bytes

Sequence data

Every track and effect is a stream of delay event pairs. The delay is a MIDI-style variable length number (7 bits per byte, big-endian, high bit set on all but the last byte). All tunes use 96 ticks per beat at 120 beats per minute; effects always run at 96 ticks per second.

Event Parameters Meaning
0x00-0x7F velocity Note on (the event byte is the note; note 60 is C5). Ends the previous note.
0x80-0x8F - Use OPL channel event & 0x0F
0x90 note Note off, if this note is playing
0x91 - End of track
0x92 instrument Set instrument
0x93 tempo Set tempo (not used)
0x94 - No operation
0x95 bend Pitch bend (0x40 = centre)
0x96 volume Set volume (not used)
0x97 flag Percussion mode (not used)
0x98 - Jump to the loop point
0x99 - Note off
0x9A - Stop the track and wait forever
0x9B 1 byte Ignored
0x9C - Set the loop point
0x9D 2 bytes Ignored

Tunes 1-3 loop. Tunes 4-8 play once and then loop a silent tail. Tune 1 is the title, 2 the menus, 3 the champion screen, 4 the race introduction, 6 is played when a character is eliminated or a life is lost, and 8 after winning or qualifying. Tunes 5 and 7 are never played. Races have no music.

Instruments

Offset Purpose
0-1 OPL register 0x60 (attack/decay), modulator and carrier
2-3 OPL register 0x80 (sustain/release), modulator and carrier
4-5 OPL register 0x20 (flags/multiplier), modulator and carrier
6-7 OPL register 0xE0 (waveform), modulator and carrier
8 Transpose
9 OPL register 0xC0 (feedback/connection)
10 Modulator level
11 Carrier level
12 Key scale level (bits 4-5 modulator, bits 0-1 carrier)
13-14 Unused
15 Pitch bend range

The driver never enables waveform select (OPL register 1), so on a real OPL2 chip all instruments play sine waves. OPL3 cards and most emulators play the stored waveforms anyway.

Engine sounds

The engine sounds (effects 0x40-0x43, one per car) are short looping sequences at the start of the driver, which the game changes in memory while the race runs: it writes the instrument (by vehicle class), the pitch bend (speed / 10, plus 0x30 while in the air) and the delay, and replaces the loop event with end of track to stop the engine.

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!)