Skip to content

Commit

Permalink
Use RETRO_ENVIRONMENT_GET_FILE_BROWSER_START_DIRECTORY to set StartDi…
Browse files Browse the repository at this point in the history
…r when available
  • Loading branch information
negativeExponent committed Sep 14, 2024
1 parent ae61727 commit 86b9a1d
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion libretro.c
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,10 @@ static char RPATH[512];
static char RETRO_DIR[512];
static const char *retro_save_directory;
static const char *retro_system_directory;
static const char *retro_browse_directory;
const char *retro_content_directory;
char retro_system_conf[512];
char retro_system_conf[512]; /* system directory path */
char retro_browse_conf[512]; /* file browser default path */
char base_dir[MAX_PATH];

static uint8_t Core_Key_State[512];
Expand Down Expand Up @@ -958,6 +960,7 @@ void WinX68k_Reset(void)
DSound_Play();
}

extern char filepath[MAX_PATH];
static int pmain(int argc, char *argv[])
{
strcpy(winx68k_dir, retro_system_conf);
Expand All @@ -967,6 +970,10 @@ static int pmain(int argc, char *argv[])

LoadConfig();

/* if available, use retro_browse_conf to set StartDir config */
if (retro_browse_conf[0] != 0)
strcpy(filepath, retro_browse_conf);

if (!WinDraw_MenuInit())
{
WinX68k_Cleanup();
Expand Down Expand Up @@ -1775,6 +1782,10 @@ void retro_init(void)
const char *system_dir = NULL;
const char *content_dir = NULL;
const char *save_dir = NULL;
const char *browse_dir = NULL;

retro_system_conf[0] = 0;
retro_browse_conf[0] = 0;

if (environ_cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &log))
log_cb = log.log;
Expand All @@ -1795,6 +1806,10 @@ void retro_init(void)
else
/* make retro_save_directory the same in case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY is not implemented by the frontend */
retro_save_directory = retro_system_directory;

/* If browse directory is defined use it for StartDir config */
if (environ_cb(RETRO_ENVIRONMENT_GET_FILE_BROWSER_START_DIRECTORY, &browse_dir) && browse_dir)
retro_browse_directory = browse_dir;

if (!retro_system_directory)
strcpy(RETRO_DIR, ".");
Expand All @@ -1803,6 +1818,9 @@ void retro_init(void)

sprintf(retro_system_conf, "%s%ckeropi", RETRO_DIR, SLASH);

if (retro_browse_directory)
strcpy(retro_browse_conf, retro_browse_directory);

if (!environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt))
exit(0);

Expand Down

0 comments on commit 86b9a1d

Please sign in to comment.