Added more parameters, including to clear CMOS, and removed -O / --debugcfg that was not used at all.

This commit is contained in:
OBattler
2023-10-12 02:07:43 +02:00
parent b44d9d71c5
commit 78ec4927d4
2 changed files with 106 additions and 45 deletions

View File

@@ -123,7 +123,6 @@ int tracing_on = 0;
/* Commandline options. */
int dump_on_exit = 0; /* (O) dump regs on exit */
int do_dump_config = 0; /* (O) dump config on load */
int start_in_fullscreen = 0; /* (O) start in fullscreen */
#ifdef _WIN32
int force_debug = 0; /* (O) force debug output */
@@ -141,10 +140,14 @@ char rom_path[1024] = { '\0' }; /* (O) full path to ROMs */
rom_path_t rom_paths = { "", NULL }; /* (O) full paths to ROMs */
char log_path[1024] = { '\0' }; /* (O) full path of logfile */
char vm_name[1024] = { '\0' }; /* (O) display name of the VM */
int do_nothing = 0;
int dump_missing = 0;
#ifdef USE_INSTRUMENT
uint8_t instru_enabled = 0;
uint64_t instru_run_ms = 0;
uint8_t instru_enabled = 0;
uint64_t instru_run_ms = 0;
#endif
int clear_cmos = 0;
int clear_flash = 0;
/* Configuration values. */
int window_remember;
@@ -398,6 +401,31 @@ pc_log(const char *fmt, ...)
# define pc_log(fmt, ...)
#endif
static void
delete_nvr_file(uint8_t flash)
{
char *fn = NULL;
int c;
/* Set up the NVR file's name. */
c = strlen(machine_get_internal_name()) + 5;
fn = (char *) malloc(c + 1);
if (fn == NULL)
fatal("Error allocating memory for the removal of the %s file\n",
flash ? "BIOS flash" : "CMOS");
if (flash)
sprintf(fn, "%s.bin", machine_get_internal_name());
else
sprintf(fn, "%s.nvr", machine_get_internal_name());
remove(nvr_path(fn));
free(fn);
fn = NULL;
}
/*
* Perform initial startup of the PC.
*
@@ -479,34 +507,39 @@ usage:
printf("\nUsage: 86box [options] [cfg-file]\n\n");
printf("Valid options are:\n\n");
printf("-? or --help - show this information\n");
printf("-C or --config path - set 'path' to be config file\n");
printf("-? or --help - show this information\n");
printf("-B or --clearflash - clears the BIOS flash file\n");
printf("-C or --config path - set 'path' to be config file\n");
#ifdef _WIN32
printf("-D or --debug - force debug output logging\n");
printf("-D or --debug - force debug output logging\n");
#endif
#if 0
printf("-E or --nographic - forces the old behavior\n");
printf("-E or --nographic - forces the old behavior\n");
#endif
printf("-F or --fullscreen - start in fullscreen mode\n");
printf("-G or --lang langid - start with specified language (e.g. en-US, or system)\n");
printf("-F or --fullscreen - start in fullscreen mode\n");
printf("-G or --lang langid - start with specified language (e.g. en-US, or system)\n");
#ifdef _WIN32
printf("-H or --hwnd id,hwnd - sends back the main dialog's hwnd\n");
printf("-H or --hwnd id,hwnd - sends back the main dialog's hwnd\n");
#endif
printf("-I or --image d:path - load 'path' as floppy image on drive d\n");
printf("-L or --logfile path - set 'path' to be the logfile\n");
printf("-N or --noconfirm - do not ask for confirmation on quit\n");
printf("-O or --dumpcfg - dump config file after loading\n");
printf("-P or --vmpath path - set 'path' to be root for vm\n");
printf("-R or --rompath path - set 'path' to be ROM path\n");
printf("-S or --settings - show only the settings dialog\n");
printf("-V or --vmname name - overrides the name of the running VM\n");
printf("-Z or --lastvmpath - the last parameter is VM path rather than config\n");
printf("-I or --image d:path - load 'path' as floppy image on drive d\n");
#ifdef USE_INSTRUMENT
printf("-J or --instrument name - set 'name' to be the profiling instrument\n");
#endif
printf("-L or --logfile path - set 'path' to be the logfile\n");
printf("-M or --dumpmissing - dump missing machines and video cards\n");
printf("-N or --noconfirm - do not ask for confirmation on quit\n");
printf("-P or --vmpath path - set 'path' to be root for vm\n");
printf("-Q or --clearnvr - clears the CMOS file\n");
printf("-R or --rompath path - set 'path' to be ROM path\n");
printf("-S or --settings - show only the settings dialog\n");
printf("-V or --vmname name - overrides the name of the running VM\n");
printf("-X or --clearboth - clears the CMOS and BIOS flash files\n");
printf("-Y or --donothing - do not show any UI or run the emulation\n");
printf("-Z or --lastvmpath - the last parameter is VM path rather than config\n");
printf("\nA config file can be specified. If none is, the default file will be used.\n");
return 0;
} else if (!strcasecmp(argv[c], "--lastvmpath") || !strcasecmp(argv[c], "-Z")) {
lvmp = 1;
} else if (!strcasecmp(argv[c], "--dumpcfg") || !strcasecmp(argv[c], "-O")) {
do_dump_config = 1;
#ifdef _WIN32
} else if (!strcasecmp(argv[c], "--debug") || !strcasecmp(argv[c], "-D")) {
force_debug = 1;
@@ -569,6 +602,17 @@ usage:
settings_only = 1;
} else if (!strcasecmp(argv[c], "--noconfirm") || !strcasecmp(argv[c], "-N")) {
confirm_exit_cmdl = 0;
} else if (!strcasecmp(argv[c], "--dumpmissing") || !strcasecmp(argv[c], "-M")) {
dump_missing = 1;
} else if (!strcasecmp(argv[c], "--donothing") || !strcasecmp(argv[c], "-Y")) {
do_nothing = 1;
} else if (!strcasecmp(argv[c], "--clearflash") || !strcasecmp(argv[c], "-B")) {
clear_flash = 1;
} else if (!strcasecmp(argv[c], "--clearnvr") || !strcasecmp(argv[c], "-Q")) {
clear_cmos = 1;
} else if (!strcasecmp(argv[c], "--clearboth") || !strcasecmp(argv[c], "-X")) {
clear_cmos = 1;
clear_flash = 1;
#ifdef _WIN32
} else if (!strcasecmp(argv[c], "--hwnd") || !strcasecmp(argv[c], "-H")) {
@@ -578,9 +622,8 @@ usage:
uid = (uint32_t *) &unique_id;
shwnd = (uint32_t *) &source_hwnd;
sscanf(argv[++c], "%08X%08X,%08X%08X", uid + 1, uid, shwnd + 1, shwnd);
} else if (!strcasecmp(argv[c], "--lang") || !strcasecmp(argv[c], "-G")) {
#endif
} else if (!strcasecmp(argv[c], "--lang") || !strcasecmp(argv[c], "-G")) {
// This function is currently unimplemented for *nix but has placeholders.
lang_init = plat_language_code(argv[++c]);
@@ -590,13 +633,13 @@ usage:
// The return value of 0 only means that the code is invalid,
// not related to that translation is exists or not for the
// selected language.
} else if (!strcasecmp(argv[c], "--test")) {
} else if (!strcasecmp(argv[c], "--test") || !strcasecmp(argv[c], "-T")) {
/* some (undocumented) test function here.. */
/* .. and then exit. */
return 0;
#ifdef USE_INSTRUMENT
} else if (!strcasecmp(argv[c], "--instrument")) {
} else if (!strcasecmp(argv[c], "--instrument") || !strcasecmp(argv[c], "-J")) {
if ((c + 1) == argc)
goto usage;
instru_enabled = 1;
@@ -779,6 +822,18 @@ usage:
/* Load the configuration file. */
config_load();
/* Clear the CMOS and/or BIOS flash file, if we were started with
the relevant parameter(s). */
if (clear_cmos) {
delete_nvr_file(0);
clear_cmos = 0;
}
if (clear_flash) {
delete_nvr_file(1);
clear_flash = 0;
}
for (uint8_t i = 0; i < FDD_NUM; i++) {
if (fn[i] != NULL) {
if (strlen(fn[i]) <= 511)
@@ -826,27 +881,29 @@ pc_init_modules(void)
wchar_t temp[512];
char tempc[512];
#ifdef PRINT_MISSING_MACHINES_AND_VIDEO_CARDS
c = m = 0;
while (machine_get_internal_name_ex(c) != NULL) {
m = machine_available(c);
if (!m)
pclog("Missing machine: %s\n", machine_getname_ex(c));
c++;
}
if (dump_missing) {
dump_missing = 0;
c = m = 0;
while (video_get_internal_name(c) != NULL) {
memset(tempc, 0, sizeof(tempc));
device_get_name(video_card_getdevice(c), 0, tempc);
if ((c > 1) && !(tempc[0]))
break;
m = video_card_available(c);
if (!m)
pclog("Missing video card: %s\n", tempc);
c++;
c = m = 0;
while (machine_get_internal_name_ex(c) != NULL) {
m = machine_available(c);
if (!m)
pclog("Missing machine: %s\n", machine_getname_ex(c));
c++;
}
c = m = 0;
while (video_get_internal_name(c) != NULL) {
memset(tempc, 0, sizeof(tempc));
device_get_name(video_card_getdevice(c), 0, tempc);
if ((c > 1) && !(tempc[0]))
break;
m = video_card_available(c);
if (!m)
pclog("Missing video card: %s\n", tempc);
c++;
}
}
#endif
pc_log("Scanning for ROM images:\n");
c = m = 0;
@@ -945,6 +1002,11 @@ pc_init_modules(void)
machine_status_init();
if (do_nothing) {
do_nothing = 0;
exit(-1);
}
return 1;
}

View File

@@ -78,7 +78,6 @@ extern "C" {
extern uint32_t lang_sys; /* (-) system language code */
extern int dump_on_exit; /* (O) dump regs on exit*/
extern int do_dump_config; /* (O) dump cfg after load */
extern int start_in_fullscreen; /* (O) start in fullscreen */
#ifdef _WIN32
extern int force_debug; /* (O) force debug output */