nes: reset board state with hard reset
This commit is contained in:
parent
53520540ea
commit
ec82f11884
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -90,6 +90,15 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
diskdiffs = new byte[NumSides][];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// returns the currently set disk image. no effect on emulation (provided the image is not modified).
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
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)
|
||||
{
|
||||
|
|
|
@ -487,7 +487,7 @@ namespace BizHawk.Emulation.Consoles.Nintendo
|
|||
List<string> hash_sha1_several = new List<string>();
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue