X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMemory.c;h=99f784600ce94a7590e87939103e930c3cd7eacc;hb=45a1ef7153910f005c01cba63d12f312071efef0;hp=fe87ab98ff340e5a44575653d018265b0978acad;hpb=e53704e691c4de8c53ebe3c54e75a9ca8825bb2b;p=picodrive.git diff --git a/Pico/Memory.c b/Pico/Memory.c index fe87ab9..99f7846 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; @@ -925,7 +925,7 @@ void ym2612_pack_state(void) #ifdef __GP2X__ if (PicoOpt & POPT_EXT_FM) - /*YM2612PicoStateSave2_940(tat, tbt)*/; + YM2612PicoStateSave2_940(tat, tbt); else #endif YM2612PicoStateSave2(tat, tbt); @@ -937,22 +937,37 @@ void ym2612_unpack_state(void) YM2612PicoStateLoad(); // feed all the registers and update internal state - for (i = 0x20; i < 0xB8; i++) { + for (i = 0x20; i < 0xA0; i++) { ym2612_write_local(0, i, 0); ym2612_write_local(1, ym2612.REGS[i], 0); } - for (i = 0x30; i < 0xB8; i++) { + for (i = 0x30; i < 0xA0; i++) { + ym2612_write_local(2, i, 0); + ym2612_write_local(3, ym2612.REGS[i|0x100], 0); + } + for (i = 0xAF; i >= 0xA0; i--) { // must apply backwards + ym2612_write_local(2, i, 0); + ym2612_write_local(3, ym2612.REGS[i|0x100], 0); + ym2612_write_local(0, i, 0); + ym2612_write_local(1, ym2612.REGS[i], 0); + } + for (i = 0xB0; i < 0xB8; i++) { + ym2612_write_local(0, i, 0); + ym2612_write_local(1, ym2612.REGS[i], 0); ym2612_write_local(2, i, 0); ym2612_write_local(3, ym2612.REGS[i|0x100], 0); } #ifdef __GP2X__ if (PicoOpt & POPT_EXT_FM) - /*ret = YM2612PicoStateLoad2_940(&tat, &tbt)*/; + ret = YM2612PicoStateLoad2_940(&tat, &tbt); else #endif ret = YM2612PicoStateLoad2(&tat, &tbt); - if (ret != 0) return; // no saved timers + if (ret != 0) { + elprintf(EL_STATUS, "old ym2612 state"); + return; // no saved timers + } tac = (1024 - ym2612.OPN.ST.TA) << 16; tbc = (256 - ym2612.OPN.ST.TB) << 16;