UserWiki:SynaMax

From Video Game Music Preservation Foundation Wiki
Revision as of 03:18, 6 December 2017 by SynaMax (talk | contribs) (Fairlight CMI *.RS File Structure: Fixed my math, lol)
Jump to: navigation, search

Fairlight CMI *.RS File Structure

Offset Size Description Notes
0x00 0x2 Magic? Always 0x0102
0x02 0x2 Speed? I'm pretty sure this is speed. 0xA3A = 2618 = 120 BPM. To get the BPM, divide 314160 by the song's speed value (314160/2618 = 120). To get the speed value, divide 314160 by the song's BPM (314160/120 = 2618)
0x04 0x2 Time Signature? So far, the last byte has always been 4.
0x06 0x2  ? Sometimes, it's 0x0001, other times it's zeroed out. Perhaps it's a sync flag?
0x80 0x80 First Pattern Chunk? It looks like the RS file is split into 0x80 byte-sized chunks
0x680 0x80 "E5" Chunk? For some reason at offset 0x680, there is a chunk that is usually filled with 0xE5, or just zeroed out.

The RS file is split into 0x80 byte-size chunks.

MegaRace HERAD "DFADP.HSQ" Driver

This is the driver that is used for Sound Blaster Pro. Provided that the sounds are turned off in the setup options, the driver is located in memory at 3B08:0100. The song currently loaded is located at 3BB6:0000. Note that since the driver is loaded at 3B08:0100, the offsets listed here are off by 0x100 since the reverse engineering process began by referencing the driver file rather than the driver loaded in RAM. As a result, to get the correct offset, just simply add 0x100 to the value and that will be the offset used by the driver. For example, 0xA2 is actually referenced in the driver as 0x1A2.

Offset Size Description Notes
0x00 0x15  ? The game uses these jumps to control the driver
0x15 0x2 Magic? (Always 0x0002) The driver uses this value to do several things, such as using this to add to the relative offsets from the music file so that they become absolute offsets.
0x17 0x2 Song Segment This is where the music file is located (for example, 3BB6:0000)
0x19 0x2 Song Length (first two bytes from music file)
0x1B 0x2 Song Segment
0x1D 0x2 Timer Timer based off of the song's speed value
0x1F 0x2 MIDI Measure Counter (this counts up after every 96 MIDI ticks and is used for the song loop)
0x21 0x2 MIDI Tick Measure Counter (Counts down from 0x60 aka 96 MIDI Ticks)
0x23 0x2 Song Repeat Counter (Counts down from 0xFFFF after passing beginning loop measure)
0x25 0x10 MIDI Event Subroutine Lookup Table Each word is an offset to a subroutine in the driver that handles a particular MIDI Event:

06CF = NoteOff (80)
065D = NoteOn (90)
08E5 = Polyphonic Aftertouch (A0)
08E5 = Control Mode Change (B0)
05D2 = Program Change (C0)
072E = Aftertouch (D0)
07DD = Pitch Bend (E0)
06F5 = End of Track (FF)

Note that Polyphonic Aftertouch and Control Mode Change share the same offset. That is because HERAD doesn't support those MIDI events so the sequencer uses this table to ignore the events and proceed with playing the event as a regular NoteOn. HERAD 2 also doesn't support Aftertouch Events, so they are parsed but ignored.

