mirror of https://github.com/mgba-emu/mgba.git
Libretro: Use anonymous memory mappers for large blocks of memor
This commit is contained in:
parent
31686c374e
commit
11dc9f5161
1
CHANGES
1
CHANGES
|
@ -19,6 +19,7 @@ Misc:
|
||||||
- GBA: Better memory handling with PNG savestates
|
- GBA: Better memory handling with PNG savestates
|
||||||
- GBA Audio: Allow GBAAVStream to have no video callback
|
- GBA Audio: Allow GBAAVStream to have no video callback
|
||||||
- ARM7: Force disable LTO on two files to work around a GCC bug
|
- ARM7: Force disable LTO on two files to work around a GCC bug
|
||||||
|
- Libretro: Use anonymous memory mappers for large blocks of memory
|
||||||
|
|
||||||
0.3.0: (2015-08-16)
|
0.3.0: (2015-08-16)
|
||||||
Features:
|
Features:
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "gba/serialize.h"
|
#include "gba/serialize.h"
|
||||||
#include "gba/context/context.h"
|
#include "gba/context/context.h"
|
||||||
#include "util/circle-buffer.h"
|
#include "util/circle-buffer.h"
|
||||||
|
#include "util/memory.h"
|
||||||
#include "util/vfs.h"
|
#include "util/vfs.h"
|
||||||
|
|
||||||
#define SAMPLES 1024
|
#define SAMPLES 1024
|
||||||
|
@ -37,6 +38,7 @@ static void _updateLux(struct GBALuminanceSource* lux);
|
||||||
static struct GBAContext context;
|
static struct GBAContext context;
|
||||||
static struct GBAVideoSoftwareRenderer renderer;
|
static struct GBAVideoSoftwareRenderer renderer;
|
||||||
static void* data;
|
static void* data;
|
||||||
|
static size_t dataSize;
|
||||||
static void* savedata;
|
static void* savedata;
|
||||||
static struct GBAAVStream stream;
|
static struct GBAAVStream stream;
|
||||||
static int rumbleLevel;
|
static int rumbleLevel;
|
||||||
|
@ -246,7 +248,8 @@ void retro_reset(void) {
|
||||||
bool retro_load_game(const struct retro_game_info* game) {
|
bool retro_load_game(const struct retro_game_info* game) {
|
||||||
struct VFile* rom;
|
struct VFile* rom;
|
||||||
if (game->data) {
|
if (game->data) {
|
||||||
data = malloc(game->size);
|
data = anonymousMemoryMap(game->size);
|
||||||
|
dataSize = game->size;
|
||||||
memcpy(data, game->data, game->size);
|
memcpy(data, game->data, game->size);
|
||||||
rom = VFileFromMemory(data, game->size);
|
rom = VFileFromMemory(data, game->size);
|
||||||
} else {
|
} else {
|
||||||
|
@ -258,11 +261,11 @@ bool retro_load_game(const struct retro_game_info* game) {
|
||||||
}
|
}
|
||||||
if (!GBAIsROM(rom)) {
|
if (!GBAIsROM(rom)) {
|
||||||
rom->close(rom);
|
rom->close(rom);
|
||||||
free(data);
|
mappedMemoryFree(data, game->size);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
savedata = malloc(SIZE_CART_FLASH1M);
|
savedata = anonymousMemoryMap(SIZE_CART_FLASH1M);
|
||||||
struct VFile* save = VFileFromMemory(savedata, SIZE_CART_FLASH1M);
|
struct VFile* save = VFileFromMemory(savedata, SIZE_CART_FLASH1M);
|
||||||
|
|
||||||
GBAContextLoadROMFromVFile(&context, rom, save);
|
GBAContextLoadROMFromVFile(&context, rom, save);
|
||||||
|
@ -272,9 +275,9 @@ bool retro_load_game(const struct retro_game_info* game) {
|
||||||
|
|
||||||
void retro_unload_game(void) {
|
void retro_unload_game(void) {
|
||||||
GBAContextStop(&context);
|
GBAContextStop(&context);
|
||||||
free(data);
|
mappedMemoryFree(data, dataSize);
|
||||||
data = 0;
|
data = 0;
|
||||||
free(savedata);
|
mappedMemoryFree(savedata, SIZE_CART_FLASH1M);
|
||||||
savedata = 0;
|
savedata = 0;
|
||||||
CircleBufferDeinit(&rumbleHistory);
|
CircleBufferDeinit(&rumbleHistory);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue