Skip to content

Commit bd41934

Browse files
VelpaChallengerlucianoj77052012
authored andcommitted
fix on_bus_read issue for genplus-gx core
- related to issue TASEmulators#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.
1 parent 220004d commit bd41934

File tree

6 files changed

+31
-21
lines changed

6 files changed

+31
-21
lines changed

Assets/dll/gpgx.wbx.zst

4.6 KB
Binary file not shown.

src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/GPGX.IDebuggable.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,23 @@ public void SetCpuRegister(string register, int value)
5959

6060
private void InitMemCallbacks()
6161
{
62-
ExecCallback = new LibGPGX.mem_cb(a =>
62+
ExecCallback = new LibGPGX.mem_cb((a, val) =>
6363
{
6464
if (MemoryCallbacks.HasExecutes)
6565
{
6666
uint flags = (uint)MemoryCallbackFlags.AccessExecute;
6767
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
6868
}
6969
});
70-
ReadCallback = new LibGPGX.mem_cb(a =>
70+
ReadCallback = new LibGPGX.mem_cb((a, val) =>
7171
{
7272
if (MemoryCallbacks.HasReads)
7373
{
7474
uint flags = (uint)MemoryCallbackFlags.AccessRead;
75-
MemoryCallbacks.CallMemoryCallbacks(a, 0, flags, "M68K BUS");
75+
MemoryCallbacks.CallMemoryCallbacks(a, val, flags, "M68K BUS");
7676
}
7777
});
78-
WriteCallback = new LibGPGX.mem_cb(a =>
78+
WriteCallback = new LibGPGX.mem_cb((a, val) =>
7979
{
8080
if (MemoryCallbacks.HasWrites)
8181
{

src/BizHawk.Emulation.Cores/Consoles/Sega/gpgx64/LibGPGX.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ public enum CDLog_Flags
148148
public abstract void gpgx_set_input_callback(input_cb cb);
149149

150150
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
151-
public delegate void mem_cb(uint addr);
151+
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).
152152

153153
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
154154
public delegate void CDCallback(int addr, CDLog_AddrType addrtype, CDLog_Flags flags);

waterbox/gpgx/cinterface/callbacks.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
typedef ECL_ENTRY void (*CDCallback)(int32 addr, int32 addrtype, int32 flags);
99

1010
extern ECL_ENTRY void (*biz_execcb)(unsigned addr);
11-
extern ECL_ENTRY void (*biz_readcb)(unsigned addr);
11+
extern ECL_ENTRY void (*biz_readcb)(unsigned addr, unsigned int value);
1212
extern ECL_ENTRY void (*biz_writecb)(unsigned addr);
1313
extern CDCallback biz_cdcallback;
1414
extern unsigned biz_lastpc;

waterbox/gpgx/cinterface/cinterface.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static uint8_t brm_format[0x40] =
5656
};
5757

5858
ECL_ENTRY void (*biz_execcb)(unsigned addr);
59-
ECL_ENTRY void (*biz_readcb)(unsigned addr);
59+
ECL_ENTRY void (*biz_readcb)(unsigned addr, unsigned int value);
6060
ECL_ENTRY void (*biz_writecb)(unsigned addr);
6161
CDCallback biz_cdcallback = NULL;
6262
unsigned biz_lastpc = 0;

waterbox/gpgx/core/m68k/m68kcpu.h

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -870,24 +870,25 @@ INLINE uint m68ki_read_imm_32(void)
870870
INLINE uint m68ki_read_8_fc(uint address, uint fc)
871871
{
872872
cpu_memory_map *temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];;
873-
if (biz_readcb)
874-
biz_readcb(address);
875873

876874
if(biz_cdcallback)
877875
CDLog68k(address,eCDLog_Flags_Data68k);
878876

879877
m68ki_set_fc(fc) /* auto-disable (see m68kcpu.h) */
880878

881-
if (temp->read8) return (*temp->read8)(ADDRESS_68K(address));
882-
else return READ_BYTE(temp->base, (address) & 0xffff);
879+
uint value;
880+
if (temp->read8)
881+
value = (*temp->read8)(ADDRESS_68K(address));
882+
else
883+
value = READ_BYTE(temp->base, (address) & 0xffff);
884+
if (biz_readcb)
885+
biz_readcb(address, value);
886+
return value;
883887
}
884888

885889
INLINE uint m68ki_read_16_fc(uint address, uint fc)
886890
{
887891
cpu_memory_map *temp;
888-
if (biz_readcb)
889-
biz_readcb(address);
890-
891892
if(biz_cdcallback)
892893
{
893894
CDLog68k(address,eCDLog_Flags_Data68k);
@@ -898,16 +899,19 @@ INLINE uint m68ki_read_16_fc(uint address, uint fc)
898899
m68ki_check_address_error(address, MODE_READ, fc) /* auto-disable (see m68kcpu.h) */
899900

900901
temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
901-
if (temp->read16) return (*temp->read16)(ADDRESS_68K(address));
902-
else return *(uint16 *)(temp->base + ((address) & 0xffff));
902+
uint value;
903+
if (temp->read16)
904+
value = (*temp->read16)(ADDRESS_68K(address));
905+
else
906+
value = *(uint16 *)(temp->base + ((address) & 0xffff));
907+
if (biz_readcb)
908+
biz_readcb(address, value);
909+
return value;
903910
}
904911

905912
INLINE uint m68ki_read_32_fc(uint address, uint fc)
906913
{
907914
cpu_memory_map *temp;
908-
if (biz_readcb)
909-
biz_readcb(address);
910-
911915
if(biz_cdcallback)
912916
{
913917
CDLog68k(address,eCDLog_Flags_Data68k);
@@ -920,8 +924,14 @@ INLINE uint m68ki_read_32_fc(uint address, uint fc)
920924
m68ki_check_address_error(address, MODE_READ, fc) /* auto-disable (see m68kcpu.h) */
921925

922926
temp = &m68ki_cpu.memory_map[((address)>>16)&0xff];
923-
if (temp->read16) return ((*temp->read16)(ADDRESS_68K(address)) << 16) | ((*temp->read16)(ADDRESS_68K(address + 2)));
924-
else return m68k_read_immediate_32(address);
927+
uint value;
928+
if (temp->read16)
929+
value = ((*temp->read16)(ADDRESS_68K(address)) << 16) | ((*temp->read16)(ADDRESS_68K(address + 2)));
930+
else
931+
value = m68k_read_immediate_32(address);
932+
if (biz_readcb)
933+
biz_readcb(address, value);
934+
return value;
925935
}
926936

927937
INLINE void m68ki_write_8_fc(uint address, uint fc, uint value)

0 commit comments

Comments
 (0)