redo opnx csm

This commit is contained in:
Eknous-P 2024-10-09 17:28:58 +04:00 committed by tildearrow
parent 901bb110cc
commit 5f47166012
17 changed files with 572 additions and 147 deletions

View file

@ -438,6 +438,9 @@ void DivPlatformYM2608Ext::tick(bool sysTick) {
}
}
if (writeSomething) {
if (chan[csmChan].active) { // CSM
writeMask^=0xf0;
}
immWrite(0x28,writeMask);
}
}
@ -612,7 +615,28 @@ void DivPlatformYM2608Ext::tick(bool sysTick) {
}
}
}
if (extMode) {
if (chan[csmChan].freqChanged) {
chan[csmChan].freq=parent->calcFreq(chan[csmChan].baseFreq,chan[csmChan].pitch,chan[csmChan].fixedArp?chan[csmChan].baseNoteOverride:chan[csmChan].arpOff,chan[csmChan].fixedArp,true,0,chan[csmChan].pitch2,chipClock,CHIP_DIVIDER);
if (chan[csmChan].freq<1) chan[csmChan].freq=1;
if (chan[csmChan].freq>1024) chan[csmChan].freq=1024;
int wf=0x400-chan[csmChan].freq;
immWrite(0x24,wf>>2);
immWrite(0x25,wf&3);
chan[csmChan].freqChanged=false;
}
if (chan[csmChan].keyOff || chan[csmChan].keyOn) {
writeNoteOn=true;
for (int i=0; i<4; i++) {
writeMask|=opChan[i].active<<(4+i);
}
}
}
if (writeNoteOn) {
if (chan[csmChan].active) { // CSM
writeMask^=0xf0;
}
writeMask^=hardResetMask;
immWrite(0x28,writeMask);
writeMask^=hardResetMask;
@ -634,6 +658,17 @@ void DivPlatformYM2608Ext::tick(bool sysTick) {
immWrite(0x28,writeMask);
}
}
if (extMode) {
if (chan[csmChan].keyOn) {
immWrite(0x27,0x81);
chan[csmChan].keyOn=false;
}
if (chan[csmChan].keyOff) {
immWrite(0x27,0x40);
chan[csmChan].keyOff=false;
}
}
}
void DivPlatformYM2608Ext::muteChannel(int ch, bool mute) {
@ -705,12 +740,12 @@ void DivPlatformYM2608Ext::forceIns() {
chan[i].freqChanged=true;
}
}
for (int i=9; i<16; i++) {
for (int i=(9+isCSM); i<(16+isCSM); i++) {
chan[i].insChanged=true;
if (i>14) { // ADPCM-B
if (i>(14+isCSM)) { // ADPCM-B
immWrite(0x10b,chan[i].outVol);
} else {
immWrite(0x18+(i-9),isMuted[i]?0:((chan[i].pan<<6)|chan[i].outVol));
immWrite(0x18+(i-(9+isCSM)),isMuted[i]?0:((chan[i].pan<<6)|chan[i].outVol));
}
}
ay->forceIns();
@ -728,6 +763,11 @@ void DivPlatformYM2608Ext::forceIns() {
opChan[i].freqChanged=true;
}
}
if (extMode && chan[csmChan].active) { // CSM
chan[csmChan].insChanged=true;
chan[csmChan].freqChanged=true;
chan[csmChan].keyOn=true;
}
if (!extMode) {
immWrite(0x27,0x00);
}
@ -740,13 +780,14 @@ void* DivPlatformYM2608Ext::getChanState(int ch) {
}
DivMacroInt* DivPlatformYM2608Ext::getChanMacroInt(int ch) {
if (ch>=9 && ch<12) return ay->getChanMacroInt(ch-9);
if (ch>=(9+isCSM) && ch<(12+isCSM)) return ay->getChanMacroInt(ch-(9+isCSM));
if (ch>=6) return &chan[ch-3].std;
if (ch>=2) return &opChan[ch-2].std;
return &chan[ch].std;
}
unsigned short DivPlatformYM2608Ext::getPan(int ch) {
if (ch==4+csmChan) return 0;
if (ch>=4+extChanOffs) return DivPlatformYM2608::getPan(ch-3);
if (ch>=extChanOffs) {
if (extMode) {
@ -788,7 +829,7 @@ void DivPlatformYM2608Ext::reset() {
}
bool DivPlatformYM2608Ext::keyOffAffectsArp(int ch) {
return (ch>8);
return (ch>(8+isCSM));
}
void DivPlatformYM2608Ext::notifyInsChange(int ins) {
@ -815,7 +856,7 @@ int DivPlatformYM2608Ext::init(DivEngine* parent, int channels, int sugRate, con
extSys=true;
reset();
return 19;
return 19+isCSM;
}
void DivPlatformYM2608Ext::quit() {