From 68e06234e3beb9c252efbb7af8aae76cff313271 Mon Sep 17 00:00:00 2001 From: notaz Date: Fri, 12 Jan 2024 02:23:31 +0200 Subject: [PATCH] sound: fix ym2612 freq latch there is only a single register, as described in: http://www.mjsstuf.x10host.com/pages/vgmPlay/vgmPlay.htm --- pico/sound/ym2612.c | 6 +++--- pico/sound/ym2612.h | 5 +++-- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index 86dbda25..f8a18625 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -1671,8 +1671,8 @@ static int OPNWriteReg(int r, int v) switch( OPN_SLOT(r) ){ case 0: /* 0xa0-0xa2 : FNUM1 | depends on fn_h (below) */ { - UINT32 fn = (((UINT32)( (CH->fn_h)&7))<<8) + v; - UINT8 blk = CH->fn_h>>3; + UINT32 fn = ((UINT32)(ym2612.OPN.ST.fn_h & 7) << 8) | v; + UINT8 blk = ym2612.OPN.ST.fn_h >> 3; /* keyscale code */ CH->kcode = (blk<<2) | opn_fktable[fn >> 7]; /* phase increment counter */ @@ -1685,7 +1685,7 @@ static int OPNWriteReg(int r, int v) } break; case 1: /* 0xa4-0xa6 : FNUM2,BLK */ - CH->fn_h = v&0x3f; + ym2612.OPN.ST.fn_h = v & 0x3f; ret = 0; break; case 2: /* 0xa8-0xaa : 3CH FNUM1 */ diff --git a/pico/sound/ym2612.h b/pico/sound/ym2612.h index 84263b2b..b981a428 100644 --- a/pico/sound/ym2612.h +++ b/pico/sound/ym2612.h @@ -78,7 +78,7 @@ typedef struct UINT8 ams; /* channel AMS */ UINT8 kcode; /* +11 key code: */ - UINT8 fn_h; /* freq latch */ + UINT8 pad2; UINT8 upd_cnt; /* eg update counter */ UINT32 fc; /* fnum,blk:adjusted to sample rate */ UINT32 block_fnum; /* current blk/fnum value for this slot (can be different betweeen slots of one channel in 3slot mode) */ @@ -101,7 +101,8 @@ typedef struct int TAC; /* timer a maxval */ int TAT; /* timer a ticker | need_save */ UINT8 TB; /* timer b */ - UINT8 pad2[3]; + UINT8 fn_h; /* freq latch */ + UINT8 pad2[2]; int TBC; /* timer b maxval */ int TBT; /* timer b ticker | need_save */ /* local time tables */ -- 2.39.2