mirror of
https://github.com/libretro/RetroArch
synced 2025-04-10 15:45:19 +00:00
remove old cheevos files
This commit is contained in:
parent
694bac565f
commit
98ba2d8cb9
@ -1,74 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2018 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <file/file_path.h>
|
|
||||||
#include <string/stdstring.h>
|
|
||||||
#include <streams/file_stream.h>
|
|
||||||
|
|
||||||
#ifdef HAVE_MENU
|
|
||||||
#include "../menu/menu_driver.h"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#include "../file_path_special.h"
|
|
||||||
#include "../configuration.h"
|
|
||||||
#include "../verbosity.h"
|
|
||||||
#include "../network/net_http_special.h"
|
|
||||||
|
|
||||||
#include "badges.h"
|
|
||||||
|
|
||||||
badges_ctx_t badges_ctx;
|
|
||||||
|
|
||||||
bool badge_exists(const char* filepath)
|
|
||||||
{
|
|
||||||
return filestream_exists(filepath);
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_badge_menu_texture(badges_ctx_t * badges, int i)
|
|
||||||
{
|
|
||||||
char badge_file[16];
|
|
||||||
char fullpath[PATH_MAX_LENGTH];
|
|
||||||
|
|
||||||
snprintf(badge_file, sizeof(badge_file), "%s%s", badges->badge_id_list[i],
|
|
||||||
badges->badge_locked[i] ? "_lock.png" : ".png");
|
|
||||||
|
|
||||||
fill_pathname_application_special(fullpath,
|
|
||||||
PATH_MAX_LENGTH * sizeof(char),
|
|
||||||
APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES);
|
|
||||||
|
|
||||||
#if defined(HAVE_MENU) || defined(HAVE_MENU_WIDGETS)
|
|
||||||
menu_display_reset_textures_list(badge_file, fullpath,
|
|
||||||
&badges->menu_texture_list[i],TEXTURE_FILTER_MIPMAP_LINEAR, NULL, NULL);
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_badge_info (badges_ctx_t *badge_struct, int id,
|
|
||||||
const char *badge_id, bool active)
|
|
||||||
{
|
|
||||||
if (!badge_struct)
|
|
||||||
return;
|
|
||||||
|
|
||||||
badge_struct->badge_id_list[id] = badge_id;
|
|
||||||
badge_struct->badge_locked[id] = active;
|
|
||||||
set_badge_menu_texture(badge_struct, id);
|
|
||||||
}
|
|
||||||
|
|
||||||
menu_texture_item get_badge_texture(int id)
|
|
||||||
{
|
|
||||||
settings_t *settings = config_get_ptr();
|
|
||||||
if (!settings || !settings->bools.cheevos_badges_enable)
|
|
||||||
return (menu_texture_item)NULL;
|
|
||||||
|
|
||||||
return badges_ctx.menu_texture_list[id];
|
|
||||||
}
|
|
@ -1,44 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2018 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RARCH_CHEEVOS_OLD_BADGE_H
|
|
||||||
#define __RARCH_CHEEVOS_OLD_BADGE_H
|
|
||||||
|
|
||||||
#include "../menu/menu_driver.h"
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
#define CHEEVOS_BADGE_LIMIT 256
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
bool badge_locked[CHEEVOS_BADGE_LIMIT];
|
|
||||||
const char * badge_id_list[CHEEVOS_BADGE_LIMIT];
|
|
||||||
menu_texture_item menu_texture_list[CHEEVOS_BADGE_LIMIT];
|
|
||||||
} badges_ctx_t;
|
|
||||||
|
|
||||||
bool badge_exists(const char* filepath);
|
|
||||||
void set_badge_menu_texture(badges_ctx_t * badges, int i);
|
|
||||||
extern void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active);
|
|
||||||
extern menu_texture_item get_badge_texture(int id);
|
|
||||||
|
|
||||||
extern badges_ctx_t badges_ctx;
|
|
||||||
static badges_ctx_t new_badges_ctx;
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif
|
|
3730
cheevos/cheevos.c
3730
cheevos/cheevos.c
File diff suppressed because it is too large
Load Diff
@ -1,165 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2018 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RARCH_CHEEVOS_OLD_H
|
|
||||||
#define __RARCH_CHEEVOS_OLD_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
|
|
||||||
#include <boolean.h>
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
Setup - mainly for debugging
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
/* Define this macro to get extra-verbose log for cheevos. */
|
|
||||||
#define CHEEVOS_VERBOSE
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
End of setup
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#define CHEEVOS_TAG "[CHEEVOS]: "
|
|
||||||
|
|
||||||
#ifdef CHEEVOS_VERBOSE
|
|
||||||
|
|
||||||
#define CHEEVOS_LOG RARCH_LOG
|
|
||||||
#define CHEEVOS_ERR RARCH_ERR
|
|
||||||
|
|
||||||
#else
|
|
||||||
|
|
||||||
void cheevos_log(const char *fmt, ...);
|
|
||||||
|
|
||||||
#define CHEEVOS_LOG cheevos_log
|
|
||||||
#define CHEEVOS_ERR cheevos_log
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
typedef struct cheevos_ctx_desc
|
|
||||||
{
|
|
||||||
unsigned idx;
|
|
||||||
char *s;
|
|
||||||
size_t len;
|
|
||||||
} cheevos_ctx_desc_t;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CHEEVOS_CONSOLE_NONE = 0,
|
|
||||||
/* Don't change those, the values match the console IDs
|
|
||||||
* at retroachievements.org. */
|
|
||||||
CHEEVOS_CONSOLE_MEGA_DRIVE = 1,
|
|
||||||
CHEEVOS_CONSOLE_NINTENDO_64 = 2,
|
|
||||||
CHEEVOS_CONSOLE_SUPER_NINTENDO = 3,
|
|
||||||
CHEEVOS_CONSOLE_GAMEBOY = 4,
|
|
||||||
CHEEVOS_CONSOLE_GAMEBOY_ADVANCE = 5,
|
|
||||||
CHEEVOS_CONSOLE_GAMEBOY_COLOR = 6,
|
|
||||||
CHEEVOS_CONSOLE_NINTENDO = 7,
|
|
||||||
CHEEVOS_CONSOLE_PC_ENGINE = 8,
|
|
||||||
CHEEVOS_CONSOLE_SEGA_CD = 9,
|
|
||||||
CHEEVOS_CONSOLE_SEGA_32X = 10,
|
|
||||||
CHEEVOS_CONSOLE_MASTER_SYSTEM = 11,
|
|
||||||
CHEEVOS_CONSOLE_PLAYSTATION = 12,
|
|
||||||
CHEEVOS_CONSOLE_ATARI_LYNX = 13,
|
|
||||||
CHEEVOS_CONSOLE_NEOGEO_POCKET = 14,
|
|
||||||
CHEEVOS_CONSOLE_GAME_GEAR = 15,
|
|
||||||
CHEEVOS_CONSOLE_GAMECUBE = 16,
|
|
||||||
CHEEVOS_CONSOLE_ATARI_JAGUAR = 17,
|
|
||||||
CHEEVOS_CONSOLE_NINTENDO_DS = 18,
|
|
||||||
CHEEVOS_CONSOLE_WII = 19,
|
|
||||||
CHEEVOS_CONSOLE_WII_U = 20,
|
|
||||||
CHEEVOS_CONSOLE_PLAYSTATION_2 = 21,
|
|
||||||
CHEEVOS_CONSOLE_XBOX = 22,
|
|
||||||
CHEEVOS_CONSOLE_SKYNET = 23,
|
|
||||||
CHEEVOS_CONSOLE_XBOX_ONE = 24,
|
|
||||||
CHEEVOS_CONSOLE_ATARI_2600 = 25,
|
|
||||||
CHEEVOS_CONSOLE_MS_DOS = 26,
|
|
||||||
CHEEVOS_CONSOLE_ARCADE = 27,
|
|
||||||
CHEEVOS_CONSOLE_VIRTUAL_BOY = 28,
|
|
||||||
CHEEVOS_CONSOLE_MSX = 29,
|
|
||||||
CHEEVOS_CONSOLE_COMMODORE_64 = 30,
|
|
||||||
CHEEVOS_CONSOLE_ZX81 = 31,
|
|
||||||
CHEEVOS_CONSOLE_ATARI_7800 = 51
|
|
||||||
} cheevos_console_t;
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CHEEVOS_DIRTY_TITLE = 1 << 0,
|
|
||||||
CHEEVOS_DIRTY_DESC = 1 << 1,
|
|
||||||
CHEEVOS_DIRTY_POINTS = 1 << 2,
|
|
||||||
CHEEVOS_DIRTY_AUTHOR = 1 << 3,
|
|
||||||
CHEEVOS_DIRTY_ID = 1 << 4,
|
|
||||||
CHEEVOS_DIRTY_BADGE = 1 << 5,
|
|
||||||
CHEEVOS_DIRTY_CONDITIONS = 1 << 6,
|
|
||||||
CHEEVOS_DIRTY_VOTES = 1 << 7,
|
|
||||||
CHEEVOS_DIRTY_DESCRIPTION = 1 << 8,
|
|
||||||
|
|
||||||
CHEEVOS_DIRTY_ALL = (1 << 9) - 1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CHEEVOS_ACTIVE_SOFTCORE = 1 << 0,
|
|
||||||
CHEEVOS_ACTIVE_HARDCORE = 1 << 1
|
|
||||||
};
|
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
CHEEVOS_FORMAT_FRAMES = 0,
|
|
||||||
CHEEVOS_FORMAT_SECS,
|
|
||||||
CHEEVOS_FORMAT_MILLIS,
|
|
||||||
CHEEVOS_FORMAT_SCORE,
|
|
||||||
CHEEVOS_FORMAT_VALUE,
|
|
||||||
CHEEVOS_FORMAT_OTHER
|
|
||||||
};
|
|
||||||
|
|
||||||
bool cheevos_load(const void *data);
|
|
||||||
|
|
||||||
void cheevos_reset_game(void);
|
|
||||||
|
|
||||||
void cheevos_populate_menu(void *data);
|
|
||||||
|
|
||||||
bool cheevos_get_description(cheevos_ctx_desc_t *desc);
|
|
||||||
|
|
||||||
bool cheevos_apply_cheats(bool *data_bool);
|
|
||||||
|
|
||||||
bool cheevos_unload(void);
|
|
||||||
|
|
||||||
bool cheevos_toggle_hardcore_mode(void);
|
|
||||||
|
|
||||||
void cheevos_test(void);
|
|
||||||
|
|
||||||
bool cheevos_set_cheats(void);
|
|
||||||
|
|
||||||
void cheevos_set_support_cheevos(bool state);
|
|
||||||
|
|
||||||
bool cheevos_get_support_cheevos(void);
|
|
||||||
|
|
||||||
cheevos_console_t cheevos_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;
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __RARCH_CHEEVOS_H */
|
|
189
cheevos/cond.c
189
cheevos/cond.c
@ -1,189 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2017 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "cond.h"
|
|
||||||
#include "var.h"
|
|
||||||
|
|
||||||
#include "../retroarch.h"
|
|
||||||
#include "../verbosity.h"
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
Parsing
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
static cheevos_cond_op_t cheevos_cond_parse_operator(const char** memaddr)
|
|
||||||
{
|
|
||||||
const char *str = *memaddr;
|
|
||||||
cheevos_cond_op_t op;
|
|
||||||
|
|
||||||
if (*str == '=' && str[1] == '=')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_EQUALS;
|
|
||||||
str += 2;
|
|
||||||
}
|
|
||||||
else if (*str == '=')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_EQUALS;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
else if (*str == '!' && str[1] == '=')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_NOT_EQUAL_TO;
|
|
||||||
str += 2;
|
|
||||||
}
|
|
||||||
else if (*str == '<' && str[1] == '=')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_LESS_THAN_OR_EQUAL;
|
|
||||||
str += 2;
|
|
||||||
}
|
|
||||||
else if (*str == '<')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_LESS_THAN;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
else if (*str == '>' && str[1] == '=')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_GREATER_THAN_OR_EQUAL;
|
|
||||||
str += 2;
|
|
||||||
}
|
|
||||||
else if (*str == '>')
|
|
||||||
{
|
|
||||||
op = CHEEVOS_COND_OP_GREATER_THAN;
|
|
||||||
str++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
CHEEVOS_ERR(CHEEVOS_TAG "unknown operator %c\n.", *str);
|
|
||||||
op = CHEEVOS_COND_OP_EQUALS;
|
|
||||||
}
|
|
||||||
|
|
||||||
*memaddr = str;
|
|
||||||
return op;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cheevos_cond_parse(cheevos_cond_t* cond, const char** memaddr)
|
|
||||||
{
|
|
||||||
const char* str = *memaddr;
|
|
||||||
cond->type = CHEEVOS_COND_TYPE_STANDARD;
|
|
||||||
|
|
||||||
if (*str != 0 && str[1] == ':')
|
|
||||||
{
|
|
||||||
int skip = 2;
|
|
||||||
|
|
||||||
switch (*str)
|
|
||||||
{
|
|
||||||
case 'R':
|
|
||||||
cond->type = CHEEVOS_COND_TYPE_RESET_IF;
|
|
||||||
break;
|
|
||||||
case 'P':
|
|
||||||
cond->type = CHEEVOS_COND_TYPE_PAUSE_IF;
|
|
||||||
break;
|
|
||||||
case 'A':
|
|
||||||
cond->type = CHEEVOS_COND_TYPE_ADD_SOURCE;
|
|
||||||
break;
|
|
||||||
case 'B':
|
|
||||||
cond->type = CHEEVOS_COND_TYPE_SUB_SOURCE;
|
|
||||||
break;
|
|
||||||
case 'C':
|
|
||||||
cond->type = CHEEVOS_COND_TYPE_ADD_HITS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
skip = 0;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
str += skip;
|
|
||||||
}
|
|
||||||
|
|
||||||
cheevos_var_parse(&cond->source, &str);
|
|
||||||
cond->op = cheevos_cond_parse_operator(&str);
|
|
||||||
cheevos_var_parse(&cond->target, &str);
|
|
||||||
cond->curr_hits = 0;
|
|
||||||
|
|
||||||
if (*str == '(' || *str == '.')
|
|
||||||
{
|
|
||||||
char* end;
|
|
||||||
cond->req_hits = (unsigned)strtol(str + 1, &end, 10);
|
|
||||||
str = end + (*end == ')' || *end == '.');
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cond->req_hits = 0;
|
|
||||||
|
|
||||||
*memaddr = str;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned cheevos_cond_count_in_set(const char* memaddr, unsigned which)
|
|
||||||
{
|
|
||||||
cheevos_cond_t dummy;
|
|
||||||
unsigned index = 0;
|
|
||||||
unsigned count = 0;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
cheevos_cond_parse(&dummy, &memaddr);
|
|
||||||
|
|
||||||
if (index == which)
|
|
||||||
count++;
|
|
||||||
|
|
||||||
if (*memaddr != '_')
|
|
||||||
break;
|
|
||||||
|
|
||||||
memaddr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
|
|
||||||
if (*memaddr != 'S')
|
|
||||||
break;
|
|
||||||
|
|
||||||
memaddr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cheevos_cond_parse_in_set(cheevos_cond_t* cond, const char* memaddr, unsigned which)
|
|
||||||
{
|
|
||||||
cheevos_cond_t dummy;
|
|
||||||
unsigned index = 0;
|
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (index == which)
|
|
||||||
{
|
|
||||||
cheevos_cond_parse(cond, &memaddr);
|
|
||||||
cond++;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
cheevos_cond_parse(&dummy, &memaddr);
|
|
||||||
|
|
||||||
if (*memaddr != '_')
|
|
||||||
break;
|
|
||||||
|
|
||||||
memaddr++;
|
|
||||||
}
|
|
||||||
|
|
||||||
index++;
|
|
||||||
|
|
||||||
if (*memaddr != 'S')
|
|
||||||
break;
|
|
||||||
|
|
||||||
memaddr++;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,63 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2017 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RARCH_CHEEVOS_COND_H
|
|
||||||
#define __RARCH_CHEEVOS_COND_H
|
|
||||||
|
|
||||||
#include "var.h"
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CHEEVOS_COND_TYPE_STANDARD,
|
|
||||||
CHEEVOS_COND_TYPE_PAUSE_IF,
|
|
||||||
CHEEVOS_COND_TYPE_RESET_IF,
|
|
||||||
CHEEVOS_COND_TYPE_ADD_SOURCE,
|
|
||||||
CHEEVOS_COND_TYPE_SUB_SOURCE,
|
|
||||||
CHEEVOS_COND_TYPE_ADD_HITS
|
|
||||||
} cheevos_cond_type_t;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CHEEVOS_COND_OP_EQUALS,
|
|
||||||
CHEEVOS_COND_OP_LESS_THAN,
|
|
||||||
CHEEVOS_COND_OP_LESS_THAN_OR_EQUAL,
|
|
||||||
CHEEVOS_COND_OP_GREATER_THAN,
|
|
||||||
CHEEVOS_COND_OP_GREATER_THAN_OR_EQUAL,
|
|
||||||
CHEEVOS_COND_OP_NOT_EQUAL_TO
|
|
||||||
} cheevos_cond_op_t;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
cheevos_cond_type_t type;
|
|
||||||
unsigned req_hits;
|
|
||||||
unsigned curr_hits;
|
|
||||||
char pause;
|
|
||||||
|
|
||||||
cheevos_var_t source;
|
|
||||||
cheevos_cond_op_t op;
|
|
||||||
cheevos_var_t target;
|
|
||||||
} cheevos_cond_t;
|
|
||||||
|
|
||||||
void cheevos_cond_parse(cheevos_cond_t* cond, const char** memaddr);
|
|
||||||
unsigned cheevos_cond_count_in_set(const char* memaddr, unsigned which);
|
|
||||||
void cheevos_cond_parse_in_set(cheevos_cond_t* cond, const char* memaddr, unsigned which);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __RARCH_CHEEVOS_COND_H */
|
|
@ -1,75 +0,0 @@
|
|||||||
#ifndef CORO_H
|
|
||||||
#define CORO_H
|
|
||||||
|
|
||||||
/*
|
|
||||||
Released under the CC0: https://creativecommons.org/publicdomain/zero/1.0/
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Use at the beginning of the coroutine, you must have declared a variable coro_t* coro */
|
|
||||||
#define CORO_ENTER() \
|
|
||||||
{ \
|
|
||||||
CORO_again: ; \
|
|
||||||
switch ( coro->step ) { \
|
|
||||||
case CORO_BEGIN: ;
|
|
||||||
|
|
||||||
/* Use to define labels which are targets to GOTO and GOSUB */
|
|
||||||
#define CORO_SUB( x ) \
|
|
||||||
case x: ;
|
|
||||||
|
|
||||||
/* Use at the end of the coroutine */
|
|
||||||
#define CORO_LEAVE() \
|
|
||||||
} } \
|
|
||||||
do { return 0; } while ( 0 )
|
|
||||||
|
|
||||||
/* Go to the x label */
|
|
||||||
#define CORO_GOTO( x ) \
|
|
||||||
do { \
|
|
||||||
coro->step = ( x ); \
|
|
||||||
goto CORO_again; \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
/* Go to a subroutine, execution continues until the subroutine returns via RET */
|
|
||||||
#define CORO_GOSUB( x ) \
|
|
||||||
do { \
|
|
||||||
coro->stack[ coro->sp++ ] = __LINE__; \
|
|
||||||
coro->step = ( x ); \
|
|
||||||
goto CORO_again; \
|
|
||||||
case __LINE__: ; \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
/* Returns from a subroutine */
|
|
||||||
#define CORO_RET() \
|
|
||||||
do { \
|
|
||||||
coro->step = coro->stack[ --coro->sp ]; \
|
|
||||||
goto CORO_again; \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
/* Yields to the caller, execution continues from this point when the coroutine is resumed */
|
|
||||||
#define CORO_YIELD() \
|
|
||||||
do { \
|
|
||||||
coro->step = __LINE__; \
|
|
||||||
return 1; \
|
|
||||||
case __LINE__: ; \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
/* The coroutine entry point, never use 0 as a label */
|
|
||||||
#define CORO_BEGIN 0
|
|
||||||
|
|
||||||
/* Sets up the coroutine */
|
|
||||||
#define CORO_SETUP() \
|
|
||||||
do { \
|
|
||||||
coro->step = CORO_BEGIN; \
|
|
||||||
coro->sp = 0; \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
#define CORO_STOP() \
|
|
||||||
do { \
|
|
||||||
return 0; \
|
|
||||||
} while ( 0 )
|
|
||||||
|
|
||||||
/* Add this macro to your coro_t structure containing the variables for the coroutine */
|
|
||||||
#define CORO_FIELDS \
|
|
||||||
int step, sp; \
|
|
||||||
int stack[ 8 ];
|
|
||||||
|
|
||||||
#endif /* CORO_H */
|
|
422
cheevos/var.c
422
cheevos/var.c
@ -1,422 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2017 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <ctype.h>
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include <libretro.h>
|
|
||||||
|
|
||||||
#include "var.h"
|
|
||||||
|
|
||||||
#include "../retroarch.h"
|
|
||||||
#include "../core.h"
|
|
||||||
#include "../verbosity.h"
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
Parsing
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
static cheevos_var_size_t cheevos_var_parse_prefix(const char** memaddr)
|
|
||||||
{
|
|
||||||
/* Careful not to use ABCDEF here, this denotes part of an actual variable! */
|
|
||||||
const char* str = *memaddr;
|
|
||||||
cheevos_var_size_t size;
|
|
||||||
|
|
||||||
switch (toupper((unsigned char)*str++))
|
|
||||||
{
|
|
||||||
case 'M':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_0;
|
|
||||||
break;
|
|
||||||
case 'N':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_1;
|
|
||||||
break;
|
|
||||||
case 'O':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_2;
|
|
||||||
break;
|
|
||||||
case 'P':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_3;
|
|
||||||
break;
|
|
||||||
case 'Q':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_4;
|
|
||||||
break;
|
|
||||||
case 'R':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_5;
|
|
||||||
break;
|
|
||||||
case 'S':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_6;
|
|
||||||
break;
|
|
||||||
case 'T':
|
|
||||||
size = CHEEVOS_VAR_SIZE_BIT_7;
|
|
||||||
break;
|
|
||||||
case 'L':
|
|
||||||
size = CHEEVOS_VAR_SIZE_NIBBLE_LOWER;
|
|
||||||
break;
|
|
||||||
case 'U':
|
|
||||||
size = CHEEVOS_VAR_SIZE_NIBBLE_UPPER;
|
|
||||||
break;
|
|
||||||
case 'H':
|
|
||||||
size = CHEEVOS_VAR_SIZE_EIGHT_BITS;
|
|
||||||
break;
|
|
||||||
case 'X':
|
|
||||||
size = CHEEVOS_VAR_SIZE_THIRTYTWO_BITS;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
str--;
|
|
||||||
/* fall through */
|
|
||||||
case ' ':
|
|
||||||
size = CHEEVOS_VAR_SIZE_SIXTEEN_BITS;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
*memaddr = str;
|
|
||||||
return size;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t cheevos_var_reduce(size_t addr, size_t mask)
|
|
||||||
{
|
|
||||||
while (mask)
|
|
||||||
{
|
|
||||||
size_t tmp = (mask - 1) & ~mask;
|
|
||||||
addr = (addr & tmp) | ((addr >> 1) & ~tmp);
|
|
||||||
mask = (mask & (mask - 1)) >> 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return addr;
|
|
||||||
}
|
|
||||||
|
|
||||||
static size_t cheevos_var_highest_bit(size_t n)
|
|
||||||
{
|
|
||||||
n |= n >> 1;
|
|
||||||
n |= n >> 2;
|
|
||||||
n |= n >> 4;
|
|
||||||
n |= n >> 8;
|
|
||||||
n |= n >> 16;
|
|
||||||
|
|
||||||
return n ^ (n >> 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
void cheevos_var_parse(cheevos_var_t* var, const char** memaddr)
|
|
||||||
{
|
|
||||||
char *end = NULL;
|
|
||||||
const char *str = *memaddr;
|
|
||||||
unsigned base = 16;
|
|
||||||
|
|
||||||
var->is_bcd = false;
|
|
||||||
|
|
||||||
if (toupper((unsigned char)*str) == 'D' && str[1] == '0' && toupper((unsigned char)str[2]) == 'X')
|
|
||||||
{
|
|
||||||
/* d0x + 4 hex digits */
|
|
||||||
str += 3;
|
|
||||||
var->type = CHEEVOS_VAR_TYPE_DELTA_MEM;
|
|
||||||
}
|
|
||||||
else if (toupper((unsigned char)*str) == 'B' && str[1] == '0' && toupper((unsigned char)str[2]) == 'X')
|
|
||||||
{
|
|
||||||
/* b0x (binary-coded decimal) */
|
|
||||||
str += 3;
|
|
||||||
var->is_bcd = true;
|
|
||||||
var->type = CHEEVOS_VAR_TYPE_ADDRESS;
|
|
||||||
}
|
|
||||||
else if (*str == '0' && toupper((unsigned char)str[1]) == 'X')
|
|
||||||
{
|
|
||||||
/* 0x + 4 hex digits */
|
|
||||||
str += 2;
|
|
||||||
var->type = CHEEVOS_VAR_TYPE_ADDRESS;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
var->type = CHEEVOS_VAR_TYPE_VALUE_COMP;
|
|
||||||
|
|
||||||
if (toupper((unsigned char)*str) == 'H')
|
|
||||||
str++;
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (toupper((unsigned char)*str) == 'V')
|
|
||||||
str++;
|
|
||||||
|
|
||||||
base = 10;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var->type != CHEEVOS_VAR_TYPE_VALUE_COMP)
|
|
||||||
{
|
|
||||||
var->size = cheevos_var_parse_prefix(&str);
|
|
||||||
}
|
|
||||||
|
|
||||||
var->value = (unsigned)strtol(str, &end, base);
|
|
||||||
*memaddr = end;
|
|
||||||
}
|
|
||||||
|
|
||||||
void cheevos_var_patch_addr(cheevos_var_t* var, cheevos_console_t console)
|
|
||||||
{
|
|
||||||
rarch_system_info_t *system = runloop_get_system_info();
|
|
||||||
|
|
||||||
var->bank_id = -1;
|
|
||||||
|
|
||||||
if (console == CHEEVOS_CONSOLE_NINTENDO)
|
|
||||||
{
|
|
||||||
if (var->value >= 0x0800 && var->value < 0x2000)
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "NES memory address in mirrorred RAM %X, adjusted to %X\n", var->value, var->value & 0x07ff);
|
|
||||||
var->value &= 0x07ff;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (console == CHEEVOS_CONSOLE_GAMEBOY_COLOR)
|
|
||||||
{
|
|
||||||
if (var->value >= 0xe000 && var->value <= 0xfdff)
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "GBC memory address in echo RAM %X, adjusted to %X\n", var->value, var->value - 0x2000);
|
|
||||||
var->value -= 0x2000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (system->mmaps.num_descriptors != 0)
|
|
||||||
{
|
|
||||||
const rarch_memory_descriptor_t *desc = NULL;
|
|
||||||
const rarch_memory_descriptor_t *end = NULL;
|
|
||||||
|
|
||||||
/* Patch the address to correctly map it to the mmaps */
|
|
||||||
if (console == CHEEVOS_CONSOLE_GAMEBOY_ADVANCE)
|
|
||||||
{
|
|
||||||
if (var->value < 0x8000) /* Internal RAM */
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "GBA memory address %X adjusted to %X\n", var->value, var->value + 0x3000000);
|
|
||||||
var->value += 0x3000000;
|
|
||||||
}
|
|
||||||
else /* Work RAM */
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "GBA memory address %X adjusted to %X\n", var->value, var->value + 0x2000000 - 0x8000);
|
|
||||||
var->value += 0x2000000 - 0x8000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (console == CHEEVOS_CONSOLE_PC_ENGINE)
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "PCE memory address %X adjusted to %X\n", var->value, var->value + 0x1f0000);
|
|
||||||
var->value += 0x1f0000;
|
|
||||||
}
|
|
||||||
else if (console == CHEEVOS_CONSOLE_SUPER_NINTENDO)
|
|
||||||
{
|
|
||||||
if (var->value < 0x020000) /* Work RAM */
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "SNES memory address %X adjusted to %X\n", var->value, var->value + 0x7e0000);
|
|
||||||
var->value += 0x7e0000;
|
|
||||||
}
|
|
||||||
else /* Save RAM */
|
|
||||||
{
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "SNES memory address %X adjusted to %X\n", var->value, var->value + 0x006000 - 0x020000);
|
|
||||||
var->value += 0x006000 - 0x020000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
desc = system->mmaps.descriptors;
|
|
||||||
end = desc + system->mmaps.num_descriptors;
|
|
||||||
|
|
||||||
for (; desc < end; desc++)
|
|
||||||
{
|
|
||||||
if (((desc->core.start ^ var->value) & desc->core.select) == 0)
|
|
||||||
{
|
|
||||||
unsigned addr = var->value;
|
|
||||||
var->bank_id = (int)(desc - system->mmaps.descriptors);
|
|
||||||
var->value = (unsigned)cheevos_var_reduce(
|
|
||||||
(addr - desc->core.start) & desc->disconnect_mask,
|
|
||||||
desc->core.disconnect);
|
|
||||||
|
|
||||||
if (var->value >= desc->core.len)
|
|
||||||
var->value -= cheevos_var_highest_bit(var->value);
|
|
||||||
|
|
||||||
var->value += desc->core.offset;
|
|
||||||
|
|
||||||
CHEEVOS_LOG(CHEEVOS_TAG "address %X set to descriptor %d at offset %X\n", addr, var->bank_id + 1, var->value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
unsigned i;
|
|
||||||
|
|
||||||
for (i = 0; i < 4; i++)
|
|
||||||
{
|
|
||||||
retro_ctx_memory_info_t meminfo;
|
|
||||||
|
|
||||||
switch (i)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
meminfo.id = RETRO_MEMORY_SYSTEM_RAM;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
meminfo.id = RETRO_MEMORY_SAVE_RAM;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
meminfo.id = RETRO_MEMORY_VIDEO_RAM;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
meminfo.id = RETRO_MEMORY_RTC;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
core_get_memory(&meminfo);
|
|
||||||
|
|
||||||
if (var->value < meminfo.size)
|
|
||||||
{
|
|
||||||
var->bank_id = i;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* HACK subtract the correct amount of bytes to reach the save RAM */
|
|
||||||
if (i == 0 && console == CHEEVOS_CONSOLE_NINTENDO)
|
|
||||||
var->value -= 0x6000;
|
|
||||||
else
|
|
||||||
var->value -= meminfo.size;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*****************************************************************************
|
|
||||||
Testing
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
uint8_t* cheevos_var_get_memory(const cheevos_var_t* var)
|
|
||||||
{
|
|
||||||
rarch_system_info_t *system = NULL;
|
|
||||||
uint8_t *memory = NULL;
|
|
||||||
size_t length = 0;
|
|
||||||
|
|
||||||
if (var->bank_id < 0)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
system = runloop_get_system_info();
|
|
||||||
|
|
||||||
if (system->mmaps.num_descriptors != 0)
|
|
||||||
{
|
|
||||||
memory = (uint8_t*)system->mmaps.descriptors[var->bank_id].core.ptr;
|
|
||||||
length = system->mmaps.descriptors[var->bank_id].core.len;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
retro_ctx_memory_info_t meminfo = {NULL, 0, 0};
|
|
||||||
|
|
||||||
switch (var->bank_id)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
meminfo.id = RETRO_MEMORY_SYSTEM_RAM;
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
meminfo.id = RETRO_MEMORY_SAVE_RAM;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
meminfo.id = RETRO_MEMORY_VIDEO_RAM;
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
meminfo.id = RETRO_MEMORY_RTC;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
CHEEVOS_ERR(CHEEVOS_TAG "invalid bank id: %d\n", var->bank_id);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
core_get_memory(&meminfo);
|
|
||||||
|
|
||||||
memory = (uint8_t*)meminfo.data;
|
|
||||||
length = meminfo.size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (memory == NULL || var->value >= length)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
return memory + var->value;
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned cheevos_var_get_value(cheevos_var_t* var)
|
|
||||||
{
|
|
||||||
const uint8_t* memory = NULL;
|
|
||||||
unsigned value = 0;
|
|
||||||
|
|
||||||
switch (var->type)
|
|
||||||
{
|
|
||||||
case CHEEVOS_VAR_TYPE_VALUE_COMP:
|
|
||||||
value = var->value;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CHEEVOS_VAR_TYPE_ADDRESS:
|
|
||||||
case CHEEVOS_VAR_TYPE_DELTA_MEM:
|
|
||||||
memory = cheevos_var_get_memory(var);
|
|
||||||
|
|
||||||
if (memory)
|
|
||||||
{
|
|
||||||
value = memory[0];
|
|
||||||
|
|
||||||
switch (var->size)
|
|
||||||
{
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_0:
|
|
||||||
value &= 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_1:
|
|
||||||
value = (value >> 1) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_2:
|
|
||||||
value = (value >> 2) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_3:
|
|
||||||
value = (value >> 3) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_4:
|
|
||||||
value = (value >> 4) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_5:
|
|
||||||
value = (value >> 5) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_6:
|
|
||||||
value = (value >> 6) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_BIT_7:
|
|
||||||
value = (value >> 7) & 1;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_NIBBLE_LOWER:
|
|
||||||
value &= 0x0f;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_NIBBLE_UPPER:
|
|
||||||
value = (value >> 4) & 0x0f;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_EIGHT_BITS:
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_SIXTEEN_BITS:
|
|
||||||
value |= memory[1] << 8;
|
|
||||||
break;
|
|
||||||
case CHEEVOS_VAR_SIZE_THIRTYTWO_BITS:
|
|
||||||
value |= memory[1] << 8;
|
|
||||||
value |= memory[2] << 16;
|
|
||||||
value |= memory[3] << 24;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (var->type == CHEEVOS_VAR_TYPE_DELTA_MEM)
|
|
||||||
{
|
|
||||||
unsigned previous = var->previous;
|
|
||||||
var->previous = value;
|
|
||||||
value = previous;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
|
|
||||||
case CHEEVOS_VAR_TYPE_DYNAMIC_VAR:
|
|
||||||
/* We shouldn't get here... */
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(var->is_bcd)
|
|
||||||
return (((value >> 4) & 0xf) * 10) + (value & 0xf);
|
|
||||||
return value;
|
|
||||||
}
|
|
@ -1,78 +0,0 @@
|
|||||||
/* RetroArch - A frontend for libretro.
|
|
||||||
* Copyright (C) 2015-2018 - Andre Leiradella
|
|
||||||
*
|
|
||||||
* RetroArch is free software: you can redistribute it and/or modify it under the terms
|
|
||||||
* of the GNU General Public License as published by the Free Software Found-
|
|
||||||
* ation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* RetroArch is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
|
|
||||||
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE. See the GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License along with RetroArch.
|
|
||||||
* If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef __RARCH_CHEEVOS_VAR_H
|
|
||||||
#define __RARCH_CHEEVOS_VAR_H
|
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
#include "cheevos.h"
|
|
||||||
|
|
||||||
#include <retro_common_api.h>
|
|
||||||
|
|
||||||
RETRO_BEGIN_DECLS
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_0 = 0,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_1,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_2,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_3,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_4,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_5,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_6,
|
|
||||||
CHEEVOS_VAR_SIZE_BIT_7,
|
|
||||||
CHEEVOS_VAR_SIZE_NIBBLE_LOWER,
|
|
||||||
CHEEVOS_VAR_SIZE_NIBBLE_UPPER,
|
|
||||||
/* Byte, */
|
|
||||||
CHEEVOS_VAR_SIZE_EIGHT_BITS, /* =Byte, */
|
|
||||||
CHEEVOS_VAR_SIZE_SIXTEEN_BITS,
|
|
||||||
CHEEVOS_VAR_SIZE_THIRTYTWO_BITS
|
|
||||||
} cheevos_var_size_t;
|
|
||||||
|
|
||||||
typedef enum
|
|
||||||
{
|
|
||||||
/* compare to the value of a live address in RAM */
|
|
||||||
CHEEVOS_VAR_TYPE_ADDRESS = 0,
|
|
||||||
|
|
||||||
/* a number. assume 32 bit */
|
|
||||||
CHEEVOS_VAR_TYPE_VALUE_COMP,
|
|
||||||
|
|
||||||
/* the value last known at this address. */
|
|
||||||
CHEEVOS_VAR_TYPE_DELTA_MEM,
|
|
||||||
|
|
||||||
/* a custom user-set variable */
|
|
||||||
CHEEVOS_VAR_TYPE_DYNAMIC_VAR
|
|
||||||
} cheevos_var_type_t;
|
|
||||||
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
cheevos_var_size_t size;
|
|
||||||
cheevos_var_type_t type;
|
|
||||||
int bank_id;
|
|
||||||
bool is_bcd;
|
|
||||||
unsigned value;
|
|
||||||
unsigned previous;
|
|
||||||
} cheevos_var_t;
|
|
||||||
|
|
||||||
void cheevos_var_parse(cheevos_var_t* var, const char** memaddr);
|
|
||||||
void cheevos_var_patch_addr(cheevos_var_t* var, cheevos_console_t console);
|
|
||||||
|
|
||||||
uint8_t* cheevos_var_get_memory(const cheevos_var_t* var);
|
|
||||||
unsigned cheevos_var_get_value(cheevos_var_t* var);
|
|
||||||
|
|
||||||
RETRO_END_DECLS
|
|
||||||
|
|
||||||
#endif /* __RARCH_CHEEVOS_VAR_H */
|
|
Loading…
x
Reference in New Issue
Block a user