remove freeze system; replacement incoming

This commit is contained in:
beirich 2011-08-03 02:13:42 +00:00
parent 0f2b81796f
commit 6f379cee76
5 changed files with 3 additions and 68 deletions

View File

@ -26,7 +26,6 @@ namespace BizHawk.Emulation.Consoles.Calculator
int m_LinkOutput, m_LinkState; int m_LinkOutput, m_LinkState;
bool m_CursorMoved; bool m_CursorMoved;
MemoryDomain.FreezeData[] sysbus_freeze = new MemoryDomain.FreezeData[0x10000];
//------- //-------
public byte ReadMemory(ushort addr) public byte ReadMemory(ushort addr)
@ -40,9 +39,6 @@ namespace BizHawk.Emulation.Consoles.Calculator
ret = rom[romPage * 0x4000 + addr - 0x4000]; //other rom page ret = rom[romPage * 0x4000 + addr - 0x4000]; //other rom page
else ret = ram[addr - 0x8000]; else ret = ram[addr - 0x8000];
//apply freeze
if (sysbus_freeze[addr].IsFrozen) ret = sysbus_freeze[addr].value;
return ret; return ret;
} }
@ -589,9 +585,6 @@ namespace BizHawk.Emulation.Consoles.Calculator
(addr, value) => ram[addr & RamSizeMask] = value); (addr, value) => ram[addr & RamSizeMask] = value);
domains.Add(MainMemoryDomain); domains.Add(MainMemoryDomain);
memoryDomains = domains.AsReadOnly(); memoryDomains = domains.AsReadOnly();
MainMemoryDomain.GetFreeze = addr => sysbus_freeze[addr];
MainMemoryDomain.SetFreeze = (addr, value) => sysbus_freeze[addr] = value;
} }
public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } } public IList<MemoryDomain> MemoryDomains { get { return memoryDomains; } }

View File

@ -23,32 +23,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
CartInfo cart; //the current cart prototype. should be moved into the board, perhaps CartInfo cart; //the current cart prototype. should be moved into the board, perhaps
INESBoard board; //the board hardware that is currently driving things INESBoard board; //the board hardware that is currently driving things
private struct FreezeRecord
{
public int Address;
public MemoryDomain.FreezeData Data;
}
List<FreezeRecord> sysbus_freeze_list = new List<FreezeRecord>();
List<FreezeRecord> ppubus_freeze_list = new List<FreezeRecord>();
MemoryDomain.FreezeData GetFreeze(List<FreezeRecord> list, int addr)
{
int index = list.FindIndex((fd) => fd.Address == addr);
if (index == -1) return MemoryDomain.FreezeData.Empty;
return list[index].Data;
}
void SetFreeze(List<FreezeRecord> list, int addr, MemoryDomain.FreezeData data)
{
int index = list.FindIndex((fd) => fd.Address == addr);
if (index != -1) list.RemoveAt(index);
if(!data.IsFrozen) return;
FreezeRecord fr = new FreezeRecord();
fr.Data = data;
fr.Address = addr;
list.Add(fr);
}
bool _irq_apu, _irq_cart; bool _irq_apu, _irq_cart;
public bool irq_apu { get { return _irq_apu; } set { _irq_apu = value; sync_irq(); } } public bool irq_apu { get { return _irq_apu; } set { _irq_apu = value; sync_irq(); } }
public bool irq_cart { get { return _irq_cart; } set { _irq_cart = value; sync_irq(); } } public bool irq_cart { get { return _irq_cart; } set { _irq_cart = value; sync_irq(); } }

View File

@ -291,15 +291,6 @@ namespace BizHawk.Emulation.Consoles.Nintendo
var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, Endian.Little, var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, Endian.Little,
addr => CIRAM[addr & 0x07FF], (addr, value) => CIRAM[addr & 0x07FF] = value); addr => CIRAM[addr & 0x07FF], (addr, value) => CIRAM[addr & 0x07FF] = value);
SystemBus.GetFreeze = addr => GetFreeze(sysbus_freeze_list, addr);
SystemBus.SetFreeze = (addr, value) => SetFreeze(sysbus_freeze_list, addr, value);
RAM.GetFreeze = addr => GetFreeze(sysbus_freeze_list, addr);
RAM.SetFreeze = (addr, value) => SetFreeze(sysbus_freeze_list, addr & 0x07FF, value);
PPUBus.GetFreeze = addr => GetFreeze(ppubus_freeze_list, addr);
PPUBus.SetFreeze = (addr, value) => SetFreeze(ppubus_freeze_list, addr, value);
//demo a game genie code //demo a game genie code
GetWatch(NESWatch.EDomain.Sysbus, 0xB424).SetGameGenie(-1, 0x10); GetWatch(NESWatch.EDomain.Sysbus, 0xB424).SetGameGenie(-1, 0x10);
GetWatch(NESWatch.EDomain.Sysbus, 0xB424).RemoveGameGenie(); GetWatch(NESWatch.EDomain.Sysbus, 0xB424).RemoveGameGenie();

View File

@ -48,32 +48,9 @@ namespace BizHawk
public readonly int Size; public readonly int Size;
public readonly Endian Endian; public readonly Endian Endian;
//perhaps inconveniently, this is a struct.
//this is a premature optimization, since I anticipate having millions of these and i didnt want millions of objects
public struct FreezeData
{
public FreezeData(Flag flags, byte value)
{
this.flags = flags;
this.value = value;
}
public readonly byte value;
public readonly Flag flags;
public enum Flag : byte
{
None = 0,
Frozen = 1,
}
public bool IsFrozen { get { return (flags & Flag.Frozen) != 0; } }
public static FreezeData Empty { get { return new FreezeData(); } }
}
public readonly Func<int, byte> PeekByte; public readonly Func<int, byte> PeekByte;
public readonly Action<int, byte> PokeByte; public readonly Action<int, byte> PokeByte;
public Func<int, FreezeData> GetFreeze;
public Action<int, FreezeData> SetFreeze;
public MemoryDomain(string name, int size, Endian endian, Func<int, byte> peekByte, Action<int, byte> pokeByte) public MemoryDomain(string name, int size, Endian endian, Func<int, byte> peekByte, Action<int, byte> pokeByte)
{ {
Name = name; Name = name;

View File

@ -44,13 +44,13 @@ namespace BizHawk.MultiClient
public void Enable() public void Enable()
{ {
enabled = true; enabled = true;
domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value)); //domain.SetFreeze(address, new MemoryDomain.FreezeData(MemoryDomain.FreezeData.Flag.Frozen, value));
} }
public void Disable() public void Disable()
{ {
enabled = false; enabled = false;
domain.SetFreeze(address, MemoryDomain.FreezeData.Empty); //domain.ClearFreeze(address);
} }
public bool IsEnabled() public bool IsEnabled()