Nonpareil's documentation (version 0.79 with patch)

Khanh-Dang Nguyen Thu Lam
07/14/2009



1. Prerequisites

This document describes the features added to nonpareil-0.79 by Eric Smith (see http://nonpareil.brouhaha.com/) by the the HP-IL and autoloading patch.

1.1. Installation (new method)

Notes:

1.2. Notes, bugs and TODO

2. Quick Howto

2.1. Setting a HPIL printer

Note that nonpareil also supports the Helios printer which currently provides better emulation (for the "Print" and "Advance" keys are correctly implemented).

  1. You need the HPIL ROM module (file hpil.mod). Get it and copy it in $HOME/.nonpareil/.

  2. Write the following lines in your $HOME/.nonpareil/41CV.nal:
      MOD hpil.mod
      HPIL hpil.conf
    

  3. Write the following lines in your $HOME/.nonpareil/hpil.conf:
      printer mode=trace double debug
    

  4. Run nonpareil and enjoy the printer.
      $ nonpareil 41cv
    
    You can see the HPIL frames displayed on the standard output.

2.2. Using the Helios printer with HPIL

Put in your .nal file (order is important):

  MOD hpil.mod
  HPIL hpil.conf
  MOD 82143a.mod  # this line must be after hpil.mod's one

In your hpil.conf file:

  set printer_switch 0

The set printer_switch 0 command is for disabling the printer switch located on the HPIL module.

3. Reference Manual

3.1. Autoloading

Nonpareil reads a .nal file at startup and execute commands in this file. This file can ask nonpareil to load MOD1 files, set up external HPIL peripheral (HP-41 only), load a user code file (HP-41 only), or write some given hexcode in any RAM location.

The full file path is $HOME/.nonpareil/XXXX.nal, where XXXX stands for the emulated platform. For example, if you run nonpareil with the 41cv KML file, nonpareil will read the $HOME/.nonpareil/41CV.nal file.

The recognized commands follow, where <foo> stands for a required parameter. When this parameter is a filename, the corresponding file is searched in the following order: the current directory, then the user nonpareil directory usually $HOME/.nonpareil/, then the default nonpareil directory, e.g. /usr/local/lib/nonpareil/. You can't use spaces in filenames.

BIN <bin_file> (only implemented for HP-41)

Load the specified BIN file. A BIN file is a user code program in binary format. See http://www.hpmuseum.org/software/41uc.htm for a detailed description of this format.

DAT <dat_file> (only implemented for HP-41)

Load the specified DAT file. A DAT file is the same as a BIN file, but the binary data are hexadecimal digits in ASCII code instead. See http://www.hpmuseum.org/software/41uc.htm for a detailed description of this format.

HPIL <configuration_file> (HP-41 only)

Load the hpil configuration file. See the HPIL section for further details about this file.

MEM41.DAT <mem41.dat_file> (HP-41 only, not yet implemented)

Load the specified RAM dump file into the emulated HP-41. The format is the one used by the emulator program Emu41.

MEMLOST <number_of_user_registers> (only implemented for HP-41)

Reset the RAM content of the HP-41 as if you got a MEMORY LOST, then set up the specified number of user registers (like the instruction SIZE would do).

MOD <mod_file> (HP-41 only)

Load the specified MOD1 file (usually with the .mod extension).

RAM <address> <value>

Load the specified value at RAM register which address is given. Adress and values are in decimal form, unless you prepend them with 0x (if so, the digits are interpreted as hexadecimal digits).

REG <number> <value> (implemented for HP-41 only)

Load the specified value at the user register which number is given. This is a same number used by the user code instructions STO and RCL. Number and values are in decimal form, unless you prepend them with 0x (if so, the digits are interpreted as hexadecimal digits).

XMEM41.DAT <xmem41.dat_file> (HP-41 only, not yet implemented)

Load the specified extendend RAM dump file into the emulated HP-41. The format is the one used by the emulator program Emu41.

3.2. Using HPIL (HP-41 only)

3.2.1. Configure the HPIL

3.2.2. HPIL emulated peripherals and their options

The list of emulated peripherals follow. (Alphabetical order)

3.2.2.1. disc

This peripheral emulates the HP9114B device (Disc Drive). Device accessory ID is 16.

Actually, HP9114B was said to have commands which are copatible with he HP82161 cassette drive, so the disc and tape implementations are the same, except that discs hold 2464 records whereas cassettes only hold 512.

Options:

debug
Enable printing of incoming HPIL frames on the standard output. Sent frames are only printed if they are different from the incoming frame. Default is disabled debugging output.

file=<full path to LIF image file>
This argument is mandatory. It sets the path to the image file to use as the cassette. If full path is not specified, nonpareil will search the file in the current working directory. Default is set to disc.img.

3.2.2.2. dumb

This peripheral just retransmits the HPIL incoming frames. For debugging purposes, you can add errors in retransmitted frames.

Options:

debug
Enable printing of incoming and sent HPIL frames on the standard output. For readability purpose, if the sent frame is the same as the received frame, the sending event is shown but the frame content is not. Default is disabled debugging output.

delay=<nb_of_microseconds>
Wait the specified number of microseconds before retransmitting the frames. Default is 0.

forget=<percentage>
Forget the specified part of incoming frames. Default is 0.

noise=<percentage>
Noisify the specified part of incoming frames. The incoming frame is actually replaced by a fram with random contents. Default is 0.

spurious=<percentage>
Specify the probability than a supplementary frame is emitted. Default is 0.

3.2.2.3. null

You don't want to use this peripheral. It acts as an powered-off peripheral and discards any received frame.

Options:

debug
Enable printing of incoming HPIL frames on the standard output. Default is disabled debugging output.

3.2.2.4. printer

This peripheral emulates the HP82182A device (HPIL thermal printer). Device accessory ID is 32. It uses the same graphical interface than the helios printer implemented in nonpareil. The format character is not implemented. The keys don't work yet.

Options:

debug
Enable printing of incoming HPIL frames on the standard output. Sent frames are only printed if they are different from the incoming frame. Default is disabled debugging output.

mode=<mode>
Specify the default mode to use (among manual, normal and trace). Default is manual.

double
Start the graphical interface in double size (zoom x2). (Bug: the check case in the menu doesn't reflect the real state.) Default is to disable double size.

3.2.2.5. serial

This peripheral emulates the HP82164A device (HP-IL/RS-232-C Interface). Device accessory ID is 66. Lots of advanced features are not yet supported.

Options:

debug
Enable printing of incoming HPIL frames on the standard output. Sent frames are only printed if they are different from the incoming frame. Default is disabled debugging output.

tty=<ttyname>
This argument is mandatory. The RS-232C part of the interface is bound to the specified device file. It could be /dev/ttyS0 for a real RS232 serial port. You can also use pseudo-terminals like /dev/ttya0.

3.2.2.6. tape

This peripheral emulates the HP82161A device (Digital Cassette Drive). Device accessory ID is 16.

This has not been extensively tested. I may have misinterpreted the Owner's Manual which is quite confusing about some important details.

Options:

debug
Enable printing of incoming HPIL frames on the standard output. Sent frames are only printed if they are different from the incoming frame. Default is disabled debugging output.

file=<full path to LIF image file>
This argument is mandatory. It sets the path to the image file to use as the cassette. If full path is not specified, nonpareil will search the file in the current working directory. Default is set to cassette.img.

3.2.2.7. tcp

This is not really a peripheral but rather a tranceiver. All incoming HPIL frames are retransmitted using the TCP/IP protocol, while all incoming TCP/IP data is forwarded to the HPIL. This is useful if you want to write your own HPIL device emulation code without modyfing nonpareil's code. You code should connect to nonpareil through a TCP socket, it could then receive and send data via the socket. The format is simple: each HPIL frame shall be a two-bytes data, the first byte (network order), more precisely its first 3 bits, is the HPIL header; the second byte is the HPIL data itself.

This pseudo-peripheral can work either as a client (it connects to a server) or as a server (it waits for a connection from a client).

Until the TCP connextion is established, all HPIL frames are discarded.

Options:

debug
Enable printing of incoming and sent HPIL frames on the standard output. Default is disabled debugging output.

listen
Tell the tcp pseudo-peripheral to listen for a TCP client (server mode). If not specified, the tcp pseudo-periphal acts as a client. Default is to disable server mode.

host=<address>
When not in server mode, specify the IP address of the server. Default is 127.0.0.1.

port=<port_number>
If in server mode, set the port number on which to wait for an incoming connextion. If in client mode, set the port number of the server. Default is 4141.

wait=<seconds>
Waits for the specified number of seconds before attempting to start the connexion. Only useful if you do wierd things such as bypassing the HPIL with two tcp pseudo-peripherals which are connected together. Default is 0.

3.2.2.8. video

This peripheral emulates the HP82163 device (HPIL video interface) or the HP92198 device (HP-IL 80-column video interface).

All escaped sequences of HP82163 should work. Some escaped sequences of HP92198 are not yet implemented.

Note: The HP82163 Owner's Manual says HP82163 doesn't answer to the SST (Send Status) request. I believe it is wrong, and nonpareil actually answers 0x80 followed by 0x00.

Options:

80
Select the 80-column mode (thus, emulating the HP92198 device). Default is to emulate the HP82163 device (32 column mode).

zoomx=<n>
Set the display zoom level for the horizontal direction . Default is set to 2.

zoomy=<n>
Set the display zoom level for the vertical direction . Default is set to 2.

4. ChangeLog

If you know about C programming, you should read the source code if the documentation is not clear enough. "Use the source, Luke!"

For convenience, the ChangeLog of the patch is reproduced here:

  2009-07-14  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* hpil_io_pilbox.c: Hopefully working version.
  
  2009-07-13  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* hpil_io.c, hpil_io_misc.c: times(NULL) was non-standard.
  
  2009-07-12  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* hpil_io_pilbox.c: Added initial support for pilbox.
  
  2009-03-19  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* digit_ops.c: Avoided two-digit results in do_add() and do_sub().
  
  2009-03-15  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* coconut_usercode.c: Fixed two bugs that prevented some programs
  	to load properly.
  	* dis_nut.c: Debug output now shows whether the proc is in hexa or
  	decimal mode.
  
  2009-03-08  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* dis_nut.c: Corrected "? rcr" to "rcr"
  
  2009-03-06  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* coconut_usercode.c: Minor fixes.
  
  2009-02-28  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* hpil_io_video.c: Corrected minor bug and commented out unused
  	function.
  
  2009-02-24  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	* dis_nut.c: Corrected wrong "? s=0".
  
  2009-02-10  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  
  	* hpil_io_tape.c:
  	- "disc" simulation should now work
  	- Can now use smaller LIF image
  	- Cleaned code
  
  	* hpil_io_printer.c: Clear the right-justify flag at end-of-line.
  
  2009-02-08  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  
  	* proc.c: Changed the jiffy length so that HPIL simulation is not
  	slowed down.
  
  	* hpil_io_tape.c: Added initial support for HP82161A Digital Cassette
  	drive and HP9114B Disc Drive
  
  	* hpil.c: Fixed bug: the selpf read opcode shall clear the entire C
  	register, instead of just setting the first two nibbles.
  	
  	* hpil_io_printer.c: Improved compatibility with the real printer.
  
  	* fonts.h, fonts.c, helios.c, hpil_io_printer.c, hpil_io_video.c:
  	- Used the new fonts.c implementation.
  	- Fixed the down arrow character.
  
  	* hpil_io_video.c: Used better font display for HP92198.
  
  2009-02-02  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  
  	* hpil_io_video.c:
  	- Fixed bug: the "ESC % m n" escape sequence didn't work as expected
  	- Removed all the compatibility mode stuff.  We don't follow the
  	  HP82163 Owners's Manual anymore: the HP82163 now answers to
  	  SST and sends 0x80 followed by 0x00.
  	- Set the character size to 8x12 for HP82163 (font is still 5x8).
  	- Set realist cursor blinking rate (as seen on video by Egan Ford).
  
  	* autoload.c, coconut_usercode.c:
  	- Implemented the REG and RAM autoloading commands.
  	- BIN and DAT commands can now load programs not END-terminated.
  	- Fixed bug: DAT files didn't load.
  	- Handled errors properly and added debugging output.
  
  	* util.h, util.c, csim.c: Renamed strlcpy() and strlncpy() to
  	x_strlcpy() and x_strlncpy() because MacOS/X already has a strlcpy()
  	which conflicts with ours (reported by Egan Ford).
  
  	* about.c: Updated credits and copyright notice.  Rewrote the dialog
  	using GtkAboutDialog.
  
  	* proc_nut.c: Corrected wrong error message.
  
  2009-02-01  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  	
  	* hpil.c: Implemented the printer switch.  The user can disable it
  	with "set printer_switch 0" in his HPIL configuration file.
  	
  	* hpil.c, hpil_io.c: Corrected default HPIL configuration when no
  	configuration file is specified or when one is specified but no
  	peripheral is declared.
  	
  	* hpil_io_printer.c: Added comments.
  
  2009-01-31  Khanh-Dang Nguyen Thu Lam <kdntl@yahoo.fr>
  
  	* csim.h (csim_t):
  	  - Added autolad_fn member in csim_t.  This is the full path
  	    to the autoloading instructions file.
  	* proc_int.h (processor_dispatch_t):
  	  - Added next_page callback.  This function shall find the next
  	    available  page.
  	  - Added install_additional_chip callback.
  	  - Added hpil_receive callback.
  	* proc.h (chip_type_t):
  	  - Added CHIP_HPIL.
  	* proc_nut.h (nut_reg_t):
  	  - Added c_to_hpil_fcn callback which implements the HPIL=C opcode.
  	  - Added hpil_receive_fcn callback which receives a HPIL frame.
  
  	* csim.c, proc.c, autoload.c, autoload.h, coconut_usercode.c,
  	  coconut_usercode.h:
  	  - Implemented autoloading files at startup.
  	  - Opening a status file with declared additional chips is now
  	    supported.  This uses the new install_additional_chip callback.
  	  - Implemented loading MOD1 at non-fixed page.  This uses
  	    the new next_page callback.
  	  - Implemented loading a user code binary into coconut.
  	  - Renamed set_default_state_path to set_default_fn because
  	    the default path now also applies to the autoloading file.
  
  	* csim.c, proc.c, proc.h, proc_nut.c,  hpil.c, hpil.h, hpil_io.c,
  	  hpil_io.h, hpil_io_misc.c, hpil_io_misc.h, hpil_io_dumb.c,
  	  hpil_io_printer.c, hpil_io_serial.c, hpil_io_tcp.c, hpil_io_video.c:
  	  - Added nearly exhaustive HPIL support for coconut.
  	  - Added support for the null, dumb, HP82162A, HP82164A,
  	    tcp, HP82163A and HP92198 HPIL peripherals.
  	  - Each peripheral runs in its own thread and may need to use
  	    gdk_threads_enter() and gdk_threads_leave(). gdk_threads_init()
  	    was added in csim.c.
  	  - In proc.c:
  	    - enum sim_cmd_t now has CMD_HPIL_FRAME_RECEIVED.
  	    - sim_get_cmd_q() is implemented.  The last peripheral on the loop
  	      needs to use the simulator's command queue to send the
  	      CMD_HPIL_FRAME_RECEIVED message.
  	    - struct sim_thread_vars_t now has the hpil_free_q member.
  	      This queue hold preallocated messages.  That way, the thread
  	      which sends a CMD_HPIL_FRAME_RECEIVED message doesn't have
  	      to allocate memory, preventing performance loss.
  
  	* printer.c, printer.h, printer_chargen.c, helios.c, helios.h:
  	  - The printer.c file is now strictly independant of helios.c.
  	    helios_chargen.c was renamed to printer_chargen.c
  	    Functions in printer.c are now used in both helios.c and
  	    hpil_io_printer.c.
  	  - Fix the glyphs "1" and upper "J".
  	  - Added Roman8 font (disabled by default).
  
  	* helios.c, phineas.c:
  	  Added a check to prevent the chip to be inited twice.
  	  This could happen when nonpareil first loads a status file
  	  in which a chip is declared, and then autoloads a MOD file
  	  which require the same chip.
  
  	* debugger_gui.c:
  	  - Used monospace font for registers fields.
  	  - Added a hardcoded (ugly) requisite size.
  
  	* proc_nut.c (nut_read_ram):
  	  - Fixed bug (nut_read_ram returned wrong values).
  
  	* csim.c, csim.h:
  	  - Used G_DIR_SEPARATOR_S instead of "/".
  	  - Defined the NONPAREIL_DIRNAME macro and set it accordingly.
  
  	* SConscript:
  	  - Added compilation of new files
  	  - Used _env.Clone instead of the deprecated _env.Copy.