Skip to content

Commit d58f0ad

Browse files
committed
add ability to load cmd file
1 parent 6ff43cb commit d58f0ad

2 files changed

Lines changed: 38 additions & 2 deletions

File tree

src/osd/retro/libretro.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ void retro_get_system_info(struct retro_system_info *info)
416416
#define GIT_VERSION ""
417417
#endif
418418
info->library_version = "0.159" GIT_VERSION;
419-
info->valid_extensions = "zip|chd|7z";
419+
info->valid_extensions = "chd|cmd|zip|7z";
420420
info->need_fullpath = true;
421421
info->block_extract = true;
422422
}

src/osd/retro/retromain.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2045,6 +2045,26 @@ static int execute_game_cmd(char* path)
20452045

20462046
return 0;
20472047
}
2048+
2049+
static char CMDFILE[512];
2050+
2051+
int loadcmdfile(char *argv)
2052+
{
2053+
int res=0;
2054+
2055+
FILE *fp = fopen(argv,"r");
2056+
2057+
if( fp != NULL )
2058+
{
2059+
if ( fgets (CMDFILE , 512 , fp) != NULL )
2060+
res=1;
2061+
fclose (fp);
2062+
}
2063+
2064+
return res;
2065+
}
2066+
2067+
20482068
/*
20492069
#ifdef __cplusplus
20502070
extern "C"
@@ -2054,7 +2074,7 @@ retro_osd_interface *retro_global_osd;
20542074

20552075
int mmain(int argc, const char *argv)
20562076
{
2057-
unsigned i;
2077+
unsigned i=0;
20582078
//osd_options options;
20592079
//cli_options MRoptions;
20602080
int result = 0;
@@ -2063,6 +2083,22 @@ int mmain(int argc, const char *argv)
20632083

20642084
strcpy(gameName,argv);
20652085

2086+
// handle cmd file
2087+
if (strlen(gameName) >= strlen("cmd")){
2088+
if(!core_stricmp(&gameName[strlen(gameName)-strlen("cmd")], "cmd"))
2089+
i=loadcmdfile(gameName);
2090+
}
2091+
2092+
if(i==1)
2093+
{
2094+
parse_cmdline(CMDFILE);
2095+
if (log_cb)
2096+
log_cb(RETRO_LOG_INFO, "Starting game from command line:%s\n",CMDFILE);
2097+
2098+
result = execute_game_cmd(ARGUV[ARGUC-1]);
2099+
2100+
}
2101+
else
20662102
if(experimental_cmdline)
20672103
{
20682104
parse_cmdline(argv);

0 commit comments

Comments
 (0)