MGL/MRA: add same_dir attribute for setname.
This commit is contained in:
@@ -72,7 +72,7 @@ static int find_by_crc(uint32_t romcrc)
|
||||
{
|
||||
if (!romcrc) return 0;
|
||||
|
||||
sprintf(cheat_zip, "%s/cheats/%s", getRootDir(), CoreName);
|
||||
sprintf(cheat_zip, "%s/cheats/%s", getRootDir(), CoreName2);
|
||||
DIR *d = opendir(cheat_zip);
|
||||
if (!d)
|
||||
{
|
||||
@@ -147,7 +147,7 @@ bool cheat_init_psx(mz_zip_archive* _z, const char *rom_path)
|
||||
const char *rom_name = strrchr(rom_path, '/');
|
||||
if (rom_name)
|
||||
{
|
||||
sprintf(cheat_zip, "%s/cheats/%s%s", getRootDir(), CoreName, rom_name);
|
||||
sprintf(cheat_zip, "%s/cheats/%s%s", getRootDir(), CoreName2, rom_name);
|
||||
char *p = strrchr(cheat_zip, '.');
|
||||
if (p) *p = 0;
|
||||
strcat(cheat_zip, ".zip");
|
||||
@@ -161,7 +161,7 @@ bool cheat_init_psx(mz_zip_archive* _z, const char *rom_path)
|
||||
const char *game_id = psx_get_game_id();
|
||||
if (game_id && game_id[0])
|
||||
{
|
||||
sprintf(cheat_zip, "%s/cheats/%s/%s.zip", getRootDir(), CoreName, psx_get_game_id());
|
||||
sprintf(cheat_zip, "%s/cheats/%s/%s.zip", getRootDir(), CoreName2, psx_get_game_id());
|
||||
printf("Trying cheat file: %s\n", cheat_zip);
|
||||
memset(_z, 0, sizeof(mz_zip_archive));
|
||||
if (mz_zip_reader_init_file(_z, cheat_zip, 0)) return true;
|
||||
@@ -212,7 +212,7 @@ void cheats_init(const char *rom_path, uint32_t romcrc)
|
||||
const char *rom_name = strrchr(rom_path, '/');
|
||||
if (rom_name)
|
||||
{
|
||||
sprintf(cheat_zip, "%s/cheats/%s%s%s", getRootDir(), CoreName, pcecd_using_cd() ? "CD" : "", rom_name);
|
||||
sprintf(cheat_zip, "%s/cheats/%s%s%s", getRootDir(), CoreName2, pcecd_using_cd() ? "CD" : "", rom_name);
|
||||
char *p = strrchr(cheat_zip, '.');
|
||||
if (p) *p = 0;
|
||||
if (pcecd_using_cd() || is_megacd()) strcat(cheat_zip, " []");
|
||||
|
||||
14
file_io.cpp
14
file_io.cpp
@@ -851,7 +851,7 @@ void FileGenerateScreenshotName(const char *name, char *out_name, int buflen)
|
||||
}
|
||||
else
|
||||
{
|
||||
create_path(SCREENSHOT_DIR, CoreName);
|
||||
create_path(SCREENSHOT_DIR, CoreName2);
|
||||
|
||||
time_t t = time(NULL);
|
||||
struct tm tm = *localtime(&t);
|
||||
@@ -859,13 +859,13 @@ void FileGenerateScreenshotName(const char *name, char *out_name, int buflen)
|
||||
if (tm.tm_year >= 119) // 2019 or up considered valid time
|
||||
{
|
||||
strftime(datecode, 31, "%Y%m%d_%H%M%S", &tm);
|
||||
snprintf(out_name, buflen, "%s/%s/%s-%s.png", SCREENSHOT_DIR, CoreName, datecode, name[0] ? name : SCREENSHOT_DEFAULT);
|
||||
snprintf(out_name, buflen, "%s/%s/%s-%s.png", SCREENSHOT_DIR, CoreName2, datecode, name[0] ? name : SCREENSHOT_DEFAULT);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 1; i < 10000; i++)
|
||||
{
|
||||
snprintf(out_name, buflen, "%s/%s/NODATE-%s_%04d.png", SCREENSHOT_DIR, CoreName, name[0] ? name : SCREENSHOT_DEFAULT, i);
|
||||
snprintf(out_name, buflen, "%s/%s/NODATE-%s_%04d.png", SCREENSHOT_DIR, CoreName2, name[0] ? name : SCREENSHOT_DEFAULT, i);
|
||||
if (!getFileType(out_name)) return;
|
||||
}
|
||||
}
|
||||
@@ -874,9 +874,9 @@ void FileGenerateScreenshotName(const char *name, char *out_name, int buflen)
|
||||
|
||||
void FileGenerateSavePath(const char *name, char* out_name, int ext_replace)
|
||||
{
|
||||
create_path(SAVE_DIR, CoreName);
|
||||
create_path(SAVE_DIR, CoreName2);
|
||||
|
||||
sprintf(out_name, "%s/%s/", SAVE_DIR, CoreName);
|
||||
sprintf(out_name, "%s/%s/", SAVE_DIR, CoreName2);
|
||||
char *fname = out_name + strlen(out_name);
|
||||
|
||||
const char *p = strrchr(name, '/');
|
||||
@@ -904,9 +904,9 @@ void FileGenerateSavePath(const char *name, char* out_name, int ext_replace)
|
||||
|
||||
void FileGenerateSavestatePath(const char *name, char* out_name, int sufx)
|
||||
{
|
||||
create_path(SAVESTATE_DIR, CoreName);
|
||||
create_path(SAVESTATE_DIR, CoreName2);
|
||||
|
||||
sprintf(out_name, "%s/%s/", SAVESTATE_DIR, CoreName);
|
||||
sprintf(out_name, "%s/%s/", SAVESTATE_DIR, CoreName2);
|
||||
char *fname = out_name + strlen(out_name);
|
||||
|
||||
const char *p = strrchr(name, '/');
|
||||
|
||||
6
menu.cpp
6
menu.cpp
@@ -413,7 +413,7 @@ void SelectFile(const char* path, const char* pFileExt, int Options, unsigned ch
|
||||
|
||||
if (Options & SCANO_SAVES)
|
||||
{
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s", SAVE_DIR, CoreName);
|
||||
snprintf(tmp, sizeof(tmp), "%s/%s", SAVE_DIR, CoreName2);
|
||||
home = tmp;
|
||||
}
|
||||
|
||||
@@ -5839,7 +5839,7 @@ void HandleUI(void)
|
||||
OsdWrite(m++, "", 0, 0);
|
||||
strcpy(s, " ROM : ");
|
||||
{
|
||||
char *path = user_io_get_core_path();
|
||||
char *path = HomeDir();
|
||||
int len = strlen(path);
|
||||
char *name = minimig_config.kickstart;
|
||||
if (!strncasecmp(name, path, len)) name += len + 1;
|
||||
@@ -6039,7 +6039,7 @@ void HandleUI(void)
|
||||
if (minimig_config.hardfile[i].filename[0])
|
||||
{
|
||||
strcpy(s, " ");
|
||||
char *path = user_io_get_core_path();
|
||||
char *path = HomeDir();
|
||||
int len = strlen(path);
|
||||
char *name = minimig_config.hardfile[i].filename;
|
||||
if (!strncasecmp(name, path, len)) name += len + 1;
|
||||
|
||||
@@ -995,6 +995,7 @@ static int xml_read_pre_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text
|
||||
(void)(sd);
|
||||
static bool insetname = false;
|
||||
static bool inrotation = false;
|
||||
static int samedir = 0;
|
||||
|
||||
static bool foundsetname = false;
|
||||
static bool foundrotation = false;
|
||||
@@ -1006,6 +1007,7 @@ static int xml_read_pre_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text
|
||||
inrotation = false;
|
||||
foundsetname = false;
|
||||
foundrotation = false;
|
||||
samedir = 0;
|
||||
break;
|
||||
|
||||
case XML_EVENT_START_NODE:
|
||||
@@ -1013,6 +1015,11 @@ static int xml_read_pre_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text
|
||||
{
|
||||
insetname = true;
|
||||
foundsetname = true;
|
||||
|
||||
for (int i = 0; i < node->n_attributes; i++)
|
||||
{
|
||||
if (!strcasecmp(node->attributes[i].name, "same_dir") && !strcmp(node->attributes[i].value, "1")) samedir = 1;
|
||||
}
|
||||
}
|
||||
else if (!strcasecmp(node->tag, "rotation"))
|
||||
{
|
||||
@@ -1022,7 +1029,7 @@ static int xml_read_pre_parse(XMLEvent evt, const XMLNode* node, SXML_CHAR* text
|
||||
break;
|
||||
|
||||
case XML_EVENT_TEXT:
|
||||
if(insetname) user_io_name_override(text);
|
||||
if(insetname) user_io_name_override(text, samedir);
|
||||
if(inrotation)
|
||||
{
|
||||
is_vertical = strncasecmp(text, "vertical", 8) == 0;
|
||||
|
||||
@@ -918,7 +918,7 @@ static bool detect_rom_settings_from_first_chunk(const char region_code, const u
|
||||
case UINT64_C(0x000000aa764e39e1): cic = CIC::CIC_NUS_8401; break;
|
||||
case UINT64_C(0x000000abb0b739e1): cic = CIC::CIC_NUS_DDUS; break;
|
||||
case UINT64_C(0x00000081ce470326): // CIC-5101 IPL3
|
||||
case UINT64_C(0x000000827a47195a): // Kuru Kuru Fever
|
||||
case UINT64_C(0x000000827a47195a): // Kuru Kuru Fever
|
||||
case UINT64_C(0x00000082551e4848): // Tower & Shaft
|
||||
cic = CIC::CIC_NUS_5101; break;
|
||||
}
|
||||
@@ -963,8 +963,8 @@ static void calc_bootcode_checksums(uint64_t bootcode_sums[2], const uint8_t* bu
|
||||
}
|
||||
|
||||
static void create_save_path(char* save_path, const MemoryType type) {
|
||||
create_path(SAVE_DIR, CoreName);
|
||||
sprintf(save_path, SAVE_DIR"/%s/", CoreName);
|
||||
create_path(SAVE_DIR, CoreName2);
|
||||
sprintf(save_path, SAVE_DIR"/%s/", CoreName2);
|
||||
char* fname = save_path + strlen(save_path);
|
||||
|
||||
char* p = strrchr(current_rom_path, '/');
|
||||
@@ -1056,8 +1056,8 @@ static void mount_save_gb(const char* old_path) {
|
||||
}
|
||||
else {
|
||||
const uint32_t core_name_len = p - (current_rom_path_gb + games_path_len);
|
||||
if (!strncmp(current_rom_path_gb + games_path_len, CoreName, core_name_len)) {
|
||||
printf("Game Boy game loaded from \"/" GAMES_DIR"/%s/\". Will use \"/" SAVE_DIR"/%s/\".\n", CoreName, core_name);
|
||||
if (!strncmp(current_rom_path_gb + games_path_len, CoreName2, core_name_len)) {
|
||||
printf("Game Boy game loaded from \"/" GAMES_DIR"/%s/\". Will use \"/" SAVE_DIR"/%s/\".\n", CoreName2, core_name);
|
||||
}
|
||||
else {
|
||||
memcpy(core_name, current_rom_path_gb + games_path_len, core_name_len);
|
||||
@@ -1118,8 +1118,8 @@ static void mount_save_gb(const char* old_path) {
|
||||
static void get_old_save_path(char* save_path) {
|
||||
static const char* ext = ".sav";
|
||||
|
||||
create_path(SAVE_DIR, CoreName);
|
||||
sprintf(save_path, SAVE_DIR"/%s/", CoreName);
|
||||
create_path(SAVE_DIR, CoreName2);
|
||||
sprintf(save_path, SAVE_DIR"/%s/", CoreName2);
|
||||
char* fname = save_path + strlen(save_path);
|
||||
|
||||
char* p = strrchr(current_rom_path, '/');
|
||||
@@ -1315,14 +1315,14 @@ static int cheat_execute(cheat_code* code) {
|
||||
|
||||
// Boot code, run only once. Skip if already executed.
|
||||
if (code->flags.is_boot_code) {
|
||||
if (code->flags.is_boot_code_executed)
|
||||
if (code->flags.is_boot_code_executed)
|
||||
return 1;
|
||||
|
||||
code->flags.is_boot_code_executed = true;
|
||||
}
|
||||
|
||||
// Game Shark button code. Only run if certain button is pressed. Hard-coded to F5 right now.
|
||||
if (code->flags.is_gs_button_code && !is_key_pressed(63))
|
||||
if (code->flags.is_gs_button_code && !is_key_pressed(63))
|
||||
return 1;
|
||||
|
||||
volatile uint8_t* mem = ((volatile uint8_t*)rdram_ptr) + code->address;
|
||||
|
||||
@@ -2378,7 +2378,7 @@ void sharpmz_ui(int idleState, int idle2State, int system
|
||||
subItem = 0;
|
||||
*menumask = 0;
|
||||
|
||||
OsdSetTitle(CoreName, 0);
|
||||
OsdSetTitle(CoreName2, 0);
|
||||
|
||||
OsdWrite(menuItem++, " Main Menu", 0, 0);
|
||||
OsdWrite(menuItem++, "", 0, 0);
|
||||
|
||||
16
user_io.cpp
16
user_io.cpp
@@ -140,19 +140,19 @@ char* user_io_create_config_name(int with_ver)
|
||||
static char core_name[32] = {};
|
||||
static char ovr_name[32] = {};
|
||||
static char orig_name[32] = {};
|
||||
|
||||
static char filepath_store[1024];
|
||||
static int ovr_samedir = 0;
|
||||
|
||||
char *user_io_make_filepath(const char *path, const char *filename)
|
||||
{
|
||||
static char filepath_store[1024];
|
||||
snprintf(filepath_store, 1024, "%s/%s", path, filename);
|
||||
|
||||
return filepath_store;
|
||||
}
|
||||
|
||||
void user_io_name_override(const char* name)
|
||||
void user_io_name_override(const char* name, int samedir)
|
||||
{
|
||||
snprintf(ovr_name, sizeof(ovr_name), "%s", name);
|
||||
ovr_samedir = samedir;
|
||||
}
|
||||
|
||||
void user_io_set_core_name(const char *name)
|
||||
@@ -166,12 +166,18 @@ char *user_io_get_core_name(int orig)
|
||||
return orig ? orig_name : core_name;
|
||||
}
|
||||
|
||||
char *user_io_get_core_name2()
|
||||
{
|
||||
return (ovr_name[0] && ovr_samedir) ? orig_name : core_name;
|
||||
}
|
||||
|
||||
char *user_io_get_core_path(const char *suffix, int recheck)
|
||||
{
|
||||
static char old_name[256] = {};
|
||||
static char tmp[1024] = {};
|
||||
char *name = (ovr_name[0] && ovr_samedir) ? orig_name : core_name;
|
||||
|
||||
if (!suffix) suffix = (!strcasecmp(core_name, "minimig")) ? "Amiga" : core_name;
|
||||
if (!suffix) suffix = (!strcasecmp(name, "minimig")) ? "Amiga" : name;
|
||||
if (recheck || strcmp(old_name, suffix) || !tmp[0])
|
||||
{
|
||||
strcpy(old_name, suffix);
|
||||
|
||||
@@ -188,8 +188,9 @@ int user_io_file_mount(const char *name, unsigned char index = 0, char pre = 0,
|
||||
void user_io_bufferinvalidate(unsigned char index);
|
||||
char *user_io_make_filepath(const char *path, const char *filename);
|
||||
char *user_io_get_core_name(int orig = 0);
|
||||
char *user_io_get_core_name2();
|
||||
char *user_io_get_core_path(const char *suffix = NULL, int recheck = 0);
|
||||
void user_io_name_override(const char* name);
|
||||
void user_io_name_override(const char* name, int samedir);
|
||||
char has_menu();
|
||||
|
||||
const char *get_image_name(int i);
|
||||
@@ -286,5 +287,6 @@ char is_uneon();
|
||||
|
||||
#define HomeDir(x) user_io_get_core_path(x)
|
||||
#define CoreName user_io_get_core_name()
|
||||
#define CoreName2 user_io_get_core_name2()
|
||||
|
||||
#endif // USER_IO_H
|
||||
|
||||
Reference in New Issue
Block a user