superctr/MDSDRV

Macro table

Closed this issue · 0 comments

Since it's annoying to manually insert effects (especially those that alter the state while a note is playing) in MML, a macro table can be used to automatically insert effects while a note is playing.

The macro table could use the same MML command as the pan envelope, alternatively a new event type is added in ctrmml.

The binary format of a macro table is as follows:

commands:
 0x00-0x3f - special commands
 0x40-0x7f - assign variable
 0x80-0xff - delay (frames - 0x7f)

special commands:
 0x00 - end macro table
 0x01 - jump
 0x02 - add to variable
 0x03 - set panning (mask with 0xc0)
 0x04 - set lfo parameters (mask with 0x3f)
 0x05 - write to FM chip common area (fmreg)
 0x06 - write to FM chip, offset to current port/channel (fmcreg)

The variables should map to internal track state, however to preserve backwards-compatibility in future versions, an internal lookup table should be used. The lookup table can also contain a bitmask representing update flags that must be updated.

Macro table should be handled after the instrument update, and before updating volume. Updating instruments through macro tables may not be supported (it would still require extra work in the MML compiler to remap the instruments in each table).

RAM needed (total 4 bytes)

 (w) macro table pointer
 (b) macro table position
 (b) macro table "restart on keyon" flag (bit7)/delay time

the "restart on keyon" flag must be handled by the key on handler (specific for psg/pcm/fm). I will create a macro for this though.

With this I will remove support for LFO delay. This can be implemented using macro table instead.