X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FMemory.c;h=e4a251b87af8384219f91bb1cc63d67f3aa6facd;hb=07abbab17a9baab5eeabe30767b0336326049994;hp=fb6b99c41e6ab98bc94b9b461e3911c3be372dbc;hpb=43e6eaad0b73b37907be3342e0fd4cf65919e9f6;p=picodrive.git diff --git a/Pico/Memory.c b/Pico/Memory.c index fb6b99c4..e4a251b8 100644 --- a/Pico/Memory.c +++ b/Pico/Memory.c @@ -796,10 +796,10 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) { //elprintf(EL_STATUS, "timer a set %i", TAnew); ym2612.OPN.ST.TA = TAnew; - //ym2612.OPN.ST.TAC = (1024-TAnew)*18; + ym2612.OPN.ST.TAC = (1024-TAnew)*18; //ym2612.OPN.ST.TAT = 0; // - timer_a_step = timer_a_offset = 16495 * (1024 - TAnew); + timer_a_step = timer_a_offset = 16466 * (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; @@ -812,10 +812,9 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) if (ym2612.OPN.ST.TB != d) { //elprintf(EL_STATUS, "timer b set %i", d); ym2612.OPN.ST.TB = d; - //ym2612.OPN.ST.TBC = (256-d)<<4; - //ym2612.OPN.ST.TBC *= 18; + ym2612.OPN.ST.TBC = (256-d) * 288; //ym2612.OPN.ST.TBT = 0; - timer_b_step = timer_b_offset = 263912 * (256 - d); + timer_b_step = timer_b_offset = 262800 * (256 - d); // 262881 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; @@ -883,14 +882,13 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80) return YM2612Write_(a, d); } -// TODO: savestates + #define ym2612_read_local() \ if (xcycles >= timer_a_next_oflow) \ ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 1; \ if (xcycles >= timer_b_next_oflow) \ ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2 - u32 ym2612_read_local_z80(void) { int xcycles = z80_cyclesDone() << 8; @@ -913,6 +911,40 @@ u32 ym2612_read_local_68k(void) return ym2612.OPN.ST.status; } +void ym2612_pack_state(void) +{ + // TODO timers +#ifdef __GP2X__ + if (PicoOpt & POPT_EXT_FM) + /*YM2612PicoStateSave2_940(0, 0)*/; + else +#endif + YM2612PicoStateSave2(0, 0); +} + +void ym2612_unpack_state(void) +{ + int i, ret, tat, tbt; + YM2612PicoStateLoad(); + + // feed all the registers and update internal state + for (i = 0x20; i < 0xB8; i++) { + ym2612_write_local(0, i, 0); + ym2612_write_local(1, ym2612.REGS[i], 0); + } + for (i = 0x30; i < 0xB8; i++) { + 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)*/; + else +#endif + ret = YM2612PicoStateLoad2(&tat, &tbt); +} + // ----------------------------------------------------------------- // z80 memhandlers