From 9cc5a000765470e8ade0c0b4f2709c68946d6623 Mon Sep 17 00:00:00 2001 From: pjgat09 Date: Sun, 19 May 2013 23:38:34 +0000 Subject: [PATCH] N64: Dirty hack to allow savestates to be loaded during the first or second frame of emulation. --- .../Consoles/Nintendo/N64/mupen64plusApi.cs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs b/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs index 35186eb03d..d97746e264 100644 --- a/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs +++ b/BizHawk.Emulation/Consoles/Nintendo/N64/mupen64plusApi.cs @@ -708,6 +708,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo.N64 public void LoadState(byte[] buffer) { + // This is a dirty hack... + // When using the dynamic recompiler if a state is loaded too early some pointers are not set up yet, so mupen + // tries to access null pointers and the emulator crashes. It seems like it takes 2 frames to fully set up the recompiler, + // so if two frames haven't been run yet, run them, then load the state. + if (bizhawkCore.Frame < 2) + { + frame_advance(); + frame_advance(); + } + m64pCoreLoadState(buffer); }