From 150615937f6ae65aa4e7f09cfbf5a078fa2ade9f Mon Sep 17 00:00:00 2001 From: Gwenhael Le Moine Date: Fri, 22 Nov 2024 19:51:05 +0100 Subject: [PATCH] add more short options --- src/x50ng.scd | 51 ++++++++++++++++++++---------- src/x50ng/options.c | 77 ++++++++++++++++++++++++--------------------- 2 files changed, 75 insertions(+), 53 deletions(-) diff --git a/src/x50ng.scd b/src/x50ng.scd index 3bdcd0d..413fa10 100644 --- a/src/x50ng.scd +++ b/src/x50ng.scd @@ -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. -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. # OPTIONS -- *-h* *--help* print this message and exit -- *--verbose* print out more information -- *--datadir*[=_absolute path_] alternate datadir (default: $XDG_CONFIG_HOME/x50ng/) -- *--overwrite-config* force writing /config.lua even if it exists -- *--50g* emulate an HP 50g (default) -- *--49gp* emulate an HP 49g+ -- *--newrpl-keyboard* label keyboard for newRPL -- *-n* *--name*[=_name_] set alternate UI name -- *-s* *--style-filename*[=_filename_] css filename in (default: style-.css) -- *-S* *--display-scale*[=_X_] scale LCD by X (default: 2) -- *--enable-debug*[=_port_] enable the debugger interface (default port: 1234) -- *--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) -- *--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) -- *-r* *--reboot* reboot on startup instead of continuing from the saved state in the state file +*-h* *--help* print this message and exit +*-v* *--version* print out version +*-V* *--verbose* print out more information +*-d* *--datadir*[=_absolute path_] alternate datadir (default: $XDG_CONFIG_HOME/x50ng/) +*-n* *--name*[=_name_] set alternate UI name +*-s* *--style*[=_filename_] css filename in (default: style-50g.css) +*-S* *--display-scale*[=_X_] scale LCD by X (default: 2) +*-r* *--reboot* reboot on startup instead of continuing from the saved state in the state file +*--overwrite-config* force writing /config.lua even if it exists + +*--newrpl-keyboard* label keyboard for newRPL + +*--enable-debug*[=_port_] enable the debugger interface (default port: 1234) +*--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) +*--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 -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* diff --git a/src/x50ng/options.c b/src/x50ng/options.c index 3bbcc90..95c64e1 100644 --- a/src/x50ng/options.c +++ b/src/x50ng/options.c @@ -158,20 +158,21 @@ void config_init( char* progname, int argc, char* argv[] ) int print_config_and_exit = false; int overwrite_config = false; - const char* optstring = "hrf:n:s:S:"; + const char* optstring = "dhrf:n:s:S:vV"; struct option long_options[] = { {"help", no_argument, NULL, 'h' }, - {"print-config", no_argument, &print_config_and_exit, true}, - {"verbose", no_argument, &clopt_verbose, true}, + {"version", no_argument, NULL, 'v' }, + {"verbose", no_argument, NULL, 'V' }, + {"print-config", no_argument, &print_config_and_exit, true}, {"overwrite-config", no_argument, &overwrite_config, true}, - {"datadir", required_argument, NULL, 1 }, + {"datadir", required_argument, NULL, 'd' }, {"50g", no_argument, NULL, 506 }, {"49gp", no_argument, NULL, 496 }, {"newrpl-keyboard", no_argument, &clopt_newrpl, true}, {"name", required_argument, NULL, 'n' }, - {"style-filename", required_argument, NULL, 's' }, + {"style", required_argument, NULL, 's' }, {"display-scale", required_argument, NULL, 'S' }, {"enable-debug", required_argument, NULL, 10 }, @@ -189,45 +190,34 @@ void config_init( char* progname, int argc, char* argv[] ) switch ( c ) { case 'h': 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 []\n" "Valid options:\n" - " -h --help print this message and exit\n" - " --verbose print out more information\n" + "-h --help print this message and exit\n" + "-v --version print out version\n" + "-V --verbose print out more information\n" + "-d --datadir[=absolute path] alternate datadir (default: $XDGCONFIGHOME/%s/)\n" + "-n --name[=name] set alternate UI name\n" + "-s --style[=filename] css filename in (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 /config.lua even if it exists\n" "\n" - " --datadir[=] alternate datadir (default: $XDG_CONFIG_HOME/%s/)\n" + "--newrpl-keyboard label keyboard for newRPL\n" "\n" - " --overwrite-config force writing /config.lua even if it exists\n" + "--enable-debug[=port] enable the debugger interface (default port: %i)\n" + "--debug use along -D to also start the debugger immediately\n" "\n" - " --50g emulate an HP 50g (default)\n" - " --49gp emulate an HP 49g+\n" - " --newrpl-keyboard label keyboard for newRPL\n" - "\n" - " -n --name[=] set alternate UI name\n" - " -s --style-filename[=] css filename in (default: style-.css)\n" - " -S --display-scale[=] scale LCD by X (default: 2)\n" - "\n" - " --enable-debug[=] enable the debugger interface\n" - " (default port: %u)\n" - " --debug use along -D to also start the debugger immediately\n" - "\n" - " --reflash[=firmware] rebuild the flash using the supplied firmware\n" - " (default: select one interactively)\n" - " (implies -r for safety reasons)\n" - " --reflash-full[=firmware] rebuild the flash using the supplied firmware and drop the flash contents\n" - " in the area beyond the firmware\n" - " -r --reboot reboot on startup instead of continuing from the\n" - " saved state in the state file\n\n", + "--reflash[=firmware] rebuild the flash using the supplied firmware (default: select one interactively) " + "(implies -r for safety reasons)\n" + "--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)\n" + "--50g use an HP 50g bootloader when (re-)flashing (default)\n" + "--49gp use an HP 49g+ bootloader when (re-)flashing\n", progname, VERSION_MAJOR, VERSION_MINOR, PATCHLEVEL, progname, progname, DEFAULT_GDBSTUB_PORT ); exit( EXIT_SUCCESS ); 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: do_enable_debugger = true; opt.debug_port = atoi( optarg ); @@ -258,15 +248,30 @@ void config_init( char* progname, int argc, char* argv[] ) if ( clopt_style_filename == NULL ) clopt_style_filename = "style-50g.css"; break; + case 'd': + opt.datadir = strdup( optarg ); + break; case 'n': clopt_name = strdup( optarg ); break; + case 'r': + if ( opt.reinit < X49GP_REINIT_REBOOT_ONLY ) + opt.reinit = X49GP_REINIT_REBOOT_ONLY; + break; case 's': clopt_style_filename = strdup( optarg ); break; case 'S': clopt_display_scale = atoi( optarg ); 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: break; }