From 1cfa050dba96aa08ec00bc6af37e86a8ad919922 Mon Sep 17 00:00:00 2001 From: goyuken Date: Tue, 7 Jan 2014 01:05:24 +0000 Subject: [PATCH] quicknes: add text savestate, and fix savestate crash on some mappers --- .../Consoles/Nintendo/QuickNES/QuickNES.cs | 19 ++++++++++++++++-- output/dll/libquicknes.dll | Bin 454842 -> 454842 bytes quicknes/nes_emu/Nes_Core.cpp | 2 +- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs index 95fc4f827f..623e9ce698 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/QuickNES/QuickNES.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using BizHawk.Emulation.Common; using System.Runtime.InteropServices; +using BizHawk.Common; namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES { @@ -217,12 +218,26 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.QuickNES public void SaveStateText(System.IO.TextWriter writer) { - throw new NotImplementedException(); + var temp = SaveStateBinary(); + temp.SaveAsHexFast(writer); + // write extra copy of stuff we don't use + writer.WriteLine("Frame {0}", Frame); } public void LoadStateText(System.IO.TextReader reader) { - throw new NotImplementedException(); + string hex = reader.ReadLine(); + if (hex.StartsWith("emuVersion")) // movie save + { + do // theoretically, our portion should start right after StartsFromSavestate, maybe... + { + hex = reader.ReadLine(); + } while (!hex.StartsWith("StartsFromSavestate")); + hex = reader.ReadLine(); + } + byte[] state = new byte[hex.Length / 2]; + state.ReadFromHexFast(hex); + LoadStateBinary(new System.IO.BinaryReader(new System.IO.MemoryStream(state))); } public void SaveStateBinary(System.IO.BinaryWriter writer) diff --git a/output/dll/libquicknes.dll b/output/dll/libquicknes.dll index b1c2e2ff6749131449a7cf9acd04beb002bccf9b..fa768bfa871719c0ccaeade12660656598c5a2ec 100644 GIT binary patch delta 61 zcmdn>P^MmfxdEuZC{1yD^p+X@yS MX5G%Vf^CZj0PzGCsQ>@~ delta 61 zcmdn>P2$H>sEmfxdEuZC{1yD^p+X@yS MX5G%Vf^CZj0Ll^-VE_OC diff --git a/quicknes/nes_emu/Nes_Core.cpp b/quicknes/nes_emu/Nes_Core.cpp index 365cab4b2f..19dbf0fcf8 100644 --- a/quicknes/nes_emu/Nes_Core.cpp +++ b/quicknes/nes_emu/Nes_Core.cpp @@ -348,7 +348,7 @@ void Nes_Core::reset( bool full_reset, bool erase_battery_ram ) // SRAM lrom_readable = 0; - sram_present = false; + sram_present = true; enable_sram( false ); if ( !cart->has_battery_ram() || erase_battery_ram ) memset( impl->sram, 0xFF, impl->sram_size );