namespace both cheevos implementations & add a runtime setting to allow debugging

This commit is contained in:
meleu 2019-03-16 22:13:57 -03:00
parent 8064672f11
commit a5acd559d6
22 changed files with 286 additions and 242 deletions

View File

@ -1688,76 +1688,70 @@ ifeq ($(HAVE_NETWORKING), 1)
# RetroAchievements
ifeq ($(HAVE_CHEEVOS), 1)
DEFINES += -DHAVE_CHEEVOS
DEFINES += -DHAVE_CHEEVOS \
-Ideps/rcheevos/include
ifeq ($(HAVE_NEW_CHEEVOS), 1)
DEFINES += -DHAVE_NEW_CHEEVOS \
-Ideps/rcheevos/include
OBJ += cheevos-new/cheevos.o \
cheevos-new/badges.o \
cheevos-new/fixup.o \
cheevos-new/parser.o \
cheevos-new/hash.o \
deps/rcheevos/src/rcheevos/trigger.o \
deps/rcheevos/src/rcheevos/condset.o \
deps/rcheevos/src/rcheevos/condition.o \
deps/rcheevos/src/rcheevos/operand.o \
deps/rcheevos/src/rcheevos/term.o \
deps/rcheevos/src/rcheevos/expression.o \
deps/rcheevos/src/rcheevos/value.o \
deps/rcheevos/src/rcheevos/lboard.o \
deps/rcheevos/src/rcheevos/alloc.o \
deps/rcheevos/src/rcheevos/format.o \
deps/rcheevos/src/rurl/url.o
OBJ += cheevos/cheevos.o \
cheevos/badges.o \
cheevos/var.o \
cheevos/cond.o \
cheevos-new/cheevos.o \
cheevos-new/fixup.o \
cheevos-new/parser.o \
cheevos-new/hash.o \
deps/rcheevos/src/rcheevos/trigger.o \
deps/rcheevos/src/rcheevos/condset.o \
deps/rcheevos/src/rcheevos/condition.o \
deps/rcheevos/src/rcheevos/operand.o \
deps/rcheevos/src/rcheevos/term.o \
deps/rcheevos/src/rcheevos/expression.o \
deps/rcheevos/src/rcheevos/value.o \
deps/rcheevos/src/rcheevos/lboard.o \
deps/rcheevos/src/rcheevos/alloc.o \
deps/rcheevos/src/rcheevos/format.o \
deps/rcheevos/src/rurl/url.o
ifeq ($(HAVE_LUA), 1)
DEFINES += -DHAVE_LUA \
-DLUA_32BITS \
-Ideps/lua/src
OBJ += deps/lua/src/lapi.o \
deps/lua/src/lcode.o \
deps/lua/src/lctype.o \
deps/lua/src/ldebug.o \
deps/lua/src/ldo.o \
deps/lua/src/ldump.o \
deps/lua/src/lfunc.o \
deps/lua/src/lgc.o \
deps/lua/src/llex.o \
deps/lua/src/lmem.o \
deps/lua/src/lobject.o \
deps/lua/src/lopcodes.o \
deps/lua/src/lparser.o \
deps/lua/src/lstate.o \
deps/lua/src/lstring.o \
deps/lua/src/ltable.o \
deps/lua/src/ltm.o \
deps/lua/src/lundump.o \
deps/lua/src/lvm.o \
deps/lua/src/lzio.o \
deps/lua/src/lauxlib.o \
deps/lua/src/lbaselib.o \
deps/lua/src/lbitlib.o \
deps/lua/src/lcorolib.o \
deps/lua/src/ldblib.o \
deps/lua/src/liolib.o \
deps/lua/src/lmathlib.o \
deps/lua/src/loslib.o \
deps/lua/src/lstrlib.o \
deps/lua/src/ltablib.o \
deps/lua/src/lutf8lib.o \
deps/lua/src/loadlib.o \
deps/lua/src/linit.o
else
DEFINES += -DRC_DISABLE_LUA
endif
# if not HAVE_NEW_CHEEVOS
ifeq ($(HAVE_LUA), 1)
DEFINES += -DHAVE_LUA \
-DLUA_32BITS \
-Ideps/lua/src
OBJ += deps/lua/src/lapi.o \
deps/lua/src/lcode.o \
deps/lua/src/lctype.o \
deps/lua/src/ldebug.o \
deps/lua/src/ldo.o \
deps/lua/src/ldump.o \
deps/lua/src/lfunc.o \
deps/lua/src/lgc.o \
deps/lua/src/llex.o \
deps/lua/src/lmem.o \
deps/lua/src/lobject.o \
deps/lua/src/lopcodes.o \
deps/lua/src/lparser.o \
deps/lua/src/lstate.o \
deps/lua/src/lstring.o \
deps/lua/src/ltable.o \
deps/lua/src/ltm.o \
deps/lua/src/lundump.o \
deps/lua/src/lvm.o \
deps/lua/src/lzio.o \
deps/lua/src/lauxlib.o \
deps/lua/src/lbaselib.o \
deps/lua/src/lbitlib.o \
deps/lua/src/lcorolib.o \
deps/lua/src/ldblib.o \
deps/lua/src/liolib.o \
deps/lua/src/lmathlib.o \
deps/lua/src/loslib.o \
deps/lua/src/lstrlib.o \
deps/lua/src/ltablib.o \
deps/lua/src/lutf8lib.o \
deps/lua/src/loadlib.o \
deps/lua/src/linit.o
else
OBJ += cheevos/cheevos.o \
cheevos/badges.o \
cheevos/var.o \
cheevos/cond.o
DEFINES += -DRC_DISABLE_LUA
endif
endif
ifeq ($(HAVE_DISCORD), 1)

View File

