diff --git a/audio/softsynth/opl/nuked.cpp b/audio/softsynth/opl/nuked.cpp index 143183ff90d8..075887cc120c 100644 --- a/audio/softsynth/opl/nuked.cpp +++ b/audio/softsynth/opl/nuked.cpp @@ -426,8 +426,6 @@ static void OPL3_EnvelopeCalc(opl3_slot *slot) case envelope_gen_num_release: reg_rate = slot->reg_rr; break; - default: - break; } } slot->pg_reset = reset; @@ -466,7 +464,7 @@ static void OPL3_EnvelopeCalc(opl3_slot *slot) } else { - shift = (rate_hi & 0x03) + eg_incstep[rate_lo][slot->chip->timer & 0x03u]; + shift = (rate_hi & 0x03) + eg_incstep[rate_lo][slot->chip->eg_timer_lo]; if (shift & 0x04) { shift = 0x03; @@ -523,8 +521,6 @@ static void OPL3_EnvelopeCalc(opl3_slot *slot) eg_inc = 1 << (shift - 1); } break; - default: - break; } slot->eg_rout = (eg_rout + eg_inc) & 0x1ff; /* Key off */ @@ -872,8 +868,6 @@ static void OPL3_ChannelSetupAlg(opl3_channel *channel) channel->slotz[0]->mod = &channel->slotz[0]->fbmod; channel->slotz[1]->mod = &channel->chip->zeromod; break; - default: - break; } return; } @@ -929,8 +923,6 @@ static void OPL3_ChannelSetupAlg(opl3_channel *channel) channel->out[2] = &channel->slotz[1]->out; channel->out[3] = &channel->chip->zeromod; break; - default: - break; } } else @@ -953,8 +945,6 @@ static void OPL3_ChannelSetupAlg(opl3_channel *channel) channel->out[2] = &channel->chip->zeromod; channel->out[3] = &channel->chip->zeromod; break; - default: - break; } } } @@ -1219,10 +1209,9 @@ inline void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4) chip->timer++; - chip->eg_add = 0; - if (chip->eg_timer) + if (chip->eg_state) { - while (shift < 36 && ((chip->eg_timer >> shift) & 1) == 0) + while (shift < 13 && ((chip->eg_timer >> shift) & 1) == 0) { shift++; } @@ -1234,6 +1223,7 @@ inline void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4) { chip->eg_add = shift + 1; } + chip->eg_timer_lo = (uint8_t)(chip->eg_timer & 0x3u); } if (chip->eg_timerrem || chip->eg_state) @@ -1392,8 +1382,6 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v) chip->stereoext = (v >> 1) & 0x01; #endif break; - default: - break; } } else @@ -1403,8 +1391,6 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v) case 0x08: chip->nts = (v >> 6) & 0x01; break; - default: - break; } } break; @@ -1483,8 +1469,6 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v) } break; #endif - default: - break; } } diff --git a/audio/softsynth/opl/nuked.h b/audio/softsynth/opl/nuked.h index 70860d2114ca..22b3bcecafd0 100644 --- a/audio/softsynth/opl/nuked.h +++ b/audio/softsynth/opl/nuked.h @@ -117,6 +117,7 @@ struct _opl3_chip { uint8_t eg_timerrem; uint8_t eg_state; uint8_t eg_add; + uint8_t eg_timer_lo; uint8_t newm; uint8_t nts; uint8_t rhy; @@ -159,7 +160,7 @@ void OPL3_WriteReg(opl3_chip *chip, uint16_t reg, uint8_t v); void OPL3_WriteRegBuffered(opl3_chip *chip, uint16_t reg, uint8_t v); void OPL3_GenerateStream(opl3_chip *chip, int16_t *sndptr, uint32_t numsamples); -void OPL3_Generate4Ch(opl3_chip *chpi, int16_t *buf4); +void OPL3_Generate4Ch(opl3_chip *chip, int16_t *buf4); void OPL3_Generate4ChResampled(opl3_chip *chip, int16_t *buf4); void OPL3_Generate4ChStream(opl3_chip *chip, int16_t *sndptr1, int16_t *sndptr2, uint32_t numsamples);