aboutsummaryrefslogtreecommitdiff
path: root/menu.c
diff options
context:
space:
mode:
authorneonloop2021-09-06 23:44:53 +0000
committerneonloop2021-09-06 23:44:53 +0000
commit7032dd1ce78e03f1f50475be76ef8b5c642c9d01 (patch)
treea232c4674a942da0bcfceaaddb5e60356a0ab183 /menu.c
parent05c5d66301f14bd8ae50490ebdc7e32e371f851b (diff)
downloadpicoarch-7032dd1ce78e03f1f50475be76ef8b5c642c9d01.tar.gz
picoarch-7032dd1ce78e03f1f50475be76ef8b5c642c9d01.tar.bz2
picoarch-7032dd1ce78e03f1f50475be76ef8b5c642c9d01.zip
Adds ips/bps softpatching
Patches named like the content will be auto-applied in memory when the game is loaded. Example: /roms/game.gba will apply patches named /roms/game.ips, /roms/game.ips1, /roms/game.IPS2, /roms/game.bps, etc. This only happens in memory, original files are unmodified. Patches are loaded in case-insensitive alphabetical order. Note that .ips12 loads before .ips2, but after .ips02. Only supports cores that load from memory (see libretro page at https://docs.libretro.com/guides/softpatching/ for compatibility list)
Diffstat (limited to 'menu.c')
-rw-r--r--menu.c32
1 files changed, 18 insertions, 14 deletions
diff --git a/menu.c b/menu.c
index 2674007..1dac041 100644
--- a/menu.c
+++ b/menu.c
@@ -245,21 +245,22 @@ int hidden_file_filter(struct dirent **namelist, int count, const char *basedir)
const char *select_content(void) {
const char *fname = NULL;
+ char content_path[MAX_PATH];
const char **extensions = core_extensions();
const char **exts_with_zip = NULL;
int i = 0, size = 0;
- if (content_path[0] == '\0') {
- if (getenv("CONTENT_DIR")) {
- strncpy(content_path, getenv("CONTENT_DIR"), sizeof(content_path) - 1);
+ if (content && content->path) {
+ strncpy(content_path, content->path, sizeof(content_path) - 1);
+ } else if (getenv("CONTENT_DIR")) {
+ strncpy(content_path, getenv("CONTENT_DIR"), sizeof(content_path) - 1);
#ifdef CONTENT_DIR
- } else {
- strncpy(content_path, CONTENT_DIR, sizeof(content_path) - 1);
+ } else {
+ strncpy(content_path, CONTENT_DIR, sizeof(content_path) - 1);
#else
- } else if (getenv("HOME")) {
- strncpy(content_path, getenv("HOME"), sizeof(content_path) - 1);
+ } else if (getenv("HOME")) {
+ strncpy(content_path, getenv("HOME"), sizeof(content_path) - 1);
#endif
- }
}
if (extensions) {
@@ -286,7 +287,7 @@ const char *select_content(void) {
return fname;
}
-int menu_select_content(void) {
+int menu_select_content(char *filename, size_t len) {
const char *fname = NULL;
int ret = -1;
@@ -295,9 +296,7 @@ int menu_select_content(void) {
if (!fname)
goto finish;
- strncpy(content_path, fname, sizeof(content_path) - 1);
- set_defaults();
- load_config();
+ strncpy(filename, fname, len - 1);
if (g_autostateld_opt)
resume_slot = 0;
ret = 0;
@@ -318,11 +317,16 @@ static int menu_loop_select_content(int id, int keys) {
return -1;
core_unload_content();
- strncpy(content_path, fname, sizeof(content_path) - 1);
+
+ content = content_init(fname);
+ if (!content) {
+ PA_ERROR("Couldn't allocate memory for content\n");
+ quit(-1);
+ }
set_defaults();
- if (core_load_content(fname)) {
+ if (core_load_content(content)) {
quit(-1);
}