From 64356591d66c842638d2899406edb84ef65a3be1 Mon Sep 17 00:00:00 2001 From: nukeykt Date: Fri, 6 Oct 2017 00:25:16 +0900 Subject: [PATCH] [Core/Sound] Nuked OPN2: fix envelope generator increment calculation --- core/sound/ym3438.c | 32 ++++++++++++++------------------ core/sound/ym3438.h | 2 +- 2 files changed, 15 insertions(+), 19 deletions(-) diff --git a/core/sound/ym3438.c b/core/sound/ym3438.c index 73163f2..9a5d169 100644 --- a/core/sound/ym3438.c +++ b/core/sound/ym3438.c @@ -39,7 +39,7 @@ * OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): * OPL2 ROMs. * - * version: 1.0.6 + * version: 1.0.7 */ #include @@ -741,28 +741,24 @@ void OPN2_EnvelopePrepare(ym3438_t *chip) rate = 0x3f; } - sum = (rate >> 2) + chip->eg_shift_lock; + sum = ((rate >> 2) + chip->eg_shift_lock) & 0x0f; if (chip->eg_rate != 0 && chip->eg_quotient == 2) { if (rate < 48) { - if ((sum & 0x0c) == 0x0c) + switch (sum) { - if ((sum & 0x03) == 0) - { - inc = 1; - } - else - { - if (sum & 0x01) - { - inc |= (rate >> 1) & 0x01; - } - if (sum & 0x02) - { - inc |= rate & 0x01; - } - } + case 12: + inc = 1; + break; + case 13: + inc = (rate >> 1) & 0x01; + break; + case 14: + inc = rate & 0x01; + break; + default: + break; } } else diff --git a/core/sound/ym3438.h b/core/sound/ym3438.h index 9bf4af0..1d1066d 100644 --- a/core/sound/ym3438.h +++ b/core/sound/ym3438.h @@ -39,7 +39,7 @@ * OPLx decapsulated(Matthew Gambrell, Olli Niemitalo): * OPL2 ROMs. * - * version: 1.0.6 + * version: 1.0.7 */ #ifndef YM3438_H