Difference between revisions of "Music sequence"
m (Cleanup) |
|||
Line 27: | Line 27: | ||
!Bytecode (US) | !Bytecode (US) | ||
!Description | !Description | ||
− | |||
|- | |- | ||
!seq_end | !seq_end | ||
Line 34: | Line 33: | ||
|0xff | |0xff | ||
|End of script, loop or function | |End of script, loop or function | ||
− | |||
|- | |- | ||
!seq_delay1 | !seq_delay1 | ||
Line 41: | Line 39: | ||
|0xfe | |0xfe | ||
|Delay for 1 tick | |Delay for 1 tick | ||
− | |||
|- | |- | ||
!seq_delay | !seq_delay | ||
Line 48: | Line 45: | ||
|0xfd, var | |0xfd, var | ||
|Delay for X ticks | |Delay for X ticks | ||
− | |||
|- | |- | ||
!seq_call | !seq_call | ||
Line 55: | Line 51: | ||
|0xfc, addr | |0xfc, addr | ||
|Call a function | |Call a function | ||
− | |||
|- | |- | ||
!seq_jump | !seq_jump | ||
Line 62: | Line 57: | ||
|0xfb, addr | |0xfb, addr | ||
|Jump to a point in the sequence script | |Jump to a point in the sequence script | ||
− | |||
|- | |- | ||
!seq_beqz | !seq_beqz | ||
Line 69: | Line 63: | ||
|0xfa, addr | |0xfa, addr | ||
|Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | |Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | ||
− | |||
|- | |- | ||
!seq_bltz | !seq_bltz | ||
Line 76: | Line 69: | ||
|0xf9, addr | |0xf9, addr | ||
|Jump if Q < 0 | |Jump if Q < 0 | ||
− | |||
|- | |- | ||
!seq_loop | !seq_loop | ||
Line 83: | Line 75: | ||
|0xf8, u8 | |0xf8, u8 | ||
|Repeat until <code>loopend</code> for X iterations (256 if X = 0) | |Repeat until <code>loopend</code> for X iterations (256 if X = 0) | ||
− | |||
|- | |- | ||
!seq_loopend | !seq_loopend | ||
Line 90: | Line 81: | ||
|0xf7 | |0xf7 | ||
|Loop end marker | |Loop end marker | ||
− | |||
|- | |- | ||
!seq_bgez | !seq_bgez | ||
Line 97: | Line 87: | ||
|0xf5, addr | |0xf5, addr | ||
|Jump if Q >= 0 | |Jump if Q >= 0 | ||
− | |||
|- | |- | ||
!seq_reservenotes | !seq_reservenotes | ||
Line 104: | Line 93: | ||
|0xf2, u8 | |0xf2, u8 | ||
|Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | |Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | ||
− | |||
|- | |- | ||
!seq_unreservenotes | !seq_unreservenotes | ||
Line 111: | Line 99: | ||
|0xf1 | |0xf1 | ||
|Drop all earlier reservations made by this sequence. | |Drop all earlier reservations made by this sequence. | ||
− | |||
|- | |- | ||
!seq_transpose | !seq_transpose | ||
Line 118: | Line 105: | ||
|0xdf, s8 | |0xdf, s8 | ||
|Set transposition in semitones. | |Set transposition in semitones. | ||
− | |||
|- | |- | ||
!seq_transposerel | !seq_transposerel | ||
Line 125: | Line 111: | ||
|0xde, s8 | |0xde, s8 | ||
|Change transposition by some delta. | |Change transposition by some delta. | ||
− | |||
|- | |- | ||
!seq_settempo | !seq_settempo | ||
Line 132: | Line 117: | ||
|0xdd, u8 | |0xdd, u8 | ||
|Set tempo in BPM. | |Set tempo in BPM. | ||
− | |||
|- | |- | ||
!seq_addtempo | !seq_addtempo | ||
Line 139: | Line 123: | ||
|0xdc, s8 | |0xdc, s8 | ||
|Change tempo by some delta. | |Change tempo by some delta. | ||
− | |||
|- | |- | ||
!seq_setvol | !seq_setvol | ||
Line 146: | Line 129: | ||
|0xdb, u8 | |0xdb, u8 | ||
|Set volume scale (0…255 = none to twice normal). | |Set volume scale (0…255 = none to twice normal). | ||
− | |||
|- | |- | ||
!seq_changevol | !seq_changevol | ||
Line 153: | Line 135: | ||
|0xda, s8 | |0xda, s8 | ||
|Change volume scale by some delta. | |Change volume scale by some delta. | ||
− | |||
|- | |- | ||
!seq_initchannels | !seq_initchannels | ||
Line 160: | Line 141: | ||
|0xd7, u16 | |0xd7, u16 | ||
|Initialize channels (bitmask). This copies mute behavior and note allocation policy. | |Initialize channels (bitmask). This copies mute behavior and note allocation policy. | ||
− | |||
|- | |- | ||
!seq_disablechannels | !seq_disablechannels | ||
Line 167: | Line 147: | ||
|0xd6, u16 | |0xd6, u16 | ||
|Uninitialize channels (bitmask). | |Uninitialize channels (bitmask). | ||
− | |||
|- | |- | ||
!seq_setmutescale | !seq_setmutescale | ||
Line 174: | Line 153: | ||
|0xd5, s8 | |0xd5, s8 | ||
|Set volume multiplier for muted mode (0…127). | |Set volume multiplier for muted mode (0…127). | ||
− | |||
|- | |- | ||
!seq_mute | !seq_mute | ||
Line 181: | Line 159: | ||
|0xd4 | |0xd4 | ||
|Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | |Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | ||
− | |||
|- | |- | ||
!seq_setmutebhv | !seq_setmutebhv | ||
Line 188: | Line 165: | ||
|0xd3, u8 | |0xd3, u8 | ||
|Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | |Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | ||
− | |||
|- | |- | ||
!seq_setshortnotevelocitytable | !seq_setshortnotevelocitytable | ||
Line 195: | Line 171: | ||
|0xd2, addr | |0xd2, addr | ||
|Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | ||
− | |||
|- | |- | ||
!seq_setshortnotedurationtable | !seq_setshortnotedurationtable | ||
Line 202: | Line 177: | ||
|0xd1, addr | |0xd1, addr | ||
|Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | ||
− | |||
|- | |- | ||
!seq_setnoteallocationpolicy | !seq_setnoteallocationpolicy | ||
Line 209: | Line 183: | ||
|0xd0, u8 | |0xd0, u8 | ||
|Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel’s reserved notes, else if 0x4 is set, from the channel’s or sequence’s reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | |Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel’s reserved notes, else if 0x4 is set, from the channel’s or sequence’s reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | ||
− | |||
|- | |- | ||
!seq_setval | !seq_setval | ||
Line 216: | Line 189: | ||
|0xcc, u8 | |0xcc, u8 | ||
|Set Q to a constant. | |Set Q to a constant. | ||
− | |||
|- | |- | ||
!seq_bitand | !seq_bitand | ||
Line 223: | Line 195: | ||
|0xc9, u8 | |0xc9, u8 | ||
|Bitand Q by a constant. | |Bitand Q by a constant. | ||
− | |||
|- | |- | ||
!seq_subtract | !seq_subtract | ||
Line 230: | Line 201: | ||
|0xc8, u8 | |0xc8, u8 | ||
|Subtract a constant from Q. | |Subtract a constant from Q. | ||
− | |||
|- | |- | ||
!seq_startchannel | !seq_startchannel | ||
Line 237: | Line 207: | ||
|0x90-0x9f, addr | |0x90-0x9f, addr | ||
|Start channel N, with a given channel script. | |Start channel N, with a given channel script. | ||
− | |||
|- | |- | ||
!seq_getvariation | !seq_getvariation | ||
Line 244: | Line 213: | ||
|0x80-0x8f | |0x80-0x8f | ||
|Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | |Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | ||
− | |||
|- | |- | ||
!seq_setvariation | !seq_setvariation | ||
Line 251: | Line 219: | ||
|0x70-0x7f | |0x70-0x7f | ||
|Set the variation bit to Q. | |Set the variation bit to Q. | ||
− | |||
|- | |- | ||
!seq_subvariation | !seq_subvariation | ||
Line 258: | Line 225: | ||
|0x50-0x5f | |0x50-0x5f | ||
|Subtract the variation bit from Q. | |Subtract the variation bit from Q. | ||
− | |||
|- | |- | ||
!seq_testchdisabled | !seq_testchdisabled | ||
Line 265: | Line 231: | ||
|0x00-0x0f | |0x00-0x0f | ||
|Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. | |Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. | ||
− | |||
|} | |} | ||
Line 277: | Line 242: | ||
!Bytecode (US) | !Bytecode (US) | ||
!Description | !Description | ||
− | |||
|- | |- | ||
!chan_end | !chan_end | ||
Line 285: | Line 249: | ||
|0xff | |0xff | ||
|End of script, loop or function | |End of script, loop or function | ||
− | |||
|- | |- | ||
!chan_delay1 | !chan_delay1 | ||
Line 293: | Line 256: | ||
|0xfe | |0xfe | ||
|Delay for 1 tick | |Delay for 1 tick | ||
− | |||
|- | |- | ||
!chan_delay | !chan_delay | ||
Line 301: | Line 263: | ||
|0xfd, var | |0xfd, var | ||
|Delay for X ticks | |Delay for X ticks | ||
− | |||
|- | |- | ||
!chan_call | !chan_call | ||
Line 309: | Line 270: | ||
|0xfc, addr | |0xfc, addr | ||
|Call a function | |Call a function | ||
− | |||
|- | |- | ||
!chan_jump | !chan_jump | ||
Line 317: | Line 277: | ||
|0xfb, addr | |0xfb, addr | ||
|Jump to a point in the channel script | |Jump to a point in the channel script | ||
− | |||
|- | |- | ||
!chan_beqz | !chan_beqz | ||
Line 325: | Line 284: | ||
|0xfa, addr | |0xfa, addr | ||
|Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | |Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | ||
− | |||
|- | |- | ||
!chan_bltz | !chan_bltz | ||
Line 333: | Line 291: | ||
|0xf9, addr | |0xf9, addr | ||
|Jump if Q < 0 | |Jump if Q < 0 | ||
− | |||
|- | |- | ||
!chan_loop | !chan_loop | ||
Line 341: | Line 298: | ||
|0xf8, u8 | |0xf8, u8 | ||
|Repeat until <code>loopend</code> for X iterations (256 if X = 0) | |Repeat until <code>loopend</code> for X iterations (256 if X = 0) | ||
− | |||
|- | |- | ||
!chan_loopend | !chan_loopend | ||
Line 349: | Line 305: | ||
|0xf7 | |0xf7 | ||
|Loop end marker | |Loop end marker | ||
− | |||
|- | |- | ||
!chan_break | !chan_break | ||
Line 357: | Line 312: | ||
|0xf6 | |0xf6 | ||
|Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | |Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | ||
− | |||
|- | |- | ||
!chan_bgez | !chan_bgez | ||
Line 365: | Line 319: | ||
|0xf5, addr | |0xf5, addr | ||
|Jump if Q >= 0 | |Jump if Q >= 0 | ||
− | |||
|- | |- | ||
!chan_hang | !chan_hang | ||
Line 373: | Line 326: | ||
|0xf3 | |0xf3 | ||
|Infinite delay. | |Infinite delay. | ||
− | |||
|- | |- | ||
!chan_reservenotes | !chan_reservenotes | ||
Line 381: | Line 333: | ||
|0xf2, u8 | |0xf2, u8 | ||
|Reserve X notes for exclusive use by this channel (dropping earlier reservations). | |Reserve X notes for exclusive use by this channel (dropping earlier reservations). | ||
− | |||
|- | |- | ||
!chan_unreservenotes | !chan_unreservenotes | ||
Line 389: | Line 340: | ||
|0xf1 | |0xf1 | ||
|Drop all earlier reservations made by this channel. | |Drop all earlier reservations made by this channel. | ||
− | |||
|- | |- | ||
!chan_dyncall | !chan_dyncall | ||
Line 397: | Line 347: | ||
|0xe4 | |0xe4 | ||
|If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by <code>setdyntable</code>/<code>dynsetdyntable</code>. | |If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by <code>setdyntable</code>/<code>dynsetdyntable</code>. | ||
− | |||
|- | |- | ||
!chan_setvibratodelay | !chan_setvibratodelay | ||
Line 405: | Line 354: | ||
|0xe3, u8 | |0xe3, u8 | ||
|Set delay until vibrato starts for each note. | |Set delay until vibrato starts for each note. | ||
− | |||
|- | |- | ||
!chan_setvibratoextentlinear | !chan_setvibratoextentlinear | ||
Line 413: | Line 361: | ||
|0xe2, u8, u8, u8 | |0xe2, u8, u8, u8 | ||
|Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | |Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | ||
− | |||
|- | |- | ||
!chan_setvibratoratelinear | !chan_setvibratoratelinear | ||
Line 421: | Line 368: | ||
|0xe1, u8, u8, u8 | |0xe1, u8, u8, u8 | ||
|Like above except for vibrato rate. | |Like above except for vibrato rate. | ||
− | |||
|- | |- | ||
!chan_setvolscale | !chan_setvolscale | ||
Line 429: | Line 375: | ||
|0xe0, u8 | |0xe0, u8 | ||
|Set scale factor for volume (0…255 = none to twice normal). | |Set scale factor for volume (0…255 = none to twice normal). | ||
− | |||
|- | |- | ||
!chan_setvol | !chan_setvol | ||
Line 437: | Line 382: | ||
|0xdf, u8 | |0xdf, u8 | ||
|Set scale factor #2 for volume (0…255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | |Set scale factor #2 for volume (0…255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | ||
− | |||
|- | |- | ||
!chan_freqscale | !chan_freqscale | ||
Line 445: | Line 389: | ||
|0xde, u16 | |0xde, u16 | ||
|Pitch bend using a raw frequency multiplier X/2^15. | |Pitch bend using a raw frequency multiplier X/2^15. | ||
− | |||
|- | |- | ||
!chan_setpan | !chan_setpan | ||
Line 453: | Line 396: | ||
|0xdd, u8 | |0xdd, u8 | ||
|Set the pan for this channel (0…128) | |Set the pan for this channel (0…128) | ||
− | |||
|- | |- | ||
!chan_setpanchanweight | !chan_setpanchanweight | ||
Line 461: | Line 403: | ||
|0xdc, u8 | |0xdc, u8 | ||
|The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0…128 maps to 0…1). W defaults to 1.0. | |The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0…128 maps to 0…1). W defaults to 1.0. | ||
− | |||
|- | |- | ||
!chan_transpose | !chan_transpose | ||
Line 469: | Line 410: | ||
|0xdb, s8 | |0xdb, s8 | ||
|Set transposition in semitones. | |Set transposition in semitones. | ||
− | |||
|- | |- | ||
!chan_setenvelope | !chan_setenvelope | ||
Line 477: | Line 417: | ||
|0xda, addr | |0xda, addr | ||
|Set ADSR envelope. See below for format. | |Set ADSR envelope. See below for format. | ||
− | |||
|- | |- | ||
!chan_setdecayrelease | !chan_setdecayrelease | ||
Line 485: | Line 424: | ||
|0xd9, u8 | |0xd9, u8 | ||
|Set ADSR decay/release rate. | |Set ADSR decay/release rate. | ||
− | |||
|- | |- | ||
!chan_setvibratoextent | !chan_setvibratoextent | ||
Line 493: | Line 431: | ||
|0xd8, u8 | |0xd8, u8 | ||
|Set vibrato extent. | |Set vibrato extent. | ||
− | |||
|- | |- | ||
!chan_setvibratorate | !chan_setvibratorate | ||
Line 501: | Line 438: | ||
|0xd7, u8 | |0xd7, u8 | ||
|Set vibrato rate. | |Set vibrato rate. | ||
− | |||
|- | |- | ||
!chan_setupdatesperframe | !chan_setupdatesperframe | ||
Line 509: | Line 445: | ||
|0xd6, u8 | |0xd6, u8 | ||
|Seems like it was meant to set the number of updates per frame? But it doesn’t actually do anything. | |Seems like it was meant to set the number of updates per frame? But it doesn’t actually do anything. | ||
− | |||
|- | |- | ||
!chan_setreverb | !chan_setreverb | ||
Line 517: | Line 452: | ||
|0xd4, u8 | |0xd4, u8 | ||
|Set amount of reverb (or “dry/wet mix”?). | |Set amount of reverb (or “dry/wet mix”?). | ||
− | |||
|- | |- | ||
!chan_pitchbend | !chan_pitchbend | ||
Line 525: | Line 459: | ||
|0xd3, s8 | |0xd3, s8 | ||
|Pitch bend by <= 1 octave in either direction (-127…127). | |Pitch bend by <= 1 octave in either direction (-127…127). | ||
− | |||
|- | |- | ||
!chan_setsustain | !chan_setsustain | ||
Line 533: | Line 466: | ||
|0xd2, u8 | |0xd2, u8 | ||
|Set ADSR sustain volume. | |Set ADSR sustain volume. | ||
− | |||
|- | |- | ||
!chan_setnoteallocationpolicy | !chan_setnoteallocationpolicy | ||
Line 541: | Line 473: | ||
|0xd1, u8 | |0xd1, u8 | ||
|Set note allocation policy for channel. See the description for sequence scripts. | |Set note allocation policy for channel. See the description for sequence scripts. | ||
− | |||
|- | |- | ||
!chan_stereoheadseteffects | !chan_stereoheadseteffects | ||
Line 549: | Line 480: | ||
|0xd0, u8 | |0xd0, u8 | ||
|Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don’t know which ones precisely – pan ''is'' still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | |Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don’t know which ones precisely – pan ''is'' still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | ||
− | |||
|- | |- | ||
!chan_setval | !chan_setval | ||
Line 557: | Line 487: | ||
|0xcc, u8 | |0xcc, u8 | ||
|Set Q to a constant. | |Set Q to a constant. | ||
− | |||
|- | |- | ||
!chan_readseq | !chan_readseq | ||
Line 565: | Line 494: | ||
|0xcb, addr | |0xcb, addr | ||
|Set Q to sequenceData[X + Q]. | |Set Q to sequenceData[X + Q]. | ||
− | |||
|- | |- | ||
!chan_setmutebhv | !chan_setmutebhv | ||
Line 573: | Line 501: | ||
|0xca, u8 | |0xca, u8 | ||
|Set mute behavior for this channel. | |Set mute behavior for this channel. | ||
− | |||
|- | |- | ||
!chan_bitand | !chan_bitand | ||
Line 581: | Line 508: | ||
|0xc9, u8 | |0xc9, u8 | ||
|Bitand Q by a constant. | |Bitand Q by a constant. | ||
− | |||
|- | |- | ||
!chan_subtract | !chan_subtract | ||
Line 589: | Line 515: | ||
|0xc8, u8 | |0xc8, u8 | ||
|Subtract a constant from Q. | |Subtract a constant from Q. | ||
− | |||
|- | |- | ||
!chan_writeseq | !chan_writeseq | ||
Line 597: | Line 522: | ||
|0xc7, u8, addr | |0xc7, u8, addr | ||
|Overwrite the byte at the given position in the sequence script by (Q + X). | |Overwrite the byte at the given position in the sequence script by (Q + X). | ||
− | |||
|- | |- | ||
!chan_setbank | !chan_setbank | ||
Line 605: | Line 529: | ||
|0xc6, u8 | |0xc6, u8 | ||
|Switch bank within instrument bank sets, to the X’th bank, 0-indexed, counting from the end. | |Switch bank within instrument bank sets, to the X’th bank, 0-indexed, counting from the end. | ||
− | |||
|- | |- | ||
!chan_dynsetdyntable | !chan_dynsetdyntable | ||
Line 613: | Line 536: | ||
|0xc5 | |0xc5 | ||
|If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | |If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | ||
− | |||
|- | |- | ||
!chan_largenoteson | !chan_largenoteson | ||
Line 621: | Line 543: | ||
|0xc4 | |0xc4 | ||
|Set notes for this channel to use “large notes” format. SM64 does this for all channels. (See <code>note</code> vs. <code>shortnote</code> in the layer section below.) | |Set notes for this channel to use “large notes” format. SM64 does this for all channels. (See <code>note</code> vs. <code>shortnote</code> in the layer section below.) | ||
− | |||
|- | |- | ||
!chan_largenotesoff | !chan_largenotesoff | ||
Line 629: | Line 550: | ||
|0xc3 | |0xc3 | ||
|Set notes for this channel to use “short notes” format. | |Set notes for this channel to use “short notes” format. | ||
− | |||
|- | |- | ||
!chan_setdyntable | !chan_setdyntable | ||
Line 637: | Line 557: | ||
|0xc2, addr | |0xc2, addr | ||
|Set dyntable to point to a given u16 array from the sequence data. | |Set dyntable to point to a given u16 array from the sequence data. | ||
− | |||
|- | |- | ||
!chan_setinstr | !chan_setinstr | ||
Line 645: | Line 564: | ||
|0xc1, u8 | |0xc1, u8 | ||
|Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | |Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | ||
− | |||
|- | |- | ||
!chan_dynsetlayer | !chan_dynsetlayer | ||
Line 653: | Line 571: | ||
|0xb0-0xbf | |0xb0-0xbf | ||
|If Q != -1, start layer N, with layer script given by dyntable[Q]. | |If Q != -1, start layer N, with layer script given by dyntable[Q]. | ||
− | |||
|- | |- | ||
!chan_freelayer | !chan_freelayer | ||
Line 661: | Line 578: | ||
|0xa0-0xaf | |0xa0-0xaf | ||
|Stop layer N. | |Stop layer N. | ||
− | |||
|- | |- | ||
!chan_setlayer | !chan_setlayer | ||
Line 669: | Line 585: | ||
|0x90-0x9f, addr | |0x90-0x9f, addr | ||
|Start layer N, with layer script starting at address X. | |Start layer N, with layer script starting at address X. | ||
− | |||
|- | |- | ||
!chan_ioreadval | !chan_ioreadval | ||
Line 677: | Line 592: | ||
|0x80-0x8f | |0x80-0x8f | ||
|Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | |Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | ||
− | |||
|- | |- | ||
!chan_iowriteval | !chan_iowriteval | ||
Line 685: | Line 599: | ||
|0x70-0x7f | |0x70-0x7f | ||
|Set IO[N] to Q. | |Set IO[N] to Q. | ||
− | |||
|- | |- | ||
!chan_setnotepriority | !chan_setnotepriority | ||
Line 693: | Line 606: | ||
|0x60-0x6f | |0x60-0x6f | ||
|Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren’t any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | |Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren’t any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | ||
− | |||
|- | |- | ||
!chan_ioreadvalsub | !chan_ioreadvalsub | ||
Line 701: | Line 613: | ||
|0x50-0x5f | |0x50-0x5f | ||
|Decrease Q by IO[N]. | |Decrease Q by IO[N]. | ||
− | |||
|- | |- | ||
!chan_ioreadval2 | !chan_ioreadval2 | ||
Line 709: | Line 620: | ||
|0x40-0x4f, u8 | |0x40-0x4f, u8 | ||
|Set Q to IO2[X], where IO2 is the IO array for channel N. | |Set Q to IO2[X], where IO2 is the IO array for channel N. | ||
− | |||
|- | |- | ||
!chan_iowriteval2 | !chan_iowriteval2 | ||
Line 717: | Line 627: | ||
|0x30-0x3f, u8 | |0x30-0x3f, u8 | ||
|Set IO2[X] to Q, where IO2 is the IO array for channel N. | |Set IO2[X] to Q, where IO2 is the IO array for channel N. | ||
− | |||
|- | |- | ||
!chan_disablechannel | !chan_disablechannel | ||
Line 725: | Line 634: | ||
|0x20-0x2f | |0x20-0x2f | ||
|Disable channel N for the parent sequence. | |Disable channel N for the parent sequence. | ||
− | |||
|- | |- | ||
!chan_startchannel | !chan_startchannel | ||
Line 733: | Line 641: | ||
|0x10-0x1f, addr | |0x10-0x1f, addr | ||
|Start channel N for the parent sequence, with channel script starting at address X. | |Start channel N for the parent sequence, with channel script starting at address X. | ||
− | |||
|- | |- | ||
!chan_testlayerfinished | !chan_testlayerfinished | ||
Line 741: | Line 648: | ||
|0x00-0x0f | |0x00-0x0f | ||
|Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). | |Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). | ||
− | |||
|} | |} | ||
Line 754: | Line 660: | ||
!Bytecode (US) | !Bytecode (US) | ||
!Description | !Description | ||
− | |||
|- | |- | ||
!layer_end | !layer_end | ||
Line 763: | Line 668: | ||
|0xff | |0xff | ||
|End of script, loop or function | |End of script, loop or function | ||
− | |||
|- | |- | ||
!layer_call | !layer_call | ||
Line 772: | Line 676: | ||
|0xfc, addr | |0xfc, addr | ||
|Call a function | |Call a function | ||
− | |||
|- | |- | ||
!layer_jump | !layer_jump | ||
Line 781: | Line 684: | ||
|0xfb, addr | |0xfb, addr | ||
|Jump to a point in the layer script | |Jump to a point in the layer script | ||
− | |||
|- | |- | ||
!layer_loop | !layer_loop | ||
Line 790: | Line 692: | ||
|0xf8, u8 | |0xf8, u8 | ||
|Repeat until <code>loopend</code> for X iterations (256 if X = 0) | |Repeat until <code>loopend</code> for X iterations (256 if X = 0) | ||
− | |||
|- | |- | ||
!layer_loopend | !layer_loopend | ||
Line 799: | Line 700: | ||
|0xf7 | |0xf7 | ||
|Loop end marker | |Loop end marker | ||
− | |||
|- | |- | ||
!layer_setshortnotedurationfromtable | !layer_setshortnotedurationfromtable | ||
Line 808: | Line 708: | ||
|0xe0-0xef | |0xe0-0xef | ||
|Set the duration for future short notes to table[N], where table defaults to <code>{229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0}</code> and can be set by <code>setshortnotedurationtable</code>. | |Set the duration for future short notes to table[N], where table defaults to <code>{229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0}</code> and can be set by <code>setshortnotedurationtable</code>. | ||
− | |||
|- | |- | ||
!layer_setshortnotevelocityfromtable | !layer_setshortnotevelocityfromtable | ||
Line 817: | Line 716: | ||
|0xd0-0xdf | |0xd0-0xdf | ||
|Set the velocity for future short notes to table[N], where table defaults to <code>{12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127}</code> and can be set by <code>setshortnotevelocitytable</code>. | |Set the velocity for future short notes to table[N], where table defaults to <code>{12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127}</code> and can be set by <code>setshortnotevelocitytable</code>. | ||
− | |||
|- | |- | ||
!layer_setpan | !layer_setpan | ||
Line 826: | Line 724: | ||
|0xca, u8 | |0xca, u8 | ||
|Set the pan for this layer (0…128). | |Set the pan for this layer (0…128). | ||
− | |||
|- | |- | ||
!layer_setshortnoteduration | !layer_setshortnoteduration | ||
Line 835: | Line 732: | ||
|0xc9, u8 | |0xc9, u8 | ||
|Set the duration for future short notes. | |Set the duration for future short notes. | ||
− | |||
|- | |- | ||
!layer_disableportamento | !layer_disableportamento | ||
Line 844: | Line 740: | ||
|0xc8 | |0xc8 | ||
|Disable portamento for later notes. | |Disable portamento for later notes. | ||
− | |||
|- | |- | ||
!layer_portamento | !layer_portamento | ||
Line 853: | Line 748: | ||
|0xc7, u8, u8, u8/var | |0xc7, u8, u8, u8/var | ||
|Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | |Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | ||
− | |||
|- | |- | ||
!layer_setinstr | !layer_setinstr | ||
Line 862: | Line 756: | ||
|0xc6, u8 | |0xc6, u8 | ||
|Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | |Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | ||
− | |||
|- | |- | ||
!layer_somethingoff | !layer_somethingoff | ||
Line 871: | Line 764: | ||
|0xc5 | |0xc5 | ||
|Turn off some bool related to how notes decay somehow? (This is the default.) | |Turn off some bool related to how notes decay somehow? (This is the default.) | ||
− | |||
|- | |- | ||
!layer_somethingon | !layer_somethingon | ||
Line 880: | Line 772: | ||
|0xc4 | |0xc4 | ||
|Turn on the same thing. | |Turn on the same thing. | ||
− | |||
|- | |- | ||
!layer_setshortnotedefaultplaypercentage | !layer_setshortnotedefaultplaypercentage | ||
Line 889: | Line 780: | ||
|0xc3, var | |0xc3, var | ||
|Set the default play percentage for short notes (see below). | |Set the default play percentage for short notes (see below). | ||
− | |||
|- | |- | ||
!layer_transpose | !layer_transpose | ||
Line 898: | Line 788: | ||
|0xc2, u8 | |0xc2, u8 | ||
|Set transposition in semitones. | |Set transposition in semitones. | ||
− | |||
|- | |- | ||
!layer_setshortnotevelocity | !layer_setshortnotevelocity | ||
Line 907: | Line 796: | ||
|0xc1, u8 | |0xc1, u8 | ||
|Set velocity for future short notes. | |Set velocity for future short notes. | ||
− | |||
|- | |- | ||
!layer_delay | !layer_delay | ||
Line 916: | Line 804: | ||
|0xc0, var | |0xc0, var | ||
|Delay for N ticks | |Delay for N ticks | ||
− | |||
|- | |- | ||
!layer_note0 | !layer_note0 | ||
Line 925: | Line 812: | ||
|0x00-0x3f, var, u8, u8 | |0x00-0x3f, var, u8, u8 | ||
|Play note with play percentage X, velocity Y, duration Z and pitch N. (Is “play percentage” the right term?). Only valid if channel is set to “large notes”. | |Play note with play percentage X, velocity Y, duration Z and pitch N. (Is “play percentage” the right term?). Only valid if channel is set to “large notes”. | ||
− | |||
|- | |- | ||
!layer_note1 | !layer_note1 | ||
Line 934: | Line 820: | ||
|0x40-0x7f, var, u8 | |0x40-0x7f, var, u8 | ||
|Play note with play percentage X, velocity Y, duration 0 and pitch N. Only valid if channel is set to “large notes”. | |Play note with play percentage X, velocity Y, duration 0 and pitch N. Only valid if channel is set to “large notes”. | ||
− | |||
|- | |- | ||
!layer_note2 | !layer_note2 | ||
Line 943: | Line 828: | ||
|0x80-0xbf, u8, u8 | |0x80-0xbf, u8, u8 | ||
|Play note with velocity X, duration Y, pitch N and the last used play percentage. Only valid if channel is set to “large notes”. | |Play note with velocity X, duration Y, pitch N and the last used play percentage. Only valid if channel is set to “large notes”. | ||
− | |||
|- | |- | ||
!layer_smallnote0 | !layer_smallnote0 | ||
Line 952: | Line 836: | ||
|0x00-0x3f, var | |0x00-0x3f, var | ||
|Play note with play percentage X and pitch N, with velocity and duration taken from the short notes settings set by setshortnote{velocity,duration} (or the fromtable variants), defaulting to 0 and 0x80 respectively if not set. Only valid if channel is set to “small notes”. | |Play note with play percentage X and pitch N, with velocity and duration taken from the short notes settings set by setshortnote{velocity,duration} (or the fromtable variants), defaulting to 0 and 0x80 respectively if not set. Only valid if channel is set to “small notes”. | ||
− | |||
|- | |- | ||
!layer_smallnote1 | !layer_smallnote1 | ||
Line 961: | Line 844: | ||
|0x40-0x7f | |0x40-0x7f | ||
|Play note with pitch N and the default play percentage, as set by setshortnotedefaultplaypercentage (there is no built-in default; using it without that command will read uninitialized memory). Velocity and duration is set like in smallnote0. Only valid if channel is set to “small notes”. | |Play note with pitch N and the default play percentage, as set by setshortnotedefaultplaypercentage (there is no built-in default; using it without that command will read uninitialized memory). Velocity and duration is set like in smallnote0. Only valid if channel is set to “small notes”. | ||
− | |||
|- | |- | ||
!layer_smallnote2 | !layer_smallnote2 | ||
Line 970: | Line 852: | ||
|0x80-0xbf | |0x80-0xbf | ||
|Play note with pitch N and the previous play percentage. Velocity and duration is set like in smallnote0. Only valid if channel is set to “small notes”. | |Play note with pitch N and the previous play percentage. Velocity and duration is set like in smallnote0. Only valid if channel is set to “small notes”. | ||
− | |||
|} | |} | ||
Revision as of 00:10, 8 November 2020
dasdasdasdMusic in Super Mario 64 is controlled by sequence files. They are in .m64 format, which is similar to MIDI. A sequence file has a sequence script, that can spawn channels, which have channel scripts, that can spawn layers (also known as tracks), which have layer scripts that can play notes. Each note is performed using an instrument from a sound bank. A sequence file can use multiple banks. The mapping from sequences to sound banks is described in sound/sequences.json. Channels can switch between banks using a command. However, in practice most sequences limit themselves to a single sound bank. The main exception is sequence 0, which is responsible for sound effects.
A sequence may play up to 16 channels with up to 4 layers per channel.
Create sequences
There are several ways for creating new sequence files.
Seq64
Seq64 is a GUI program for editing sequence files for Super Mario 64 and other Nintendo games. It also features full MIDI importing and exporting.
https://github.com/sauraen/seq64
Manually
Sequence files can also be created manually in a textual format. Create a new assembly file in the sequences directory, for example sound/sequences/us/23_custom_sequence.s. This file should begin with the following header:
.include "seq_macros.inc"
.section .rodata
.align 0
Next you can write down a series of commands. See include/seq_macros.inc or https://hackmd.io/opEB-OmxRa26P8h8pA-x7w for a list of available commands.
Commands
Sequence commands
Mnemonic | Param 1 | Param 2 | Bytecode (US) | Description |
---|---|---|---|---|
seq_end | 0xff | End of script, loop or function | ||
seq_delay1 | 0xfe | Delay for 1 tick | ||
seq_delay | ticks | 0xfd, var | Delay for X ticks | |
seq_call | address | 0xfc, addr | Call a function | |
seq_jump | address | 0xfb, addr | Jump to a point in the sequence script | |
seq_beqz | address | 0xfa, addr | Jump if Q == 0, where Q is an s8 used to hold temporary sequence script state | |
seq_bltz | address | 0xf9, addr | Jump if Q < 0 | |
seq_loop | iterations | 0xf8, u8 | Repeat until loopend for X iterations (256 if X = 0)
| |
seq_loopend | 0xf7 | Loop end marker | ||
seq_bgez | address | 0xf5, addr | Jump if Q >= 0 | |
seq_reservenotes | numNotes | 0xf2, u8 | Reserve X notes for exclusive use by this sequence (dropping earlier reservations). A limited number of notes can be played at once (configurable per level, usually 16); if more than that are played, an existing one will be stopped and reused. This command can prevent that from happening across sequences. | |
seq_unreservenotes | 0xf1 | Drop all earlier reservations made by this sequence. | ||
seq_transpose | semitones | 0xdf, s8 | Set transposition in semitones. | |
seq_transposerel | semitones | 0xde, s8 | Change transposition by some delta. | |
seq_settempo | tempo | 0xdd, u8 | Set tempo in BPM. | |
seq_addtempo | tempo | 0xdc, s8 | Change tempo by some delta. | |
seq_setvol | volume | 0xdb, u8 | Set volume scale (0…255 = none to twice normal). | |
seq_changevol | volume | 0xda, s8 | Change volume scale by some delta. | |
seq_initchannels | channelMask | 0xd7, u16 | Initialize channels (bitmask). This copies mute behavior and note allocation policy. | |
seq_disablechannels | channelMask | 0xd6, u16 | Uninitialize channels (bitmask). | |
seq_setmutescale | mulitplier | 0xd5, s8 | Set volume multiplier for muted mode (0…127). | |
seq_mute | 0xd4 | Set sequence to muted mode. Depending on what behavior has been set this will do different things; from lowering volume to not running scripts. | ||
seq_setmutebhv | bitmask | 0xd3, u8 | Set mute behavior (bitmask). Bit 0x20 lowers volume, bit 0x40 does something to layers, and bit 0x80 pauses the sequence script. Default mute behavior is to have all of those bits set. | |
seq_setshortnotevelocitytable | address | 0xd2, addr | Set velocity table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |
seq_setshortnotedurationtable | address | 0xd1, addr | Set duration table for short notes (see further down). Target should be an array of bytes in the sequence data of length 16. | |
seq_setnoteallocationpolicy | policyMask | 0xd0, u8 | Set note allocation policy (bitmask). If bit 0x1 is set, it will try to steal notes back from what was previously played on the same layer. If bit 0x2 is set, notes will be allocated exclusively from the channel’s reserved notes, else if 0x4 is set, from the channel’s or sequence’s reserved notes, else if 0x8 is set, from unreserved notes, otherwise from all sources. Not used by the game. | |
seq_setval | value | 0xcc, u8 | Set Q to a constant. | |
seq_bitand | value | 0xc9, u8 | Bitand Q by a constant. | |
seq_subtract | value | 0xc8, u8 | Subtract a constant from Q. | |
seq_startchannel | channel | address | 0x90-0x9f, addr | Start channel N, with a given channel script. |
seq_getvariation | 0x80-0x8f | Set Q to the variation bit, which is initially either 0 or 0x80 (i.e. -128, since Q is s8). This bit comes from the sequence load command. For instance, to play the Koopa shell music, the game plays sequence 0x8E, which is the same as sequence 0xE but with the variation bit set. | ||
seq_setvariation | 0x70-0x7f | Set the variation bit to Q. | ||
seq_subvariation | 0x50-0x5f | Subtract the variation bit from Q. | ||
seq_testchdisabled | channel | 0x00-0x0f | Set Q to 1 or 0, depending on whether channel N has been disabled by channel script. |
Channel commands
Mnemonic | Param 1 | Param 2 | Param 3 | Bytecode (US) | Description |
---|---|---|---|---|---|
chan_end | 0xff | End of script, loop or function | |||
chan_delay1 | 0xfe | Delay for 1 tick | |||
chan_delay | ticks | 0xfd, var | Delay for X ticks | ||
chan_call | address | 0xfc, addr | Call a function | ||
chan_jump | address | 0xfb, addr | Jump to a point in the channel script | ||
chan_beqz | address | 0xfa, addr | Jump if Q == 0, where Q is an s8 used to hold temporary channel script state | ||
chan_bltz | address | 0xf9, addr | Jump if Q < 0 | ||
chan_loop | iterations | 0xf8, u8 | Repeat until loopend for X iterations (256 if X = 0)
| ||
chan_loopend | 0xf7 | Loop end marker | |||
chan_break | 0xf6 | Decrease loop/function stack depth by 1. Combine with a jump to break out of a loop. | |||
chan_bgez | address | 0xf5, addr | Jump if Q >= 0 | ||
chan_hang | 0xf3 | Infinite delay. | |||
chan_reservenotes | numNotes | 0xf2, u8 | Reserve X notes for exclusive use by this channel (dropping earlier reservations). | ||
chan_unreservenotes | numNotes | 0xf1 | Drop all earlier reservations made by this channel. | ||
chan_dyncall | 0xe4 | If Q != -1, make a function call to position dyntable[Q], where dyntable is a channel-specific u16 array which can set by setdyntable /dynsetdyntable .
| |||
chan_setvibratodelay | 0xe3, u8 | Set delay until vibrato starts for each note. | |||
chan_setvibratoextentlinear | 0xe2, u8, u8, u8 | Set vibrato extent for each note as a function that starts at X, goes up linearly to Y over a time span given by Z, then stays there. | |||
chan_setvibratoratelinear | 0xe1, u8, u8, u8 | Like above except for vibrato rate. | |||
chan_setvolscale | volume | 0xe0, u8 | Set scale factor for volume (0…255 = none to twice normal). | ||
chan_setvol | volume | 0xdf, u8 | Set scale factor #2 for volume (0…255 = none to twice normal). The two scale factors are separately controlled by outer audio logic, e.g. when changing between rooms, when playing sound effects, etc. The game almost exclusively uses setvol, so that should probably be preferred, but setvolscale shows up in a few locations in the sound effect sequence. | ||
chan_freqscale | value | 0xde, u16 | Pitch bend using a raw frequency multiplier X/2^15. | ||
chan_setpan | pan | 0xdd, u8 | Set the pan for this channel (0…128) | ||
chan_setpanchanweight | 0xdc, u8 | The pan for each note will be computed as W * channel pan + (1 - W) * note pan. This sets W (0…128 maps to 0…1). W defaults to 1.0. | |||
chan_transpose | semitones | 0xdb, s8 | Set transposition in semitones. | ||
chan_setenvelope | address | 0xda, addr | Set ADSR envelope. See below for format. | ||
chan_setdecayrelease | rate | 0xd9, u8 | Set ADSR decay/release rate. | ||
chan_setvibratoextent | extent | 0xd8, u8 | Set vibrato extent. | ||
chan_setvibratorate | rate | 0xd7, u8 | Set vibrato rate. | ||
chan_setupdatesperframe | 0xd6, u8 | Seems like it was meant to set the number of updates per frame? But it doesn’t actually do anything. | |||
chan_setreverb | reverb | 0xd4, u8 | Set amount of reverb (or “dry/wet mix”?). | ||
chan_pitchbend | bend | 0xd3, s8 | Pitch bend by <= 1 octave in either direction (-127…127). | ||
chan_setsustain | volume | 0xd2, u8 | Set ADSR sustain volume. | ||
chan_setnoteallocationpolicy | policyMask | 0xd1, u8 | Set note allocation policy for channel. See the description for sequence scripts. | ||
chan_stereoheadseteffects | enable | 0xd0, u8 | Enable (1) or disable (0) some pan/volume effects related to stereo/headset. I don’t know which ones precisely – pan is still taken into account even with this disabled. With this disabled, stereo/headset gets the same output. | ||
chan_setval | value | 0xcc, u8 | Set Q to a constant. | ||
chan_readseq | address | 0xcb, addr | Set Q to sequenceData[X + Q]. | ||
chan_setmutebhv | 0xca, u8 | Set mute behavior for this channel. | |||
chan_bitand | value | 0xc9, u8 | Bitand Q by a constant. | ||
chan_subtract | value | 0xc8, u8 | Subtract a constant from Q. | ||
chan_writeseq | address | 0xc7, u8, addr | Overwrite the byte at the given position in the sequence script by (Q + X). | ||
chan_setbank | bank | 0xc6, u8 | Switch bank within instrument bank sets, to the X’th bank, 0-indexed, counting from the end. | ||
chan_dynsetdyntable | 0xc5 | If Q != -1, set dyntable to point to position dyntable[Q] in the sequence data. | |||
chan_largenoteson | 0xc4 | Set notes for this channel to use “large notes” format. SM64 does this for all channels. (See note vs. shortnote in the layer section below.)
| |||
chan_largenotesoff | 0xc3 | Set notes for this channel to use “short notes” format. | |||
chan_setdyntable | address | 0xc2, addr | Set dyntable to point to a given u16 array from the sequence data. | ||
chan_setinstr | instrument | 0xc1, u8 | Set instrument (program?) within bank. 0x80-0x83 set raw waves (sawtooth, triangle, sine, square), 0x7f is special, otherwise 0-indexed. | ||
chan_dynsetlayer | 0xb0-0xbf | If Q != -1, start layer N, with layer script given by dyntable[Q]. | |||
chan_freelayer | layer | 0xa0-0xaf | Stop layer N. | ||
chan_setlayer | layer | address | 0x90-0x9f, addr | Start layer N, with layer script starting at address X. | |
chan_ioreadval | 0x80-0x8f | Set Q to IO[N], where IO is an array of bytes that can be read/written by both the game and the channel script. If N < 4, IO[N] is then set to -1. | |||
chan_iowriteval | 0x70-0x7f | Set IO[N] to Q. | |||
chan_setnotepriority | 0x60-0x6f | Set note priority for later notes played on this channel to N. When the game wants to play a note and there aren’t any free notes available, a note with smaller or equal priority is discarded. Should be >= 2; 0 and 1 have internal meaning. Defaults to 3. | |||
chan_ioreadvalsub | 0x50-0x5f | Decrease Q by IO[N]. | |||
chan_ioreadval2 | 0x40-0x4f, u8 | Set Q to IO2[X], where IO2 is the IO array for channel N. | |||
chan_iowriteval2 | 0x30-0x3f, u8 | Set IO2[X] to Q, where IO2 is the IO array for channel N. | |||
chan_disablechannel | channel | 0x20-0x2f | Disable channel N for the parent sequence. | ||
chan_startchannel | channel | address | 0x10-0x1f, addr | Start channel N for the parent sequence, with channel script starting at address X. | |
chan_testlayerfinished | layer | 0x00-0x0f | Set Q to 1 or 0, depending on whether layer N has been disabled (either forcibly or by finishing its script). |
Layer commands
Mnemonic | Param 1 | Param 2 | Param 3 | Param 4 | Bytecode (US) | Description |
---|---|---|---|---|---|---|
layer_end | 0xff | End of script, loop or function | ||||
layer_call | address | 0xfc, addr | Call a function | |||
layer_jump | address | 0xfb, addr | Jump to a point in the layer script | |||
layer_loop | iterations | 0xf8, u8 | Repeat until loopend for X iterations (256 if X = 0)
| |||
layer_loopend | 0xf7 | Loop end marker | ||||
layer_setshortnotedurationfromtable | 0xe0-0xef | Set the duration for future short notes to table[N], where table defaults to {229, 203, 177, 151, 139, 126, 113, 100, 87, 74, 61, 48, 36, 23, 10, 0} and can be set by setshortnotedurationtable .
| ||||
layer_setshortnotevelocityfromtable | 0xd0-0xdf | Set the velocity for future short notes to table[N], where table defaults to {12, 25, 38, 51, 57, 64, 71, 76, 83, 89, 96, 102, 109, 115, 121, 127} and can be set by setshortnotevelocitytable .
| ||||
layer_setpan | pan | 0xca, u8 | Set the pan for this layer (0…128). | |||
layer_setshortnoteduration | duration | 0xc9, u8 | Set the duration for future short notes. | |||
layer_disableportamento | 0xc8 | Disable portamento for later notes. | ||||
layer_portamento | 0xc7, u8, u8, u8/var | Enable portamento (aka glissando; continuously sliding pitch). X describes the mode of operation somehow using its 0x80 bit and a value 0-5 in its lower-order bits. Y describes the target pitch. Z gives the duration, and is a u8 if the 0x80 bit is set, otherwise a var. | ||||
layer_setinstr | instrument | 0xc6, u8 | Set instrument/program. Similar to the channel command, except arguments 0x7f and above are not supported. | |||
layer_somethingoff | 0xc5 | Turn off some bool related to how notes decay somehow? (This is the default.) | ||||
layer_somethingon | 0xc4 | Turn on the same thing. | ||||
layer_setshortnotedefaultplaypercentage | percentage | 0xc3, var | Set the default play percentage for short notes (see below). | |||
layer_transpose | semitones | 0xc2, u8 | Set transposition in semitones. | |||
layer_setshortnotevelocity | velocity | 0xc1, u8 | Set velocity for future short notes. | |||
layer_delay | ticks | 0xc0, var | Delay for N ticks | |||
layer_note0 | pitch | percentage | velocity | duration | 0x00-0x3f, var, u8, u8 | Play note with play percentage X, velocity Y, duration Z and pitch N. (Is “play percentage” the right term?). Only valid if channel is set to “large notes”. |
layer_note1 | pitch | percentage | velocity | 0x40-0x7f, var, u8 | Play note with play percentage X, velocity Y, duration 0 and pitch N. Only valid if channel is set to “large notes”. | |
layer_note2 | velocity | duration | 0x80-0xbf, u8, u8 | Play note with velocity X, duration Y, pitch N and the last used play percentage. Only valid if channel is set to “large notes”. | ||
layer_smallnote0 | pitch | percentage | 0x00-0x3f, var | Play note with play percentage X and pitch N, with velocity and duration taken from the short notes settings set by setshortnote{velocity,duration} (or the fromtable variants), defaulting to 0 and 0x80 respectively if not set. Only valid if channel is set to “small notes”. | ||
layer_smallnote1 | pitch | 0x40-0x7f | Play note with pitch N and the default play percentage, as set by setshortnotedefaultplaypercentage (there is no built-in default; using it without that command will read uninitialized memory). Velocity and duration is set like in smallnote0. Only valid if channel is set to “small notes”. | |||
layer_smallnote2 | pitch | 0x80-0xbf | Play note with pitch N and the previous play percentage. Velocity and duration is set like in smallnote0. Only valid if channel is set to “small notes”. |
See also
- Custom music for SM64 on SMW Central
- m64 format posted on HackMD