mirror of
https://github.com/libretro/RetroArch.git
synced 2025-02-13 05:10:42 +00:00
Create CORE_CTL_RETRO_GET_MEMORY
This commit is contained in:
parent
e516a64a0c
commit
ae2cf510cd
13
content.c
13
content.c
@ -351,13 +351,16 @@ static bool load_ram_file(ram_type_t *ram)
|
||||
*/
|
||||
static bool save_ram_file(ram_type_t *ram)
|
||||
{
|
||||
size_t size = core.retro_get_memory_size(ram->type);
|
||||
void *data = core.retro_get_memory_data(ram->type);
|
||||
retro_ctx_memory_info_t mem_info;
|
||||
|
||||
if (!data || size == 0)
|
||||
mem_info.ram = ram;
|
||||
|
||||
core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info);
|
||||
|
||||
if (!mem_info.data || mem_info.size == 0)
|
||||
return false;
|
||||
|
||||
if (!retro_write_file(ram->path, data, size))
|
||||
if (!retro_write_file(ram->path, mem_info.data, mem_info.size))
|
||||
{
|
||||
RARCH_ERR("%s.\n",
|
||||
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM));
|
||||
@ -366,7 +369,7 @@ static bool save_ram_file(ram_type_t *ram)
|
||||
/* In case the file could not be written to,
|
||||
* the fallback function 'dump_to_file_desperate'
|
||||
* will be called. */
|
||||
if (!dump_to_file_desperate(data, size, ram->type))
|
||||
if (!dump_to_file_desperate(mem_info.data, mem_info.size, ram->type))
|
||||
{
|
||||
RARCH_WARN("Failed ... Cannot recover save file.\n");
|
||||
}
|
||||
|
@ -174,6 +174,15 @@ bool core_ctl(enum core_ctl_state state, void *data)
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case CORE_CTL_RETRO_GET_MEMORY:
|
||||
{
|
||||
retro_ctx_memory_info_t *info = (retro_ctx_memory_info_t*)data;
|
||||
if (!info || !info->ram)
|
||||
return false;
|
||||
info->size = core.retro_get_memory_size(info->ram->type);
|
||||
info->data = core.retro_get_memory_data(info->ram->type);
|
||||
}
|
||||
break;
|
||||
case CORE_CTL_RETRO_LOAD_GAME:
|
||||
{
|
||||
retro_ctx_load_content_info_t *load_info =
|
||||
|
@ -24,6 +24,7 @@ extern "C" {
|
||||
|
||||
#include <boolean.h>
|
||||
|
||||
#include "content.h"
|
||||
#include "libretro.h"
|
||||
|
||||
enum
|
||||
@ -82,6 +83,8 @@ enum core_ctl_state
|
||||
*/
|
||||
CORE_CTL_VERIFY_API_VERSION,
|
||||
|
||||
CORE_CTL_RETRO_GET_MEMORY,
|
||||
|
||||
/**
|
||||
* Initialize system A/V information.
|
||||
**/
|
||||
@ -92,6 +95,13 @@ enum core_ctl_state
|
||||
CORE_CTL_RETRO_LOAD_GAME
|
||||
};
|
||||
|
||||
typedef struct retro_ctx_memory_info
|
||||
{
|
||||
void *data;
|
||||
size_t size;
|
||||
ram_type_t *ram;
|
||||
} retro_ctx_memory_info_t;
|
||||
|
||||
typedef struct retro_ctx_load_content_info
|
||||
{
|
||||
struct retro_game_info *info;
|
||||
|
Loading…
x
Reference in New Issue
Block a user