mirror of
https://github.com/libretro/RetroArch
synced 2025-04-24 15:02:35 +00:00
Create runloop_check_cheevos
This commit is contained in:
parent
94915815ae
commit
fad523ea3e
32
cheevos.c
32
cheevos.c
@ -273,7 +273,6 @@ typedef struct
|
|||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
int loaded;
|
|
||||||
int console_id;
|
int console_id;
|
||||||
bool core_supports;
|
bool core_supports;
|
||||||
|
|
||||||
@ -285,9 +284,9 @@ typedef struct
|
|||||||
retro_ctx_memory_info_t meminfo[4];
|
retro_ctx_memory_info_t meminfo[4];
|
||||||
} cheevos_locals_t;
|
} cheevos_locals_t;
|
||||||
|
|
||||||
|
|
||||||
static cheevos_locals_t cheevos_locals =
|
static cheevos_locals_t cheevos_locals =
|
||||||
{
|
{
|
||||||
0,
|
|
||||||
0,
|
0,
|
||||||
true,
|
true,
|
||||||
{NULL, 0},
|
{NULL, 0},
|
||||||
@ -295,8 +294,9 @@ static cheevos_locals_t cheevos_locals =
|
|||||||
{0}
|
{0}
|
||||||
};
|
};
|
||||||
|
|
||||||
static int cheats_are_enabled = 0;
|
bool cheevos_loaded = false;
|
||||||
static int cheats_were_enabled = 0;
|
int cheats_are_enabled = 0;
|
||||||
|
int cheats_were_enabled = 0;
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
Supporting functions.
|
Supporting functions.
|
||||||
@ -2558,7 +2558,7 @@ bool cheevos_load(const void *data)
|
|||||||
|
|
||||||
url[0] = '\0';
|
url[0] = '\0';
|
||||||
|
|
||||||
cheevos_locals.loaded = 0;
|
cheevos_loaded = 0;
|
||||||
|
|
||||||
/* Just return OK if the core doesn't support cheevos, or info is NULL. */
|
/* Just return OK if the core doesn't support cheevos, or info is NULL. */
|
||||||
if (!cheevos_locals.core_supports || !info)
|
if (!cheevos_locals.core_supports || !info)
|
||||||
@ -2676,7 +2676,7 @@ found:
|
|||||||
{
|
{
|
||||||
cheevos_deactivate_unlocks(game_id, &timeout);
|
cheevos_deactivate_unlocks(game_id, &timeout);
|
||||||
free((void*)json);
|
free((void*)json);
|
||||||
cheevos_locals.loaded = 1;
|
cheevos_loaded = true;
|
||||||
|
|
||||||
cheevos_make_playing_url(game_id, url, sizeof(url));
|
cheevos_make_playing_url(game_id, url, sizeof(url));
|
||||||
task_push_http_transfer(url, true, NULL,
|
task_push_http_transfer(url, true, NULL,
|
||||||
@ -2698,18 +2698,14 @@ void cheevos_reset_game(void)
|
|||||||
const cheevo_t *end = cheevo + cheevos_locals.core.count;
|
const cheevo_t *end = cheevo + cheevos_locals.core.count;
|
||||||
|
|
||||||
for (; cheevo < end; cheevo++)
|
for (; cheevo < end; cheevo++)
|
||||||
{
|
|
||||||
cheevo->last = 1;
|
cheevo->last = 1;
|
||||||
}
|
|
||||||
|
|
||||||
cheevo = cheevos_locals.unofficial.cheevos;
|
cheevo = cheevos_locals.unofficial.cheevos;
|
||||||
end = cheevo + cheevos_locals.unofficial.count;
|
end = cheevo + cheevos_locals.unofficial.count;
|
||||||
|
|
||||||
for (; cheevo < end; cheevo++)
|
for (; cheevo < end; cheevo++)
|
||||||
{
|
|
||||||
cheevo->last = 1;
|
cheevo->last = 1;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void cheevos_populate_menu(void *data, bool hardcore)
|
void cheevos_populate_menu(void *data, bool hardcore)
|
||||||
{
|
{
|
||||||
@ -2840,13 +2836,13 @@ bool cheevos_apply_cheats(bool *data_bool)
|
|||||||
|
|
||||||
bool cheevos_unload(void)
|
bool cheevos_unload(void)
|
||||||
{
|
{
|
||||||
if (!cheevos_locals.loaded)
|
if (!cheevos_loaded)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
cheevos_free_cheevo_set(&cheevos_locals.core);
|
cheevos_free_cheevo_set(&cheevos_locals.core);
|
||||||
cheevos_free_cheevo_set(&cheevos_locals.unofficial);
|
cheevos_free_cheevo_set(&cheevos_locals.unofficial);
|
||||||
|
|
||||||
cheevos_locals.loaded = 0;
|
cheevos_loaded = false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -2876,16 +2872,9 @@ bool cheevos_toggle_hardcore_mode(void)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cheevos_test(void)
|
void cheevos_test(void)
|
||||||
{
|
|
||||||
if (!cheevos_locals.loaded)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
if (!cheats_are_enabled && !cheats_were_enabled)
|
|
||||||
{
|
{
|
||||||
settings_t *settings = config_get_ptr();
|
settings_t *settings = config_get_ptr();
|
||||||
if (!settings->cheevos.enable)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
cheevos_test_cheevo_set(&cheevos_locals.core);
|
cheevos_test_cheevo_set(&cheevos_locals.core);
|
||||||
|
|
||||||
@ -2897,9 +2886,6 @@ bool cheevos_test(void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool cheevos_set_cheats(void)
|
bool cheevos_set_cheats(void)
|
||||||
{
|
{
|
||||||
cheats_were_enabled = cheats_are_enabled;
|
cheats_were_enabled = cheats_are_enabled;
|
||||||
|
@ -53,7 +53,7 @@ bool cheevos_unload(void);
|
|||||||
|
|
||||||
bool cheevos_toggle_hardcore_mode(void);
|
bool cheevos_toggle_hardcore_mode(void);
|
||||||
|
|
||||||
bool cheevos_test(void);
|
void cheevos_test(void);
|
||||||
|
|
||||||
bool cheevos_set_cheats(void);
|
bool cheevos_set_cheats(void);
|
||||||
|
|
||||||
@ -65,6 +65,10 @@ void cheevos_parse_guest_addr(cheevos_var_t *var, unsigned value);
|
|||||||
|
|
||||||
uint8_t *cheevos_get_memory(const cheevos_var_t *var);
|
uint8_t *cheevos_get_memory(const cheevos_var_t *var);
|
||||||
|
|
||||||
|
extern bool cheevos_loaded;
|
||||||
|
extern int cheats_are_enabled;
|
||||||
|
extern int cheats_were_enabled;
|
||||||
|
|
||||||
RETRO_END_DECLS
|
RETRO_END_DECLS
|
||||||
|
|
||||||
#endif /* __RARCH_CHEEVOS_H */
|
#endif /* __RARCH_CHEEVOS_H */
|
||||||
|
@ -760,6 +760,8 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data)
|
|||||||
*/
|
*/
|
||||||
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !video_driver_is_alive() || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL) || (runloop_max_frames && (*(video_driver_get_frame_count_ptr()) >= runloop_max_frames)) || runloop_exec)
|
#define time_to_exit(quit_key_pressed) (runloop_shutdown_initiated || quit_key_pressed || !video_driver_is_alive() || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL) || (runloop_max_frames && (*(video_driver_get_frame_count_ptr()) >= runloop_max_frames)) || runloop_exec)
|
||||||
|
|
||||||
|
#define runloop_check_cheevos() (settings->cheevos.enable && cheevos_loaded && (!cheats_are_enabled && !cheats_were_enabled))
|
||||||
|
|
||||||
static enum runloop_state runloop_check_state(
|
static enum runloop_state runloop_check_state(
|
||||||
settings_t *settings,
|
settings_t *settings,
|
||||||
uint64_t current_input,
|
uint64_t current_input,
|
||||||
@ -1244,6 +1246,7 @@ int runloop_iterate(unsigned *sleep_ms)
|
|||||||
core_run();
|
core_run();
|
||||||
|
|
||||||
#ifdef HAVE_CHEEVOS
|
#ifdef HAVE_CHEEVOS
|
||||||
|
if (runloop_check_cheevos())
|
||||||
cheevos_test();
|
cheevos_test();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user