bsnes: implement r/w callback value passing
The value will now be passed to the frontend for read callbacks and both read and write callbacks' values can now be changed in the callback. execute would probably be possible but would require some additional code changes which I'm not sure about
This commit is contained in:
parent
6fe1b2d190
commit
6284b56e81
Binary file not shown.
|
@ -199,8 +199,8 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
public delegate void snes_no_lag_t(bool sgb_poll);
|
||||
public delegate string snes_path_request_t(int slot, string hint, bool required);
|
||||
public delegate void snes_trace_t(string disassembly, string register_info);
|
||||
public delegate void snes_read_hook_t(uint address);
|
||||
public delegate void snes_write_hook_t(uint address, byte value);
|
||||
public delegate void snes_read_hook_t(uint address, ref byte value);
|
||||
public delegate void snes_write_hook_t(uint address, ref byte value);
|
||||
public delegate void snes_exec_hook_t(uint address);
|
||||
public delegate long snes_time_t();
|
||||
public delegate bool snes_msu_open_t(ushort track_id);
|
||||
|
|
|
@ -323,19 +323,19 @@ namespace BizHawk.Emulation.Cores.Nintendo.BSNES
|
|||
private void snes_trace(string disassembly, string registerInfo)
|
||||
=> _tracer.Put(new(disassembly: disassembly, registerInfo: registerInfo));
|
||||
|
||||
private void ReadHook(uint addr)
|
||||
private void ReadHook(uint addr, ref byte value)
|
||||
{
|
||||
if (MemoryCallbacks.HasReads)
|
||||
{
|
||||
MemoryCallbacks.CallMemoryCallbacks(addr, 0, (uint) MemoryCallbackFlags.AccessRead, "System Bus");
|
||||
value = (byte) MemoryCallbacks.CallMemoryCallbacks(addr, value, (uint) MemoryCallbackFlags.AccessRead, "System Bus");
|
||||
}
|
||||
}
|
||||
|
||||
private void WriteHook(uint addr, byte value)
|
||||
private void WriteHook(uint addr, ref byte value)
|
||||
{
|
||||
if (MemoryCallbacks.HasWrites)
|
||||
{
|
||||
MemoryCallbacks.CallMemoryCallbacks(addr, value, (uint) MemoryCallbackFlags.AccessWrite, "System Bus");
|
||||
value = (byte) MemoryCallbacks.CallMemoryCallbacks(addr, value, (uint) MemoryCallbackFlags.AccessWrite, "System Bus");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -30,8 +30,8 @@ struct Platform {
|
|||
bool writeHookEnabled = false;
|
||||
bool executeHookEnabled = false;
|
||||
virtual auto cpuTrace(vector<string>) -> void {}
|
||||
virtual auto readHook(uint address) -> void {}
|
||||
virtual auto writeHook(uint address, uint8 value) -> void {}
|
||||
virtual auto readHook(uint address, uint8& value) -> void {}
|
||||
virtual auto writeHook(uint address, uint8& value) -> void {}
|
||||
virtual auto execHook(uint address) -> void {}
|
||||
virtual auto time() -> int64 { return ::time(0); }
|
||||
};
|
||||
|
|
|
@ -7,8 +7,6 @@ auto CPU::idle() -> void {
|
|||
}
|
||||
|
||||
auto CPU::read(uint address) -> uint8 {
|
||||
if (__builtin_expect(platform->readHookEnabled, 0))
|
||||
platform->readHook(address);
|
||||
|
||||
if(address & 0x408000) {
|
||||
if(address & 0x800000 && io.fastROM) {
|
||||
|
@ -41,6 +39,8 @@ auto CPU::read(uint address) -> uint8 {
|
|||
|
||||
status.irqLock = 0;
|
||||
auto data = bus.read(address, r.mdr);
|
||||
if (__builtin_expect(platform->readHookEnabled, 0))
|
||||
platform->readHook(address, data);
|
||||
step<4,0>();
|
||||
aluEdge();
|
||||
//$00-3f,80-bf:4000-43ff reads are internal to CPU, and do not update the MDR
|
||||
|
|
|
@ -9,8 +9,8 @@ typedef void (*snes_controller_latch_t)(void);
|
|||
typedef void (*snes_no_lag_t)(bool sgb_poll);
|
||||
typedef char* (*snes_path_request_t)(int slot, const char* hint, bool required);
|
||||
typedef void (*snes_trace_t)(const char* disassembly, const char* register_info);
|
||||
typedef void (*snes_read_hook_t)(uint32_t address);
|
||||
typedef void (*snes_write_hook_t)(uint32_t address, uint8_t value);
|
||||
typedef void (*snes_read_hook_t)(uint32_t address, uint8_t& value);
|
||||
typedef void (*snes_write_hook_t)(uint32_t address, uint8_t& value);
|
||||
typedef void (*snes_exec_hook_t)(uint32_t address);
|
||||
typedef int64_t (*snes_time_t)(void);
|
||||
typedef void (*snes_msu_open_t)(uint16_t track_id);
|
||||
|
|
|
@ -26,8 +26,8 @@ struct Program : Emulator::Platform
|
|||
auto notify(string text) -> void override;
|
||||
auto getBackdropColor() -> uint16 override;
|
||||
auto cpuTrace(vector<string>) -> void override;
|
||||
auto readHook(uint address) -> void override;
|
||||
auto writeHook(uint address, uint8 value) -> void override;
|
||||
auto readHook(uint address, uint8& value) -> void override;
|
||||
auto writeHook(uint address, uint8& value) -> void override;
|
||||
auto execHook(uint address) -> void override;
|
||||
auto time() -> int64 override;
|
||||
|
||||
|
@ -482,12 +482,12 @@ auto Program::cpuTrace(vector<string> parts) -> void
|
|||
snesCallbacks.snes_trace(parts[0], parts[1]);
|
||||
}
|
||||
|
||||
auto Program::readHook(uint address) -> void
|
||||
auto Program::readHook(uint address, uint8& value) -> void
|
||||
{
|
||||
snesCallbacks.snes_read_hook(address);
|
||||
snesCallbacks.snes_read_hook(address, value);
|
||||
}
|
||||
|
||||
auto Program::writeHook(uint address, uint8 value) -> void
|
||||
auto Program::writeHook(uint address, uint8& value) -> void
|
||||
{
|
||||
snesCallbacks.snes_write_hook(address, value);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue