mirror of https://github.com/mgba-emu/mgba.git
Libretro: Fix memory maps
This commit is contained in:
parent
a0af67842a
commit
7e3e9cf771
|
@ -271,49 +271,7 @@ void retro_run(void) {
|
||||||
videoCallback(outputBuffer, width, height, BYTES_PER_PIXEL * 256);
|
videoCallback(outputBuffer, width, height, BYTES_PER_PIXEL * 256);
|
||||||
}
|
}
|
||||||
|
|
||||||
void retro_reset(void) {
|
void static _setupMaps(struct mCore* core) {
|
||||||
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);
|
|
||||||
|
|
||||||
#ifdef M_CORE_GBA
|
#ifdef M_CORE_GBA
|
||||||
if (core->platform(core) == PLATFORM_GBA) {
|
if (core->platform(core) == PLATFORM_GBA) {
|
||||||
struct GBA* gba = core->board;
|
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);
|
environCallback(RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS, &yes);
|
||||||
}
|
}
|
||||||
#endif
|
#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);
|
savedata = anonymousMemoryMap(SIZE_CART_FLASH1M);
|
||||||
struct VFile* save = VFileFromMemory(savedata, 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->loadROM(core, rom);
|
||||||
core->loadSave(core, save);
|
core->loadSave(core, save);
|
||||||
core->reset(core);
|
core->reset(core);
|
||||||
|
|
||||||
|
_setupMaps(core);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue