OPN: fix out of bounds when using some FM effects

on non-FM channels
issue #2286
This commit is contained in:
tildearrow 2024-12-09 01:57:30 -05:00
parent 5eae178dcb
commit 52a4588ad9
4 changed files with 36 additions and 0 deletions

View file

@ -938,6 +938,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_RS: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -954,6 +955,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_AM: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -970,6 +972,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_DR: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -986,6 +989,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_SL: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -1002,6 +1006,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_RR: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -1018,6 +1023,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_D2R: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -1034,6 +1040,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_DT: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -1050,6 +1057,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
break;
}
case DIV_CMD_FM_SSG: {
if (c.chan>=psgChanOffs) break;
if (c.value<0) {
for (int i=0; i<4; i++) {
DivInstrumentFM::Operator& op=chan[c.chan].state.op[i];
@ -1086,6 +1094,7 @@ int DivPlatformYM2203::dispatch(DivCommand c) {
}
break;
case DIV_CMD_FM_HARD_RESET:
if (c.chan>=psgChanOffs) break;
chan[c.chan].hardReset=c.value;
break;
case DIV_CMD_MACRO_OFF: