Exemplo n.º 1
0
 private void Remove(CallbackContainer cb)
 {
     if (MGBAHawk.ZZHacky.BizClearWatchpoint(_mgba.Core, cb.ID))
     {
         _callbacks.Remove(cb);
     }
 }
Exemplo n.º 2
0
        public void Add(IMemoryCallback callback)
        {
            if (!AvailableScopes.Contains(callback.Scope))
            {
                throw new InvalidOperationException($"{callback.Scope} is not currently supported for callbacks");
            }

            if (!callback.Address.HasValue)
            {
                throw new NotImplementedException("Wildcard callbacks (no address specified) not currently implemented.");
            }

            var container = new CallbackContainer(callback);

            if (container.Callback.Type == MemoryCallbackType.Execute)
            {
                _executeCallback = RunExecCallback;
                _execPcs[callback.Address.Value] = callback;
                MGBAHawk.ZZHacky.BizSetExecCallback(_mgba.Core, _executeCallback);
            }
            else
            {
                MGBAHawk.ZZHacky.BizSetMemCallback(_mgba.Core, container.CallDelegate);
                container.ID = MGBAHawk.ZZHacky.BizSetWatchpoint(_mgba.Core, callback.Address.Value, container.WatchPointType);
            }

            _callbacks.Add(container);
        }