Skip to content

Commit

Permalink
Add support for booting mra files via bootcore ini setting. Includes …
Browse files Browse the repository at this point in the history
…lastcore/lastexactcore functionality

Co-authored-by: Zakk <[email protected]>
  • Loading branch information
zakk4223 and zakk4223 authored Mar 8, 2020
1 parent 1ba9732 commit caca702
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 12 deletions.
13 changes: 7 additions & 6 deletions bootcore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@
#include <stdlib.h>
#include <dirent.h>


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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 : "");
Expand All @@ -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)
{
Expand Down
2 changes: 1 addition & 1 deletion bootcore.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ void bootcore_init(const char *path);
extern char bootcoretype[64];
extern int16_t btimeout;

#endif // __BOOTCORE_H__
#endif // __BOOTCORE_H__
7 changes: 7 additions & 0 deletions file_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1583,3 +1583,10 @@ direntext_t* flist_SelectedItem()
{
return &DirItem[iSelectedEntry];
}

bool isMraName(char *path)
{
char *spl = strrchr(path, '.');
return (spl && !strcmp(spl, ".mra"));
}

2 changes: 2 additions & 0 deletions file_io.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 3 additions & 4 deletions menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#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
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion user_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit caca702

Please sign in to comment.