From ff343e46c0df9ab9b28e3a5ef02bb70eb17e8f0e Mon Sep 17 00:00:00 2001 From: Snesrev Date: Sat, 11 Mar 2023 14:15:54 +0100 Subject: [PATCH] RtlUpdateSnesPatchForBugfix() had a bug Also removed dup patch --- src/sm_cpu_infra.c | 6 +----- src/sm_rtl.c | 2 ++ 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/sm_cpu_infra.c b/src/sm_cpu_infra.c index b7b3484..cc8bba6 100644 --- a/src/sm_cpu_infra.c +++ b/src/sm_cpu_infra.c @@ -553,7 +553,7 @@ void RtlUpdateSnesPatchForBugfix() { // Patch HandleMessageBoxInteraction logic { uint8 t[] = { 0x20, 0x50, 0x96, 0x60 }; PatchBytes(0x8584A3, t, sizeof(t)); } // while ((bug_fix_counter < 1 ? joypad1_newkeys : joypad1_lastkeys) == 0); - { uint8 t[] = { 0x20, 0x36, 0x81, 0x22, 0x59, 0x94, 0x80, 0xc2, 0x30, 0xa5, (bug_fix_counter < 1) ? 0x8f : 0x85, 0xf0, 0xf3, 0x60 }; PatchBytes(0x859650, t, sizeof(t)); } + { uint8 t[] = { 0x20, 0x36, 0x81, 0x22, 0x59, 0x94, 0x80, 0xc2, 0x30, 0xa5, (bug_fix_counter < 1) ? 0x8f : 0x8b, 0xf0, 0xf3, 0x60 }; PatchBytes(0x859650, t, sizeof(t)); } { uint8 t[] = { 0x18, 0x18 }; PatchBytes(0x8584CC, t, sizeof(t)); } // Don't wait 2 loops } @@ -676,10 +676,6 @@ Snes *SnesInit(const char *filename) { { uint8 t[] = { 0x18, 0x18, 0x18 }; PatchBytes(0x858532, t, sizeof(t)); } // WaitForNMI_NoUpdate { uint8 t[] = { 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18, 0x18 }; PatchBytes(0x85856b, t, sizeof(t)); } // HandleMusicQueue etc. - // Remove WaitForLagFrame in various places - { uint8 t[] = { 0x18, 0x18, 0x18 }; PatchBytes(0x85861C, t, sizeof(t)); } // RestorePpuForMessageBox - { uint8 t[] = { 0x18, 0x18, 0x18 }; PatchBytes(0x858651, t, sizeof(t)); } // RestorePpuForMessageBox - // Patch DisplayMessageBox { uint8 t[] = { 0x18, 0x18, 0x18 }; PatchBytes(0x858096, t, sizeof(t)); } // Remove MsgBoxDelayFrames_2 { uint8 t[] = { 0x18, 0x18, 0x18 }; PatchBytes(0x8580B4, t, sizeof(t)); } // Remove MsgBoxDelayFrames_2 diff --git a/src/sm_rtl.c b/src/sm_rtl.c index ba93f3d..87a4076 100644 --- a/src/sm_rtl.c +++ b/src/sm_rtl.c @@ -245,6 +245,8 @@ void StateRecorder_Load(StateRecorder *sr, FILE *f, bool replay_mode) { if (!is_reset) RtlRestoreMusicAfterLoad_Locked(false); + RtlUpdateSnesPatchForBugfix(); + // Temporarily fix reset state // if (g_snes->cpu->k == 0x82 && g_snes->cpu->pc == 0xf716) // g_snes->cpu->pc = 0xf71c;