From 45a1ef7153910f005c01cba63d12f312071efef0 Mon Sep 17 00:00:00 2001 From: notaz Date: Thu, 26 Jun 2008 19:32:34 +0000 Subject: [PATCH] tried to adjust timers using formulae git-svn-id: file:///home/notaz/opt/svn/PicoDrive@497 be3aeb3a-fb24-0410-a615-afba39da0efa --- Pico/Memory.c | 4 ++-- Pico/PicoInt.h | 8 ++++++-- platform/linux/940ctl_ym2612.c | 10 ++++++++++ 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/Pico/Memory.c b/Pico/Memory.c index 755b5b50..99f78460 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -798,7 +798,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) ym2612.OPN.ST.TA = TAnew; //ym2612.OPN.ST.TAC = (1024-TAnew)*18; //ym2612.OPN.ST.TAT = 0; - timer_a_step = timer_a_offset = 16466 * (1024 - TAnew); + timer_a_step = timer_a_offset = TIMER_A_TICK_ZCYCLES * (1024 - TAnew); if (ym2612.OPN.ST.mode & 1) { int cycles = is_from_z80 ? z80_cyclesDone() : cycles_68k_to_z80(SekCyclesDone()); timer_a_next_oflow = (cycles << 8) + timer_a_step; @@ -813,7 +813,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) ym2612.OPN.ST.TB = d; //ym2612.OPN.ST.TBC = (256-d) * 288; //ym2612.OPN.ST.TBT = 0; - timer_b_step = timer_b_offset = 262800 * (256 - d); // 262881 + timer_b_step = timer_b_offset = TIMER_B_TICK_ZCYCLES * (256 - d); // 262800 if (ym2612.OPN.ST.mode & 2) { int cycles = is_from_z80 ? z80_cyclesDone() : cycles_68k_to_z80(SekCyclesDone()); timer_b_next_oflow = (cycles << 8) + timer_b_step; diff --git a/Pico/PicoInt.h b/Pico/PicoInt.h index c2f8b60f..4ac115f3 100644 --- a/Pico/PicoInt.h +++ b/Pico/PicoInt.h @@ -480,6 +480,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 #define timers_cycle() \ if (timer_a_next_oflow > 0 && timer_a_next_oflow < TIMER_NO_OFLOW) \ @@ -490,8 +494,8 @@ void ym2612_unpack_state(void); #define timers_reset() \ timer_a_next_oflow = timer_b_next_oflow = TIMER_NO_OFLOW; \ - timer_a_step = timer_a_offset = 16495 * 1024; \ - timer_b_step = timer_b_offset = 263912 * 256; + timer_a_step = timer_a_offset = TIMER_A_TICK_ZCYCLES * 1024; \ + timer_b_step = timer_b_offset = TIMER_B_TICK_ZCYCLES * 256; // VideoPort.c diff --git a/platform/linux/940ctl_ym2612.c b/platform/linux/940ctl_ym2612.c index 32e672fd..b6b593ac 100644 --- a/platform/linux/940ctl_ym2612.c +++ b/platform/linux/940ctl_ym2612.c @@ -53,6 +53,16 @@ void YM2612PicoStateLoad_940(void) } } +void YM2612PicoStateSave2_940(int tat, int tbt) +{ + YM2612PicoStateSave2(tat, tbt); +} + +int YM2612PicoStateLoad2_940(int *tat, int *tbt) +{ + return YM2612PicoStateLoad2(tat, tbt); +} + void sharedmem_init(void) { -- 2.39.5