gpgx waterbox - dynamically allocate some sega CD memory areas to reduce state size. raw core is now about 800K in normal mode; 2MB in sega CD mode

This commit is contained in:
nattthebear 2016-03-27 12:00:50 -04:00
parent 10272b4857
commit 5876c60571
9 changed files with 28 additions and 15 deletions

View File

@ -68,7 +68,7 @@ namespace BizHawk.Emulation.Cores.Consoles.Sega.gpgx
try
{
Elf = new ElfRunner(Path.Combine(comm.CoreFileProvider.DllPath(), "gpgx.elf"), 1024 * 1024, 36 * 1024 * 1024, 3 * 1024 * 1024);
Elf = new ElfRunner(Path.Combine(comm.CoreFileProvider.DllPath(), "gpgx.elf"), 8 * 1024 * 1024, 36 * 1024 * 1024, 4 * 1024 * 1024);
if (Elf.ShouldMonitor)
Core = BizInvoker.GetInvoker<LibGPGX>(Elf, Elf);
else

View File

@ -12,7 +12,7 @@ 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 -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast \
-Wall -Werror=pointer-to-int-cast -Werror=int-to-pointer-cast -Werror=implicit-function-declaration \
-std=c99 -fomit-frame-pointer -fvisibility=hidden \
-DLSB_FIRST -DUSE_32BPP_RENDERING -DINLINE=static\ __inline__ \
-ffreestanding -nostdinc -nostdlib \

View File

@ -246,7 +246,7 @@ GPGX_EX void gpgx_clear_sram(void)
// clear and format bram
memset(scd.bram, 0, 0x2000);
brm_format[0x10] = brm_format[0x12] = brm_format[0x14] = brm_format[0x16] = 0x00;
brm_format[0x11] = brm_format[0x13] = brm_format[0x15] = brm_format[0x17] = (sizeof(scd.bram) / 64) - 3;
brm_format[0x11] = brm_format[0x13] = brm_format[0x15] = brm_format[0x17] = (0x2000 / 64) - 3;
memcpy(scd.bram + 0x2000 - 0x40, brm_format, 0x40);
if (scd.cartridge.id)
@ -512,7 +512,6 @@ GPGX_EX int gpgx_init(const char *feromextension, ECL_ENTRY int (*feload_archive
bg_pattern_cache = alloc_invisible(0x80000);
ext.md_cart.rom = alloc_sealed(32 * 1024 * 1024);
scd.bootrom = malloc(0x20000); // FIXME: this should be sealed, but that crashes. huh?
SZHVC_add = alloc_sealed(131072);
SZHVC_sub = alloc_sealed(131072);
ym2612_lfo_pm_table = alloc_sealed(131072);

View File

@ -39,6 +39,7 @@
#include "shared.h"
#include "eeprom_93c.h"
#include "terebi_oekaki.h"
#include "scrc32.h"
#define MAPPER_NONE (0x00)
#define MAPPER_TEREBI (0x01)

View File

@ -49,7 +49,7 @@ static unsigned int cart_ram_read_byte(unsigned int address)
{
return scd.cartridge.area[(address >> 1) & scd.cartridge.mask];
}
return 0xff;
}
@ -202,8 +202,9 @@ void cd_cart_init(void)
/* disable cartridge backup memory */
memset(&sram, 0, sizeof (T_SRAM));
scd.cartridge.area = malloc(0x4000);
/* clear backup RAM */
memset(scd.cartridge.area, 0x00, sizeof(scd.cartridge.area));
memset(scd.cartridge.area, 0x00, 0x4000);
/* backup RAM size mask */
scd.cartridge.mask = (1 << (scd.cartridge.id + 13)) - 1;

View File

@ -40,7 +40,7 @@
/* CD compatible ROM/RAM cartridge */
typedef struct
{
uint8 area[0x4000]; // not unioned with cartrom, so need not be a specific size for that; and we only use 16k ebram in bizhawk
uint8 *area; // always 16K in bizhawk
uint8 boot; /* cartridge boot mode (0x00: boot from CD with ROM/RAM cartridge enabled, 0x40: boot from ROM cartridge with CD enabled) */
uint8 id; /* RAM cartridge ID (related to RAM size, 0 if disabled) */
uint8 prot; /* RAM cartridge write protection */

View File

@ -1072,6 +1072,12 @@ void scd_init(void)
{
int i;
scd.prg_ram = malloc(0x80000);
scd.word_ram[0] = malloc(0x20000);
scd.word_ram[1] = malloc(0x20000);
scd.word_ram_2M = malloc(0x40000);
scd.bram = malloc(0x2000);
/****************************************************************/
/* MAIN-CPU low memory map ($000000-$7FFFFF) */
/****************************************************************/
@ -1181,10 +1187,11 @@ void scd_init(void)
gfx_init();
/* Clear RAM */
memset(scd.prg_ram, 0x00, sizeof(scd.prg_ram));
memset(scd.word_ram, 0x00, sizeof(scd.word_ram));
memset(scd.word_ram_2M, 0x00, sizeof(scd.word_ram_2M));
memset(scd.bram, 0x00, sizeof(scd.bram));
memset(scd.prg_ram, 0x00, 0x80000);
memset(scd.word_ram[0], 0x00, 0x20000);
memset(scd.word_ram[1], 0x00, 0x20000);
memset(scd.word_ram_2M, 0x00, 0x40000);
memset(scd.bram, 0x00, 0x2000);
}
void scd_reset(int hard)

View File

@ -61,10 +61,10 @@ typedef struct
{
cd_cart_t cartridge; /* ROM/RAM Cartridge */
uint8 *bootrom; /* 128K internal BOOT ROM */
uint8 prg_ram[0x80000]; /* 512K PRG-RAM */
uint8 word_ram[2][0x20000]; /* 2 x 128K Word RAM (1M mode) */
uint8 word_ram_2M[0x40000]; /* 256K Word RAM (2M mode) */
uint8 bram[0x2000]; /* 8K Backup RAM */
uint8 *prg_ram; /* 512K PRG-RAM */
uint8 *word_ram[2]; /* 2 x 128K Word RAM (1M mode) */
uint8 *word_ram_2M; /* 256K Word RAM (2M mode) */
uint8 *bram; /* 8K Backup RAM */
reg16_t regs[0x100]; /* 256 x 16-bit ASIC registers */
uint32 cycles; /* Master clock counter */
int32 stopwatch; /* Stopwatch counter */

View File

@ -39,6 +39,7 @@
#include <ctype.h>
#include "shared.h"
#include <emulibc.h>
/*** ROM Information ***/
#define ROMCONSOLE 256
@ -400,6 +401,10 @@ int load_bios(void)
/* check if CD BOOTROM is already loaded */
if (!(system_bios & 0x10) || ((system_bios & 0x0c) != (region_code >> 4)))
{
// GPGX emulates the HINT vector patching by actually writing to the rom,
// so we can't move this to alloc_sealed without some other changes
scd.bootrom = malloc(0x20000);
/* load CD BOOTROM (fixed 128KB size) */
switch (region_code)
{