all repos — mgba @ 7e3e9cf771f911bd8cec04665a6968ad20cd4d97

mGBA Game Boy Advance Emulator

Libretro: Fix memory maps
Jeffrey Pfau jeffrey@endrift.com
Thu, 15 Sep 2016 16:02:34 -0700
commit

7e3e9cf771f911bd8cec04665a6968ad20cd4d97

parent

a0af67842add0d49b3339d5f1b3b91945ee0a47c

1 files changed, 49 insertions(+), 43 deletions(-)

jump to
M src/platform/libretro/libretro.csrc/platform/libretro/libretro.c

@@ -271,49 +271,7 @@ core->desiredVideoDimensions(core, &width, &height);

videoCallback(outputBuffer, width, height, BYTES_PER_PIXEL * 256); } -void retro_reset(void) { - core->reset(core); - - if (rumbleCallback) { - CircleBufferClear(&rumbleHistory); - } -} - -bool retro_load_game(const struct retro_game_info* game) { - struct VFile* rom; - if (game->data) { - data = anonymousMemoryMap(game->size); - dataSize = game->size; - memcpy(data, game->data, game->size); - rom = VFileFromMemory(data, game->size); - } else { - data = 0; - rom = VFileOpen(game->path, O_RDONLY); - } - if (!rom) { - return false; - } - - core = mCoreFindVF(rom); - if (!core) { - rom->close(rom); - mappedMemoryFree(data, game->size); - return false; - } - mCoreInitConfig(core, NULL); - core->init(core); - core->setAVStream(core, &stream); - - outputBuffer = malloc(256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); - core->setVideoBuffer(core, outputBuffer, 256); - - core->setAudioBufferSize(core, SAMPLES); - - blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768); - blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768); - - core->setRumble(core, &rumble); - +void static _setupMaps(struct mCore* core) { #ifdef M_CORE_GBA if (core->platform(core) == PLATFORM_GBA) { struct GBA* gba = core->board;

@@ -407,6 +365,51 @@ environCallback(RETRO_ENVIRONMENT_SET_MEMORY_MAPS, &mmaps);

environCallback(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &yes); } #endif +} + +void retro_reset(void) { + core->reset(core); + _setupMaps(core); + + if (rumbleCallback) { + CircleBufferClear(&rumbleHistory); + } +} + +bool retro_load_game(const struct retro_game_info* game) { + struct VFile* rom; + if (game->data) { + data = anonymousMemoryMap(game->size); + dataSize = game->size; + memcpy(data, game->data, game->size); + rom = VFileFromMemory(data, game->size); + } else { + data = 0; + rom = VFileOpen(game->path, O_RDONLY); + } + if (!rom) { + return false; + } + + core = mCoreFindVF(rom); + if (!core) { + rom->close(rom); + mappedMemoryFree(data, game->size); + return false; + } + mCoreInitConfig(core, NULL); + core->init(core); + core->setAVStream(core, &stream); + + outputBuffer = malloc(256 * VIDEO_VERTICAL_PIXELS * BYTES_PER_PIXEL); + core->setVideoBuffer(core, outputBuffer, 256); + + core->setAudioBufferSize(core, SAMPLES); + + blip_set_rates(core->getAudioChannel(core, 0), core->frequency(core), 32768); + blip_set_rates(core->getAudioChannel(core, 1), core->frequency(core), 32768); + + core->setRumble(core, &rumble); savedata = anonymousMemoryMap(SIZE_CART_FLASH1M); struct VFile* save = VFileFromMemory(savedata, SIZE_CART_FLASH1M);

@@ -415,6 +418,9 @@ _reloadSettings();

core->loadROM(core, rom); core->loadSave(core, save); core->reset(core); + + _setupMaps(core); + return true; }