From a4e1defad36904d9652f80b1fd113ae8d2f708bc Mon Sep 17 00:00:00 2001 From: adelikat Date: Tue, 21 Apr 2020 13:27:40 -0500 Subject: [PATCH] make PCE core a lot faster, one is supposed to check for the existence of callbacks before calling them --- BizHawk.Emulation.Cores/CPUs/HuC6280/Execute.cs | 6 +++++- BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs | 16 ++++++++++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/Execute.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/Execute.cs index 67b969c143..9b24d0735d 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/Execute.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/Execute.cs @@ -60,7 +60,11 @@ namespace BizHawk.Emulation.Cores.Components.H6280 LagIFlag = FlagI; if (Debug) Logger(State()); - MemoryCallbacks.CallMemoryCallbacks(PC, 0, (uint)MemoryCallbackFlags.AccessExecute, "System Bus"); + + if (MemoryCallbacks.HasExecutes) + { + MemoryCallbacks.CallMemoryCallbacks(PC, 0, (uint)MemoryCallbackFlags.AccessExecute, "System Bus"); + } if (CDL != null && CDL.Active) CDLOpcode(); diff --git a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs index ec3b8bd9a2..155b1ce839 100644 --- a/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs +++ b/BizHawk.Emulation.Cores/CPUs/HuC6280/HuC6280.cs @@ -326,8 +326,13 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { byte page = MPR[address >> 13]; var result = ReadMemory21((page << 13) | (address & 0x1FFF)); - uint flags = (uint)(MemoryCallbackFlags.AccessRead); - MemoryCallbacks.CallMemoryCallbacks(address, result, flags, "System Bus"); + + if (MemoryCallbacks.HasReads) + { + uint flags = (uint)(MemoryCallbackFlags.AccessRead); + MemoryCallbacks.CallMemoryCallbacks(address, result, flags, "System Bus"); + } + return result; } @@ -335,8 +340,11 @@ namespace BizHawk.Emulation.Cores.Components.H6280 { byte page = MPR[address >> 13]; WriteMemory21((page << 13) | (address & 0x1FFF), value); - uint flags = (uint)(MemoryCallbackFlags.AccessWrite); - MemoryCallbacks.CallMemoryCallbacks(address, value, flags, "System Bus"); + if (MemoryCallbacks.HasWrites) + { + uint flags = (uint)(MemoryCallbackFlags.AccessWrite); + MemoryCallbacks.CallMemoryCallbacks(address, value, flags, "System Bus"); + } } private ushort ReadWord(ushort address)