From: kub Date: Sun, 26 Jan 2020 19:12:18 +0000 (+0100) Subject: audio fixes for overdrive demo X-Git-Tag: v2.00~798 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7aab47685971b17e42719a7f876a6f469032406a;p=picodrive.git audio fixes for overdrive demo --- diff --git a/cpu/cz80/cz80.c b/cpu/cz80/cz80.c index 6b9afcde..51abc40f 100644 --- a/cpu/cz80/cz80.c +++ b/cpu/cz80/cz80.c @@ -278,7 +278,8 @@ Cz80_Check_Interrupt: CPU->ICount -= CPU->ExtraCycles; CPU->ExtraCycles = 0; } - goto Cz80_Exec; + if (!CPU->HaltState) + goto Cz80_Exec; } } else CPU->ICount = 0; diff --git a/cpu/cz80/cz80_op.c b/cpu/cz80/cz80_op.c index 5d623caf..317e9587 100644 --- a/cpu/cz80/cz80_op.c +++ b/cpu/cz80/cz80_op.c @@ -687,7 +687,6 @@ OP_CCF: OP(0x76): // HALT OP_HALT: CPU->HaltState = 1; -// CPU->ICount = 0; goto Cz80_Check_Interrupt; OP(0xf3): // DI diff --git a/pico/memory.c b/pico/memory.c index 1d9b9135..d61491c1 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -733,8 +733,10 @@ static void PicoWrite8_vdp(u32 a, u32 d) static void PicoWrite16_vdp(u32 a, u32 d) { - if ((a & 0x00f9) == 0x0010) // PSG Sound + if ((a & 0x00f9) == 0x0010) { // PSG Sound psg_write_68k(d); + return; + } if ((a & 0x00e0) == 0x0000) { PicoVideoWrite(a, d); return; @@ -898,10 +900,10 @@ void ym2612_sync_timers(int z80_cycles, int mode_old, int mode_new) int xcycles = z80_cycles << 8; /* check for overflows */ - if ((mode_old & 4) && xcycles > Pico.t.timer_a_next_oflow) + if ((mode_old & 4) && xcycles >= Pico.t.timer_a_next_oflow) ym2612.OPN.ST.status |= 1; - if ((mode_old & 8) && xcycles > Pico.t.timer_b_next_oflow) + if ((mode_old & 8) && xcycles >= Pico.t.timer_b_next_oflow) ym2612.OPN.ST.status |= 2; /* update timer a */ diff --git a/pico/pico_int.h b/pico/pico_int.h index 58d3da88..70bfa710 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -822,10 +822,10 @@ void ym2612_pack_state(void); void ym2612_unpack_state(void); #define TIMER_NO_OFLOW 0x70000000 -// tA = 72 * (1024 - NA) / M -#define TIMER_A_TICK_ZCYCLES 17203 -// tB = 1152 * (256 - NA) / M -#define TIMER_B_TICK_ZCYCLES 262800 // 275251 broken, see Dai Makaimura +// tA = 72 * (1024 - NA) / M, with M = mclock/2 -> tick = 72 * 2/mclock +#define TIMER_A_TICK_ZCYCLES 17203 // zcycles = Q8*tick*zclock = Q8*77*2*7/15 +// tB = 1152 * (256 - NA) / M, +#define TIMER_B_TICK_ZCYCLES 275251 // zcycles = Q8*1152*2*7/15 #define timers_cycle() \ if (Pico.t.timer_a_next_oflow > 0 && Pico.t.timer_a_next_oflow < TIMER_NO_OFLOW) \ @@ -837,7 +837,8 @@ void ym2612_unpack_state(void); #define timers_reset() \ Pico.t.timer_a_next_oflow = Pico.t.timer_b_next_oflow = TIMER_NO_OFLOW; \ Pico.t.timer_a_step = TIMER_A_TICK_ZCYCLES * 1024; \ - Pico.t.timer_b_step = TIMER_B_TICK_ZCYCLES * 256; + Pico.t.timer_b_step = TIMER_B_TICK_ZCYCLES * 256; \ + ym2612.OPN.ST.status &= ~3; // videoport.c diff --git a/pico/sound/ym2612_arm.S b/pico/sound/ym2612_arm.S index 4cb92850..e3ec370d 100644 --- a/pico/sound/ym2612_arm.S +++ b/pico/sound/ym2612_arm.S @@ -206,8 +206,9 @@ .macro update_ssg_eg ldrh r0, [r5,#0x30] @ ssg+ssgn ldrb r2, [r5,#0x17] @ state + and r3, r0, #0x08 + cmp r3, #0x08 @ ssg enabled && ldrh r3, [r5,#0x1a] @ volume - cmp r0, #0x08 @ ssg enabled && cmpge r2, #EG_REL+1 @ state > EG_REL && cmpge r3, #0x200 @ volume >= 0x200? blt 9f