diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs
index 51711d3fb0..2815d5de91 100644
--- a/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs
+++ b/BizHawk.Emulation/Consoles/Nintendo/NES/BoardSystem.cs
@@ -326,6 +326,44 @@ namespace BizHawk.Emulation.Consoles.Nintendo
return board;
}
+ void BoardSystemHardReset()
+ {
+ INESBoard newboard;
+ // fds has a unique activation setup
+ if (board is FDS)
+ {
+ var newfds = new FDS();
+ var oldfds = board as FDS;
+ newfds.biosrom = oldfds.biosrom;
+ newfds.SetDiskImage(oldfds.GetDiskImage());
+ newboard = newfds;
+ }
+ else
+ {
+ newboard = CreateBoardInstance(board.GetType());
+ }
+ newboard.Create(this);
+ newboard.Configure(origin);
+ newboard.ROM = board.ROM;
+ newboard.VROM = board.VROM;
+ if (board.WRAM != null)
+ newboard.WRAM = new byte[board.WRAM.Length];
+ if (board.VRAM != null)
+ newboard.VRAM = new byte[board.VRAM.Length];
+ newboard.PostConfigure();
+ // the old board's sram must be restored
+ if (newboard is FDS)
+ {
+ var newfds = newboard as FDS;
+ var oldfds = board as FDS;
+ newfds.StoreSaveRam(oldfds.ReadSaveRam());
+ }
+ else if (board.SaveRam != null)
+ {
+ Buffer.BlockCopy(board.SaveRam, 0, newboard.SaveRam, 0, board.SaveRam.Length);
+ }
+ }
+
static NES()
{
diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs
index 78a8851abc..56c09a081c 100644
--- a/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs
+++ b/BizHawk.Emulation/Consoles/Nintendo/NES/Core.cs
@@ -130,10 +130,13 @@ namespace BizHawk.Emulation.Consoles.Nintendo
ports[0] = new JoypadPortDevice(this, 0);
ports[1] = new JoypadPortDevice(this, 1);
+ BoardSystemHardReset();
+
apu = new APU(this, apu);
// don't replace the magicSoundProvider on reset, as it's not needed
// if (magicSoundProvider != null) magicSoundProvider.Dispose();
+
// set up region
switch (cart.system)
{
@@ -186,6 +189,8 @@ namespace BizHawk.Emulation.Consoles.Nintendo
if ((i & 4) != 0) ram[i] = 0xFF; else ram[i] = 0x00;
}
+ SetupMemoryDomains();
+
//in this emulator, reset takes place instantaneously
cpu.PC = (ushort)(ReadMemory(0xFFFC) | (ReadMemory(0xFFFD) << 8));
cpu.P = 0x34;
diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs
index 9afa7113d0..22a3cf202c 100644
--- a/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs
+++ b/BizHawk.Emulation/Consoles/Nintendo/NES/FDS/FDS.cs
@@ -90,6 +90,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo
diskdiffs = new byte[NumSides][];
}
+ ///
+ /// returns the currently set disk image. no effect on emulation (provided the image is not modified).
+ ///
+ ///
+ public byte[] GetDiskImage()
+ {
+ return diskimage;
+ }
+
// as we have [INESBoardImplCancel], this will only be called with an fds disk image
public override bool Configure(NES.EDetectionOrigin origin)
{
diff --git a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs
index 8f8795b234..a2bdab082f 100644
--- a/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs
+++ b/BizHawk.Emulation/Consoles/Nintendo/NES/NES.cs
@@ -487,7 +487,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
List hash_sha1_several = new List();
string hash_sha1 = null, hash_md5 = null;
Unif unif = null;
-
+
origin = EDetectionOrigin.None;
if (file.Length < 16) throw new Exception("Alleged NES rom too small to be anything useful");
@@ -525,8 +525,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
board.PostConfigure();
HardReset();
- SetupMemoryDomains();
-
return;
}
else
@@ -576,7 +574,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
LoadWriteLine("Could not locate game in nescartdb");
if (USE_DATABASE)
{
- if(hash_md5 != null) choice = IdentifyFromGameDB(hash_md5);
+ if (hash_md5 != null) choice = IdentifyFromGameDB(hash_md5);
if (choice == null)
{
choice = IdentifyFromGameDB(hash_sha1);
@@ -590,7 +588,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
LoadWriteLine("Using information from UNIF header");
choice = unif.GetCartInfo();
choice.game = new NESGameInfo();
- choice.game.name = gameInfo.Name;
+ choice.game.name = gameInfo.Name;
origin = EDetectionOrigin.UNIF;
}
if (iNesHeaderInfo != null)
@@ -744,7 +742,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
board.PostConfigure();
HardReset();
- SetupMemoryDomains();
}
void SyncState(Serializer ser)