From 3d8bd155a7f0fbf330e6eebe8235eb029a15fd39 Mon Sep 17 00:00:00 2001 From: ekeeke Date: Tue, 26 Sep 2017 10:25:48 +0200 Subject: [PATCH] [Core/Sound] fixed EG counter loopback behavior (verified on real YM3438 die by nukez) --- core/sound/ym2612.c | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/core/sound/ym2612.c b/core/sound/ym2612.c index c109a2d..26ace38 100644 --- a/core/sound/ym2612.c +++ b/core/sound/ym2612.c @@ -24,6 +24,10 @@ /* ** CHANGELOG: ** +** 26-09-2017 Eke-Eke (Genesis Plus GX): +** - fixed EG counter loopback behavior (verified on YM3438 die) +** - reverted changes to EG rates 2-7 increment values +** ** 09-04-2017 Eke-Eke (Genesis Plus GX): ** - fixed LFO PM implementation: block & keyscale code should not be modified by LFO (verified on YM2612 die) ** - fixed Timer B overflow handling @@ -240,12 +244,11 @@ O(18),O(18),O(18),O(18),O(18),O(18),O(18),O(18), /* rates 00-11 */ /* -O( 0),O( 1),O( 2),O( 3), -O( 0),O( 1),O( 2),O( 3), +O( 0),O( 1) */ -O(18),O(18),O( 0),O( 0), -O( 0),O( 0),O( 2),O( 2), /* Nemesis's tests */ - +O(18),O(18), /* from Nemesis's tests on real YM2612 hardware */ + O( 2),O( 3), +O( 0),O( 1),O( 2),O( 3), O( 0),O( 1),O( 2),O( 3), O( 0),O( 1),O( 2),O( 3), O( 0),O( 1),O( 2),O( 3), @@ -2017,7 +2020,7 @@ void YM2612Update(int *buffer, int length) refresh_fc_eg_chan(&ym2612.CH[5]); /* buffering */ - for(i=0; i < length ; i++) + for(i=0; i= 3) { + /* reset EG timer */ ym2612.OPN.eg_timer = 0; + + /* increment EG counter */ ym2612.OPN.eg_cnt++; + + /* EG counter is 12-bit only and zero value is skipped (verified on real hardware) */ + if (ym2612.OPN.eg_cnt == 4096) + ym2612.OPN.eg_cnt = 1; + + /* advance envelope generator */ advance_eg_channels(&ym2612.CH[0], ym2612.OPN.eg_cnt); }