Libretro: Fix memory maps

This commit is contained in:
Jeffrey Pfau 2016-09-15 16:02:34 -07:00
parent a0af67842a
commit 7e3e9cf771
1 changed files with 49 additions and 43 deletions

View File

@ -271,49 +271,7 @@ void retro_run(void) {
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 @@ bool retro_load_game(const struct retro_game_info* game) {
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 @@ bool retro_load_game(const struct retro_game_info* game) {
core->loadROM(core, rom);
core->loadSave(core, save);
core->reset(core);
_setupMaps(core);
return true;
}