Track byte code

Sappy 2006

 
Sappy 2006: Track byte code

Track byte code

Wxx (0x80++)
Wait for the specified number of clock ticks
FINE (0xB1)
Musical term. Ends the track.
GOTO, label (0xB2)
Unconditional jump.
PATT, label (0xB3)
Unconditional jump, but remembers where to return. Can be nested up to three times.
PEND (0xB4)
Ends a pattern and returns to it's call source. Ignored if not called from somewhere.
REPT, xx, label (0xB5)
Jumps to the specified label xx times. If xx is zero, it repeats ad infinitum like a GOTO. REPT commands cannot be nested, and cannot be specified in a MIDI sequencer.
PRIO, xx (0xBA)
Sets the priority of the track. xx is from 0 to 255 when directly editing the .s file, 0 to 127 in a MIDI sequencer.
TEMPO, xx/2 (0xBB)
This sets the tempo of the entire song. xx is from 22 to 510.
KEYSH, xx (0xBC)
This modulates the key of the track. xx is from -128 to 127. This command cannot be specified in a MIDI sequencer.

The following commands are in "Running Status" mode. This allows operation from their parameters alone, which is good when a whole lot are seen in sequence, like a pitch bend or volume slide.

VOICE, xx (0xBD)
Selects a patch for this track. xx is from 0 to 127.
VOL, xx (0xBC)
Sets the track volume. xx is from 0 to 127.
PAN, xx (0xBF)
Sets the track's stereo pan position. xx is from -64 to 63, but if it's a CGB instrument, hardware restrictions limit you to just "left", "center" and "right".
BEND, cV + xx (0xC0)
BENDR, xx (0xC1)
LFOS, xx (0xC2)
LFODL, xx (0xC3)
MOD, xx (0xC4)
MODT, xx (0xC5)
TUNE, cV + xx (0xC8)

These are note commands. They can be used seamlessly with Running Status commands because of their bytecodes.

Nxx [, key [, vel]] (0xD0++)
Plays a note. xx is the note length from 00 to 96. 24 is a quarter note, 96 a whole. Key is in the "Cn3" format where the first character is the name of the note ("CDEFGAB"), the second either "n" for a natural or "s" for a sharp and the third the octave. There are also "minus octaves", written like "CnM2" and stuff. Octaves effectively range from M2 to 8. From CnM2 to Gn8 covers all 127 MIDI key numbers. Velocity ranges from 0 to 127, but unlike in MIDI, velocity 0 is not synonimous to "note off".
EOT [, key] (0xCE)
Stops the matching TIE note.
TIE [, key, [, vel]] (0xCF)
This note, which works just like Nxx, continues to sound until the next matching EOT command.