add some stuff

This commit is contained in:
feos 2020-03-01 11:01:17 +03:00 committed by adelikat
parent 4597e8b334
commit fc5d8b2de6
1 changed files with 27 additions and 6 deletions

View File

@ -45,10 +45,14 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
var container = new CallbackContainer(callback); var container = new CallbackContainer(callback);
if (container.Callback.Type != MemoryCallbackType.Execute) if (container.Callback.Type == MemoryCallbackType.Execute)
{
// TODO
}
else
{ {
LibmGBA.BizSetMemCallback(container.Call); LibmGBA.BizSetMemCallback(container.Call);
//LibmGBA.BizSetWatchpoint(_core, callback.Address, container.WatchPointType); container.ID = LibmGBA.BizSetWatchpoint(_core, callback.Address.Value, container.WatchPointType);
} }
_callbacks.Add(container); _callbacks.Add(container);
@ -56,17 +60,31 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public void Remove(MemoryCallbackDelegate action) public void Remove(MemoryCallbackDelegate action)
{ {
// TODO var cbToRemove = _callbacks.Where(container => container.Callback.Callback == action).FirstOrDefault();
if (LibmGBA.BizClearWatchpoint(_core, cbToRemove.ID) == true)
{
_callbacks.Remove(cbToRemove);
}
} }
public void RemoveAll(IEnumerable<MemoryCallbackDelegate> actions) public void RemoveAll(IEnumerable<MemoryCallbackDelegate> actions)
{ {
// TODO foreach (var action in actions)
{
Remove(action);
}
} }
public void Clear() public void Clear()
{ {
// TODO foreach (var cb in _callbacks)
{
if (LibmGBA.BizClearWatchpoint(_core, cb.ID) == true)
{
_callbacks.Remove(cb);
}
}
} }
public IEnumerator<IMemoryCallback> GetEnumerator() => _callbacks.Select(c => c.Callback).GetEnumerator(); public IEnumerator<IMemoryCallback> GetEnumerator() => _callbacks.Select(c => c.Callback).GetEnumerator();
@ -87,6 +105,9 @@ namespace BizHawk.Emulation.Cores.Nintendo.GBA
public IMemoryCallback Callback { get; } public IMemoryCallback Callback { get; }
// the core returns this when setting a wp and needs it to clear that wp
public int ID { get; set; }
public LibmGBA.mWatchpointType WatchPointType public LibmGBA.mWatchpointType WatchPointType
{ {
get get