OPL4: fix playSub() memory corruption

Valgrind has lost!
issue #2536
This commit is contained in:
tildearrow 2025-05-28 02:09:14 -05:00
parent 3032e78a47
commit 34ad285efd

View file

@ -2635,10 +2635,12 @@ int DivPlatformOPL::dispatch(DivCommand c) {
} }
void DivPlatformOPL::forceIns() { void DivPlatformOPL::forceIns() {
int oplChans=0;
if (oplType==3) { if (oplType==3) {
chanMap=properDrums?chanMapOPL3Drums:chanMapOPL3; chanMap=properDrums?chanMapOPL3Drums:chanMapOPL3;
melodicChans=properDrums?15:18; melodicChans=properDrums?15:18;
totalChans=properDrums?20:18; totalChans=properDrums?20:18;
oplChans=totalChans;
if (chipType==4) { if (chipType==4) {
pcmChanOffs=totalChans; pcmChanOffs=totalChans;
totalChans+=24; totalChans+=24;
@ -2647,8 +2649,9 @@ void DivPlatformOPL::forceIns() {
chanMap=properDrums?chanMapOPL2Drums:chanMapOPL2; chanMap=properDrums?chanMapOPL2Drums:chanMapOPL2;
melodicChans=properDrums?6:9; melodicChans=properDrums?6:9;
totalChans=properDrums?11:9; totalChans=properDrums?11:9;
oplChans=totalChans;
} }
for (int i=0; i<totalChans; i++) { for (int i=0; i<oplChans; i++) {
int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2; int ops=(slots[3][i]!=255 && chan[i].state.ops==4 && oplType==3)?4:2;
chan[i].insChanged=true; chan[i].insChanged=true;
chan[i].freqChanged=true; chan[i].freqChanged=true;