1
0
Fork 0
forked from Miroirs/x49gp

add more short options

This commit is contained in:
Gwenhael Le Moine 2024-11-22 19:51:05 +01:00
parent a3b530ec17
commit 150615937f
No known key found for this signature in database
GPG key ID: FDFE3669426707A7
2 changed files with 75 additions and 53 deletions

View file

@ -43,31 +43,48 @@ The third and final group contains two items: *Reset*, which resets the calculat
During the first launch, *x50ng* generates a new configuration with default values and empty memory. *x50ng* does not ship with a default firmware, only with the bootloaders for the supported calculators. Hence, the user is required to select a firmware to load into the flash. *x50ng* will show a file selection window for that task. For the stock firmware HP has always used the file extension “.bin”, any other files (including the update.scp files that typically come with them!) are generally not actual firmware files. During the first launch, *x50ng* generates a new configuration with default values and empty memory. *x50ng* does not ship with a default firmware, only with the bootloaders for the supported calculators. Hence, the user is required to select a firmware to load into the flash. *x50ng* will show a file selection window for that task. For the stock firmware HP has always used the file extension “.bin”, any other files (including the update.scp files that typically come with them!) are generally not actual firmware files.
When the file selection dialog is cancelled or the file could not be read, *x50ng* creates a flash without firmware; the bootloader will complain and offer ways to correct the situation just like it would on a real device, which include receiving a firmware via USB (currently not available in *x50ng*, see _Caveats_ below) or loading one from the SD card. Apart from these options, it's also possible to recover from this by exiting *x50ng* and either delet ing the flash file or using one of the options *-f* and *-F*, causing *x50ng* to rebuild the flash and ask for a firmware again. When the file selection dialog is cancelled or the file could not be read, *x50ng* creates a flash without firmware; the bootloader will complain and offer ways to correct the situation just like it would on a real device, which include receiving a firmware via USB (currently not available in *x50ng*, see _Caveats_ below) or loading one from the SD card. Apart from these options, it's also possible to recover from this by exiting *x50ng* and either deleting the flash file or using one of the options *-f* and *-F*, causing *x50ng* to rebuild the flash and ask for a firmware again.
Please consult HP's manual (for their official firmware) or the documentation of the custom firmware (if using one) for an explanation of using the calculator. Please consult HP's manual (for their official firmware) or the documentation of the custom firmware (if using one) for an explanation of using the calculator.
# OPTIONS # OPTIONS
- *-h* *--help* print this message and exit *-h* *--help* print this message and exit
- *--verbose* print out more information *-v* *--version* print out version
- *--datadir*[=_absolute path_] alternate datadir (default: $XDG_CONFIG_HOME/x50ng/) *-V* *--verbose* print out more information
- *--overwrite-config* force writing <datadir>/config.lua even if it exists *-d* *--datadir*[=_absolute path_] alternate datadir (default: $XDG_CONFIG_HOME/x50ng/)
- *--50g* emulate an HP 50g (default) *-n* *--name*[=_name_] set alternate UI name
- *--49gp* emulate an HP 49g+ *-s* *--style*[=_filename_] css filename in <datadir> (default: style-50g.css)
- *--newrpl-keyboard* label keyboard for newRPL *-S* *--display-scale*[=_X_] scale LCD by X (default: 2)
- *-n* *--name*[=_name_] set alternate UI name *-r* *--reboot* reboot on startup instead of continuing from the saved state in the state file
- *-s* *--style-filename*[=_filename_] css filename in <datadir> (default: style-<model>.css) *--overwrite-config* force writing <datadir>/config.lua even if it exists
- *-S* *--display-scale*[=_X_] scale LCD by X (default: 2)
- *--enable-debug*[=_port_] enable the debugger interface (default port: 1234) *--newrpl-keyboard* label keyboard for newRPL
- *--debug* use along -D to also start the debugger immediately
- *--reflash*[=_firmware_] rebuild the flash using the supplied firmware (default: select one interactively) (implies -r for safety reasons) *--enable-debug*[=_port_] enable the debugger interface (default port: 1234)
- *--reflash-full*[=_firmware_] rebuild the flash using the supplied firmware and drop the flash contents in the area beyond the firmware (default: select one interactively) (implies -r for safety reasons) *--debug* use along -D to also start the debugger immediately
- *-r* *--reboot* reboot on startup instead of continuing from the saved state in the state file
*--reflash*[=_firmware_] rebuild the flash using the supplied firmware (default: select one interactively) (implies -r for safety reasons)
*--reflash-full*[=_firmware_] rebuild the flash using the supplied firmware and drop the flash contents in the area beyond the firmware (default: select one interactively) (implies -r for safety reasons)
*--50g* use an HP 50g bootloader when (re-)flashing (default)
*--49gp* use an HP 49g+ bootloader when (re-)flashing
# FILES # FILES
All files are located under ~/.config/x50ng/ ## System-wide
- *style-50g.css* and *style-49gp.css*
Default styles provided defining colors and fonts (mostly) for the GUI. The format is CSS as defined by gtk+-3.
- *firmware/*
This directory contains a _Makefile_ that will download and extract the following files:
- the arm bootloaders [ from _https://www.hpcalc.org/hp49/pc/rom/hp-arm-models-bootloader.zip_ ]
- the latest official HP ROM 2.15 [ from _https://www.hpcalc.org/hp49/pc/rom/hp4950v215.zip_ ]
- the latest newRPL build [ from _https://hpgcc3.org/downloads/newrplfw.bin_ ]
## All further files are located under ~/.config/x50ng/
- *config.lua* - *config.lua*

View file

@ -158,20 +158,21 @@ void config_init( char* progname, int argc, char* argv[] )
int print_config_and_exit = false; int print_config_and_exit = false;
int overwrite_config = false; int overwrite_config = false;
const char* optstring = "hrf:n:s:S:"; const char* optstring = "dhrf:n:s:S:vV";
struct option long_options[] = { struct option long_options[] = {
{"help", no_argument, NULL, 'h' }, {"help", no_argument, NULL, 'h' },
{"print-config", no_argument, &print_config_and_exit, true}, {"version", no_argument, NULL, 'v' },
{"verbose", no_argument, &clopt_verbose, true}, {"verbose", no_argument, NULL, 'V' },
{"print-config", no_argument, &print_config_and_exit, true},
{"overwrite-config", no_argument, &overwrite_config, true}, {"overwrite-config", no_argument, &overwrite_config, true},
{"datadir", required_argument, NULL, 1 }, {"datadir", required_argument, NULL, 'd' },
{"50g", no_argument, NULL, 506 }, {"50g", no_argument, NULL, 506 },
{"49gp", no_argument, NULL, 496 }, {"49gp", no_argument, NULL, 496 },
{"newrpl-keyboard", no_argument, &clopt_newrpl, true}, {"newrpl-keyboard", no_argument, &clopt_newrpl, true},
{"name", required_argument, NULL, 'n' }, {"name", required_argument, NULL, 'n' },
{"style-filename", required_argument, NULL, 's' }, {"style", required_argument, NULL, 's' },
{"display-scale", required_argument, NULL, 'S' }, {"display-scale", required_argument, NULL, 'S' },
{"enable-debug", required_argument, NULL, 10 }, {"enable-debug", required_argument, NULL, 10 },
@ -189,45 +190,34 @@ void config_init( char* progname, int argc, char* argv[] )
switch ( c ) { switch ( c ) {
case 'h': case 'h':
fprintf( stderr, fprintf( stderr,
"%s %i.%i.%i Emulator for HP 49G+ / 50G calculators\n" "%s %i.%i.%i\n"
"Emulator for HP 49G+ / 50G calculators' hardware\n"
"Usage: %s [<options>]\n" "Usage: %s [<options>]\n"
"Valid options:\n" "Valid options:\n"
"-h --help print this message and exit\n" "-h --help print this message and exit\n"
" --verbose print out more information\n" "-v --version print out version\n"
"\n" "-V --verbose print out more information\n"
" --datadir[=<absolute path>] alternate datadir (default: $XDG_CONFIG_HOME/%s/)\n" "-d --datadir[=absolute path] alternate datadir (default: $XDGCONFIGHOME/%s/)\n"
"\n" "-n --name[=name] set alternate UI name\n"
"-s --style[=filename] css filename in <datadir> (default: style-50g.css)\n"
"-S --display-scale[=X] scale LCD by X (default: 2)\n"
"-r --reboot reboot on startup instead of continuing from the saved state in the state file\n"
"--overwrite-config force writing <datadir>/config.lua even if it exists\n" "--overwrite-config force writing <datadir>/config.lua even if it exists\n"
"\n" "\n"
" --50g emulate an HP 50g (default)\n"
" --49gp emulate an HP 49g+\n"
"--newrpl-keyboard label keyboard for newRPL\n" "--newrpl-keyboard label keyboard for newRPL\n"
"\n" "\n"
" -n --name[=<name>] set alternate UI name\n" "--enable-debug[=port] enable the debugger interface (default port: %i)\n"
" -s --style-filename[=<filename>] css filename in <datadir> (default: style-<model>.css)\n"
" -S --display-scale[=<X>] scale LCD by X (default: 2)\n"
"\n"
" --enable-debug[=<port>] enable the debugger interface\n"
" (default port: %u)\n"
"--debug use along -D to also start the debugger immediately\n" "--debug use along -D to also start the debugger immediately\n"
"\n" "\n"
" --reflash[=firmware] rebuild the flash using the supplied firmware\n" "--reflash[=firmware] rebuild the flash using the supplied firmware (default: select one interactively) "
" (default: select one interactively)\n"
"(implies -r for safety reasons)\n" "(implies -r for safety reasons)\n"
" --reflash-full[=firmware] rebuild the flash using the supplied firmware and drop the flash contents\n" "--reflash-full[=firmware] rebuild the flash using the supplied firmware and drop the flash contents in the "
" in the area beyond the firmware\n" "area beyond the firmware (default: select one interactively) (implies -r for safety reasons)\n"
" -r --reboot reboot on startup instead of continuing from the\n" "--50g use an HP 50g bootloader when (re-)flashing (default)\n"
" saved state in the state file\n\n", "--49gp use an HP 49g+ bootloader when (re-)flashing\n",
progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname, progname, DEFAULT_GDBSTUB_PORT ); progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname, progname, DEFAULT_GDBSTUB_PORT );
exit( EXIT_SUCCESS ); exit( EXIT_SUCCESS );
break; break;
case 'r':
if ( opt.reinit < X49GP_REINIT_REBOOT_ONLY )
opt.reinit = X49GP_REINIT_REBOOT_ONLY;
break;
case 1:
opt.datadir = strdup( optarg );
break;
case 10: case 10:
do_enable_debugger = true; do_enable_debugger = true;
opt.debug_port = atoi( optarg ); opt.debug_port = atoi( optarg );
@ -258,15 +248,30 @@ void config_init( char* progname, int argc, char* argv[] )
if ( clopt_style_filename == NULL ) if ( clopt_style_filename == NULL )
clopt_style_filename = "style-50g.css"; clopt_style_filename = "style-50g.css";
break; break;
case 'd':
opt.datadir = strdup( optarg );
break;
case 'n': case 'n':
clopt_name = strdup( optarg ); clopt_name = strdup( optarg );
break; break;
case 'r':
if ( opt.reinit < X49GP_REINIT_REBOOT_ONLY )
opt.reinit = X49GP_REINIT_REBOOT_ONLY;
break;
case 's': case 's':
clopt_style_filename = strdup( optarg ); clopt_style_filename = strdup( optarg );
break; break;
case 'S': case 'S':
clopt_display_scale = atoi( optarg ); clopt_display_scale = atoi( optarg );
break; break;
case 'v':
fprintf( stderr, "%i.%i.%i\n", VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL );
exit( EXIT_SUCCESS );
break;
case 'V':
clopt_verbose = true;
break;
default: default:
break; break;
} }