2022-02-15 03:12:20 +00:00
|
|
|
/**
|
|
|
|
* Furnace Tracker - multi-system chiptune tracker
|
|
|
|
* Copyright (C) 2021-2022 tildearrow and contributors
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*/
|
|
|
|
|
2021-05-16 22:43:10 +00:00
|
|
|
#include "genesisext.h"
|
2021-05-18 21:02:49 +00:00
|
|
|
#include "../engine.h"
|
2021-05-16 22:43:10 +00:00
|
|
|
#include <math.h>
|
|
|
|
|
2021-05-18 21:02:49 +00:00
|
|
|
#include "genesisshared.h"
|
|
|
|
|
2022-01-28 05:55:51 +00:00
|
|
|
#define CHIP_FREQBASE 9440540
|
|
|
|
|
2021-05-16 22:43:10 +00:00
|
|
|
int DivPlatformGenesisExt::dispatch(DivCommand c) {
|
|
|
|
if (c.chan<2) {
|
|
|
|
return DivPlatformGenesis::dispatch(c);
|
|
|
|
}
|
|
|
|
if (c.chan>5) {
|
|
|
|
c.chan-=3;
|
|
|
|
return DivPlatformGenesis::dispatch(c);
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
int ch=c.chan-2;
|
|
|
|
int ordch=orderedOps[ch];
|
2021-05-16 22:43:10 +00:00
|
|
|
switch (c.cmd) {
|
2021-05-18 21:02:49 +00:00
|
|
|
case DIV_CMD_NOTE_ON: {
|
2022-04-21 07:24:06 +00:00
|
|
|
DivInstrument* ins=parent->getIns(opChan[ch].ins,DIV_INS_FM);
|
2022-01-22 22:43:57 +00:00
|
|
|
|
|
|
|
if (opChan[ch].insChanged) {
|
|
|
|
chan[2].state.alg=ins->fm.alg;
|
|
|
|
chan[2].state.fb=ins->fm.fb;
|
2022-01-22 23:06:18 +00:00
|
|
|
chan[2].state.fms=ins->fm.fms;
|
2022-01-22 22:43:57 +00:00
|
|
|
chan[2].state.ams=ins->fm.ams;
|
|
|
|
chan[2].state.op[ordch]=ins->fm.op[ordch];
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
|
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[ordch];
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator& op=chan[2].state.op[ordch];
|
2022-02-03 21:17:30 +00:00
|
|
|
// TODO: how does this work?!
|
2021-12-18 08:25:42 +00:00
|
|
|
if (isOpMuted[ch]) {
|
|
|
|
rWrite(baseAddr+0x40,127);
|
2021-05-18 21:02:49 +00:00
|
|
|
} else {
|
|
|
|
if (opChan[ch].insChanged) {
|
2022-02-03 21:17:30 +00:00
|
|
|
rWrite(baseAddr+0x40,127-(((127-op.tl)*(opChan[ch].vol&0x7f))/127));
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
if (opChan[ch].insChanged) {
|
|
|
|
rWrite(baseAddr+0x30,(op.mult&15)|(dtTable[op.dt&7]<<4));
|
|
|
|
rWrite(baseAddr+0x50,(op.ar&31)|(op.rs<<6));
|
|
|
|
rWrite(baseAddr+0x60,(op.dr&31)|(op.am<<7));
|
|
|
|
rWrite(baseAddr+0x70,op.d2r&31);
|
|
|
|
rWrite(baseAddr+0x80,(op.rr&15)|(op.sl<<4));
|
|
|
|
rWrite(baseAddr+0x90,op.ssgEnv&15);
|
|
|
|
}
|
|
|
|
if (opChan[ch].insChanged) { // TODO how does this work?
|
2022-01-22 22:43:57 +00:00
|
|
|
rWrite(chanOffs[2]+0xb0,(chan[2].state.alg&7)|(chan[2].state.fb<<3));
|
|
|
|
rWrite(chanOffs[2]+0xb4,(opChan[ch].pan<<6)|(chan[2].state.fms&7)|((chan[2].state.ams&3)<<4));
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
opChan[ch].insChanged=false;
|
|
|
|
|
2022-01-19 05:01:34 +00:00
|
|
|
if (c.value!=DIV_NOTE_NULL) {
|
2022-04-22 09:23:52 +00:00
|
|
|
opChan[ch].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
|
2022-03-30 04:58:50 +00:00
|
|
|
opChan[ch].portaPause=false;
|
2022-01-19 05:01:34 +00:00
|
|
|
opChan[ch].freqChanged=true;
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
opChan[ch].keyOn=true;
|
|
|
|
opChan[ch].active=true;
|
2021-05-16 22:43:10 +00:00
|
|
|
break;
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
2021-05-16 22:43:10 +00:00
|
|
|
case DIV_CMD_NOTE_OFF:
|
2021-05-18 21:02:49 +00:00
|
|
|
opChan[ch].keyOff=true;
|
2022-02-21 02:39:14 +00:00
|
|
|
opChan[ch].keyOn=false;
|
2021-05-18 21:02:49 +00:00
|
|
|
opChan[ch].active=false;
|
|
|
|
break;
|
|
|
|
case DIV_CMD_VOLUME: {
|
|
|
|
opChan[ch].vol=c.value;
|
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[ordch];
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator& op=chan[2].state.op[ordch];
|
2021-12-18 08:25:42 +00:00
|
|
|
if (isOpMuted[ch]) {
|
|
|
|
rWrite(baseAddr+0x40,127);
|
2021-05-18 21:02:49 +00:00
|
|
|
} else {
|
2022-01-18 22:18:07 +00:00
|
|
|
rWrite(baseAddr+0x40,127-(((127-op.tl)*(opChan[ch].vol&0x7f))/127));
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DIV_CMD_GET_VOLUME: {
|
|
|
|
return opChan[ch].vol;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DIV_CMD_INSTRUMENT:
|
2022-01-17 23:01:40 +00:00
|
|
|
if (opChan[ch].ins!=c.value || c.value2==1) {
|
2021-05-18 21:02:49 +00:00
|
|
|
opChan[ch].insChanged=true;
|
|
|
|
}
|
|
|
|
opChan[ch].ins=c.value;
|
|
|
|
break;
|
|
|
|
case DIV_CMD_PANNING: {
|
2022-03-06 19:39:20 +00:00
|
|
|
if (c.value==0) {
|
|
|
|
opChan[ch].pan=3;
|
|
|
|
} else {
|
|
|
|
opChan[ch].pan=((c.value&15)>0)|(((c.value>>4)>0)<<1);
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
2022-04-07 06:14:34 +00:00
|
|
|
if (parent->song.sharedExtStat) {
|
|
|
|
for (int i=0; i<4; i++) {
|
|
|
|
if (ch==i) continue;
|
|
|
|
opChan[i].pan=opChan[ch].pan;
|
|
|
|
}
|
|
|
|
}
|
2022-01-22 22:43:57 +00:00
|
|
|
rWrite(chanOffs[2]+0xb4,(opChan[ch].pan<<6)|(chan[2].state.fms&7)|((chan[2].state.ams&3)<<4));
|
2021-05-18 21:02:49 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DIV_CMD_PITCH: {
|
|
|
|
opChan[ch].pitch=c.value;
|
|
|
|
opChan[ch].freqChanged=true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DIV_CMD_NOTE_PORTA: {
|
2022-04-22 09:23:52 +00:00
|
|
|
int destFreq=NOTE_FNUM_BLOCK(c.value2,11);
|
2021-05-19 19:39:39 +00:00
|
|
|
int newFreq;
|
2021-05-18 21:02:49 +00:00
|
|
|
bool return2=false;
|
2022-04-23 21:52:31 +00:00
|
|
|
if (opChan[ch].portaPause) {
|
|
|
|
opChan[ch].baseFreq=opChan[ch].portaPauseFreq;
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
if (destFreq>opChan[ch].baseFreq) {
|
2022-04-22 09:23:52 +00:00
|
|
|
newFreq=opChan[ch].baseFreq+c.value;
|
2021-05-19 19:39:39 +00:00
|
|
|
if (newFreq>=destFreq) {
|
|
|
|
newFreq=destFreq;
|
2021-05-18 21:02:49 +00:00
|
|
|
return2=true;
|
|
|
|
}
|
|
|
|
} else {
|
2022-04-22 09:23:52 +00:00
|
|
|
newFreq=opChan[ch].baseFreq-c.value;
|
2021-05-19 19:39:39 +00:00
|
|
|
if (newFreq<=destFreq) {
|
|
|
|
newFreq=destFreq;
|
2021-05-18 21:02:49 +00:00
|
|
|
return2=true;
|
|
|
|
}
|
|
|
|
}
|
2022-04-22 21:46:24 +00:00
|
|
|
// what the heck!
|
2021-05-19 19:39:39 +00:00
|
|
|
if (!opChan[ch].portaPause) {
|
2022-04-22 09:23:52 +00:00
|
|
|
if ((newFreq&0x7ff)>1288) {
|
2022-04-23 21:52:31 +00:00
|
|
|
opChan[ch].portaPauseFreq=(644)|((newFreq+0x800)&0xf800);
|
2022-04-22 09:23:52 +00:00
|
|
|
opChan[ch].portaPause=true;
|
2022-04-23 21:52:31 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if ((newFreq&0x7ff)<644) {
|
|
|
|
opChan[ch].portaPauseFreq=newFreq=(1287)|((newFreq-0x800)&0xf800);
|
2021-05-19 19:39:39 +00:00
|
|
|
opChan[ch].portaPause=true;
|
2022-04-23 21:52:31 +00:00
|
|
|
break;
|
2021-05-19 19:39:39 +00:00
|
|
|
}
|
|
|
|
}
|
2022-04-23 21:52:31 +00:00
|
|
|
opChan[ch].portaPause=false;
|
|
|
|
opChan[ch].freqChanged=true;
|
2021-05-19 19:39:39 +00:00
|
|
|
opChan[ch].baseFreq=newFreq;
|
2021-05-18 21:02:49 +00:00
|
|
|
if (return2) return 2;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case DIV_CMD_SAMPLE_MODE: {
|
2022-04-13 05:34:00 +00:00
|
|
|
// not ignored actually!
|
|
|
|
if (!parent->song.ignoreDACModeOutsideIntendedChannel) {
|
|
|
|
dacMode=c.value;
|
|
|
|
rWrite(0x2b,c.value<<7);
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
break;
|
|
|
|
}
|
2022-04-13 05:34:00 +00:00
|
|
|
case DIV_CMD_SAMPLE_BANK:
|
|
|
|
if (!parent->song.ignoreDACModeOutsideIntendedChannel) {
|
|
|
|
sampleBank=c.value;
|
|
|
|
if (sampleBank>(parent->song.sample.size()/12)) {
|
|
|
|
sampleBank=parent->song.sample.size()/12;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2021-05-18 21:02:49 +00:00
|
|
|
case DIV_CMD_LEGATO: {
|
2022-04-22 09:23:52 +00:00
|
|
|
opChan[ch].baseFreq=NOTE_FNUM_BLOCK(c.value,11);
|
2021-05-18 21:02:49 +00:00
|
|
|
opChan[ch].freqChanged=true;
|
|
|
|
break;
|
|
|
|
}
|
2022-03-30 05:09:53 +00:00
|
|
|
case DIV_CMD_FM_LFO: {
|
|
|
|
lfoValue=(c.value&7)|((c.value>>4)<<3);
|
|
|
|
rWrite(0x22,lfoValue);
|
|
|
|
break;
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
case DIV_CMD_FM_MULT: { // TODO
|
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[orderedOps[c.value]];
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator& op=chan[2].state.op[orderedOps[c.value]];
|
|
|
|
op.mult=c.value2&15;
|
|
|
|
rWrite(baseAddr+0x30,(op.mult&15)|(dtTable[op.dt&7]<<4));
|
2021-05-16 22:43:10 +00:00
|
|
|
break;
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
case DIV_CMD_FM_TL: { // TODO
|
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[orderedOps[c.value]];
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator& op=chan[2].state.op[orderedOps[c.value]];
|
|
|
|
op.tl=c.value2;
|
2022-04-03 07:28:46 +00:00
|
|
|
if (isOpMuted[ch]) {
|
|
|
|
rWrite(baseAddr+0x40,127);
|
|
|
|
} else if (isOutput[chan[2].state.alg][c.value]) {
|
2022-01-22 22:43:57 +00:00
|
|
|
rWrite(baseAddr+0x40,127-(((127-op.tl)*(opChan[ch].vol&0x7f))/127));
|
2021-05-18 21:02:49 +00:00
|
|
|
} else {
|
2022-01-22 22:43:57 +00:00
|
|
|
rWrite(baseAddr+0x40,op.tl);
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
2021-05-16 22:43:10 +00:00
|
|
|
break;
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
case DIV_CMD_FM_AR: {
|
|
|
|
if (c.value<0) {
|
|
|
|
for (int i=0; i<4; i++) {
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator& op=chan[2].state.op[i];
|
|
|
|
op.ar=c.value2&31;
|
2021-05-18 21:02:49 +00:00
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[i];
|
2022-01-22 22:43:57 +00:00
|
|
|
rWrite(baseAddr+0x50,(op.ar&31)|(op.rs<<6));
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
} else {
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator& op=chan[2].state.op[orderedOps[c.value]];
|
|
|
|
op.ar=c.value2&31;
|
2021-05-18 21:02:49 +00:00
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[orderedOps[c.value]];
|
2022-01-22 22:43:57 +00:00
|
|
|
rWrite(baseAddr+0x50,(op.ar&31)|(op.rs<<6));
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2021-05-17 20:06:11 +00:00
|
|
|
case DIV_CMD_GET_VOLMAX:
|
|
|
|
return 127;
|
|
|
|
break;
|
2021-05-28 05:36:25 +00:00
|
|
|
case DIV_ALWAYS_SET_VOLUME:
|
|
|
|
return 0;
|
|
|
|
break;
|
2021-05-18 21:02:49 +00:00
|
|
|
case DIV_CMD_PRE_PORTA:
|
|
|
|
break;
|
2021-05-16 22:43:10 +00:00
|
|
|
default:
|
2021-12-06 08:26:33 +00:00
|
|
|
//printf("WARNING: unimplemented command %d\n",c.cmd);
|
2021-05-16 22:43:10 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2021-12-18 08:25:42 +00:00
|
|
|
void DivPlatformGenesisExt::muteChannel(int ch, bool mute) {
|
|
|
|
if (ch<2) {
|
|
|
|
DivPlatformGenesis::muteChannel(ch,mute);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (ch>5) {
|
|
|
|
DivPlatformGenesis::muteChannel(ch-3,mute);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
isOpMuted[ch-2]=mute;
|
|
|
|
|
2021-12-27 21:47:37 +00:00
|
|
|
int ordch=orderedOps[ch-2];
|
2021-12-18 08:25:42 +00:00
|
|
|
unsigned short baseAddr=chanOffs[2]|opOffs[ordch];
|
2022-01-22 22:43:57 +00:00
|
|
|
DivInstrumentFM::Operator op=chan[2].state.op[ordch];
|
2022-02-02 07:46:29 +00:00
|
|
|
if (isOpMuted[ch-2]) {
|
2021-12-18 08:25:42 +00:00
|
|
|
rWrite(baseAddr+0x40,127);
|
2022-02-02 07:46:29 +00:00
|
|
|
immWrite(baseAddr+0x40,127);
|
2022-01-22 22:43:57 +00:00
|
|
|
} else if (isOutput[chan[2].state.alg][ordch]) {
|
2022-02-02 07:46:29 +00:00
|
|
|
rWrite(baseAddr+0x40,127-(((127-op.tl)*(opChan[ch-2].vol&0x7f))/127));
|
|
|
|
immWrite(baseAddr+0x40,127-(((127-op.tl)*(opChan[ch-2].vol&0x7f))/127));
|
2021-12-18 08:25:42 +00:00
|
|
|
} else {
|
|
|
|
rWrite(baseAddr+0x40,op.tl);
|
2022-02-02 07:46:29 +00:00
|
|
|
immWrite(baseAddr+0x40,op.tl);
|
2021-12-18 08:25:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-18 21:02:49 +00:00
|
|
|
static int opChanOffsL[4]={
|
|
|
|
0xa9, 0xaa, 0xa8, 0xa2
|
|
|
|
};
|
|
|
|
|
|
|
|
static int opChanOffsH[4]={
|
|
|
|
0xad, 0xae, 0xac, 0xa6
|
|
|
|
};
|
|
|
|
|
2022-04-15 20:01:11 +00:00
|
|
|
void DivPlatformGenesisExt::tick(bool sysTick) {
|
2021-05-18 21:02:49 +00:00
|
|
|
if (extMode) {
|
|
|
|
bool writeSomething=false;
|
|
|
|
unsigned char writeMask=2;
|
|
|
|
for (int i=0; i<4; i++) {
|
|
|
|
writeMask|=opChan[i].active<<(4+i);
|
|
|
|
if (opChan[i].keyOn || opChan[i].keyOff) {
|
|
|
|
writeSomething=true;
|
|
|
|
writeMask&=~(1<<(4+i));
|
|
|
|
opChan[i].keyOff=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (writeSomething) {
|
2021-12-21 06:29:07 +00:00
|
|
|
immWrite(0x28,writeMask);
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-04-15 20:01:11 +00:00
|
|
|
DivPlatformGenesis::tick(sysTick);
|
2021-05-18 21:02:49 +00:00
|
|
|
|
|
|
|
bool writeNoteOn=false;
|
|
|
|
unsigned char writeMask=2;
|
|
|
|
if (extMode) for (int i=0; i<4; i++) {
|
|
|
|
if (opChan[i].freqChanged) {
|
2022-04-22 22:42:42 +00:00
|
|
|
opChan[i].freq=(opChan[i].baseFreq&0xf800)|parent->calcFreq(opChan[i].baseFreq&0x7ff,opChan[i].pitch,false,4);
|
2022-04-22 09:23:52 +00:00
|
|
|
if (chan[i].freq>65535) chan[i].freq=65535;
|
|
|
|
immWrite(opChanOffsH[i],opChan[i].freq>>8);
|
|
|
|
immWrite(opChanOffsL[i],opChan[i].freq&0xff);
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
|
|
|
writeMask|=opChan[i].active<<(4+i);
|
|
|
|
if (opChan[i].keyOn) {
|
|
|
|
writeNoteOn=true;
|
|
|
|
writeMask|=1<<(4+i);
|
|
|
|
opChan[i].keyOn=false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (writeNoteOn) {
|
2021-12-21 06:29:07 +00:00
|
|
|
immWrite(0x28,writeMask);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void DivPlatformGenesisExt::forceIns() {
|
2022-04-03 07:28:46 +00:00
|
|
|
for (int i=0; i<6; i++) {
|
|
|
|
for (int j=0; j<4; j++) {
|
|
|
|
unsigned short baseAddr=chanOffs[i]|opOffs[j];
|
|
|
|
DivInstrumentFM::Operator& op=chan[i].state.op[j];
|
|
|
|
if (i==2) { // extended channel
|
|
|
|
if (isOpMuted[j]) {
|
|
|
|
rWrite(baseAddr+0x40,127);
|
|
|
|
} else if (isOutput[chan[i].state.alg][j]) {
|
|
|
|
rWrite(baseAddr+0x40,127-(((127-op.tl)*(opChan[j].vol&0x7f))/127));
|
|
|
|
} else {
|
|
|
|
rWrite(baseAddr+0x40,op.tl);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (isMuted[i]) {
|
|
|
|
rWrite(baseAddr+ADDR_TL,127);
|
|
|
|
} else {
|
|
|
|
if (isOutput[chan[i].state.alg][j]) {
|
|
|
|
rWrite(baseAddr+ADDR_TL,127-(((127-op.tl)*(chan[i].outVol&0x7f))/127));
|
|
|
|
} else {
|
|
|
|
rWrite(baseAddr+ADDR_TL,op.tl);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
rWrite(baseAddr+ADDR_MULT_DT,(op.mult&15)|(dtTable[op.dt&7]<<4));
|
|
|
|
rWrite(baseAddr+ADDR_RS_AR,(op.ar&31)|(op.rs<<6));
|
|
|
|
rWrite(baseAddr+ADDR_AM_DR,(op.dr&31)|(op.am<<7));
|
|
|
|
rWrite(baseAddr+ADDR_DT2_D2R,op.d2r&31);
|
|
|
|
rWrite(baseAddr+ADDR_SL_RR,(op.rr&15)|(op.sl<<4));
|
|
|
|
rWrite(baseAddr+ADDR_SSG,op.ssgEnv&15);
|
|
|
|
}
|
|
|
|
rWrite(chanOffs[i]+ADDR_FB_ALG,(chan[i].state.alg&7)|(chan[i].state.fb<<3));
|
|
|
|
rWrite(chanOffs[i]+ADDR_LRAF,(isMuted[i]?0:(chan[i].pan<<6))|(chan[i].state.fms&7)|((chan[i].state.ams&3)<<4));
|
|
|
|
if (chan[i].active) {
|
|
|
|
chan[i].keyOn=true;
|
|
|
|
chan[i].freqChanged=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (dacMode) {
|
|
|
|
rWrite(0x2b,0x80);
|
|
|
|
}
|
|
|
|
immWrite(0x22,lfoValue);
|
2021-12-21 06:29:07 +00:00
|
|
|
for (int i=0; i<4; i++) {
|
|
|
|
opChan[i].insChanged=true;
|
2022-02-21 02:39:14 +00:00
|
|
|
if (opChan[i].active) {
|
|
|
|
opChan[i].keyOn=true;
|
|
|
|
opChan[i].freqChanged=true;
|
|
|
|
}
|
2021-05-18 21:02:49 +00:00
|
|
|
}
|
2021-05-16 22:43:10 +00:00
|
|
|
}
|
2021-05-17 01:49:54 +00:00
|
|
|
|
2022-01-27 05:29:16 +00:00
|
|
|
void* DivPlatformGenesisExt::getChanState(int ch) {
|
|
|
|
if (ch>=6) return &chan[ch-3];
|
|
|
|
if (ch>=2) return &opChan[ch-2];
|
|
|
|
return &chan[ch];
|
|
|
|
}
|
|
|
|
|
2021-12-11 18:14:38 +00:00
|
|
|
void DivPlatformGenesisExt::reset() {
|
|
|
|
DivPlatformGenesis::reset();
|
2021-05-17 01:49:54 +00:00
|
|
|
|
2021-05-18 21:02:49 +00:00
|
|
|
for (int i=0; i<4; i++) {
|
2021-12-11 18:14:38 +00:00
|
|
|
opChan[i]=DivPlatformGenesisExt::OpChannel();
|
2021-05-18 21:02:49 +00:00
|
|
|
opChan[i].vol=127;
|
|
|
|
}
|
|
|
|
|
|
|
|
// channel 3 mode
|
2021-12-21 06:29:07 +00:00
|
|
|
immWrite(0x27,0x40);
|
2021-05-17 01:49:54 +00:00
|
|
|
extMode=true;
|
2021-12-11 18:14:38 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
bool DivPlatformGenesisExt::keyOffAffectsArp(int ch) {
|
|
|
|
return (ch>8);
|
|
|
|
}
|
|
|
|
|
2021-12-29 07:08:50 +00:00
|
|
|
bool DivPlatformGenesisExt::keyOffAffectsPorta(int ch) {
|
|
|
|
return (ch>8);
|
|
|
|
}
|
|
|
|
|
2022-01-18 04:59:52 +00:00
|
|
|
void DivPlatformGenesisExt::notifyInsChange(int ins) {
|
|
|
|
DivPlatformGenesis::notifyInsChange(ins);
|
|
|
|
for (int i=0; i<4; i++) {
|
|
|
|
if (opChan[i].ins==ins) {
|
|
|
|
opChan[i].insChanged=true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-01-30 20:55:31 +00:00
|
|
|
int DivPlatformGenesisExt::getPortaFloor(int ch) {
|
|
|
|
return (ch>8)?12:0;
|
|
|
|
}
|
|
|
|
|
2022-01-28 17:59:53 +00:00
|
|
|
int DivPlatformGenesisExt::init(DivEngine* parent, int channels, int sugRate, unsigned int flags) {
|
|
|
|
DivPlatformGenesis::init(parent,channels,sugRate,flags);
|
2021-12-18 08:25:42 +00:00
|
|
|
for (int i=0; i<4; i++) {
|
|
|
|
isOpMuted[i]=false;
|
|
|
|
}
|
2021-12-11 18:14:38 +00:00
|
|
|
|
|
|
|
reset();
|
2021-05-17 01:49:54 +00:00
|
|
|
return 13;
|
2021-05-17 20:06:11 +00:00
|
|
|
}
|
2021-12-15 05:37:27 +00:00
|
|
|
|
|
|
|
void DivPlatformGenesisExt::quit() {
|
|
|
|
DivPlatformGenesis::quit();
|
|
|
|
}
|
|
|
|
|
|
|
|
DivPlatformGenesisExt::~DivPlatformGenesisExt() {
|
2022-03-06 19:39:20 +00:00
|
|
|
}
|