For documentation purposes, here is how the 'instrument set' table works. With this missing part solved, it's possible to change which instrument set each sequence uses and probably add new sequences in the game, probably up to 127 sequences.
The table is located at 0x7cc620 and it's loaded separately from the music sequences:
0x007CC620 0046 0052 0054 0056 0058 005A 005C 005E
0x007CC630 0060 0062 0064 0067 0069 006B 006D 006F
0x007CC640 0071 0073 0075 0077 0079 007B 007D 007F
0x007CC650 0081 0083 0085 0087 0089 008B 008D 008F
0x007CC660 0091 0093 0095 0B0A 0908 0706 0504 0302
0x007CC670 0100 0122 0111 0122 010E 0113 010F 0112
0x007CC680 010B 010D 0221 1001 1401 1501 1601 1701
0x007CC690 1801 1201 1901 1F01 2101 1A01 0E01 1B01
0x007CC6A0 1A01 1C01 1D01 2501 1401 2001 1E01 1B01
0x007CC6B0 1A01 2301 2401 1B00 0000 0000 0000 0000
The green bytes consist of 0x23 halfwords (2 bytes), which is the same number of sequences in the ROM. Each entry is actually a relative pointer to the 'instrument set' used by that sequence. To read the table, just use the sequence number * 2 (halfword) + 0x7cc620 (start of the table).
For instance --> Title Screen Music (sequence 0x02)
= 0x0054 (value in the table for 0x02 at offset 0x7cc624)
+ 0x7cc620 (start of the table)
----------
value at 0x7cc674 = 0x0111
Now 0x01 and 0x11 are actually two separate bytes, not an halfword. I'm not sure if the first one is also an instrument set, but the second one certainly is. So, this sequence uses instrument set 0x11 (in decimal = 17).
This number relates to the "NInst" instruments in the .ctl file. Using srip (download from dextrose.com), you can extract all (or most) sounds in the ROM and it outputs a control.h file which includes information about the sound structs used in the game in a sort of reconstructed .ctl file.
There are 37 NInst entries (0x25). Each one of these contries contain an index to the individual instrument sounds.
SRIP outputs all sounds in the format A00 + Ninst number (00 to 37) + sound index.
Here is NInstrument NInst17 (0x11), the Title Screen SMB Music instrument set:
Sound1700, 0x00 = Snare Drum
Sound1701, 0x01 = Fingered Bass
NULL, 0x02 = NULL = same as last one (0x01)
Sound1703, 0x03 = Organ
Sound1704, 0x04 = Steel Drum
Sound1705, 0x05 = Trumpet
Sound1706, 0x06 = Slap Bass
Sound1707, 0x07 = Synth
Sound1708, 0x08 = Clavinet
NULL, 0x09 = NULL = same as last one (0x08)
Sound1710, 0x0A = Drum Sample (hi-hat)
Sound1711, 0x0B = Drum Sample
Sound1712, 0x0C = Drum Sample
Sound1713, 0x0D = Drum Sample
This is the index used inside the Title Screen Music (for the 0xC1 instrument command, or '@' in mml2m64). Some of the NInst are sound effects, such as explosions and Mario sounds.
If someone could help labelling out all the sound files (trying to keep names close to standard General Midi instruments), that would be of great help.
Getting back to the table, here is the code that copy this pointer table to RAM, in case we want to move it in the future:
803198BC: LUI V1, 0x8022
803198C0: ADDIU V1, V1, 0x6B58
803198C4: LUI A0, 0x007D
803198C8: SW V0, 0x0000 (V1)
803198CC: ADDIU A0, A0, 0xC620 ; 0x7cc620
803198D0: OR A1, V0, R0
803198D4: JAL 0x80318040 ; BlockDmaCopy
803198D8: ADDIU A2, R0, 0x0100
0x80226b58 is a pointer to the location of this 'instrument set' table in RAM. (It will point to 0x801D0370, or wherever it gets allocated).
____________________ Mario 64 notes @ http://sites.google.com/site/messiaen64/ |