.\" Hey, EMACS: -*- nroff -*- .\" Please adjust this date whenever revising the manpage. .Dd August 29, 2018 .Dt TARGET_ALLCAPS 1 .Os .Sh NAME .Nm TARGET .Nd Emulator for HP 49g+ / 50g calculators .Sh SYNOPSIS .Nm .Op Fl d Ns Oo Ns = Ns Ar port Oc | Fl Fl debug Ns Oo Ns = Ns Ar port Oc | Fl D Ns Oo Ns = Ns Ar port Oc | Fl Fl enable-debug Ns Oo Ns = Ns Ar port Oc .Op Fl h | Fl Fl help .Op Ar config .Sh DESCRIPTION .Nm is an emulator capable of running any software written for the HP 49g+ and HP 50g calculators, including ARM programs or even custom firmware. It achieves this by using a modified version of QEMU to emulate the ARM hardware based around the Samsung S3C2410 chip. .Pp Visually .Nm appears as an undecorated window mirroring the appearance of the emulated calculator. The display area obviously shows the virtual calculator's screen contents. .Ss Input For mouse input, the keys shown in the window can be interacted with; left-clicking on one holds it down for as long as the mouse button is down, right-clicking on one holds it down until any key is left-clicked. .Pp Another method of interacting with the calculator is through a physical keyboard. .Em A-Z , .Em 0-9 , .Em F1-F6 , .Em cursor keys , .Em \&' , .Em Backspace , .Em \&^ , .Em \&+ , .Em \&- , .Em \&* , .Em \&/ , .Em \&. , .Em Space , .Em Enter correspond to their sensible calculator counterparts. In addition, .Em Delete acts as extra Backspace key, .Em \&, acts as extra decimal separator key, .Em Shift presses the Leftshift key (green on the 49g+, white on the 50g), .Em Control presses the Rightshift key (red on the 49g+, orange on the 50g), .Em Tab presses the Alpha key (yellow on the 49g+ and 50g), and .Em Escape presses the On key. Note that in order to allow multiple-key combinations involving e.g. .Em Shift without surprises, such as pressing .Em Shift .Ns - Ns .Em 8 on a US QWERTY keyboard producing the key sequence .Dq Leftshift-hold multiply , .Nm ignores all keyboard modifier states except NumLock. Because that may make certain virtual keys inaccessible to a laptop keyboard without a numpad, there are certain additional key definitions to support at least some common keyboard layouts: .Bl -tag -width indent .It US, UK, International QWERTY: .Em \e acts as \&* key, .Em \&= acts as \&+ key. .It German QWERTZ: .Em # acts as \&* key, .Em ß acts as \&/ key. .El .Pp (Further suggestions are welcome.) These additional key definitions do not need their respective layouts to work, so e.g. .Em \e will act as \&* on any keyboard that has it as an unshifted key. .Pp Pressing physical keys and clicking on virtual ones can be freely combined. Right-clicked keys are released when no keys are held down by the left mouse button or physical keys anymore. To avoid stuck keys, .Nm forcibly releases all keys when losing focus. .Pp There are two remaining miscellaneous key definitions: .Em F12 resets the calculator, like inserting a paperclip into the tiny hole at the back of the real device or removing all of its power sources (batteries, USB) would; .Em Menu opens a popup menu granting access to several emulator control items. This popup menu can also be opened by right-clicking on the screen area. .Ss The popup menu The first group of items in the popup menu deals with the calculator's SD card. The SD card can either be backed by a directory on the host system (item .Sy Mount SD folder ... ; .Nm will simulate a FAT-formatted file system on the fly), or by an image file (item .Sy Mount SD image ... ) . The former is more convenient for general use, but when debugging a hypothetical replacement firmware's SD driver, the latter variant's accuracy (it allows corrupting the filesystem, for instance) might be more desirable. The virtual SD card can be absent entirely, too (item .Sy Unmount SD ) . .Pp The second group consists of only one item, and it is only visible when one of the debug options has been used while starting .Nm . Named .Sy Start debugger , it (re-)starts the GDB remote debugging interface. This is hidden by default because accidental clicks will seemingly freeze the emulator while it waits for an incoming connection. .Pp The third and final group contains two items: .Sy Reset , which resets the calculator just like the .Em F12 key, and .Sy Quit , which closes .Nm and saves the configuration, CPU registers, hardware registers, and memory contents to their respective files. This saving step is also performed when .Nm is closed in another way, e.g. pressing .Em Control-C in the controlling terminal. .Ss First launch During the first launch, .Nm generates a new configuration with default values and empty memory. .Nm 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. .Nm will show a file selection window for that task. For the stock firmware HP has always used the file extension .Dq .bin , any other files (including the update.scp files that typically come with them!) are generally not actual firmware files. .Pp When the file selection dialog is cancelled or the file could not be read, .Nm 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 .Nm , see .Em Caveats below) or loading one from the SD card. Apart from these options, it's also possible to recover from this by exiting .Nm and either deleting the flash file or using one of the options .Fl f and .Fl F , causing .Nm to rebuild the flash and ask for a firmware again. .Pp 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. .Sh OPTIONS .Bl -tag -width indent .It Fl d Ns Oo Ns = Ns Ar port Oc , Fl Fl debug Ns Oo Ns = Ns Ar port Oc Enable the GDB remote debugging interface on the specified port (default 1234) and start the interface immediately. When used multiple times, the last explicitly specified port wins. If the connection is closed before .Nm is shut down, then the interface can be restarted from the popup menu. .It Fl D Ns Oo Ns = Ns Ar port Oc , Fl Fl enable-debug Ns Oo Ns = Ns Ar port Oc Same as .Fl d , but without starting the interface immediately. The popup menu has to be used to do so. When combined with .Fl d , the last explicitly specified port will still win, and the GDB interface will be started immediately. This facilitates using an alias for .Do Nm .Fl D Dc when the possibility for spontaneous debug sessions exists. .It Fl f Ns Oo Ns = Ns Ar firmware Oc , Fl Fl reflash Ns Oo Ns = Ns Ar firmware Oc Rebuild the flash. If the firmware is not specified, .Nm will ask for one through a file selection dialog window like on the first launch. The flash area beyond the firmware is left untouched, though; in the stock firmware this area is available to the user as port 2. Implies .Fl r for safety reasons: the firmware may have changed, so the code at the location where .Nm was stopped previously could be entirely different from the code at that location afterwards; a reboot ensures an orderly reinitialization of the operating system. .It Fl F Ns Oo Ns = Ns Ar firmware Oc , Fl Fl reflash-full Ns Oo Ns = Ns Ar firmware Oc Same as .Fl f , but erase the area beyond the firmware too. This has the same effect as deleting the flash, but with the added benefit of being able to specify the firmware on the command-line for automation in scripts. .It Fl r , Fl Fl reboot Reboot the calculator instead of starting from the state saved in the configuration file. .It Fl h , Fl Fl help Print a compact help message and exit. .It Ar config Use .Ar config as the configuration file instead of the default one. See below for details on the format; if the file does not exist, it will be created with default values. .El .Sh FILES .Bl -tag -width indent .It Sy ~/. Ns Nm Ns Sy /config The default location for the configuration file. The file format is the INI-like .Dq key-file format defined by GLib. The configuration file stores, for the most part, the state of the calculator's hardware, excluding the memory. The peripherals' official names according the the S3C2410 datasheet are used as section names with the prefix .Dq s3c2410- , the respective register names are the keys used in a section, and the values are the numbers stored in these registers. For the ARM processor itself, the section name is s3c2410-arm, and the keys correspond to the names of attributes in the QEMU CPU state structures. .Pp In addition, there are keys called .Em filename in the sections .Em flash , .Em sram , .Em s3c2410-sram , .Em s3c2410-sdi which allow changing the filename of the files where the state of the respective memory is held. These can be absolute paths, or paths relative to the location of the configuration file (in the simplest case, only a filename). Any files that do not exist will be created with appropriate size and placeholder content. For .Em s3c2410-sdi , the empty string is accepted as a special value for no inserted SD card. .Pp Finally, the .Em gui section contains the keys .Em name , which specifies the window title (possibly useful when multiple different instances are present), and .Em type , which specifies the type of the calculator (accepted values are .Sy hp49g+ and .Sy hp50g ) . .It Sy flash The default name of the file backing the flash memory; required size: 2 MiB. If this file does not exist or is too small, the calculator type's appropriate bootloader will be copied into the first 16 KiB. Do NOT simply put a firmware file here, it will not work. Just use the builtin firmware installation mechanism instead. .It Sy sram The default name of the file backing the SRAM memory; required size: 512 KiB. .It Sy s3c2410-sram The default name of the file backing the S3C2410's internal SRAM memory; required size: 4 KiB. .El .Sh CAVEATS The emulation of the calculators' hardware is not fully accurate. Most notably, emulation speed is not authentic (it depends on the host's capabilites), and communication ports (serial, infrared, USB) are not available. For most purposes this is good enough, though.