memorycallbacks with domains - Phase 2 - change api to Call methods and refactor accordingly, everything should behave as it was before the refactor at this point. No cores have yet to be implemented with domains other than the default bus they already had
This commit is contained in:
parent
04ce66c397
commit
cd289c474e
|
@ -74,38 +74,38 @@ namespace BizHawk.Emulation.Common
|
|||
_empty = false;
|
||||
}
|
||||
|
||||
private static void Call(ObservableCollection<IMemoryCallback> cbs, uint addr)
|
||||
private static void Call(ObservableCollection<IMemoryCallback> cbs, uint addr, string domain)
|
||||
{
|
||||
for (int i = 0; i < cbs.Count; i++)
|
||||
{
|
||||
if (!cbs[i].Address.HasValue || cbs[i].Address == (addr & cbs[i].AddressMask))
|
||||
if (!cbs[i].Address.HasValue || (cbs[i].Domain == domain && cbs[i].Address == (addr & cbs[i].AddressMask)))
|
||||
{
|
||||
cbs[i].Callback();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void CallReads(uint addr)
|
||||
public void CallReads(uint addr, string domain)
|
||||
{
|
||||
if (_hasReads)
|
||||
{
|
||||
Call(_reads, addr);
|
||||
Call(_reads, addr, domain);
|
||||
}
|
||||
}
|
||||
|
||||
public void CallWrites(uint addr)
|
||||
public void CallWrites(uint addr, string domain)
|
||||
{
|
||||
if (_hasWrites)
|
||||
{
|
||||
Call(_writes, addr);
|
||||
Call(_writes, addr, domain);
|
||||
}
|
||||
}
|
||||
|
||||
public void CallExecutes(uint addr)
|
||||
public void CallExecutes(uint addr, string domain)
|
||||
{
|
||||
if (_hasExecutes)
|
||||
{
|
||||
Call(_execs, addr);
|
||||
Call(_execs, addr, domain);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -46,19 +46,19 @@ namespace BizHawk.Emulation.Common
|
|||
void Add(IMemoryCallback callback);
|
||||
|
||||
/// <summary>
|
||||
/// Executes all Read callbacks for the given address
|
||||
/// Executes all Read callbacks for the given address and domain
|
||||
/// </summary>
|
||||
void CallReads(uint addr);
|
||||
void CallReads(uint addr, string domain);
|
||||
|
||||
/// <summary>
|
||||
/// Executes all Write callbacks for the given address
|
||||
/// Executes all Write callbacks for the given address and domain
|
||||
/// </summary>
|
||||
void CallWrites(uint addr);
|
||||
void CallWrites(uint addr, string domain);
|
||||
|
||||
/// <summary>
|
||||
/// Executes all Execute callbacks for the given address
|
||||
/// Executes all Execute callbacks for the given address and domain
|
||||
/// </summary>
|
||||
void CallExecutes(uint addr);
|
||||
void CallExecutes(uint addr, string domain);
|
||||
|
||||
/// <summary>
|
||||
/// Removes the given callback from the list
|
||||
|
|
|
@ -192,7 +192,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
|
|||
|
||||
if (MemoryCallbacks != null)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(RegisterPC);
|
||||
MemoryCallbacks.CallExecutes(RegisterPC, "System Bus");
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
|
|||
{
|
||||
if (MemoryCallbacks != null && !peek)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
}
|
||||
|
||||
return ReadMemory(addr, peek);
|
||||
|
@ -41,7 +41,7 @@ namespace BizHawk.Emulation.Cores.Components.CP1610
|
|||
{
|
||||
if (MemoryCallbacks != null && !poke)
|
||||
{
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
}
|
||||
|
||||
WriteMemory(addr, value, poke);
|
||||
|
|
|
@ -60,7 +60,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280
|
|||
LagIFlag = FlagI;
|
||||
|
||||
if (Debug) Logger(State());
|
||||
MemoryCallbacks.CallExecutes(PC);
|
||||
MemoryCallbacks.CallExecutes(PC, "System Bus");
|
||||
|
||||
if (CDL != null && CDL.Active) CDLOpcode();
|
||||
|
||||
|
|
|
@ -230,7 +230,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280
|
|||
{
|
||||
byte page = MPR[address >> 13];
|
||||
var result = ReadMemory21((page << 13) | (address & 0x1FFF));
|
||||
MemoryCallbacks.CallReads(address);
|
||||
MemoryCallbacks.CallReads(address, "System Bus");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ namespace BizHawk.Emulation.Cores.Components.H6280
|
|||
{
|
||||
byte page = MPR[address >> 13];
|
||||
WriteMemory21((page << 13) | (address & 0x1FFF), value);
|
||||
MemoryCallbacks.CallWrites(address);
|
||||
MemoryCallbacks.CallWrites(address, "System Bus");
|
||||
}
|
||||
|
||||
private ushort ReadWord(ushort address)
|
||||
|
|
|
@ -55,7 +55,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80
|
|||
|
||||
if (MemoryCallbacks != null)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(RegPC.Word);
|
||||
MemoryCallbacks.CallExecutes(RegPC.Word, "System Bus");
|
||||
}
|
||||
|
||||
++RegR;
|
||||
|
|
|
@ -45,7 +45,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80
|
|||
{
|
||||
if (MemoryCallbacks != null)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
}
|
||||
|
||||
return ReadMemory(addr);
|
||||
|
@ -55,7 +55,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80
|
|||
{
|
||||
if (MemoryCallbacks != null)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
}
|
||||
|
||||
if (FetchMemory != null)
|
||||
|
@ -70,7 +70,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80
|
|||
{
|
||||
if (MemoryCallbacks != null)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
}
|
||||
|
||||
if (FetchMemory != null)
|
||||
|
@ -85,7 +85,7 @@ namespace BizHawk.Emulation.Cores.Components.Z80
|
|||
{
|
||||
if (MemoryCallbacks != null)
|
||||
{
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
}
|
||||
|
||||
WriteMemory(addr, value);
|
||||
|
|
|
@ -183,9 +183,9 @@ namespace BizHawk.Emulation.Cores.Computers.AppleII
|
|||
|
||||
private void SetCallbacks()
|
||||
{
|
||||
_machine.Memory.ReadCallback = MemoryCallbacks.CallReads;
|
||||
_machine.Memory.WriteCallback = MemoryCallbacks.CallWrites;
|
||||
_machine.Memory.ExecuteCallback = MemoryCallbacks.CallExecutes;
|
||||
_machine.Memory.ReadCallback = (addr) => MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
_machine.Memory.WriteCallback = (addr) => MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
_machine.Memory.ExecuteCallback = (addr) => MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
_machine.Memory.InputCallback = InputCallbacks.Call;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -134,7 +134,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
_mapper.Bit13 = addr.Bit(13);
|
||||
var temp = _mapper.ReadMemory((ushort)(addr & 0x1FFF));
|
||||
_tia.BusState = temp;
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
|
||||
return temp;
|
||||
}
|
||||
|
@ -155,7 +155,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
_mapper.WriteMemory((ushort)(addr & 0x1FFF), value);
|
||||
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
}
|
||||
|
||||
internal void PokeMemory(ushort addr, byte value)
|
||||
|
@ -165,7 +165,7 @@ namespace BizHawk.Emulation.Cores.Atari.Atari2600
|
|||
|
||||
private void ExecFetch(ushort addr)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(addr);
|
||||
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
}
|
||||
|
||||
private void RebootCore()
|
||||
|
|
|
@ -259,7 +259,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
|
||||
private void ExecFetch(ushort addr)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(addr);
|
||||
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
}
|
||||
|
||||
private void Reset_Mapper(string m)
|
||||
|
|
|
@ -23,7 +23,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
{
|
||||
public byte ReadMemory(ushort addr)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
|
||||
if ((addr & 0xFCE0) == 0)
|
||||
{
|
||||
|
@ -100,7 +100,7 @@ namespace BizHawk.Emulation.Cores.Atari.A7800Hawk
|
|||
|
||||
public void WriteMemory(ushort addr, byte value)
|
||||
{
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
|
||||
if ((addr & 0xFCE0) == 0)
|
||||
{
|
||||
|
|
|
@ -166,9 +166,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
|
|||
void InitCallbacks()
|
||||
{
|
||||
padcb = new LibVBANext.StandardCallback(() => InputCallbacks.Call());
|
||||
fetchcb = new LibVBANext.AddressCallback((addr) => MemoryCallbacks.CallExecutes(addr));
|
||||
readcb = new LibVBANext.AddressCallback((addr) => MemoryCallbacks.CallReads(addr));
|
||||
writecb = new LibVBANext.AddressCallback((addr) => MemoryCallbacks.CallWrites(addr));
|
||||
fetchcb = new LibVBANext.AddressCallback((addr) => MemoryCallbacks.CallExecutes(addr, "System Bus"));
|
||||
readcb = new LibVBANext.AddressCallback((addr) => MemoryCallbacks.CallReads(addr, "System Bus"));
|
||||
writecb = new LibVBANext.AddressCallback((addr) => MemoryCallbacks.CallWrites(addr, "System Bus"));
|
||||
tracecb = new LibVBANext.TraceCallback((addr, opcode) => Tracer.Put(Trace(addr, opcode)));
|
||||
_inputCallbacks.ActiveChanged += SyncPadCallback;
|
||||
_memorycallbacks.ActiveChanged += SyncMemoryCallbacks;
|
||||
|
|
|
@ -68,9 +68,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.Gameboy
|
|||
|
||||
private void InitMemoryCallbacks()
|
||||
{
|
||||
_readcb = addr => MemoryCallbacks.CallReads(addr);
|
||||
_writecb = addr => MemoryCallbacks.CallWrites(addr);
|
||||
_execcb = addr => MemoryCallbacks.CallExecutes(addr);
|
||||
_readcb = addr => MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
_writecb = addr => MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
_execcb = addr => MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
_memorycallbacks.ActiveChanged += RefreshMemoryCallbacks;
|
||||
}
|
||||
|
||||
|
|
|
@ -759,13 +759,13 @@ namespace BizHawk.Emulation.Cores.Nintendo.N64.NativeApi
|
|||
switch (_breakparams._type)
|
||||
{
|
||||
case BreakType.Read:
|
||||
_breakparams._mcs.CallReads(_breakparams._addr);
|
||||
_breakparams._mcs.CallReads(_breakparams._addr, "System Bus");
|
||||
break;
|
||||
case BreakType.Write:
|
||||
_breakparams._mcs.CallWrites(_breakparams._addr);
|
||||
_breakparams._mcs.CallWrites(_breakparams._addr, "System Bus");
|
||||
break;
|
||||
case BreakType.Execute:
|
||||
_breakparams._mcs.CallExecutes(_breakparams._addr);
|
||||
_breakparams._mcs.CallExecutes(_breakparams._addr, "System Bus");
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -828,7 +828,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
|
||||
public void ExecFetch(ushort addr)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(addr);
|
||||
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
}
|
||||
|
||||
public byte ReadMemory(ushort addr)
|
||||
|
@ -873,7 +873,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
ret = sysbus_watch[addr].ApplyGameGenie(ret);
|
||||
}
|
||||
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
|
||||
DB = ret;
|
||||
return ret;
|
||||
|
@ -928,7 +928,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.NES
|
|||
Board.WritePRG(addr - 0x8000, value);
|
||||
}
|
||||
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
}
|
||||
|
||||
// the palette for each VS game needs to be chosen explicitly since there are 6 different ones.
|
||||
|
|
|
@ -361,7 +361,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
private void ReadHook(uint addr)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
// we RefreshMemoryCallbacks() after the trigger in case the trigger turns itself off at that point
|
||||
// EDIT: for now, theres some IPC re-entrancy problem
|
||||
// RefreshMemoryCallbacks();
|
||||
|
@ -369,7 +369,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
private void ExecHook(uint addr)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(addr);
|
||||
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
// we RefreshMemoryCallbacks() after the trigger in case the trigger turns itself off at that point
|
||||
// EDIT: for now, theres some IPC re-entrancy problem
|
||||
// RefreshMemoryCallbacks();
|
||||
|
@ -377,7 +377,7 @@ namespace BizHawk.Emulation.Cores.Nintendo.SNES
|
|||
|
||||
private void WriteHook(uint addr, byte val)
|
||||
{
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
// we RefreshMemoryCallbacks() after the trigger in case the trigger turns itself off at that point
|
||||
// EDIT: for now, theres some IPC re-entrancy problem
|
||||
// RefreshMemoryCallbacks();
|
||||
|
|
|
@ -61,9 +61,9 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
|
|||
|
||||
private void InitMemCallbacks()
|
||||
{
|
||||
ExecCallback = new LibGPGX.mem_cb(a => MemoryCallbacks.CallExecutes(a));
|
||||
ReadCallback = new LibGPGX.mem_cb(a => MemoryCallbacks.CallReads(a));
|
||||
WriteCallback = new LibGPGX.mem_cb(a => MemoryCallbacks.CallWrites(a));
|
||||
ExecCallback = new LibGPGX.mem_cb(a => MemoryCallbacks.CallExecutes(a, "M68K BUS"));
|
||||
ReadCallback = new LibGPGX.mem_cb(a => MemoryCallbacks.CallReads(a, "M68K BUS"));
|
||||
WriteCallback = new LibGPGX.mem_cb(a => MemoryCallbacks.CallWrites(a, "M68K BUS"));
|
||||
_memoryCallbacks.ActiveChanged += RefreshMemCallbacks;
|
||||
}
|
||||
|
||||
|
|
|
@ -881,13 +881,13 @@ namespace BizHawk.Emulation.Cores.Sony.PSX
|
|||
switch (type)
|
||||
{
|
||||
case OctoshockDll.eShockMemCb.Read:
|
||||
MemoryCallbacks.CallReads(address);
|
||||
MemoryCallbacks.CallReads(address, "System Bus");
|
||||
break;
|
||||
case OctoshockDll.eShockMemCb.Write:
|
||||
MemoryCallbacks.CallWrites(address);
|
||||
MemoryCallbacks.CallWrites(address, "System Bus");
|
||||
break;
|
||||
case OctoshockDll.eShockMemCb.Execute:
|
||||
MemoryCallbacks.CallExecutes(address);
|
||||
MemoryCallbacks.CallExecutes(address, "System Bus");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,15 +140,15 @@ namespace BizHawk.Emulation.Cores.WonderSwan
|
|||
|
||||
void ReadCallback(uint addr)
|
||||
{
|
||||
MemoryCallbacks.CallReads(addr);
|
||||
MemoryCallbacks.CallReads(addr, "System Bus");
|
||||
}
|
||||
void WriteCallback(uint addr)
|
||||
{
|
||||
MemoryCallbacks.CallWrites(addr);
|
||||
MemoryCallbacks.CallWrites(addr, "System Bus");
|
||||
}
|
||||
void ExecCallback(uint addr)
|
||||
{
|
||||
MemoryCallbacks.CallExecutes(addr);
|
||||
MemoryCallbacks.CallExecutes(addr, "System Bus");
|
||||
}
|
||||
void ButtonCallback()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue