Pass values to memory callbacks in GPGX (squashed PR #3821)

* fix on_bus_read issue for genplus-gx core

- related to issue #3813
- update signatures, create new value variable in each of the memory read core functions, pass it to the callback and return it instead of the inline calculations. Also, pass val to write and exec callbacks in IDebuggable since they all use the same mem_cb signature and it would break otherwise. I want to update write and exec callbacks in next commit though to ensure nothing unexpected happens.

* update write callbacks for genplus-gx

- related to issue #3813

* update exec callbacks for genplus-gx

- closes #3813

* twice memory peek for deep freeze via on_bus_read bizhawk

Read a first time to pass the read value to the callback, read a second time to read the updated value in case it was updated by the callback and effectively deep freeze the value, no matter if 8, 16 or 32 width

* remove lines from unknown source

I have no idea where those lines came from. But I never meant to add them. This should look like it currently looks in master

* reinsert const, use implicit delegate constructors

* update submodule commit to before override memory values

* rename a to addr, unsigned int to just unsigned
This commit is contained in:
VelpaChallenger 2025-04-03 16:46:57 -03:00 committed by GitHub
parent a562a0d23c
commit 53cdf182ae
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 18 additions and 18 deletions

Binary file not shown.

View File

@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using BizHawk.Common;
@ -72,28 +72,28 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
private void InitMemCallbacks()
{
ExecCallback = a =>
ExecCallback = (addr, val) =>
{
if (MemoryCallbacks.HasExecutes)
{
const uint flags = (uint)MemoryCallbackFlags.AccessExecute;
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
MemoryCallbacks.CallMemoryCallbacks(addr, val, flags, "M68K BUS");
}
};
ReadCallback = a =>
ReadCallback = (addr, val) =>
{
if (MemoryCallbacks.HasReads)
{
const uint flags = (uint)MemoryCallbackFlags.AccessRead;
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
MemoryCallbacks.CallMemoryCallbacks(addr, val, flags, "M68K BUS");
}
};
WriteCallback = a =>
WriteCallback = (addr, val) =>
{
if (MemoryCallbacks.HasWrites)
{
const uint flags = (uint)MemoryCallbackFlags.AccessWrite;
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
MemoryCallbacks.CallMemoryCallbacks(addr, val, flags, "M68K BUS");
}
};
_memoryCallbacks.ActiveChanged += RefreshMemCallbacks;

View File

@ -194,7 +194,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
public abstract void gpgx_set_input_callback(input_cb cb);
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void mem_cb(uint addr);
public delegate void mem_cb(uint addr, uint value); //value MUST be uint, since the value will be trimmed if the type is byte (8-bit) or ushort (16-bit) and the value read/written/executed is bigger than that (i.e 32 bits).
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
public delegate void CDCallback(int addr, CDLog_AddrType addrtype, CDLog_Flags flags);

View File

@ -7,9 +7,9 @@
typedef ECL_ENTRY void (*CDCallback)(int32 addr, int32 addrtype, int32 flags);
extern ECL_ENTRY void (*biz_execcb)(unsigned addr);
extern ECL_ENTRY void (*biz_readcb)(unsigned addr);
extern ECL_ENTRY void (*biz_writecb)(unsigned addr);
extern ECL_ENTRY void (*biz_execcb)(unsigned addr, unsigned value);
extern ECL_ENTRY void (*biz_readcb)(unsigned addr, unsigned value);
extern ECL_ENTRY void (*biz_writecb)(unsigned addr, unsigned value);
extern CDCallback biz_cdcb;
extern ECL_ENTRY void (*cdd_readcallback)(int lba, void *dest, int subcode);

View File

@ -61,9 +61,9 @@ static uint8_t brm_format[0x40] =
0x52,0x41,0x4d,0x5f,0x43,0x41,0x52,0x54,0x52,0x49,0x44,0x47,0x45,0x5f,0x5f,0x5f
};
ECL_ENTRY void (*biz_execcb)(unsigned addr);
ECL_ENTRY void (*biz_readcb)(unsigned addr);
ECL_ENTRY void (*biz_writecb)(unsigned addr);
ECL_ENTRY void (*biz_execcb)(unsigned addr, unsigned int value);
ECL_ENTRY void (*biz_readcb)(unsigned addr, unsigned int value);
ECL_ENTRY void (*biz_writecb)(unsigned addr, unsigned int value);
CDCallback biz_cdcb = NULL;
ECL_ENTRY void (*cdd_readcallback)(int lba, void *dest, int subcode);
uint8 *tempsram;
@ -790,7 +790,7 @@ void bk_cpu_hook(hook_type_t type, int width, unsigned int address, unsigned int
case HOOK_M68K_E:
{
if (biz_execcb)
biz_execcb(address);
biz_execcb(address, value);
if (biz_cdcb)
{
@ -804,7 +804,7 @@ void bk_cpu_hook(hook_type_t type, int width, unsigned int address, unsigned int
case HOOK_M68K_R:
{
if (biz_readcb)
biz_readcb(address);
biz_readcb(address, value);
break;
}
@ -812,7 +812,7 @@ void bk_cpu_hook(hook_type_t type, int width, unsigned int address, unsigned int
case HOOK_M68K_W:
{
if (biz_writecb)
biz_writecb(address);
biz_writecb(address, value);
break;
}
@ -1035,7 +1035,7 @@ GPGX_EX void gpgx_reset(int hard)
gen_reset(0);
}
GPGX_EX void gpgx_set_mem_callback(ECL_ENTRY void (*read)(unsigned), ECL_ENTRY void (*write)(unsigned), ECL_ENTRY void (*exec)(unsigned))
GPGX_EX void gpgx_set_mem_callback(ECL_ENTRY void (*read)(unsigned, unsigned), ECL_ENTRY void (*write)(unsigned, unsigned), ECL_ENTRY void (*exec)(unsigned, unsigned))
{
biz_readcb = read;
biz_writecb = write;