show a message if the core doesn't support cheevos

This commit is contained in:
Andre Leiradella 2015-11-03 14:28:18 -02:00
parent a1b8c566dc
commit 20d8571bbd

View File

@ -880,10 +880,8 @@ static int cheevos_parse(const char *json)
Test all the achievements (call once per frame).
*****************************************************************************/
static const uint8_t *get_memory(unsigned offset)
static const uint8_t *cheevos_get_memory(unsigned offset)
{
static const uint8_t zeroes[4] = {0};
size_t size = core.retro_get_memory_size( RETRO_MEMORY_SYSTEM_RAM );
uint8_t *memory;
@ -920,7 +918,7 @@ static const uint8_t *get_memory(unsigned offset)
return memory + offset;
}
return zeroes;
return NULL;
}
static unsigned get_var_value(cheevos_var_t *var)
@ -935,7 +933,10 @@ static unsigned get_var_value(cheevos_var_t *var)
if (var->type == CHEEVOS_VAR_TYPE_ADDRESS || var->type == CHEEVOS_VAR_TYPE_DELTA_MEM)
{
/* TODO Check with Scott if the bank id is needed */
memory = get_memory(var->value);
memory = cheevos_get_memory(var->value);
if (memory)
{
live_val = memory[0];
if (var->size >= CHEEVOS_VAR_SIZE_BIT_0 && var->size <= CHEEVOS_VAR_SIZE_BIT_7)
@ -954,6 +955,9 @@ static unsigned get_var_value(cheevos_var_t *var)
live_val |= memory[2] << 16;
live_val |= memory[3] << 24;
}
}
else
live_val = 0;
if (var->type == CHEEVOS_VAR_TYPE_DELTA_MEM)
{
@ -1741,10 +1745,18 @@ int cheevos_load(const struct retro_game_info *info)
int i;
const char *json;
cheevos_locals.loaded = 0;
/* Just return OK if cheevos are disabled. */
if (!config_get_ptr()->cheevos.enable)
return 0;
if (!cheevos_get_memory(0))
{
rarch_main_msg_queue_push("This core doesn't support achievements", 0, 5 * 60, false);
return -1;
}
for (i = 0; i < sizeof(finders) / sizeof(finders[0]); i++)
{
game_id = finders[i](info, 5000000);
@ -1776,6 +1788,5 @@ int cheevos_load(const struct retro_game_info *info)
else
rarch_main_msg_queue_push("This game doesn't feature achievements", 0, 5 * 60, false);
cheevos_locals.loaded = 0;
return -1;
}