public static void OPL3_ChannelWriteA0(ref opl3_channel channel, byte data) { if (channel.chip.newm != 0 && channel.chtype == ChannelType.ch_4op2) { return; } channel.f_num = (ushort)((channel.f_num & 0x300) | data); channel.ksv = (byte)((channel.block << 1) | ((channel.f_num >> (0x09 - channel.chip.nts)) & 0x01)); OPL3_EnvelopeUpdateKSL(ref channel.slots[0]); OPL3_EnvelopeUpdateKSL(ref channel.slots[1]); if (channel.chip.newm != 0 && channel.chtype == ChannelType.ch_4op) { channel.pair.f_num = channel.f_num; channel.pair.ksv = channel.ksv; OPL3_EnvelopeUpdateKSL(ref channel.pair.slots[0]); OPL3_EnvelopeUpdateKSL(ref channel.pair.slots[1]); } }
public static void OPL3_ChannelWriteC0(ref opl3_channel channel, byte data) { channel.fb = (byte)((data & 0x0e) >> 1); channel.con = (byte)(data & 0x01); channel.alg = channel.con; if ((channel.chip.newm) != 0) { if (channel.chtype == ChannelType.ch_4op) { channel.pair.alg = (byte)(0x04 | (channel.con << 1) | (channel.pair.con)); channel.alg = 0x08; OPL3_ChannelSetupAlg(ref channel.pair); } else if (channel.chtype == ChannelType.ch_4op2) { channel.alg = (byte)(0x04 | (channel.pair.con << 1) | (channel.con)); channel.pair.alg = 0x08; OPL3_ChannelSetupAlg(ref channel); } else { OPL3_ChannelSetupAlg(ref channel); } } else { OPL3_ChannelSetupAlg(ref channel); } if (channel.chip.newm != 0) { channel.cha = (ushort)(((data >> 4) & 0x01) != 0 ? ~0 : 0); channel.chb = (ushort)(((data >> 5) & 0x01) != 0 ? ~0 : 0); } else { channel.cha = channel.chb = unchecked ((ushort)~0); } }
public static void OPL3_ChannelKeyOff(ref opl3_channel channel) { if (channel.chip.newm != 0) { if (channel.chtype == ChannelType.ch_4op) { OPL3_EnvelopeKeyOff(ref channel.slots[0], EnvelopeKeyType.norm); OPL3_EnvelopeKeyOff(ref channel.slots[1], EnvelopeKeyType.norm); OPL3_EnvelopeKeyOff(ref channel.pair.slots[0], EnvelopeKeyType.norm); OPL3_EnvelopeKeyOff(ref channel.pair.slots[1], EnvelopeKeyType.norm); } else if (channel.chtype == ChannelType.ch_2op || channel.chtype == ChannelType.ch_drum) { OPL3_EnvelopeKeyOff(ref channel.slots[0], EnvelopeKeyType.norm); OPL3_EnvelopeKeyOff(ref channel.slots[1], EnvelopeKeyType.norm); } } else { OPL3_EnvelopeKeyOff(ref channel.slots[0], EnvelopeKeyType.norm); OPL3_EnvelopeKeyOff(ref channel.slots[1], EnvelopeKeyType.norm); } }
public static void OPL3_ChannelSetupAlg(ref opl3_channel channel) { unsafe { if (channel.chtype == ChannelType.ch_drum) { if (channel.ch_num == 7 || channel.ch_num == 8) { fixed(short *p = &channel.chip.zeromod) { channel.slots[0].mod = p; channel.slots[1].mod = p; } return; } switch (channel.alg & 0x01) { case 0x00: fixed(short *f = &channel.slots[0].fbmod) { fixed(short *o = &channel.slots[0]._out) { channel.slots[0].mod = f; channel.slots[1].mod = o; } } break; case 0x01: fixed(short *f = &channel.slots[0].fbmod) { fixed(short *o = &channel.chip.zeromod) { channel.slots[0].mod = f; channel.slots[1].mod = o; } } break; } return; } if ((channel.alg & 0x08) != 0) { return; } if ((channel.alg & 0x04) != 0) { channel.pair._out[0] = channel.chip.zeromod; channel.pair._out[1] = channel.chip.zeromod; channel.pair._out[2] = channel.chip.zeromod; channel.pair._out[3] = channel.chip.zeromod; switch (channel.alg & 0x03) { case 0x00: fixed(short *f = &channel.pair.slots[0].fbmod) { fixed(short *o = &channel.pair.slots[0]._out) { channel.pair.slots[0].mod = f; channel.pair.slots[1].mod = o; } } fixed(short *f = &channel.pair.slots[1]._out) { fixed(short *o = &channel.slots[0]._out) { channel.slots[0].mod = f; channel.slots[1].mod = o; } } channel._out[0] = channel.slots[1]._out; channel._out[1] = channel.chip.zeromod; channel._out[2] = channel.chip.zeromod; channel._out[3] = channel.chip.zeromod; break; case 0x01: // channel.pair.slots[0].mod = channel.pair.slots[0].fbmod; // channel.pair.slots[1].mod = channel.pair.slots[0]._out; // channel.slots[0].mod = channel.chip.zeromod; // channel.slots[1].mod = channel.slots[0]._out; // channel._out[0] = channel.pair.slots[1]._out; // channel._out[1] = channel.slots[1]._out; // channel._out[2] = channel.chip.zeromod; // channel._out[3] = channel.chip.zeromod; break; case 0x02: // channel.pair.slots[0].mod = channel.pair.slots[0].fbmod; // channel.pair.slots[1].mod = channel.chip.zeromod; // channel.slots[0].mod = channel.pair.slots[1]._out; // channel.slots[1].mod = channel.slots[0]._out; // channel._out[0] = channel.pair.slots[0]._out; // channel._out[1] = channel.slots[1]._out; // channel._out[2] = channel.chip.zeromod; // channel._out[3] = channel.chip.zeromod; // break; case 0x03: // channel.pair.slots[0].mod = channel.pair.slots[0].fbmod; // channel.pair.slots[1].mod = channel.chip.zeromod; // channel.slots[0].mod = channel.pair.slots[1]._out; // channel.slots[1].mod = channel.chip.zeromod; // channel._out[0] = channel.pair.slots[0]._out; // channel._out[1] = channel.slots[0]._out; // channel._out[2] = channel.slots[1]._out; // channel._out[3] = channel.chip.zeromod; break; } } else { switch (channel.alg & 0x01) { case 0x00: fixed(short *f = &channel.slots[0].fbmod) { fixed(short *o = &channel.slots[0]._out) { channel.slots[0].mod = f; channel.slots[1].mod = o; } } channel._out[0] = channel.slots[1]._out; channel._out[1] = channel.chip.zeromod; channel._out[2] = channel.chip.zeromod; channel._out[3] = channel.chip.zeromod; break; case 0x01: //channel.slots[0].mod = channel.slots[0].fbmod; //channel.slots[1].mod = channel.chip.zeromod; channel._out[0] = channel.slots[0]._out; channel._out[1] = channel.slots[1]._out; channel._out[2] = channel.chip.zeromod; channel._out[3] = channel.chip.zeromod; break; } } } }