@ -41,7 +41,7 @@
#include <rthreads/rthreads.h>
#endif
#include "badges.h"
#include "../cheevos/badges.h" /* RCHEEVOS TODO: fix path */
#include "cheevos.h"
#include "fixup.h"
#include "parser.h"
@ -159,12 +159,12 @@ static cheevos_locals_t cheevos_locals =
{0}, /* token */
};
bool cheevos_loaded = false;
bool cheevos_hardcore_active = false;
bool cheevos_hardcore_paused = false;
bool cheevos_state_loaded_flag = false;
int cheats_are_enabled = 0;
int cheats_were_enabled = 0;
bool rcheevos_loaded = false;
bool rcheevos_hardcore_active = false;
bool rcheevos_hardcore_paused = false;
bool rcheevos_state_loaded_flag = false;
int rcheevos_cheats_are_enabled = 0;
int rcheevos_cheats_were_enabled = 0;
#ifdef HAVE_THREADS
#define CHEEVOS_LOCK(l) do { slock_lock(l); } while (0)
@ -288,7 +288,7 @@ static int cheevos_parse(const char* json)
cheevos_lboard_t* lboard = NULL;
cheevos_racheevo_t* rac = NULL;
cheevos_fixup_init(&cheevos_locals.fixups);
rcheevos_fixup_init(&cheevos_locals.fixups);
res = cheevos_get_patchdata(json, &cheevos_locals.patchdata);
@ -364,7 +364,7 @@ static int cheevos_parse(const char* json)
}
rc_parse_trigger(cheevo->trigger, cheevo->info->memaddr, NULL, 0);
cheevo->active = CHEEVOS_ACTIVE_SOFTCORE | CHEEVOS_ACTIVE_HARDCORE;
cheevo->active = RCHEEVOS_ACTIVE_SOFTCORE | RCHEEVOS_ACTIVE_HARDCORE;
cheevo->last = 1;
}
}
@ -406,7 +406,7 @@ error:
CHEEVOS_FREE(cheevos_locals.unofficial);
CHEEVOS_FREE(cheevos_locals.lboards);
cheevos_free_patchdata(&cheevos_locals.patchdata);
cheevos_fixup_destroy(&cheevos_locals.fixups);
rcheevos_fixup_destroy(&cheevos_locals.fixups);
return -1;
}
@ -488,8 +488,8 @@ static void cheevos_award(cheevos_cheevo_t* cheevo, int mode)
/* Deactivates the cheevo. */
cheevo->active &= ~mode;
if (mode == CHEEVOS_ACTIVE_HARDCORE)
cheevo->active &= ~CHEEVOS_ACTIVE_SOFTCORE;
if (mode == RCHEEVOS_ACTIVE_HARDCORE)
cheevo->active &= ~RCHEEVOS_ACTIVE_SOFTCORE;
/* Show the OSD message. */
snprintf(buffer, sizeof(buffer), "Achievement Unlocked: %s", cheevo->info->title);
@ -497,7 +497,7 @@ static void cheevos_award(cheevos_cheevo_t* cheevo, int mode)
runloop_msg_queue_push(cheevo->info->description, 0, 3 * 60, false, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
/* Start the award task. */
if ((mode & CHEEVOS_ACTIVE_HARDCORE) != 0)
if ((mode & RCHEEVOS_ACTIVE_HARDCORE) != 0)
cheevos_award_task_hardcore(NULL, NULL, cheevo, "");
else
cheevos_award_task_softcore(NULL, NULL, cheevo, "");
@ -523,7 +523,7 @@ static void cheevos_award(cheevos_cheevo_t* cheevo, int mode)
static unsigned cheevos_peek(unsigned address, unsigned num_bytes, void* ud)
{
const uint8_t* data = cheevos_fixup_find(&cheevos_locals.fixups,
const uint8_t* data = rcheevos_fixup_find(&cheevos_locals.fixups,
address, cheevos_locals.patchdata.console_id);
unsigned value = 0;
@ -540,12 +540,12 @@ static unsigned cheevos_peek(unsigned address, unsigned num_bytes, void* ud)
static void cheevos_test_cheevo_set(bool official)
{
settings_t *settings = config_get_ptr();
int mode = CHEEVOS_ACTIVE_SOFTCORE;
int mode = RCHEEVOS_ACTIVE_SOFTCORE;
cheevos_cheevo_t* cheevo;
int i, count;
if (settings && settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused)
mode = CHEEVOS_ACTIVE_HARDCORE;
if (settings && settings->bools.cheevos_hardcore_mode_enable && !rcheevos_hardcore_paused)
mode = RCHEEVOS_ACTIVE_HARDCORE;
if (official)
{
@ -696,7 +696,7 @@ static void cheevos_test_leaderboards(void)
}
}
void cheevos_reset_game(void)
void rcheevos_reset_game(void)
{
cheevos_cheevo_t* cheevo;
cheevos_lboard_t* lboard;
@ -721,7 +721,7 @@ void cheevos_reset_game(void)
}
}
void cheevos_populate_menu(void* data)
void rcheevos_populate_menu(void* data)
{
#ifdef HAVE_MENU
int i = 0;
@ -732,9 +732,9 @@ void cheevos_populate_menu(void* data)
if ( settings->bools.cheevos_enable
&& settings->bools.cheevos_hardcore_mode_enable
&& cheevos_loaded)
&& rcheevos_loaded)
{
if (!cheevos_hardcore_paused)
if (!rcheevos_hardcore_paused)
menu_entries_append_enum(info->list,
msg_hash_to_str(MENU_ENUM_LABEL_VALUE_ACHIEVEMENT_PAUSE),
msg_hash_to_str(MENU_ENUM_LABEL_ACHIEVEMENT_PAUSE),
@ -752,7 +752,7 @@ void cheevos_populate_menu(void* data)
for (i = 0, count = cheevos_locals.patchdata.core_count; i < count; i++, cheevo++)
{
if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE))
if (!(cheevo->active & RCHEEVOS_ACTIVE_HARDCORE))
{
menu_entries_append_enum(info->list, cheevo->info->title,
cheevo->info->description,
@ -760,9 +760,9 @@ void cheevos_populate_menu(void* data)
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
set_badge_info(&badges_ctx, i, cheevo->info->badge,
(cheevo->active & CHEEVOS_ACTIVE_HARDCORE));
(cheevo->active & RCHEEVOS_ACTIVE_HARDCORE));
}
else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE))
else if (!(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE))
{
menu_entries_append_enum(info->list, cheevo->info->title,
cheevo->info->description,
@ -770,7 +770,7 @@ void cheevos_populate_menu(void* data)
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
set_badge_info(&badges_ctx, i, cheevo->info->badge,
(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE));
(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE));
}
else
{
@ -780,7 +780,7 @@ void cheevos_populate_menu(void* data)
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
set_badge_info(&badges_ctx, i, cheevo->info->badge,
(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE));
(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE));
}
}
@ -790,7 +790,7 @@ void cheevos_populate_menu(void* data)
for (i = 0, count = cheevos_locals.patchdata.unofficial_count; i < count; i++, cheevo++)
{
if (!(cheevo->active & CHEEVOS_ACTIVE_HARDCORE))
if (!(cheevo->active & RCHEEVOS_ACTIVE_HARDCORE))
{
menu_entries_append_enum(info->list, cheevo->info->title,
cheevo->info->description,
@ -798,9 +798,9 @@ void cheevos_populate_menu(void* data)
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
set_badge_info(&badges_ctx, i, cheevo->info->badge,
(cheevo->active & CHEEVOS_ACTIVE_HARDCORE));
(cheevo->active & RCHEEVOS_ACTIVE_HARDCORE));
}
else if (!(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE))
else if (!(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE))
{
menu_entries_append_enum(info->list, cheevo->info->title,
cheevo->info->description,
@ -808,7 +808,7 @@ void cheevos_populate_menu(void* data)
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
set_badge_info(&badges_ctx, i, cheevo->info->badge,
(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE));
(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE));
}
else
{
@ -818,7 +818,7 @@ void cheevos_populate_menu(void* data)
MENU_SETTINGS_CHEEVOS_START + i, 0, 0);
set_badge_info(&badges_ctx, i, cheevo->info->badge,
(cheevo->active & CHEEVOS_ACTIVE_SOFTCORE));
(cheevo->active & RCHEEVOS_ACTIVE_SOFTCORE));
}
}
}
@ -839,7 +839,7 @@ void cheevos_populate_menu(void* data)
#endif
}
bool cheevos_get_description(cheevos_ctx_desc_t* desc)
bool rcheevos_get_description(rcheevos_ctx_desc_t* desc)
{
unsigned idx;
const cheevos_cheevo_t* cheevo;
@ -849,7 +849,7 @@ bool cheevos_get_description(cheevos_ctx_desc_t* desc)
*desc->s = 0;
if (cheevos_loaded)
if (rcheevos_loaded)
{
idx = desc->idx;
@ -871,15 +871,15 @@ bool cheevos_get_description(cheevos_ctx_desc_t* desc)
return true;
}
bool cheevos_apply_cheats(bool* data_bool)
bool rcheevos_apply_cheats(bool* data_bool)
{
cheats_are_enabled = *data_bool;
cheats_were_enabled |= cheats_are_enabled;
rcheevos_cheats_are_enabled = *data_bool;
rcheevos_cheats_were_enabled |= rcheevos_cheats_are_enabled;
return true;
}
bool cheevos_unload(void)
bool rcheevos_unload(void)
{
bool running = false;
unsigned i = 0, count = 0;
@ -904,7 +904,7 @@ bool cheevos_unload(void)
#endif
}
if (cheevos_loaded)
if (rcheevos_loaded)
{
for (i = 0, count = cheevos_locals.patchdata.core_count; i < count; i++)
{
@ -925,20 +925,20 @@ bool cheevos_unload(void)
CHEEVOS_FREE(cheevos_locals.unofficial);
CHEEVOS_FREE(cheevos_locals.lboards);
cheevos_free_patchdata(&cheevos_locals.patchdata);
cheevos_fixup_destroy(&cheevos_locals.fixups);
rcheevos_fixup_destroy(&cheevos_locals.fixups);
cheevos_locals.core = NULL;
cheevos_locals.unofficial = NULL;
cheevos_locals.lboards = NULL;
cheevos_loaded = false;
cheevos_hardcore_paused = false;
rcheevos_loaded = false;
rcheevos_hardcore_paused = false;
}
return true;
}
bool cheevos_toggle_hardcore_mode(void)
bool rcheevos_toggle_hardcore_mode(void)
{
settings_t *settings = config_get_ptr();
@ -947,13 +947,13 @@ bool cheevos_toggle_hardcore_mode(void)
/* reset and deinit rewind to avoid cheat the score */
if ( settings->bools.cheevos_hardcore_mode_enable
&& !cheevos_hardcore_paused)
&& !rcheevos_hardcore_paused)
{
const char *msg = msg_hash_to_str(
MSG_CHEEVOS_HARDCORE_MODE_ENABLE);
/* reset the state loaded flag in case it was set */
cheevos_state_loaded_flag = false;
rcheevos_state_loaded_flag = false;
/* send reset core cmd to avoid any user
* savestate previusly loaded. */
@ -974,7 +974,7 @@ bool cheevos_toggle_hardcore_mode(void)
return true;
}
void cheevos_test(void)
void rcheevos_test(void)
{
settings_t *settings = config_get_ptr();
@ -987,28 +987,28 @@ void cheevos_test(void)
if (settings->bools.cheevos_hardcore_mode_enable &&
settings->bools.cheevos_leaderboards_enable &&
!cheevos_hardcore_paused)
!rcheevos_hardcore_paused)
cheevos_test_leaderboards();
}
}
bool cheevos_set_cheats(void)
bool rcheevos_set_cheats(void)
{
cheats_were_enabled = cheats_are_enabled;
rcheevos_cheats_were_enabled = rcheevos_cheats_are_enabled;
return true;
}
void cheevos_set_support_cheevos(bool state)
void rcheevos_set_support_cheevos(bool state)
{
cheevos_locals.core_supports = state;
}
bool cheevos_get_support_cheevos(void)
bool rcheevos_get_support_cheevos(void)
{
return cheevos_locals.core_supports;
}
int cheevos_get_console(void)
int rcheevos_get_console(void)
{
return cheevos_locals.patchdata.console_id;
}
@ -1365,7 +1365,7 @@ found:
CORO_STOP();
}
cheevos_loaded = true;
rcheevos_loaded = true;
/*
* Inputs: CHEEVOS_VAR_GAMEID
@ -1382,13 +1382,13 @@ found:
if (coro->settings->bools.cheevos_verbose_enable && cheevos_locals.patchdata.core_count > 0)
{
char msg[256];
int mode = CHEEVOS_ACTIVE_SOFTCORE;
int mode = RCHEEVOS_ACTIVE_SOFTCORE;
const cheevos_cheevo_t* cheevo = cheevos_locals.core;
const cheevos_cheevo_t* end = cheevo + cheevos_locals.patchdata.core_count;
int number_of_unlocked = cheevos_locals.patchdata.core_count;
if (coro->settings->bools.cheevos_hardcore_mode_enable && !cheevos_hardcore_paused)
mode = CHEEVOS_ACTIVE_HARDCORE;
if (coro->settings->bools.cheevos_hardcore_mode_enable && !rcheevos_hardcore_paused)
mode = RCHEEVOS_ACTIVE_HARDCORE;
for (; cheevo < end; cheevo++)
if (cheevo->active & mode)
@ -1961,7 +1961,7 @@ found:
if (coro->json)
{
mode = coro->i == 0 ? CHEEVOS_ACTIVE_SOFTCORE : CHEEVOS_ACTIVE_HARDCORE;
mode = coro->i == 0 ? RCHEEVOS_ACTIVE_SOFTCORE : RCHEEVOS_ACTIVE_HARDCORE;
cheevos_deactivate_unlocks(coro->json, cheevos_unlock_cb, &mode);
CHEEVOS_FREE(coro->json);
}
@ -2035,14 +2035,14 @@ static void cheevos_task_handler(retro_task_t *task)
}
}
bool cheevos_load(const void *data)
bool rcheevos_load(const void *data)
{
retro_task_t *task;
const struct retro_game_info *info = NULL;
coro_t *coro = NULL;
cheevos_loaded = false;
cheevos_hardcore_paused = false;
rcheevos_loaded = false;
rcheevos_hardcore_paused = false;
if (!cheevos_locals.core_supports || !data)
return false;

View File

@ -27,49 +27,49 @@
RETRO_BEGIN_DECLS
typedef struct cheevos_ctx_desc
typedef struct rcheevos_ctx_desc
{
unsigned idx;
char *s;
size_t len;
} cheevos_ctx_desc_t;
} rcheevos_ctx_desc_t;
enum
{
CHEEVOS_ACTIVE_SOFTCORE = 1 << 0,
CHEEVOS_ACTIVE_HARDCORE = 1 << 1
RCHEEVOS_ACTIVE_SOFTCORE = 1 << 0,
RCHEEVOS_ACTIVE_HARDCORE = 1 << 1
};
bool cheevos_load(const void *data);
bool rcheevos_load(const void *data);
void cheevos_reset_game(void);
void rcheevos_reset_game(void);
void cheevos_populate_menu(void *data);
void rcheevos_populate_menu(void *data);
bool cheevos_get_description(cheevos_ctx_desc_t *desc);
bool rcheevos_get_description(rcheevos_ctx_desc_t *desc);
bool cheevos_apply_cheats(bool *data_bool);
bool rcheevos_apply_cheats(bool *data_bool);
bool cheevos_unload(void);
bool rcheevos_unload(void);
bool cheevos_toggle_hardcore_mode(void);
bool rcheevos_toggle_hardcore_mode(void);
void cheevos_test(void);
void rcheevos_test(void);
bool cheevos_set_cheats(void);
bool rcheevos_set_cheats(void);
void cheevos_set_support_cheevos(bool state);
void rcheevos_set_support_cheevos(bool state);
bool cheevos_get_support_cheevos(void);
bool rcheevos_get_support_cheevos(void);
int cheevos_get_console(void);
int rcheevos_get_console(void);
extern bool cheevos_loaded;
extern bool cheevos_hardcore_active;
extern bool cheevos_hardcore_paused;
extern bool cheevos_state_loaded_flag;
extern int cheats_are_enabled;
extern int cheats_were_enabled;
extern bool rcheevos_loaded;
extern bool rcheevos_hardcore_active;
extern bool rcheevos_hardcore_paused;
extern bool rcheevos_state_loaded_flag;
extern int rcheevos_cheats_are_enabled;
extern int rcheevos_cheats_were_enabled;
RETRO_END_DECLS

View File

@ -64,20 +64,20 @@ static size_t cheevos_var_highest_bit(size_t n)
return n ^ (n >> 1);
}
void cheevos_fixup_init(cheevos_fixups_t* fixups)
void rcheevos_fixup_init(cheevos_fixups_t* fixups)
{
fixups->elements = NULL;
fixups->capacity = fixups->count = 0;
fixups->dirty = false;
}
void cheevos_fixup_destroy(cheevos_fixups_t* fixups)
void rcheevos_fixup_destroy(cheevos_fixups_t* fixups)
{
CHEEVOS_FREE(fixups->elements);
cheevos_fixup_init(fixups);
rcheevos_fixup_init(fixups);
}
const uint8_t* cheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console)
const uint8_t* rcheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console)
{
cheevos_fixup_t key;
cheevos_fixup_t* found;
@ -114,13 +114,13 @@ const uint8_t* cheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, in
fixups->elements[fixups->count].address = address;
fixups->elements[fixups->count++].location = location =
cheevos_patch_address(address, console);
rcheevos_patch_address(address, console);
fixups->dirty = true;
return location;
}
const uint8_t* cheevos_patch_address(unsigned address, int console)
const uint8_t* rcheevos_patch_address(unsigned address, int console)
{
rarch_system_info_t* system = runloop_get_system_info();
const void* pointer = NULL;

View File

@ -36,12 +36,12 @@ typedef struct
bool dirty;
} cheevos_fixups_t;
void cheevos_fixup_init(cheevos_fixups_t* fixups);
void cheevos_fixup_destroy(cheevos_fixups_t* fixups);
void rcheevos_fixup_init(cheevos_fixups_t* fixups);
void rcheevos_fixup_destroy(cheevos_fixups_t* fixups);
const uint8_t* cheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console);
const uint8_t* rcheevos_fixup_find(cheevos_fixups_t* fixups, unsigned address, int console);
const uint8_t* cheevos_patch_address(unsigned address, int console);
const uint8_t* rcheevos_patch_address(unsigned address, int console);
RETRO_END_DECLS

View File

@ -25,13 +25,13 @@ Setup - mainly for debugging
*****************************************************************************/
/* Define this macro to get extra-verbose log for cheevos. */
#undef CHEEVOS_VERBOSE
#define CHEEVOS_VERBOSE
/*****************************************************************************
End of setup
*****************************************************************************/
#define CHEEVOS_TAG "[CHEEVOS]: "
#define CHEEVOS_TAG "[RCHEEVOS]: "
#define CHEEVOS_FREE(p) do { void* q = (void*)p; if (q != NULL) free(q); } while (0)
#ifdef CHEEVOS_VERBOSE

