sound, improve ym2612 timers implementation

This commit is contained in:
kub 2023-06-22 22:18:47 +00:02
parent e0c4dac19c
commit c3d70d1305
4 changed files with 15 additions and 18 deletions

View file

@ -872,16 +872,18 @@ void ym2612_pack_state(void);
void ym2612_unpack_state(void);
#define TIMER_NO_OFLOW 0x70000000
// 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() \
// NB ~0.2% timers speed up (1/8(A), 2(B) z80 cycles), HACK for A/V sync in OD2
// tA = 72 * (1024 - TA) / M, with M = mclock/2
#define TIMER_A_TICK_ZCYCLES (cycles_68k_to_z80(256LL* 72*2)-32) // Q8
// tB = 16*72 * ( 256 - TB) / M
#define TIMER_B_TICK_ZCYCLES (cycles_68k_to_z80(256LL*16*72*2)-32*16) // Q8
#define timers_cycle(ticks) \
if (Pico.t.timer_a_next_oflow > 0 && Pico.t.timer_a_next_oflow < TIMER_NO_OFLOW) \
Pico.t.timer_a_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \
Pico.t.timer_a_next_oflow -= ticks << 8; \
if (Pico.t.timer_b_next_oflow > 0 && Pico.t.timer_b_next_oflow < TIMER_NO_OFLOW) \
Pico.t.timer_b_next_oflow -= Pico.m.pal ? 70938*256 : 59659*256; \
Pico.t.timer_b_next_oflow -= ticks << 8; \
ym2612_sync_timers(0, ym2612.OPN.ST.mode, ym2612.OPN.ST.mode);
#define timers_reset() \