From b4735502a5a9976dfb891f8828b110cc5c06c1a8 Mon Sep 17 00:00:00 2001 From: nattthebear Date: Sat, 26 Mar 2016 14:44:44 -0400 Subject: [PATCH] gpgx waterbox: fix a few misc bugs in elfrunner, and fix a few misc bugs in the core so that Virtua Racing now works --- BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs | 2 +- BizHawk.Emulation.Cores/MemoryBlock.cs | 3 ++- waterbox/gpgx/Makefile | 3 ++- waterbox/gpgx/cinterface/cinterface.c | 1 + waterbox/gpgx/core/cart_hw/svp/ssp16.c | 8 ++++---- waterbox/gpgx/core/cart_hw/svp/svp.c | 2 +- waterbox/libc/functions/_PDCLIB/emulibc.c | 5 +++++ waterbox/libc/includes/emulibc.h | 3 +++ 8 files changed, 19 insertions(+), 8 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs index 8269f89144..3e8e149735 100644 --- a/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs +++ b/BizHawk.Emulation.Cores/Consoles/Sega/gpgx/GPGX.cs @@ -68,7 +68,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx try { - Elf = new ElfRunner(Path.Combine(comm.CoreFileProvider.DllPath(), "gpgx.elf"), 256 * 1024, 36 * 1024 * 1024, 4 * 1024 * 1024); + Elf = new ElfRunner(Path.Combine(comm.CoreFileProvider.DllPath(), "gpgx.elf"), 1024 * 1024, 36 * 1024 * 1024, 3 * 1024 * 1024); if (Elf.ShouldMonitor) Core = BizInvoker.GetInvoker(Elf, Elf); else diff --git a/BizHawk.Emulation.Cores/MemoryBlock.cs b/BizHawk.Emulation.Cores/MemoryBlock.cs index ff18a322a9..68244ba9ab 100644 --- a/BizHawk.Emulation.Cores/MemoryBlock.cs +++ b/BizHawk.Emulation.Cores/MemoryBlock.cs @@ -61,7 +61,7 @@ namespace BizHawk.Emulation.Cores static MemoryBlock() { int p = PageSize = Environment.SystemPageSize; - while (p != 0) + while (p != 1) { p >>= 1; PageShift++; @@ -253,6 +253,7 @@ namespace BizHawk.Emulation.Cores Kernel32.MemoryProtection old; if (!Kernel32.VirtualProtect(Z.UU(zstart), Z.UU(zend - zstart), p, out old)) throw new InvalidOperationException("VirtualProtect() returned FALSE!"); + ps = i + 1; } } } diff --git a/waterbox/gpgx/Makefile b/waterbox/gpgx/Makefile index 50640f54bc..8ed2abc75e 100644 --- a/waterbox/gpgx/Makefile +++ b/waterbox/gpgx/Makefile @@ -12,7 +12,8 @@ ARCH = 64 CCFLAGS:=-Icore -Iutil -Icore/m68k -Icore/z80 -Icore/input_hw \ -Icore/cart_hw -Icore/cart_hw/svp -Icore/sound -Icore/ntsc -Icore/cd_hw \ - -Wall -std=c99 -fomit-frame-pointer -fvisibility=hidden \ + -Wall -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast \ + -std=c99 -fomit-frame-pointer -fvisibility=hidden \ -DLSB_FIRST -DUSE_32BPP_RENDERING -DINLINE=static\ __inline__ \ -ffreestanding -nostdinc -nostdlib \ -I../libc/includes -I../libc/internals \ diff --git a/waterbox/gpgx/cinterface/cinterface.c b/waterbox/gpgx/cinterface/cinterface.c index fe668db9c6..b4f103ac8d 100644 --- a/waterbox/gpgx/cinterface/cinterface.c +++ b/waterbox/gpgx/cinterface/cinterface.c @@ -496,6 +496,7 @@ struct InitSettings GPGX_EX int gpgx_init(const char *feromextension, ECL_ENTRY int (*feload_archive_cb)(const char *filename, unsigned char *buffer, int maxsize), int sixbutton, char system_a, char system_b, int region, struct InitSettings *settings) { + _debug_puts("Initializing GPGX native..."); memset(&bitmap, 0, sizeof(bitmap)); strncpy(romextension, feromextension, 3); diff --git a/waterbox/gpgx/core/cart_hw/svp/ssp16.c b/waterbox/gpgx/core/cart_hw/svp/ssp16.c index 9cf343e1d2..5d451818e1 100644 --- a/waterbox/gpgx/core/cart_hw/svp/ssp16.c +++ b/waterbox/gpgx/core/cart_hw/svp/ssp16.c @@ -219,7 +219,7 @@ #define IJind (((op>>6)&4)|(op&3)) #define GET_PC() (PC - (unsigned short *)svp->iram_rom) -#define GET_PPC_OFFS() ((unsigned int)PC - (unsigned int)svp->iram_rom - 2) +#define GET_PPC_OFFS() ((uintptr_t)PC - (uintptr_t)svp->iram_rom - 2) #define SET_PC(d) PC = (unsigned short *)svp->iram_rom + d #define REG_READ(r) (((r) <= 4) ? ssp->gr[r].byte.h : read_handlers[r]()) @@ -559,7 +559,7 @@ static u32 pm_io(int reg, int write, u32 d) ssp->pmac_read[reg] += 1<<16;*/ if ((signed int)(ssp->pmac[0][reg] & 0xffff) == -1) ssp->pmac[0][reg] += 1<<16; ssp->pmac[0][reg] ++; - + d = ((unsigned short *)cart.rom)[addr|((mode&0xf)<<16)]; } else if ((mode & 0x47ff) == 0x0018) /* DRAM */ @@ -1282,7 +1282,7 @@ void ssp1601_run(int cycles) #endif break; case 0x3c: - OP_CMPA(op & 0xff); + OP_CMPA(op & 0xff); #ifdef LOG_SVP if (op&0x100) elprintf(EL_SVP|EL_ANOMALY, "FIXME: simm with upper bit set"); #endif @@ -1307,7 +1307,7 @@ void ssp1601_run(int cycles) #endif break; case 0x7c: - OP_EORA(op & 0xff); + OP_EORA(op & 0xff); #ifdef LOG_SVP if (op&0x100) elprintf(EL_SVP|EL_ANOMALY, "FIXME: simm with upper bit set"); #endif diff --git a/waterbox/gpgx/core/cart_hw/svp/svp.c b/waterbox/gpgx/core/cart_hw/svp/svp.c index 882c7d6015..eee72c047d 100644 --- a/waterbox/gpgx/core/cart_hw/svp/svp.c +++ b/waterbox/gpgx/core/cart_hw/svp/svp.c @@ -16,7 +16,7 @@ svp_t *svp = NULL; void svp_init(void) { - svp = (void *) ((char *)cart.rom + 0x200000); + svp = malloc(sizeof(svp_t)); memset(svp, 0, sizeof(*svp)); } diff --git a/waterbox/libc/functions/_PDCLIB/emulibc.c b/waterbox/libc/functions/_PDCLIB/emulibc.c index 27314a2c22..303b01eb6b 100644 --- a/waterbox/libc/functions/_PDCLIB/emulibc.c +++ b/waterbox/libc/functions/_PDCLIB/emulibc.c @@ -21,6 +21,11 @@ void *alloc_invisible(size_t size) return _ecl_sbrk_invisible(size); } +void _debug_puts(const char *s) +{ + _ecl_debug_puts(s); +} + void *_PDCLIB_sbrk(size_t n) { void *ret = _ecl_sbrk(n); diff --git a/waterbox/libc/includes/emulibc.h b/waterbox/libc/includes/emulibc.h index 4b4a14223e..608dbea2c3 100644 --- a/waterbox/libc/includes/emulibc.h +++ b/waterbox/libc/includes/emulibc.h @@ -19,4 +19,7 @@ void *alloc_sealed(size_t size); // you are absolutely sure will not harm savestates void *alloc_invisible(size_t size); +// send a debug string somewhere, bypassing stdio +void _debug_puts(const char *); + #endif