accurate_sprites performance improvement, PSP is untested
[picodrive.git] / Pico / Memory.c
index fb6b99c..dbf0118 100644 (file)
@@ -799,7 +799,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80)
             //ym2612.OPN.ST.TAC = (1024-TAnew)*18;\r
             //ym2612.OPN.ST.TAT = 0;\r
             //\r
-            timer_a_step = timer_a_offset = 16495 * (1024 - TAnew);\r
+            timer_a_step = timer_a_offset = 16466 * (1024 - TAnew);\r
             if (ym2612.OPN.ST.mode & 1) {\r
               int cycles = is_from_z80 ? z80_cyclesDone() : cycles_68k_to_z80(SekCyclesDone());\r
               timer_a_next_oflow = (cycles << 8) + timer_a_step;\r
@@ -815,7 +815,7 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80)
             //ym2612.OPN.ST.TBC  = (256-d)<<4;\r
             //ym2612.OPN.ST.TBC *= 18;\r
             //ym2612.OPN.ST.TBT  = 0;\r
-            timer_b_step = timer_b_offset = 263912 * (256 - d);\r
+            timer_b_step = timer_b_offset = 262800 * (256 - d); // 262881\r
             if (ym2612.OPN.ST.mode & 2) {\r
               int cycles = is_from_z80 ? z80_cyclesDone() : cycles_68k_to_z80(SekCyclesDone());\r
               timer_b_next_oflow = (cycles << 8) + timer_b_step;\r
@@ -883,14 +883,13 @@ int ym2612_write_local(u32 a, u32 d, int is_from_z80)
   return YM2612Write_(a, d);\r
 }\r
 \r
-// TODO: savestates\r
+\r
 #define ym2612_read_local() \\r
   if (xcycles >= timer_a_next_oflow) \\r
     ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 1; \\r
   if (xcycles >= timer_b_next_oflow) \\r
     ym2612.OPN.ST.status |= (ym2612.OPN.ST.mode >> 2) & 2\r
 \r
-\r
 u32 ym2612_read_local_z80(void)\r
 {\r
   int xcycles = z80_cyclesDone() << 8;\r
@@ -913,6 +912,23 @@ u32 ym2612_read_local_68k(void)
   return ym2612.OPN.ST.status;\r
 }\r
 \r
+// TODO: new ym2612 savestates, also save timers\r
+void ym2612_unpack_state(void)\r
+{\r
+  int i;\r
+  YM2612PicoStateLoad();\r
+\r
+  // feed all the registers and update internal state\r
+  for (i = 0x20; i < 0xC0; i++) {\r
+    ym2612_write_local(0, i, 0);\r
+    ym2612_write_local(1, ym2612.REGS[i], 0);\r
+  }\r
+  for (i = 0x30; i < 0xC0; i++) {\r
+    ym2612_write_local(2, i, 0);\r
+    ym2612_write_local(3, ym2612.REGS[i|0x100], 0);\r
+  }\r
+}\r
+\r
 // -----------------------------------------------------------------\r
 //                        z80 memhandlers\r
 \r