From 0d6bdc200b00413abe41fef0294aca1cb95f7ccf Mon Sep 17 00:00:00 2001 From: nattthebear Date: Wed, 19 Jul 2017 20:38:19 -0400 Subject: [PATCH] sameboy: a bit of savestate optimization --- .../Consoles/Nintendo/Gameboy/Sameboy.cs | 10 +++---- waterbox/sameboy/gb.c | 28 ++----------------- 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs index 1b7231b02d..c9d5269710 100644 --- a/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs +++ b/BizHawk.Emulation.Cores/Consoles/Nintendo/Gameboy/Sameboy.cs @@ -63,11 +63,11 @@ namespace BizHawk.Emulation.Cores.Consoles.Nintendo.Gameboy _core = PreInit(new PeRunnerOptions { Filename = "sameboy.wbx", - SbrkHeapSizeKB = 128, - InvisibleHeapSizeKB = 16 * 1024, - SealedHeapSizeKB = 5 * 1024, - PlainHeapSizeKB = 4096, - MmapHeapSizeKB = 34 * 1024 + SbrkHeapSizeKB = 192, + InvisibleHeapSizeKB = 4, + SealedHeapSizeKB = 9 * 1024, + PlainHeapSizeKB = 4, + MmapHeapSizeKB = 1024 }); _cgb = (rom[0x143] & 0xc0) == 0xc0 && !sgb; diff --git a/waterbox/sameboy/gb.c b/waterbox/sameboy/gb.c index e8e90d55bd..ce14dc647c 100644 --- a/waterbox/sameboy/gb.c +++ b/waterbox/sameboy/gb.c @@ -5,11 +5,8 @@ #include #include #include -#ifndef _WIN32 -#include -#include -#endif #include "gb.h" +#include "../emulibc/emulibc.h" void GB_attributed_logv(GB_gameboy_t *gb, GB_log_attributes attributes, const char *fmt, va_list args) { @@ -75,27 +72,6 @@ void GB_init_cgb(GB_gameboy_t *gb) GB_reset(gb); } -void GB_free(GB_gameboy_t *gb) -{ - gb->magic = 0; - if (gb->ram) { - free(gb->ram); - } - if (gb->vram) { - free(gb->vram); - } - if (gb->mbc_ram) { - free(gb->mbc_ram); - } - if (gb->rom) { - free(gb->rom); - } - if (gb->breakpoints) { - free(gb->breakpoints); - } - memset(gb, 0, sizeof(*gb)); -} - int GB_load_boot_rom(GB_gameboy_t *gb, const char *path) { FILE *f = fopen(path, "rb"); @@ -127,7 +103,7 @@ int GB_load_rom(GB_gameboy_t *gb, const char *path) if (gb->rom) { free(gb->rom); } - gb->rom = malloc(gb->rom_size); + gb->rom = alloc_sealed(gb->rom_size); memset(gb->rom, 0xFF, gb->rom_size); /* Pad with 0xFFs */ fread(gb->rom, gb->rom_size, 1, f); fclose(f);