0x35 0x6  ? Table (00 03 01 04 02 05)
0x3B 0x6  ? Table (08 0B 09 0C 0A 0D)
0x41 0x6  ? Table (10 13 11 14 12 15)
0x47 0x18 Frequency Table These are the FNUM values that make up the 12 note Chromatic musical scale for HERAD. Basically, changing these values will modify the "tuning" of the scale.
0x5F 0x12 FNUM/Block Number Register Values These register values are sent directly to the OPL chip, however these values are missing the Key-On bit (bit 5, 0xB0-0xB8).
0x71 0x12 OPL Register Lookup Table Table (00 01 02 08 09 0A 10 11 12 03 04 05 0B 0C 0D 13 14 15). Some subroutines use this to write to all the OPL registers.
0x7A 0x16 Fine Pitch Bend Table
0x90 0xA Coarse Pitch Bend Table
0x9A 0x2 Song Flag Left over from Dune. When set to 0x80, this plays the song, but when this changes to 0x00, playback stops. The driver checks to see if the highest bit is set to 1 and if it is, the song plays, so any value between 0x80 and 0xBF will work. 0xC0, was used to fade out songs in Dune, but this feature has been removed. 0xC0 is still used to end songs when the game quits.
0x9C 0x3  ? (Always 0xEEEEEE) Changing this doesn't affect playback but it is used by several subroutines in the driver.
0x9F 0x2  ? Two byte timer that counts up by rotating (bit shifting) to the left by 1
0xA1 0x1 Padding (Always 0x90, changing this doesn't affect playback)
0xA2 0x12 Current Midi Delay Counter (counts down until next event)
0xB4 0x12 MIDI Track Position (counts up until reaching the track end)
0xC6 0x12 Start of MIDI Tracks (Absolute address in music file, rather than relative address in music file header)
0xD8 0x12 List of MIDI tracks using drum keymap instrument If MIDI track uses keymap instrument, the absolute offset of the instrument in the music file will be used. If the instrument changes back to a normal instrument, the value zeros out.
0xEA 0x12 Current Instrument (first byte) / MIDI Pitch (second byte) The pitch here is after any transpose macros have been applied. Also, if the keymap instrument is used, the first byte will display the instrument(s) that are actually being played. If no instrument or note data exist, the values will be 0xFF/0x00 respectively. NoteOffs are enabled by setting the highest bit to 1 in the pitch byte.
0xFC 0x12 Pitch Slide Range Flag (first byte) / Root Note Transpose (second byte) for each MIDI track
0x10E 0x12 Pitch Slide Duration Counter (first byte) / Pitch Slide Duration (second byte) for each MIDI track The Pitch Slide Counter starts at the value assigned by the second byte.
0x120 0x12 Pitch Slide Counter (first byte) / Pitch Slide Range (second byte) for each MIDI track The Pitch Slide Counter starts at 0x40 (unless it is transposed) and either goes up or down depending on Pitch Slide Range value.
0x132 0x12 Modulator Output Level Scaling (first byte) / Carrier Output Level Scaling (Second byte) These values are taken from the current instrument.
0x144 0x12 Modulator Output Level (first byte) / Carrier Output Level (Second byte) These values are taken from the current instrument.
0X156 0x12 Modulator Output Level Register (first byte) / Carrier Output Level Register (Second byte) These are the final register values that are sent to the OPL chip.
0x168 0x12 Panning/Feedback/Connector Register Value
0x17A 0x12 Loop MIDI Delay Values These are the values that the MIDI delay counters load when the song loops.
0x18C 0x12 Loop Start Absolute Address for each MIDI track (loads after the song passes the loop beginning measure)
0x19E 0x24  ? Seems to be just zeros
0x1C2 0x1 Terminator (flashes 0xFF during playback)
0x1C3 EOF Binary Data (starts with "HSQ" with 0x2002 at the end) (0x4853512002)

Dune HERAD "DUNEADL.HSQ" Driver (Floppy Version)

Offset Size Description Notes
0x00 0x21  ? Changing some values crash the game, while others don't
0x21 0x2  ? Something to do with the song speed (Always 0x0240)
0x17 0x2  ? (Always 0x00E0)
0x19 0x2 Song length + 0x0040 This value is the first two bytes from music file with 0x0040 added, for example WORMSUIT.HSQ's song length (0x3C7E) will show up as 0x3CBE
0x1B 0x2  ? (Always 0x00E0)
0x29 0x2  ? (OPL Timer?)
0x2B 0x2 MIDI Measure Counter This counts up after every 96 MIDI ticks and is used for the song loop
0x2D 0x2 MIDI Tick Measure Counter Counts down from 0x60 aka 96 MIDI Ticks
0x2F 0x12  ? Changing some values crash the game, while others don't
0x41 0x6  ? Table (00 03 01 04 02 05)
0x47 0x6  ? Table (08 0B 09 0C 0A 0D)
0x4D 0x6  ? Table (10 13 11 14 12 15)
0x53 0x18 Frequency Table These are the FNUM values that make up the 12 note Chromatic musical scale for HERAD. Basically, changing these values will modify the "tuning" of the scale.
0x6B 0x12 FNUM/Block Number Register Values These register values are sent directly to the OPL chip, however these values are missing the Key-On bit (bit 5, 0xB0-0xB8).
0x7D 0x9  ? Table (00 01 02 08 09 0A 10 11 12)
0x86 0x16 Fine Pitch Bend Table
0x9C 0xA Coarse Pitch Bend Table
0xA6 0x1 Song Reset/Fade Out Controls 0x80 = Play song. 0x00 = resets the song back to the beginning, then the value switches back to 0x80 to play the song. 0xC0 = Fades the song out and waits until the Fade Out MIDI Tick Timer at 0xA8 counts to zero before resetting the song from the beginning).
0xA7 0x1 Change Song Depending on which screen the game is in, this is set to 0x1 so when the current song is finished playing or fades out, a new song will play. In the Options menu of Dune, if "Music On (CD-Style)" is selected, this byte is always 0x1 when a song is playing.
0xA8 0x1 Fade Out MIDI Tick Timer Counts down from 0xFF with each MIDI tick. Once this reaches zero, the value at 0xA6 changes back to 0x0000.
0xA9 0x2  ? Something to do with the fade out timer. When not active, this is at 0x1111. Seems to count in only 0x11,0x22,0x44,0x88.
0xAB 0x1 Padding (Always 0x90, changing this doesn't affect playback)
0xAC 0x12 Current Event Midi Tick Counter (counts down until next event)
0xBE 0x12 MIDI Track Position + 0x0040 Absolute value with 0x0040 added (counts up until reaching the track end)
0xD0 0x12 Start of MIDI Tracks + 0x0040 Absolute value with 0x0040 added (Absolute address in music file, rather than relative address in music file header)
0xE2 0x12 Current Instrument (first byte) / MIDI Pitch (second byte) The pitch here is after any transpose macros have been applied. If no instrument or note data exist, the values will be 0xFF/0x00 respectively. NoteOffs are enabled by zeroing out the pitch byte.
0xF4 0x12 Pitch Slide Range Flag (first byte) / Root Note Transpose (second byte) for each MIDI track
0x106 0x12 Pitch Slide Duration Counter (first byte) / Pitch Slide Duration (second byte) for each MIDI track The Pitch Slide Counter starts at the value assigned by the second byte.
0x118 0x12 Pitch Slide Counter (first byte) / Pitch Slide Range (second byte) for each MIDI track The Pitch Slide Counter starts at 0x40 (unless it is transposed) and either goes up or down depending on Pitch Slide Range value.
0x12A 0x12 Modulator Output Level Scaling (first byte) / Carrier Output Level Scaling (Second byte) These values are taken from the current instrument.
0x13C 0x12 Modulator Output Level (first byte) / Carrier Output Level (Second byte) These values are taken from the current instrument data and also include the Key scaling level register values.
0X14E 0x12 Modulator Output Level Register (first byte) / Carrier Output Level Register (Second byte) These are the final register values that are sent to the OPL chip. These values also include the Key scaling level register values.
0x160 0x12 Feedback Scaling - Velocity (first byte) / Feedback/Connector (second byte) These values are taken from the current instrument data, however the second byte is the unmodified register value of the feedback and connector settings.
0x172 0x12 Modulator Output Level Aftertouch Scaling (first byte) / Carrier Output Level Aftertouch Scaling (second byte) These values are taken from the current instrument data
0x184 0x12 Feedback Scaling - Aftertouch / Feedback/Connector Register Value The first value is taken from the current instrument data, however the second byte is the final modified register value of the feedback and connector settings that will be sent to the OPL2 chip.
0x196 0x12 Loop Counter Values These are the values that the MIDI tick counters load when the song loops.
0x1A8 0x12 Loop Start Absolute Address for each MIDI track + 0x0040 (loads after the song passes the loop beginning measure)
0x1BA EOF Binary Data (always starts with "HSQ" string with 0x16 at the end) (0x48535116)

Dune HERAD "DUNEADL.HSQ" Driver (CD Version)

To be completed.

Dune HERAD "DUNEAGD.HSQ" Driver (Floppy Version)

Offset Size Description Notes
0x3E4 EOF Binary Data (always starts with "AGD" string with 0x16 at the end) (0x41474416)

Dune HERAD "DUNEAGD.HSQ" Driver (CD Version)

To be completed.

Dune HERAD "DUNEADL.SQZ" Driver (Demo Version)

To be completed.

Nintendo WSYS File Structure

Header Chunk

Offset Size Description Notes
0x0 0x4 "WSYS" Header
0x4 0x4 File Size File Size
0x8 0x8 unknown Just zeros?
0x10 0x4 "WINF" absolute offset Need more info on WINF chunk
0x14 0x4 "WBCT" absolute offset Need more info on WBCT chunk
0x18 0x8 unknown Just zeros?

Sample data Chunk

Each sample entry is 0x24 bytes long.

Offset Size Description Notes
0x0 0x2 "E700" Header?
0x2 0x2 MIDI Pitch MIDI Pitch
0x4 0x4 Sample Rate Represented as a floating point value
0x8 0x4 Sample Start Offset Absolute offset inside the AW file where the start of the ADPCM sample is located
0xC 0x4 Sample Size Size of the ADPCM sample
0x10 0x4 Loop flag 00000000 = off; FFFFFFFF = on
0x14 0x4 Loop start point Sample where loop starts
0x18 0x4 Loop end point Sample where loop ends
0x1C 0x4 unknown? Something to do with the loop point samples
0x20 0x4 unknown?

"WINF" Chunk

More work needs to be done here.

Offset Size Description Notes
0x0 0x4 "WINF" Header
0x4 0x4 unknown Number of AW files?
0x8 0x8 AW filename absolute offset Points to the name of the AW file. AW files contain all the ADPCM sample data.