sound: fix ym2612 freq latch
authornotaz <notasas@gmail.com>
Fri, 12 Jan 2024 00:23:31 +0000 (02:23 +0200)
committeririxxxx <31696370+irixxxx@users.noreply.github.com>
Fri, 12 Jan 2024 20:34:19 +0000 (21:34 +0100)
there is only a single register, as described in:
http://www.mjsstuf.x10host.com/pages/vgmPlay/vgmPlay.htm

pico/sound/ym2612.c
pico/sound/ym2612.h

index 86dbda2..f8a1862 100644 (file)
@@ -1671,8 +1671,8 @@ static int OPNWriteReg(int r, int v)
                switch( OPN_SLOT(r) ){\r
                case 0:         /* 0xa0-0xa2 : FNUM1 | depends on fn_h (below) */\r
                        {\r
-                               UINT32 fn = (((UINT32)( (CH->fn_h)&7))<<8) + v;\r
-                               UINT8 blk = CH->fn_h>>3;\r
+                               UINT32 fn = ((UINT32)(ym2612.OPN.ST.fn_h & 7) << 8) | v;\r
+                               UINT8 blk = ym2612.OPN.ST.fn_h >> 3;\r
                                /* keyscale code */\r
                                CH->kcode = (blk<<2) | opn_fktable[fn >> 7];\r
                                /* phase increment counter */\r
@@ -1685,7 +1685,7 @@ static int OPNWriteReg(int r, int v)
                        }\r
                        break;\r
                case 1:         /* 0xa4-0xa6 : FNUM2,BLK */\r
-                       CH->fn_h = v&0x3f;\r
+                       ym2612.OPN.ST.fn_h = v & 0x3f;\r
                        ret = 0;\r
                        break;\r
                case 2:         /* 0xa8-0xaa : 3CH FNUM1 */\r
index 84263b2..b981a42 100644 (file)
@@ -78,7 +78,7 @@ typedef struct
        UINT8   ams;            /* channel AMS */\r
 \r
        UINT8   kcode;          /* +11 key code:                        */\r
-       UINT8   fn_h;           /* freq latch           */\r
+       UINT8   pad2;\r
        UINT8   upd_cnt;        /* eg update counter */\r
        UINT32  fc;             /* fnum,blk:adjusted to sample rate */\r
        UINT32  block_fnum;     /* current blk/fnum value for this slot (can be different betweeen slots of one channel in 3slot mode) */\r
@@ -101,7 +101,8 @@ typedef struct
        int             TAC;            /* timer a maxval       */\r
        int             TAT;            /* timer a ticker | need_save */\r
        UINT8   TB;                     /* timer b              */\r
-       UINT8   pad2[3];\r
+       UINT8   fn_h;           /* freq latch           */\r
+       UINT8   pad2[2];\r
        int             TBC;            /* timer b maxval       */\r
        int             TBT;            /* timer b ticker | need_save */\r
        /* local time tables */\r