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

@ -1427,6 +1427,7 @@ int DivPlatformYM2610::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];
@ -1443,6 +1444,7 @@ int DivPlatformYM2610::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];
@ -1459,6 +1461,7 @@ int DivPlatformYM2610::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];
@ -1475,6 +1478,7 @@ int DivPlatformYM2610::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];
@ -1491,6 +1495,7 @@ int DivPlatformYM2610::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];
@ -1507,6 +1512,7 @@ int DivPlatformYM2610::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];
@ -1523,6 +1529,7 @@ int DivPlatformYM2610::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];
@ -1539,6 +1546,7 @@ int DivPlatformYM2610::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];
@ -1575,6 +1583,7 @@ int DivPlatformYM2610::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: