From: notaz Date: Mon, 12 Jun 2023 20:55:50 +0000 (+0300) Subject: sound: fix ym2612 address handling X-Git-Tag: v2.00~207 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=225260ba40e70c23dee07443389ef88d42009897;p=picodrive.git sound: fix ym2612 address handling I already fixed this back in 2017 with 151df6adf9d63c9b8c8a61946243800610ac3a65, but forgot about ym2612_write_local(). Fixes missing sounds in Overdrive2. --- diff --git a/pico/memory.c b/pico/memory.c index 3cc2feea..74628290 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -1112,31 +1112,20 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80) int addr; a &= 3; - if (a == 1 && ym2612.OPN.ST.address == 0x2a) /* DAC data */ - { - int cycles = is_from_z80 ? z80_cyclesDone() : z80_cycles_from_68k(); - //elprintf(EL_STATUS, "%03i dac w %08x z80 %i", cycles, d, is_from_z80); - if (ym2612.dacen) - PsndDoDAC(cycles); - ym2612.dacout = ((int)d - 0x80) << 6; - return 0; - } - switch (a) { case 0: /* address port 0 */ + case 2: /* address port 1 */ ym2612.OPN.ST.address = d; - ym2612.addr_A1 = 0; + ym2612.addr_A1 = (a & 2) >> 1; #ifdef __GP2X__ if (PicoIn.opt & POPT_EXT_FM) YM2612Write_940(a, d, -1); #endif return 0; case 1: /* data port 0 */ - if (ym2612.addr_A1 != 0) - return 0; - - addr = ym2612.OPN.ST.address; + case 3: /* data port 1 */ + addr = ym2612.OPN.ST.address | ((int)ym2612.addr_A1 << 8); ym2612.REGS[addr] = d; switch (addr) @@ -1201,6 +1190,14 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80) } return 0; } + case 0x2a: { /* DAC data */ + int cycles = is_from_z80 ? z80_cyclesDone() : z80_cycles_from_68k(); + //elprintf(EL_STATUS, "%03i dac w %08x z80 %i", cycles, d, is_from_z80); + if (ym2612.dacen) + PsndDoDAC(cycles); + ym2612.dacout = ((int)d - 0x80) << 6; + return 0; + } case 0x2b: { /* DAC Sel (YM2612) */ ym2612.dacen = d & 0x80; #ifdef __GP2X__ @@ -1210,22 +1207,6 @@ static int ym2612_write_local(u32 a, u32 d, int is_from_z80) } } break; - - case 2: /* address port 1 */ - ym2612.OPN.ST.address = d; - ym2612.addr_A1 = 1; -#ifdef __GP2X__ - if (PicoIn.opt & POPT_EXT_FM) YM2612Write_940(a, d, -1); -#endif - return 0; - - case 3: /* data port 1 */ - if (ym2612.addr_A1 != 1) - return 0; - - addr = ym2612.OPN.ST.address | 0x100; - ym2612.REGS[addr] = d; - break; } #ifdef __GP2X__ diff --git a/pico/sound/ym2612.c b/pico/sound/ym2612.c index 219aacd1..39958f59 100644 --- a/pico/sound/ym2612.c +++ b/pico/sound/ym2612.c @@ -1886,6 +1886,7 @@ int YM2612Write_(unsigned int a, unsigned int v) switch( a & 3 ){ case 0: /* address port 0 */ case 2: /* address port 1 */ + /* reminder: this is not used, see ym2612_write_local() */ ym2612.OPN.ST.address = v; ym2612.addr_A1 = (a & 2) >> 1; ret = 0;