diff --git a/cheevos.c b/cheevos.c index ef53cd5e01..912f42d70e 100644 --- a/cheevos.c +++ b/cheevos.c @@ -313,7 +313,6 @@ static void cheevos_log_url(const char* format, const char* url) char* next; strlcpy(copy, url, sizeof(copy)); - aux = strstr(copy, "?p="); if (aux == NULL) @@ -463,14 +462,11 @@ static void cheevos_log_cheevo(const cheevo_t* cheevo, const cheevos_field_t* memaddr_ud) { char memaddr[256]; - size_t length; - - length = memaddr_ud->length; - - if (length > sizeof(memaddr)) - length = sizeof(memaddr); - - strlcpy(memaddr, memaddr_ud->string, length); + + strlcpy(memaddr, memaddr_ud->string, sizeof(memaddr)); + + if (memaddr_ud->length < sizeof(memaddr)) + memaddr[memaddr_ud->length] = 0; RARCH_LOG("CHEEVOS cheevo %p\n", cheevo); RARCH_LOG("CHEEVOS id: %u\n", cheevo->id); @@ -752,7 +748,7 @@ static int cheevos_get_value(const char *json, unsigned key_hash, if ((jsonsax_parse(json, &handlers, (void*)&ud) == JSONSAX_OK) && ud.value && ud.length < length) { - strlcpy(value, ud.value, length); + strlcpy(value, ud.value, ud.length + 1); return 0; } @@ -983,9 +979,8 @@ void cheevos_parse_guest_addr(cheevos_var_t *var, unsigned value) switch (cheevos_locals.console_id) { + /* Patch the address to correctly map it to the mmaps */ case CHEEVOS_CONSOLE_GAMEBOY_ADVANCE: - /* Patch the address to correctly map it to the mmaps */ - if (var->value < 0x8000) /* Internal RAM */ var->value += 0x3000000; else /* Work RAM */ @@ -994,6 +989,15 @@ void cheevos_parse_guest_addr(cheevos_var_t *var, unsigned value) case CHEEVOS_CONSOLE_PC_ENGINE: var->value += 0x1f0000; break; + case CHEEVOS_CONSOLE_SUPER_NINTENDO: + if (var->value < 0x020000) /* Work RAM */ + var->value += 0x7e0000; + else /* Save RAM */ + { + var->value -= 0x020000; + var->value += 0x006000; + } + break; default: break; } @@ -1509,18 +1513,25 @@ Test all the achievements (call once per frame). uint8_t *cheevos_get_memory(const cheevos_var_t *var) { + uint8_t *memory; + if (var->bank_id >= 0) { rarch_system_info_t *system; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system->mmaps.num_descriptors != 0) - return (uint8_t *)system->mmaps.descriptors[var->bank_id].core.ptr + var->value; - - return (uint8_t *)cheevos_locals.meminfo[var->bank_id].data + var->value; + memory = (uint8_t *)system->mmaps.descriptors[var->bank_id].core.ptr; + else + memory = (uint8_t *)cheevos_locals.meminfo[var->bank_id].data; + + if (memory) + memory += var->value; } - - return NULL; + else + memory = NULL; + + return memory; } static unsigned cheevos_get_var_value(cheevos_var_t *var) @@ -2570,7 +2581,6 @@ bool cheevos_load(const void *data) cheevos_locals.meminfo[3].id = RETRO_MEMORY_RTC; core_get_memory(&cheevos_locals.meminfo[3]); -#ifdef CHEEVOS_VERBOSE RARCH_LOG("CHEEVOS system RAM: %p %u\n", cheevos_locals.meminfo[0].data, cheevos_locals.meminfo[0].size); RARCH_LOG("CHEEVOS save RAM: %p %u\n", @@ -2579,7 +2589,6 @@ bool cheevos_load(const void *data) cheevos_locals.meminfo[2].data, cheevos_locals.meminfo[2].size); RARCH_LOG("CHEEVOS RTC: %p %u\n", cheevos_locals.meminfo[3].data, cheevos_locals.meminfo[3].size); -#endif /* Bail out if cheevos are disabled. * But set the above anyways, command_read_ram needs it. */ @@ -2814,12 +2823,12 @@ void cheevos_populate_menu(void *data, bool hardcore) bool cheevos_get_description(cheevos_ctx_desc_t *desc) { - cheevo_t *cheevos = cheevos_locals.core.cheevos; + cheevo_t *cheevos = cheevos_locals.core.cheevos; if (desc->idx >= cheevos_locals.core.count) { - cheevos = cheevos_locals.unofficial.cheevos; - desc->idx -= cheevos_locals.unofficial.count; + cheevos = cheevos_locals.unofficial.cheevos; + desc->idx -= cheevos_locals.unofficial.count; } strlcpy(desc->s, cheevos[desc->idx].description, desc->len);