mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 06:44:27 +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)
|
static bool save_ram_file(ram_type_t *ram)
|
||||||
{
|
{
|
||||||
size_t size = core.retro_get_memory_size(ram->type);
|
retro_ctx_memory_info_t mem_info;
|
||||||
void *data = core.retro_get_memory_data(ram->type);
|
|
||||||
|
|
||||||
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;
|
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",
|
RARCH_ERR("%s.\n",
|
||||||
msg_hash_to_str(MSG_FAILED_TO_SAVE_SRAM));
|
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,
|
/* In case the file could not be written to,
|
||||||
* the fallback function 'dump_to_file_desperate'
|
* the fallback function 'dump_to_file_desperate'
|
||||||
* will be called. */
|
* 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");
|
RARCH_WARN("Failed ... Cannot recover save file.\n");
|
||||||
}
|
}
|
||||||
|
@ -174,6 +174,15 @@ bool core_ctl(enum core_ctl_state state, void *data)
|
|||||||
|
|
||||||
switch (state)
|
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:
|
case CORE_CTL_RETRO_LOAD_GAME:
|
||||||
{
|
{
|
||||||
retro_ctx_load_content_info_t *load_info =
|
retro_ctx_load_content_info_t *load_info =
|
||||||
|
@ -24,6 +24,7 @@ extern "C" {
|
|||||||
|
|
||||||
#include <boolean.h>
|
#include <boolean.h>
|
||||||
|
|
||||||
|
#include "content.h"
|
||||||
#include "libretro.h"
|
#include "libretro.h"
|
||||||
|
|
||||||
enum
|
enum
|
||||||
@ -82,6 +83,8 @@ enum core_ctl_state
|
|||||||
*/
|
*/
|
||||||
CORE_CTL_VERIFY_API_VERSION,
|
CORE_CTL_VERIFY_API_VERSION,
|
||||||
|
|
||||||
|
CORE_CTL_RETRO_GET_MEMORY,
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize system A/V information.
|
* Initialize system A/V information.
|
||||||
**/
|
**/
|
||||||
@ -92,6 +95,13 @@ enum core_ctl_state
|
|||||||
CORE_CTL_RETRO_LOAD_GAME
|
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
|
typedef struct retro_ctx_load_content_info
|
||||||
{
|
{
|
||||||
struct retro_game_info *info;
|
struct retro_game_info *info;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user