From 24e8ca6856dfdcb9bc8bd0af1e843e7c1d5b3490 Mon Sep 17 00:00:00 2001 From: Themaister Date: Thu, 18 Aug 2011 00:24:57 +0200 Subject: [PATCH] Some more needed stuff ... --- docs/ssnes.1 | 5 +++++ file.c | 12 +++++++++--- general.h | 5 ++++- ssnes.c | 7 +++++++ 4 files changed, 25 insertions(+), 4 deletions(-) diff --git a/docs/ssnes.1 b/docs/ssnes.1 index 3ec6a5a980..1e00eb7c58 100644 --- a/docs/ssnes.1 +++ b/docs/ssnes.1 @@ -138,6 +138,11 @@ Network port used for netplay. This defaults to 55435. This option affects both Attempts to apply an UPS patch to the current ROM image. No files are altered. If this flag is not specified, SSNES will look for a .ups file with same basename as ROM specified. +.TP +\fB--bps PATCH\fR +Attempts to apply a BPS patch to the current ROM image. No files are altered. +If this flag is not specified, SSNES will look for a .bps file with same basename as ROM specified. + .TP \fB--xml MAP, -X MAP\fR Specifies path to XML memory map for the given ROM. diff --git a/file.c b/file.c index ce80943d57..e1ee107990 100644 --- a/file.c +++ b/file.c @@ -133,14 +133,20 @@ static void patch_rom(uint8_t **buf, ssize_t *size) void *patch_data = NULL; enum patch_type type = PATCH_NONE; - if (*g_extern.ups_name && (patch_size = read_file(g_extern.ups_name, &patch_data)) >= 0) + if (g_extern.ups_pref && g_extern.bps_pref) + { + SSNES_WARN("Both UPS and BPS patch explicitly defined, ignoring both ...\n"); + return; + } + + if (!g_extern.bps_pref && *g_extern.ups_name && (patch_size = read_file(g_extern.ups_name, &patch_data)) >= 0) type = PATCH_UPS; - else if (*g_extern.bps_name && (patch_size = read_file(g_extern.bps_name, &patch_data)) >= 0) + else if (!g_extern.ups_pref && *g_extern.bps_name && (patch_size = read_file(g_extern.bps_name, &patch_data)) >= 0) type = PATCH_BPS; if (type == PATCH_NONE) { - SSNES_LOG("Could not find any ROM patch.\n"); + SSNES_LOG("Did not find a valid ROM patch.\n"); return; } diff --git a/general.h b/general.h index 91277548de..e2406cd9e7 100644 --- a/general.h +++ b/general.h @@ -181,9 +181,12 @@ struct global char savefile_name_asrm[512]; char savefile_name_bsrm[512]; char savestate_name[256]; + char xml_name[512]; + + bool ups_pref; + bool bps_pref; char ups_name[512]; char bps_name[512]; - char xml_name[512]; unsigned state_slot; diff --git a/ssnes.c b/ssnes.c index 0b9586d3bc..054170e617 100644 --- a/ssnes.c +++ b/ssnes.c @@ -429,6 +429,7 @@ static void print_help(void) #endif puts("\t-v/--verbose: Verbose logging."); puts("\t-U/--ups: Specifies path for UPS patch that will be applied to ROM."); + puts("\t--bps: Specifies path for BPS patch that will be applied to ROM."); puts("\t-X/--xml: Specifies path to XML memory map."); puts("\t-D/--detach: Detach SSNES from the running console. Not relevant for all platforms.\n"); @@ -484,6 +485,7 @@ static void parse_input(int argc, char *argv[]) { "frames", 1, NULL, 'F' }, { "port", 1, &val, 'p' }, { "ups", 1, NULL, 'U' }, + { "bps", 1, &val, 'B' }, { "xml", 1, NULL, 'X' }, { "detach", 0, NULL, 'D' }, { NULL, 0, NULL, 0 } @@ -635,6 +637,7 @@ static void parse_input(int argc, char *argv[]) case 'U': strlcpy(g_extern.ups_name, optarg, sizeof(g_extern.ups_name)); + g_extern.ups_pref = true; break; case 'X': @@ -653,6 +656,10 @@ static void parse_input(int argc, char *argv[]) case 'p': g_extern.netplay_port = strtol(optarg, NULL, 0); break; + case 'B': + strlcpy(g_extern.bps_name, optarg, sizeof(g_extern.bps_name)); + g_extern.bps_pref = true; + break; default: break; }