quicknes: add text savestate, and fix savestate crash on some mappers

This commit is contained in:
goyuken 2014-01-07 01:05:24 +00:00
parent 768b940cfc
commit 1cfa050dba
3 changed files with 18 additions and 3 deletions

View File

@ -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)

Binary file not shown.

View File

@ -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 );