shithub: zelda3

Download patch

ref: 5baed18b311a8f745f5a51080a3aabdd2071cdf7
parent: b67db8a71369a7f000c2180ada2ffbd2e349b636
author: Snesrev <snesrev@protonmail.com>
date: Sat Oct 8 22:33:31 EDT 2022

Fix VerifySnapshotsEq issue with hdma_table

--- a/zelda_cpu_infra.c
+++ b/zelda_cpu_infra.c
@@ -46,6 +46,7 @@
   memcpy(s->ram, g_snes->ram, 0x20000);
   memcpy(s->sram, g_snes->cart->ram, g_snes->cart->ramSize);
   memcpy(s->vram, g_snes->ppu->vram, sizeof(uint16) * 0x8000);
+  memcpy(s->ram + 0x1DBA0, s->ram + 0x1B00, 224 * 2);  // hdma_table (partial)
 }
 
 static void MakeMySnapshot(Snapshot *s) {
@@ -52,6 +53,7 @@
   memcpy(s->ram, g_zenv.ram, 0x20000);
   memcpy(s->sram, g_zenv.sram, 0x2000);
   memcpy(s->vram, g_zenv.ppu->vram, sizeof(uint16) * 0x8000);
+  memcpy(s->ram + 0x1B00, s->ram + 0x1DBA0, 224 * 2);  // hdma_table (partial)
 }
 
 static void RestoreMySnapshot(Snapshot *s) {
@@ -105,10 +107,8 @@
   memcpy(&b->ram[0x1f0d], &a->ram[0x1f0d], 0x3f - 0xd);
   memcpy(b->ram + 0x138, a->ram + 0x138, 256 - 0x38); // copy the stack over
 
-  memcpy(a->ram + 0x1DBA0, b->ram + 0x1DBA0, 240 * 2);  // hdma_table
-  memcpy(b->ram + 0x1B00, b->ram + 0x1DBA0, 224 * 2);  // hdma_table (partial)
-
   memcpy(a->ram + 0x1cc0, b->ram + 0x1cc0, 2);  // some leftover stuff in hdma table
+  memcpy(a->ram + 0x1dd60, b->ram + 0x1dd60, 16 * 2);  // some leftover stuff in hdma table
 
   if (memcmp(b->ram, a->ram, 0x20000)) {
     fprintf(stderr, "@%d: Memory compare failed (mine != theirs, prev):\n", frame_counter);
@@ -351,7 +351,7 @@
   VerifySnapshotsEq(&g_snapshot_mine, &g_snapshot_theirs, &g_snapshot_before);
 
   if (g_fail) {
-    //    g_fail = false;
+    g_fail = false;
     if (1) {
       RestoreMySnapshot(&g_snapshot_before);
       //SaveLoadSlot(kSaveLoad_Save, 0);