add memory API, remove HardReset from IEmulator
This commit is contained in:
parent
c61cf558ca
commit
e62c1bc673
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using System.Collections.Generic;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
|
||||
|
@ -440,5 +439,8 @@ namespace BizHawk.Emulation.Consoles.Calculator
|
|||
{
|
||||
return new byte[0];
|
||||
}
|
||||
}
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { throw new NotImplementedException(); } }
|
||||
public MemoryDomain MainMemory { get { throw new NotImplementedException(); } }
|
||||
}
|
||||
}
|
|
@ -842,5 +842,8 @@ namespace BizHawk.Emulation.Consoles.Gameboy
|
|||
}
|
||||
|
||||
public bool DeterministicEmulation { get; set; }
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { throw new NotImplementedException(); } }
|
||||
public MemoryDomain MainMemory { get { throw new NotImplementedException(); } }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using BizHawk.Emulation.CPUs.H6280;
|
||||
|
@ -104,6 +105,7 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
RomPages = RomData.Length / 8192;
|
||||
}
|
||||
Cpu.ResetPC();
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
||||
public int Frame { get; set; }
|
||||
|
@ -275,5 +277,19 @@ namespace BizHawk.Emulation.Consoles.TurboGrafx
|
|||
writer.Close();
|
||||
return buf;
|
||||
}
|
||||
|
||||
private void SetupMemoryDomains()
|
||||
{
|
||||
var domains = new List<MemoryDomain>(1);
|
||||
var MainMemoryDomain = new MemoryDomain("Main Memory", Ram.Length, Endian.Little,
|
||||
addr => Ram[addr & 0x7FFF],
|
||||
(addr, value) => Ram[addr & 0x7FFF] = value);
|
||||
domains.Add(MainMemoryDomain);
|
||||
memoryDomains = domains.AsReadOnly();
|
||||
}
|
||||
|
||||
private IList<MemoryDomain> memoryDomains;
|
||||
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
|
||||
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using BizHawk.Emulation.CPUs.M68K;
|
||||
using BizHawk.Emulation.CPUs.Z80;
|
||||
|
@ -187,5 +188,8 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
{
|
||||
return new byte[0];
|
||||
}
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { throw new NotImplementedException(); } }
|
||||
public MemoryDomain MainMemory { get { throw new NotImplementedException(); } }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
@ -7,14 +8,10 @@ using BizHawk.Emulation.Sound;
|
|||
|
||||
/*****************************************************
|
||||
|
||||
VDP:
|
||||
TODO:
|
||||
+ HCounter
|
||||
+ Old TMS video modes (SG-1000)
|
||||
|
||||
GENERAL:
|
||||
+ Port 3F emulation (Japanese BIOS)
|
||||
+ Try to clean up the organization of the source code.
|
||||
+ SG-1000 support
|
||||
|
||||
**********************************************************/
|
||||
|
||||
|
@ -105,6 +102,8 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
InitSegaMapper();
|
||||
else
|
||||
InitCodeMastersMapper();
|
||||
|
||||
SetupMemoryDomains();
|
||||
}
|
||||
|
||||
public void LoadGame(IGame game)
|
||||
|
@ -333,5 +332,29 @@ namespace BizHawk.Emulation.Consoles.Sega
|
|||
}
|
||||
|
||||
private readonly string[] validRegions = {"Export", "Japan"};
|
||||
|
||||
private IList<MemoryDomain> memoryDomains;
|
||||
|
||||
private void SetupMemoryDomains()
|
||||
{
|
||||
var domains = new List<MemoryDomain>(3);
|
||||
var MainMemoryDomain = new MemoryDomain("Main RAM", SystemRam.Length, Endian.Little,
|
||||
addr => SystemRam[addr & RamSizeMask],
|
||||
(addr, value) => SystemRam[addr & RamSizeMask] = value);
|
||||
var VRamDomain = new MemoryDomain("Video RAM", Vdp.VRAM.Length, Endian.Little,
|
||||
addr => Vdp.VRAM[addr & 0x3FFF],
|
||||
(addr, value) => Vdp.VRAM[addr & 0x3FFF] = value);
|
||||
var SaveRamDomain = new MemoryDomain("Save RAM", SaveRAM.Length, Endian.Little,
|
||||
addr => SaveRAM[addr%SaveRAM.Length],
|
||||
(addr, value) => { SaveRAM[addr%SaveRAM.Length]=value; SaveRamModified=true;});
|
||||
|
||||
domains.Add(MainMemoryDomain);
|
||||
domains.Add(VRamDomain);
|
||||
domains.Add(SaveRamDomain);
|
||||
memoryDomains = domains.AsReadOnly();
|
||||
}
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }
|
||||
public MemoryDomain MainMemory { get { return memoryDomains[0]; } }
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk
|
||||
|
@ -35,5 +36,8 @@ namespace BizHawk
|
|||
public int BufferHeight { get { return 192; } }
|
||||
public int BackgroundColor { get { return 0; } }
|
||||
public void GetSamples(short[] samples) { }
|
||||
|
||||
public IList<MemoryDomain> MemoryDomains { get { return new List<MemoryDomain>(0); } }
|
||||
public MemoryDomain MainMemory { get { return null; } }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,4 +1,6 @@
|
|||
using System.IO;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
|
||||
namespace BizHawk
|
||||
{
|
||||
|
@ -12,7 +14,6 @@ namespace BizHawk
|
|||
|
||||
void LoadGame(IGame game);
|
||||
void FrameAdvance(bool render);
|
||||
void HardReset();
|
||||
|
||||
int Frame { get; }
|
||||
bool DeterministicEmulation { get; set; }
|
||||
|
@ -28,7 +29,37 @@ namespace BizHawk
|
|||
void SaveStateBinary(BinaryWriter writer);
|
||||
void LoadStateBinary(BinaryReader reader);
|
||||
byte[] SaveStateBinary();
|
||||
|
||||
// ----- Client Debugging API stuff -----
|
||||
IList<MemoryDomain> MemoryDomains { get; }
|
||||
MemoryDomain MainMemory { get; }
|
||||
}
|
||||
|
||||
public class MemoryDomain
|
||||
{
|
||||
private readonly string Name;
|
||||
private readonly int Size;
|
||||
private readonly Endian Endian;
|
||||
|
||||
public readonly Func<int, byte> PeekByte;
|
||||
public readonly Action<int, byte> PokeByte;
|
||||
|
||||
public MemoryDomain(string name, int size, Endian endian, Func<int, byte> peekByte, Action<int, byte> pokeByte)
|
||||
{
|
||||
Name = name;
|
||||
Size = size;
|
||||
Endian = endian;
|
||||
PeekByte = peekByte;
|
||||
PokeByte = pokeByte;
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return Name;
|
||||
}
|
||||
}
|
||||
|
||||
public enum Endian { Big, Little, Unknown }
|
||||
|
||||
public enum DisplayType { NTSC, PAL }
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
private Control renderTarget;
|
||||
private RetainedViewportPanel retainedPanel;
|
||||
|
||||
private string CurrentlyOpenRom;
|
||||
private int SaveSlot = 0; //Saveslot sytem
|
||||
|
||||
private bool EmulatorPaused = false;
|
||||
|
@ -271,6 +271,8 @@ namespace BizHawk.MultiClient
|
|||
{
|
||||
new BizHawk.Emulation.Consoles.Gameboy.Debugger(Global.Emulator as Gameboy).Show();
|
||||
}
|
||||
|
||||
CurrentlyOpenRom = path;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -315,7 +317,7 @@ namespace BizHawk.MultiClient
|
|||
if (Global.ClientControls["Hard Reset"])
|
||||
{
|
||||
Global.ClientControls.UnpressButton("Hard Reset");
|
||||
Global.Emulator.HardReset();
|
||||
LoadRom(CurrentlyOpenRom);
|
||||
}
|
||||
|
||||
if (Global.ClientControls["Fast Forward"])
|
||||
|
@ -473,7 +475,7 @@ namespace BizHawk.MultiClient
|
|||
|
||||
private void powerToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
{
|
||||
Global.Emulator.HardReset();
|
||||
LoadRom(CurrentlyOpenRom);
|
||||
}
|
||||
|
||||
private void resetToolStripMenuItem_Click(object sender, EventArgs e)
|
||||
|
|
Loading…
Reference in New Issue