View File

@ -34,7 +34,7 @@ Setup - mainly for debugging
*****************************************************************************/
/* Define this macro to get extra-verbose log for cheevos. */
#undef CHEEVOS_VERBOSE
#define CHEEVOS_VERBOSE
/*****************************************************************************
End of setup

114
command.c
View File

@ -41,11 +41,9 @@
#ifdef HAVE_CHEEVOS
#include "cheevos/cheevos.h"
#ifdef HAVE_NEW_CHEEVOS
#include "cheevos-new/fixup.h"
#else
#include "cheevos/var.h"
#endif
#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove lines */
#include "cheevos-new/fixup.h"
#endif
#ifdef HAVE_DISCORD
@ -276,9 +274,10 @@ bool command_set_shader(const char *arg)
#define SMY_CMD_STR "READ_CORE_RAM"
static bool command_read_ram(const char *arg)
{
#if !defined(HAVE_NEW_CHEEVOS)
/* RCHEEVOS TODO: remove settings init and test */
settings_t *settings = config_get_ptr();
cheevos_var_t var;
#endif
unsigned i;
char *reply = NULL;
const uint8_t *data = NULL;
@ -294,13 +293,18 @@ static bool command_read_ram(const char *arg)
reply[0] = '\0';
reply_at = reply + snprintf(reply, alloc_size - 1, SMY_CMD_STR " %x", addr);
#if defined(HAVE_NEW_CHEEVOS)
data = cheevos_patch_address(addr, cheevos_get_console());
#else
var.value = addr;
cheevos_var_patch_addr(&var, cheevos_get_console());
data = cheevos_var_get_memory(&var);
#endif
/* RCHEEVOS TODO: remove if condition below */
if (settings->bools.cheevos_rcheevos_enable)
{
data = rcheevos_patch_address(addr, rcheevos_get_console());
}
/* RCHEEVOS TODO: remove whole else block below */
else
{
var.value = addr;
cheevos_var_patch_addr(&var, cheevos_get_console());
data = cheevos_var_get_memory(&var);
}
if (data)
{
@ -321,19 +325,28 @@ static bool command_read_ram(const char *arg)
static bool command_write_ram(const char *arg)
{
unsigned nbytes = 0;
#if defined(HAVE_NEW_CHEEVOS)
unsigned int addr = strtoul(arg, (char**)&arg, 16);
uint8_t *data = (uint8_t *)cheevos_patch_address(addr, cheevos_get_console());
#else
cheevos_var_t var;
uint8_t *data = NULL;
unsigned nbytes = 0;
uint8_t *data = NULL;
unsigned int addr = 0;
var.value = strtoul(arg, (char**)&arg, 16);
cheevos_var_patch_addr(&var, cheevos_get_console());
/* RCHEEVOS TODO: remove settings init and test */
settings_t *settings = config_get_ptr();
data = cheevos_var_get_memory(&var);
#endif
if (settings->bools.cheevos_rcheevos_enable)
{
addr = strtoul(arg, (char**)&arg, 16);
data = (uint8_t *)rcheevos_patch_address(addr, rcheevos_get_console());
}
/* RCHEEVOS TODO: remove the whole else block below */
else
{
cheevos_var_t var;
var.value = strtoul(arg, (char**)&arg, 16);
cheevos_var_patch_addr(&var, cheevos_get_console());
data = cheevos_var_get_memory(&var);
}
if (data)
{
@ -1089,7 +1102,9 @@ static void command_event_init_controllers(void)
static void command_event_deinit_core(bool reinit)
{
#ifdef HAVE_CHEEVOS
cheevos_unload();
/* RCHEEVOS TODO: remove settings init and test */
settings_t *settings = config_get_ptr();
settings->bools.cheevos_rcheevos_enable ? rcheevos_unload() : cheevos_unload();
#endif
RARCH_LOG("Unloading game..\n");
@ -1144,7 +1159,8 @@ static void command_event_load_auto_state(void)
#endif
#ifdef HAVE_CHEEVOS
if (cheevos_hardcore_active)
/* RCHEEVOS TODO: remove OR below */
if (cheevos_hardcore_active || rcheevos_hardcore_active)
goto error;
#endif
@ -1395,7 +1411,8 @@ static bool command_event_save_auto_state(void)
goto error;
#ifdef HAVE_CHEEVOS
if (cheevos_hardcore_active)
/* RCHEEVOS TODO: remove OR below */
if (cheevos_hardcore_active || rcheevos_hardcore_active)
goto error;
#endif
@ -1695,7 +1712,8 @@ static bool command_event_main_state(unsigned cmd)
if (content_load_state(state_path, false, false))
{
#ifdef HAVE_CHEEVOS
cheevos_state_loaded_flag = true;
/* RCHEEVOS TODO: remove duplication below */
rcheevos_state_loaded_flag = cheevos_state_loaded_flag = true;
#endif
ret = true;
#ifdef HAVE_NETWORKING
@ -1842,7 +1860,8 @@ bool command_event(enum event_command cmd, void *data)
return false;
#ifdef HAVE_CHEEVOS
if (cheevos_hardcore_active)
/* RCHEEVOS TODO: remove OR below */
if (cheevos_hardcore_active || rcheevos_hardcore_active)
return false;
#endif
if (!command_event_main_state(cmd))
@ -1872,29 +1891,34 @@ bool command_event(enum event_command cmd, void *data)
command_event_init_controllers();
break;
case CMD_EVENT_RESET:
/* RCHEEVOS TODO: remove starting block bracket, settings init and tests */
{
#ifdef HAVE_CHEEVOS
cheevos_state_loaded_flag = false;
cheevos_hardcore_paused = false;
settings_t *settings = config_get_ptr();
rcheevos_state_loaded_flag = cheevos_state_loaded_flag = false;
rcheevos_hardcore_paused = cheevos_hardcore_paused = false;
#endif
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET));
runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET));
runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
#ifdef HAVE_CHEEVOS
cheevos_set_cheats();
settings->bools.cheevos_rcheevos_enable ? rcheevos_set_cheats() : cheevos_set_cheats();
#endif
core_reset();
core_reset();
#ifdef HAVE_CHEEVOS
cheevos_reset_game();
settings->bools.cheevos_rcheevos_enable ? rcheevos_reset_game() : cheevos_reset_game();
#endif
#if HAVE_NETWORKING
netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL);
netplay_driver_ctl(RARCH_NETPLAY_CTL_RESET, NULL);
#endif
return false;
return false;
}
case CMD_EVENT_SAVE_STATE:
{
settings_t *settings = config_get_ptr();
#ifdef HAVE_CHEEVOS
if (cheevos_hardcore_active)
/* RCHEEVOS TODO: remove OR below */
if (cheevos_hardcore_active || rcheevos_hardcore_active)
return false;
#endif
@ -1976,7 +2000,11 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE:
#ifdef HAVE_CHEEVOS
cheevos_toggle_hardcore_mode();
/* RCHEEVOS TODO: remove starting block bracket, settings init and test */
{
settings_t *settings = config_get_ptr();
settings->bools.cheevos_rcheevos_enable ? rcheevos_toggle_hardcore_mode() : cheevos_toggle_hardcore_mode();
}
#endif
break;
/* this fallthrough is on purpose, it should do
@ -2017,7 +2045,8 @@ bool command_event(enum event_command cmd, void *data)
break;
case CMD_EVENT_REWIND_DEINIT:
#ifdef HAVE_CHEEVOS
if (cheevos_hardcore_active)
/* RCHEEVOS TODO: remove OR below */
if (cheevos_hardcore_active || rcheevos_hardcore_active)
return false;
#endif
state_manager_event_deinit();
@ -2026,7 +2055,8 @@ bool command_event(enum event_command cmd, void *data)
{
settings_t *settings = config_get_ptr();
#ifdef HAVE_CHEEVOS
if (cheevos_hardcore_active)
/* RCHEEVOS TODO: remove OR below */
if (cheevos_hardcore_active || rcheevos_hardcore_active)
return false;
#endif
if (settings->bools.rewind_enable)

View File

@ -1521,6 +1521,8 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings,
SETTING_BOOL("cheevos_leaderboards_enable", &settings->bools.cheevos_leaderboards_enable, true, false, false);
SETTING_BOOL("cheevos_verbose_enable", &settings->bools.cheevos_verbose_enable, true, false, false);
SETTING_BOOL("cheevos_auto_screenshot", &settings->bools.cheevos_auto_screenshot, true, false, false);
SETTING_BOOL("cheevos_rcheevos_enable", &settings->bools.cheevos_rcheevos_enable, true, false, false);
/* RCHEEVOS TODO: remove line above */
#ifdef HAVE_XMB
SETTING_BOOL("cheevos_badges_enable", &settings->bools.cheevos_badges_enable, true, false, false);
#endif

View File

@ -237,6 +237,7 @@ typedef struct settings
bool cheevos_badges_enable;
bool cheevos_verbose_enable;
bool cheevos_auto_screenshot;
bool cheevos_rcheevos_enable; /* RCHEEVOS TODO: remove line */
/* Camera */
bool camera_allow;

View File

@ -41,6 +41,7 @@
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#ifdef HAVE_MENU

View File

@ -37,6 +37,7 @@
#ifdef HAVE_CHEEVOS
#include "cheevos/cheevos.h"
#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#ifdef HAVE_OPENGL
@ -1924,7 +1925,8 @@ bool rarch_environment_cb(unsigned cmd, void *data)
{
bool state = *(const bool*)data;
RARCH_LOG("Environ SET_SUPPORT_ACHIEVEMENTS: %s.\n", state ? "yes" : "no");
cheevos_set_support_cheevos(state);
/* RCHEEVOS TODO: remove settings test */
settings->bools.cheevos_rcheevos_enable ? rcheevos_set_support_cheevos(state) : cheevos_set_support_cheevos(state);
}
#endif
break;

View File

@ -158,30 +158,15 @@ ACHIEVEMENTS
#include "../libretro-common/formats/json/jsonsax.c"
#include "../network/net_http_special.c"
#ifdef HAVE_NEW_CHEEVOS
#include "../cheevos-new/cheevos.c"
#include "../cheevos-new/badges.c"
#include "../cheevos-new/fixup.c"
#include "../cheevos-new/hash.c"
#include "../cheevos-new/parser.c"
#include "../deps/rcheevos/src/rcheevos/alloc.c"
#include "../deps/rcheevos/src/rcheevos/condition.c"
#include "../deps/rcheevos/src/rcheevos/condset.c"
#include "../deps/rcheevos/src/rcheevos/expression.c"
#include "../deps/rcheevos/src/rcheevos/format.c"
#include "../deps/rcheevos/src/rcheevos/lboard.c"
#include "../deps/rcheevos/src/rcheevos/operand.c"
#include "../deps/rcheevos/src/rcheevos/term.c"
#include "../deps/rcheevos/src/rcheevos/trigger.c"
#include "../deps/rcheevos/src/rcheevos/value.c"
#include "../deps/rcheevos/src/rurl/url.c"
#else
#include "../cheevos/cheevos.c"
#include "../cheevos/badges.c"
#include "../cheevos/cond.c"
#include "../cheevos/var.c"
#endif
#endif

View File

@ -41,6 +41,7 @@
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#include "cheat_manager.h"
@ -68,6 +69,8 @@ unsigned cheat_manager_get_size(void)
void cheat_manager_apply_cheats(void)
{
#ifdef HAVE_CHEEVOS
/* RCHEEVOS TODO: remove settings init */
settings_t *settings = config_get_ptr();
bool data_bool = false;
#endif
unsigned i, idx = 0;
@ -100,7 +103,8 @@ void cheat_manager_apply_cheats(void)
#ifdef HAVE_CHEEVOS
data_bool = idx != 0;
cheevos_apply_cheats(&data_bool);
/* RCHEEVOS TODO: remove settings test */
settings->bools.cheevos_rcheevos_enable ? rcheevos_apply_cheats(&data_bool) : cheevos_apply_cheats(&data_bool);
#endif
}

View File

@ -78,6 +78,7 @@
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#include "../../record/record_driver.h"

View File

@ -21,6 +21,7 @@
#ifdef HAVE_CHEEVOS
#include "../../cheevos/cheevos.h"
#include "../../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#include "../../verbosity.h"
@ -572,12 +573,14 @@ static int action_bind_sublabel_cheevos_entry(
char *s, size_t len)
{
#ifdef HAVE_CHEEVOS
settings_t *settings = config_get_ptr(); /* RCHEEVOS TODO: remove line */
cheevos_ctx_desc_t desc_info;
unsigned new_id = type - MENU_SETTINGS_CHEEVOS_START;
desc_info.idx = new_id;
desc_info.s = s;
desc_info.len = len;
cheevos_get_description(&desc_info);
/* RCHEEVOS TODO: remove test */
settings->bools.cheevos_rcheevos_enable ? rcheevos_get_description((rcheevos_ctx_desc_t*) &desc_info) : cheevos_get_description(&desc_info);
strlcpy(s, desc_info.s, len);
#endif

View File

@ -39,6 +39,7 @@
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#ifdef HAVE_NETWORKING
@ -2686,7 +2687,8 @@ static int menu_displaylist_parse_load_content_settings(
if (settings->bools.quick_menu_show_save_load_state
#ifdef HAVE_CHEEVOS
&& !cheevos_hardcore_active
/* RCHEEVOS TODO: remove 'rcheevos_*' below */
&& !(rcheevos_hardcore_active || cheevos_hardcore_active)
#endif
)
{
@ -2709,7 +2711,8 @@ static int menu_displaylist_parse_load_content_settings(
if (settings->bools.quick_menu_show_save_load_state &&
settings->bools.quick_menu_show_undo_save_load_state
#ifdef HAVE_CHEEVOS
&& !cheevos_hardcore_active
/* RCHEEVOS TODO: remove 'rcheevos_*' below */
&& !(rcheevos_hardcore_active || cheevos_hardcore_active)
#endif
)
{
@ -5040,10 +5043,13 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, menu_displaylist
break;
case DISPLAYLIST_ACHIEVEMENT_LIST:
#ifdef HAVE_CHEEVOS
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
cheevos_populate_menu(info);
info->need_push = true;
info->need_refresh = true;
{ /* RCHEEVOS TODO: remove brackets, settings and settings test */
settings_t *settings = config_get_ptr();
menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list);
settings->bools.cheevos_rcheevos_enable ? rcheevos_populate_menu(info) : cheevos_populate_menu(info);
info->need_push = true;
info->need_refresh = true;
}
#endif
break;

View File

@ -50,6 +50,7 @@
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#include "../frontend/frontend_driver.h"
@ -3465,7 +3466,8 @@ static void achievement_hardcore_mode_write_handler(rarch_setting_t *setting)
if (settings && settings->bools.cheevos_enable && settings->bools.cheevos_hardcore_mode_enable)
{
cheevos_toggle_hardcore_mode();
/* RCHEEVOS TODO: remove settings test */
settings->bools.cheevos_rcheevos_enable ? rcheevos_toggle_hardcore_mode() : cheevos_toggle_hardcore_mode();
command_event(CMD_EVENT_RESET, NULL);
return;
}

View File

@ -23,6 +23,7 @@
#ifdef HAVE_CHEEVOS
#include "../../cheevos/cheevos.h"
#include "../../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#include "menu_dialog.h"
@ -173,10 +174,14 @@ int menu_dialog_iterate(char *s, size_t len, const char *label)
#ifdef HAVE_CHEEVOS
case MENU_DIALOG_HELP_CHEEVOS_DESCRIPTION:
desc_info.idx = menu_dialog_current_id;
desc_info.s = s;
desc_info.len = len;
cheevos_get_description(&desc_info);
{ /* RCHEEVOS TODO: remove brackets, settings and settings test */
settings_t *settings = config_get_ptr();
desc_info.idx = menu_dialog_current_id;
desc_info.s = s;
desc_info.len = len;
settings->bools.cheevos_rcheevos_enable ? rcheevos_get_description((rcheevos_ctx_desc_t*) &desc_info) : cheevos_get_description(&desc_info);
}
break;
#endif

View File

@ -30,6 +30,7 @@
#include "../../gfx/video_driver.h"
#include "../../managers/core_option_manager.h"
#include "../../cheevos/cheevos.h"
#include "../../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#include "../../content.h"
#define BASIC_INFO "info"

View File

@ -78,6 +78,7 @@
#ifdef HAVE_CHEEVOS
#include "cheevos/cheevos.h"
#include "cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#ifdef HAVE_DISCORD
@ -3231,7 +3232,8 @@ bool runloop_msg_queue_pull(const char **ret)
*/
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !is_alive || bsv_movie_is_end_of_file() || ((runloop_max_frames != 0) && (frame_count >= runloop_max_frames)) || runloop_exec)
#define runloop_check_cheevos() (settings->bools.cheevos_enable && cheevos_loaded && (!cheats_are_enabled && !cheats_were_enabled))
/* RCHEEVOS TODO: remove 'rcheevos_*' tests below */
#define runloop_check_cheevos() (settings->bools.cheevos_enable && (rcheevos_loaded || cheevos_loaded) && (!(rcheevos_cheats_are_enabled || cheats_are_enabled) && !(rcheevos_cheats_were_enabled || cheats_were_enabled)))
#ifdef HAVE_NETWORKING
/* FIXME: This is an ugly way to tell Netplay this... */
@ -4118,17 +4120,18 @@ static enum runloop_state runloop_check_state(
}
#ifdef HAVE_CHEEVOS
cheevos_hardcore_active = settings->bools.cheevos_enable
/* RCHEEVOS TODO: remove the 'rcheevos_*' below */
rcheevos_hardcore_active = cheevos_hardcore_active = settings->bools.cheevos_enable
&& settings->bools.cheevos_hardcore_mode_enable
&& cheevos_loaded && !cheevos_hardcore_paused;
&& (rcheevos_loaded || cheevos_loaded) && !(rcheevos_hardcore_paused || cheevos_hardcore_paused);
if (cheevos_hardcore_active && cheevos_state_loaded_flag)
if ((rcheevos_hardcore_active || cheevos_hardcore_active) && (rcheevos_state_loaded_flag || cheevos_state_loaded_flag))
{
cheevos_hardcore_paused = true;
rcheevos_hardcore_paused = cheevos_hardcore_paused = true;
runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_DISABLED), 0, 180, true, NULL, MESSAGE_QUEUE_ICON_DEFAULT, MESSAGE_QUEUE_CATEGORY_INFO);
}
if (!cheevos_hardcore_active)
if (!(rcheevos_hardcore_active || cheevos_hardcore_active))
#endif
{
char s[128];
@ -4144,7 +4147,8 @@ static enum runloop_state runloop_check_state(
/* Checks if slowmotion toggle/hold was being pressed and/or held. */
#ifdef HAVE_CHEEVOS
if (!cheevos_hardcore_active)
/* RCHEEVOS TODO: remove the 'rcheevos_*' below */
if (!(rcheevos_hardcore_active || cheevos_hardcore_active))
#endif
{
static bool old_slowmotion_button_state = false;
@ -4493,8 +4497,8 @@ int runloop_iterate(unsigned *sleep_ms)
rarch_core_runtime_tick();
#ifdef HAVE_CHEEVOS
if (runloop_check_cheevos())
cheevos_test();
if (runloop_check_cheevos()) /* RCHEEVOS TODO: remove settings test */
settings->bools.cheevos_rcheevos_enable ? rcheevos_test() : cheevos_test();
#endif
cheat_manager_apply_retro_cheats();

View File

@ -71,6 +71,7 @@
#ifdef HAVE_CHEEVOS
#include "../cheevos/cheevos.h"
#include "../cheevos-new/cheevos.h" /* RCHEEVOS TODO: remove line */
#endif
#include "task_content.h"
@ -738,13 +739,15 @@ static bool content_file_load(
#ifdef HAVE_CHEEVOS
if (!special)
{
/* RCHEEVOS TODO: remove settings and settings tests */
settings_t *settings = config_get_ptr();
const char *content_path = content->elems[0].data;
enum rarch_content_type type = path_is_media_type(content_path);
cheevos_set_cheats();
settings->bools.cheevos_rcheevos_enable ? rcheevos_set_cheats() : cheevos_set_cheats();
if (type == RARCH_CONTENT_NONE && !string_is_empty(content_path))
cheevos_load(info);
settings->bools.cheevos_rcheevos_enable ? rcheevos_load(info) : cheevos_load(info);
}
#endif