sketch out some thoughts regarding breakpoints

This commit is contained in:
zeromus 2011-03-16 05:06:21 +00:00
parent 26f006b1c9
commit 2b1f72a84a
3 changed files with 35 additions and 1 deletions

View File

@ -211,6 +211,14 @@ namespace BizHawk.Emulation.Consoles.Nintendo
//apply freeze
if (sysbus_freeze[addr].IsFrozen) ret = sysbus_freeze[addr].value;
//handle breakpoints and stuff.
//the idea is that each core can implement its own watch class on an address which will track all the different kinds of monitors and breakpoints and etc.
//but since freeze is a common case, it was implemented through its own mechanisms
if (sysbus_freeze[addr].HasWatch)
{
(sysbus_freeze[addr].watch as NESWatch).Read();
}
return ret;
}

View File

@ -34,6 +34,16 @@ namespace BizHawk.Emulation.Consoles.Nintendo
SetPalette(Palettes.FCEUX_Standard);
}
class NESWatch
{
public Action OnRead;
public void Read()
{
if (OnRead != null) OnRead();
}
}
public enum EMirrorType
{
Vertical, Horizontal,
@ -183,6 +193,13 @@ namespace BizHawk.Emulation.Consoles.Nintendo
SystemBus.GetFreeze = addr => sysbus_freeze[addr];
SystemBus.SetFreeze = (addr,value) => sysbus_freeze[addr] = value;
//demo a watchpoint
var test = new NESWatch();
test.OnRead = () => Console.WriteLine("0x8000 was read!");
MemoryDomain.FreezeData temp = SystemBus.GetFreeze(0x8000);
temp.SetWatch(test);
SystemBus.SetFreeze(0x8000,temp);
domains.Add(RAM);
domains.Add(SystemBus);
domains.Add(PPUBus);

View File

@ -48,22 +48,31 @@ namespace BizHawk
public readonly int Size;
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;
watch = null;
}
public byte value;
public Flag flags;
public object watch;
public void SetWatch(object watch)
{
this.watch = watch;
}
public enum Flag : byte
{
None = 0,
Frozen = 1
}
public bool IsFrozen { get { return flags != Flag.None; } }
public bool IsFrozen { get { return (flags & Flag.Frozen) != 0; } }
public bool HasWatch { get { return watch != null; } }
public static FreezeData Unfrozen { get { return new FreezeData(); } }
}