From caca70296a2e24eb0021ca201a3a44093642670f Mon Sep 17 00:00:00 2001 From: zakk4223 Date: Sun, 8 Mar 2020 11:54:14 -0400 Subject: [PATCH] Add support for booting mra files via bootcore ini setting. Includes lastcore/lastexactcore functionality Co-authored-by: Zakk --- bootcore.cpp | 13 +++++++------ bootcore.h | 2 +- file_io.cpp | 7 +++++++ file_io.h | 2 ++ menu.cpp | 7 +++---- user_io.cpp | 2 +- 6 files changed, 21 insertions(+), 12 deletions(-) diff --git a/bootcore.cpp b/bootcore.cpp index 49bc447..39d54fa 100644 --- a/bootcore.cpp +++ b/bootcore.cpp @@ -10,13 +10,15 @@ #include #include + +extern int arcade_load(const char *xml); int16_t btimeout; char bootcoretype[64]; bool isExactcoreName(char *path) { char *spl = strrchr(path, '.'); - return (spl && !strcmp(spl, ".rbf")); + return (spl && (!strcmp(spl, ".rbf") || !strcmp(spl, ".mra"))); } char *getcoreName(char *path) @@ -103,8 +105,7 @@ char* loadLastcore() long size = ftell(fd); fseek(fd, 0L, SEEK_SET); - char *lastcore = new char[size + 1]; - + char *lastcore = new char[size + 1](); int ret = fread(lastcore, sizeof(char), size, fd); fclose(fd); if (ret == size) @@ -147,7 +148,7 @@ char *findCore(const char *name, char *coreName, int indent) snprintf(path, 256, "%s/%s", name, entry->d_name); if (strstr(path, coreName) != NULL) { spl = strrchr(path, '.'); - if (spl && !strcmp(spl, ".rbf")) + if (spl && (!strcmp(spl, ".rbf") || !strcmp(spl, ".mra"))) { closedir(dir); return path; @@ -205,7 +206,7 @@ void bootcore_init(const char *path) { if (!cfg.bootcore_timeout) { - fpga_load_rbf(bootcore); + isMraName(bootcore) ? arcade_load(bootcore) : fpga_load_rbf(bootcore); } strcpy(cfg.bootcore, strcmp(bootcore, "menu.rbf") ? bootcore : ""); @@ -218,7 +219,7 @@ void bootcore_init(const char *path) { strcpy(auxstr, path); - auxpointer = !strcmp(cfg.bootcore, "lastexactcore") ? getcoreExactName(auxstr) : getcoreName(auxstr); + auxpointer = (!strcmp(cfg.bootcore, "lastexactcore") || isMraName(auxstr)) ? getcoreExactName(auxstr) : getcoreName(auxstr); if (auxpointer != NULL) { diff --git a/bootcore.h b/bootcore.h index e86c891..ff1c917 100644 --- a/bootcore.h +++ b/bootcore.h @@ -15,4 +15,4 @@ void bootcore_init(const char *path); extern char bootcoretype[64]; extern int16_t btimeout; -#endif // __BOOTCORE_H__ \ No newline at end of file +#endif // __BOOTCORE_H__ diff --git a/file_io.cpp b/file_io.cpp index 03299d3..6a4287f 100644 --- a/file_io.cpp +++ b/file_io.cpp @@ -1583,3 +1583,10 @@ direntext_t* flist_SelectedItem() { return &DirItem[iSelectedEntry]; } + +bool isMraName(char *path) +{ + char *spl = strrchr(path, '.'); + return (spl && !strcmp(spl, ".mra")); +} + diff --git a/file_io.h b/file_io.h index 997ad78..e812a63 100644 --- a/file_io.h +++ b/file_io.h @@ -110,6 +110,8 @@ const char *getRootDir(); const char *getFullPath(const char *name); uint32_t getFileType(const char *name); +bool isMraName(char *path); + #define COEFF_DIR "filters" #define GAMMA_DIR "gamma" diff --git a/menu.cpp b/menu.cpp index 34aa44f..2a6f15b 100644 --- a/menu.cpp +++ b/menu.cpp @@ -52,13 +52,12 @@ along with this program. If not, see . #include "cfg.h" #include "input.h" #include "battery.h" -#include "bootcore.h" #include "cheats.h" #include "video.h" #include "joymapping.h" #include "recent.h" - #include "support.h" +#include "bootcore.h" /*menu states*/ enum MENU @@ -777,7 +776,7 @@ const char* get_rbf_name_bootcore(char *str) if (!p) return str; char *spl = strrchr(p + 1, '.'); - if (spl && !strcmp(spl, ".rbf")) + if (spl && (!strcmp(spl, ".rbf") || !strcmp(spl, ".mra"))) { *spl = 0; } @@ -4909,7 +4908,7 @@ void HandleUI(void) PrintFileName(str, 14, 0); sprintf(str, " Loading..."); OsdWrite(15, str, 1, 0); - fpga_load_rbf(cfg.bootcore); + isMraName(cfg.bootcore) ? arcade_load(getFullPath(cfg.bootcore)) : fpga_load_rbf(cfg.bootcore); } } } diff --git a/user_io.cpp b/user_io.cpp index 7590bf2..ccc7ae4 100644 --- a/user_io.cpp +++ b/user_io.cpp @@ -718,7 +718,7 @@ void user_io_init(const char *path, const char *xml) MiSTer_ini_parse(); if (cfg.bootcore[0] != '\0') { - bootcore_init(path); + bootcore_init(xml ? xml : path); } video_mode_load();