OPLL: 88%

TODO:
- effects
- FM macros (ugh)
- muting
- proper drum mode
- proper VRC7
This commit is contained in:
tildearrow 2022-02-28 01:25:10 -05:00
parent 3ca90fd0c8
commit 6dc01159ee
2 changed files with 36 additions and 19 deletions

View file

@ -241,7 +241,7 @@ void DivPlatformOPLL::tick() {
}*/ }*/
if (chan[i].keyOn || chan[i].keyOff) { if (chan[i].keyOn || chan[i].keyOff) {
if (chan[i].drums) { if (i>=6 && drums) {
drumState&=~(0x10>>(chan[i].note%12)); drumState&=~(0x10>>(chan[i].note%12));
immWrite(0x0e,0x20|drumState); immWrite(0x0e,0x20|drumState);
} else { } else {
@ -266,11 +266,11 @@ void DivPlatformOPLL::tick() {
int freqt=toFreq(chan[i].freq); int freqt=toFreq(chan[i].freq);
chan[i].freqH=freqt>>8; chan[i].freqH=freqt>>8;
chan[i].freqL=freqt&0xff; chan[i].freqL=freqt&0xff;
if (!chan[i].drums) { if (i<6 || !drums) {
immWrite(0x10+i,freqt&0xff); immWrite(0x10+i,freqt&0xff);
} }
} }
if (chan[i].keyOn && chan[i].drums) { if (chan[i].keyOn && i>=6 && drums) {
//printf("%d\n",chan[i].note%12); //printf("%d\n",chan[i].note%12);
drumState|=(0x10>>(chan[i].note%12)); drumState|=(0x10>>(chan[i].note%12));
immWrite(0x0e,0x20|drumState); immWrite(0x0e,0x20|drumState);
@ -374,7 +374,8 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
rWrite(0x07,(car.sl<<4)|(car.rr)); rWrite(0x07,(car.sl<<4)|(car.rr));
} }
if (chan[c.chan].state.opllPreset==16) { // compatible drums mode if (chan[c.chan].state.opllPreset==16) { // compatible drums mode
chan[c.chan].drums=true; if (c.chan>=6) {
drums=true;
immWrite(0x16,0x20); immWrite(0x16,0x20);
immWrite(0x26,0x05); immWrite(0x26,0x05);
immWrite(0x16,0x20); immWrite(0x16,0x20);
@ -385,8 +386,12 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
immWrite(0x27,0x05); immWrite(0x27,0x05);
immWrite(0x18,0xC0); immWrite(0x18,0xC0);
immWrite(0x28,0x01); immWrite(0x28,0x01);
}
} else { } else {
chan[c.chan].drums=false; if (c.chan>=6) {
drums=false;
immWrite(0x0e,0);
}
rWrite(0x30+c.chan,(15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)|(chan[c.chan].state.opllPreset<<4)); rWrite(0x30+c.chan,(15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)|(chan[c.chan].state.opllPreset<<4));
} }
} }
@ -397,7 +402,7 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value); chan[c.chan].baseFreq=NOTE_FREQUENCY(c.value);
chan[c.chan].note=c.value; chan[c.chan].note=c.value;
if (chan[c.chan].drums) { if (c.chan>=6 && drums) {
switch (chan[c.chan].note%12) { switch (chan[c.chan].note%12) {
case 0: // kick case 0: // kick
drumVol[0]=(15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15); drumVol[0]=(15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15);
@ -444,7 +449,7 @@ int DivPlatformOPLL::dispatch(DivCommand c) {
if (!chan[c.chan].std.hasVol) { if (!chan[c.chan].std.hasVol) {
chan[c.chan].outVol=c.value; chan[c.chan].outVol=c.value;
} }
if (!chan[c.chan].drums) { if (c.chan<6 || !drums) {
rWrite(0x30+c.chan,(15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)|(chan[c.chan].state.opllPreset<<4)); rWrite(0x30+c.chan,(15-(chan[c.chan].outVol*(15-chan[c.chan].state.op[1].tl))/15)|(chan[c.chan].state.opllPreset<<4));
} }
break; break;
@ -587,6 +592,18 @@ void DivPlatformOPLL::forceIns() {
chan[i].freqChanged=true; chan[i].freqChanged=true;
} }
} }
if (drums) {
immWrite(0x16,0x20);
immWrite(0x26,0x05);
immWrite(0x16,0x20);
immWrite(0x26,0x05);
immWrite(0x17,0x50);
immWrite(0x27,0x05);
immWrite(0x17,0x50);
immWrite(0x27,0x05);
immWrite(0x18,0xC0);
immWrite(0x28,0x01);
}
} }
void DivPlatformOPLL::toggleRegisterDump(bool enable) { void DivPlatformOPLL::toggleRegisterDump(bool enable) {

View file

@ -35,7 +35,7 @@ class DivPlatformOPLL: public DivDispatch {
unsigned char freqH, freqL; unsigned char freqH, freqL;
int freq, baseFreq, pitch, note; int freq, baseFreq, pitch, note;
unsigned char ins; unsigned char ins;
bool active, insChanged, freqChanged, keyOn, keyOff, drums, portaPause, furnaceDac, inPorta; bool active, insChanged, freqChanged, keyOn, keyOff, portaPause, furnaceDac, inPorta;
int vol, outVol; int vol, outVol;
unsigned char pan; unsigned char pan;
Channel(): Channel():
@ -51,7 +51,6 @@ class DivPlatformOPLL: public DivDispatch {
freqChanged(false), freqChanged(false),
keyOn(false), keyOn(false),
keyOff(false), keyOff(false),
drums(false),
portaPause(false), portaPause(false),
furnaceDac(false), furnaceDac(false),
inPorta(false), inPorta(false),
@ -76,6 +75,7 @@ class DivPlatformOPLL: public DivDispatch {
unsigned char regPool[256]; unsigned char regPool[256];
bool useYMFM; bool useYMFM;
bool drums;
short oldWrites[256]; short oldWrites[256];
short pendingWrites[256]; short pendingWrites[256];