The 9845 Utilities Project

This project is just dedicated to all those little programs, which make the life with vintage computers (and the 9845 systems in particular) easier. There is no real plan for this project, it is just a collection of small utilites I've written in the past.

Utilities for the PC

Here's a summary of the programs which run on the PC side, in alphabetical order. See the following sections for details.

Utility Description
Add Simulates HP9845 BPC binary integer add instructions (ADA, ADB). Useful to analyze BPC arithmetics, e.g. for building checksums.
Analyzer GPIB analyzer ("sniffer"). Used to trace communication between any other devices connected to the same GPIB bus. Requires a NEC7210 based IEEE488 interface. Terminates either when being addressed over GPIB (talker or listener) or when the maximum number of 10,000 samples is reached.
Bmpconvert Converts between Windows BMP bitmap image files and 9845 bitmap image files with GSTORE format
Getfile Receives an arbitrary file from the GPIB bus.
Hp2txt Converts string based HP text files (including BASIC files, saved with "SAVE") into DOS text files.
Ima2hpi Does the transformation from IMA disk images (esp. derived from TD0 images via Teledisk) back to hpi disc images (raw binary image format). Can be used together with Sergey Erokhin's Teledisk TDCVT unpacker and Dietmar Harlos's FDI2IMA utility in order to reproduce clean generic binary images from Teledisk archives.
Imggen Generates image file filled with 256-byte-block test pattern of arbitrary size. Quite useful for many test applications.
Invert Performs a bitwise negation on the whole file. Essential for 9845 ROM images.
Rar Simulates HP9845 BPC binary integer rotate right instructions (RAR, RBR). Useful to analyze BPC arithmetics, e.g. for building checksums.
Romcheck Calculates validation & identification checksums for HP9845 ROM dumps. Uses the same checksum algorithm which is used by HP for establishing ROM integrity.
Rommerge Combines upper & lower ROM into one ROM block & lists ROM statistics like checksum etc. Takes inverted ROM images (as produced by a ROM dump) and outputs normal executable positive logic object code.
Sendfile Sends an arbitrary file to the GPIB bus.

Add

Simulates HP9845 BPC binary integer add instructions (ADA, ADB). Useful to analyze BPC arithmetics, e.g. for building checksums.

Syntax:

add <arg1> <arg2>

with <arg1> and <arg2> signed integers between -32768 and +32767. The result will be calculated including processor-internal extend and overflow flags.

Analyzer

GPIB analyzer ("sniffer"). Used to trace communication between any other devices connected to the same GPIB bus. Requires a NEC7210 based IEEE488 interface. The analyzer itself is configured to the GPIB address 20 and terminates either when being addressed over GPIB (talker or listener) or when the maximum count of 10,000 samples is reached. The current version works only under Windows 9x/ME and with a NEC µPD7210 compatible board at base address 0x2E0. The log is sent to standard output.

Syntax:

analyzer

Usage is as follows:

  1. Execute the analyzer utility with "analyzer > logfile".
  2. Start the HP-IB/GPIB activity you want to monitor.
  3. When finished, stop recording by sending a trigger to the GPIB address 20, e.g. from the 9845 with "TRIGGER 720".
  4. Examine the logfile for recorded data.

Bmpconvert

The Bmpconvert utility can be used to convert between standard windows bitmap format and the file format of the 9845B graphics. All 9845 display systems are now supported, including 9845B enhanced monochrome and 9845C color graphics. Color images can be converted between the different systems by using a BMP file as intermediate storage.

Syntax:

Usage: bmpconvert [<options>] <infile> <outfile>

with <infile> input image file and <outfile> output image file and <options> a combination of :
-bdat      produce BDAT format (default)
-data      produce DATA format
-standard  produce monochrome format for 98750A displays (default)
-enhanced  produce monochrome format for 98780A displays
-color     produce color data (needs three separate 9845C files for either input or output)
-info      output file info only (do not create or change files)

The BMP images must have the size 560 by 455 pixel with a color depth of 1, 4, 8 or 24 bit(s) per pixel. The utility automatically checks the <input_file>. If it is a BMP file, a 9845 image file is produced with the name <output_file>. It can be controlled with the -bdat and -data switches, whether a BDAT or DATA file shall be created (BDAT is the default). If not, Bmpconvert assumes the input file to be a 9845 image and tries to produce the appropriate BMP image file. The options -standard, -enhanced and -color specify the target system, and, of course, whether monochrome or color bitmaps are produced. Use the -info option in combination with a filename to see what kind of image data the file contains.

Please note that in color mode, there are three parts needed for BDAT or DATA files. Please specify only the first part as <infile> or <outfile>, the program then looks in the current directory for the remaining parts. You should use the convention naming the first part XXXXX1, the second part XXXXX2 and the last part XXXXX3, where XXXXX stand for an arbitrary filename with 1 to 5 characters.

Example:

bmpconvert -color SAMPL1.DATA sampl.bmp

converts the 9845 image consiting of the files SAMPL1.DATA, SAMPL2.DATA and SAMPL3.DATA into a Windows bitmap named sampl.bmp.

Also note, that when converting a Windows bitmap file into a 9845 image bmpconvert applies color reduction, but no dithering. If you need to convert e.g. a photograph, please use a conventional image editor like Photoshop with the included eight-color palette PAL file (palette8colors.PAL) to do the dithering before applying bmpconvert.

More information on the way the 9845 saves graphics data can be found in the Tutorial on Using Bitmaps.

The MSDEMO program can be used on the 9845 to load, modify and save images in the various 9845 graphics formats (see the 9845 Mouse Project).

Getfile

Receives an arbitrary file from the GPIB bus. Once the program is started, it waits in device mode until it is addressed for a binary file transfer. The transfer is block-oriented, i.e. file data transmission is assumed in 256-byte-blocks, so the fast handshake feature can be used at the 9845 side. This also complies to the actual physical file size on the 9845, which is always a multiple of 256, the physical sector size. By default, the file transfer is terminated by EOI asserted by the controller either with the last byte sent or with a single byte of value 26 (ASCII EOF, will not be written into the local file copy if it is the first and only byte in the last block transmission). If required, end-of-file can alternatively be indicated by a special EOF multi-character string, which must be at the start of the last data block as well, and then will not be written into the local file copy, too. Therefore, the last transmitted data block can be smaller than 256 bytes, if it is properly terminated with either EOI asserted or an EOF string.

Getfile currently works only with NEC µPD7210 compatible GPIB interface cards. Future support will probably include RS232 connections and other GPIB chips.

Syntax:

getfile [<options>][<output_file>]

If <output_file> is omitted and the -host option is not used, the user will be prompted for a filename. If <output_file> does not exist, it will be created automatically. Already existing files will be overwritten without warning.

Getfile can be configured with the following options:

Option Description
-h Output a summary of the command line options.
-a <address> Use <address> as primary GPIB address (default 20).
-host Assume the first received record as filename. The record can either be terminated by CR, LF or both. Use this option if the filename shall be controlled by the remote host.
-trailer Send a checksum to host after file data has been received. Checksum is a signed 16-bit arithmetic sum over all received data words.
-loop Enable multi-file mode (loops until CTRL-C is pressed). If one file has been completed and the -host option has not been used, the user will be prompted for the next filename after each transfer.
-eof <string> Specifies use of special end-of-file marker string. <string> must be enclosed in double quotes. At the first occurrance of <string> at the beginning of a data record the transmission will be terminated.
-l <loglevel> Specify a higher detail of reporting. Normal is loglevel 2. Use 0 for quiet operation and 3 or 4 for diagnostic purposes.
-p Show transfer progress (one dot per 256 bytes, will be directed to standard error)
-v Show detailed activity reporting. At the end of a transmission, the number of received blocks and bytes, the transmission speed and the checksum will be printed.

Here is a simple 9845 program to work with the getfile program:

100   INTEGER Buf(127)
110   ! -- Fill buffer with random pattern --
120   FOR I=0 TO 127
130     Buf(I)=RND*65536-32768
140   NEXT I
150   Blocks=50         ! File size in 256-byte-blocks (example)
160   Target=20         ! PC remote GPIB address
170   Target=Target+700 ! Add interface select code
180   Checksum=0
190   ! -- Send data with fast handshake --
200   FOR I=1 TO Blocks
210     OUTPUT Target BFHS  NOFORMAT;Buf(*)
220     Checksum=(Checksum+SUM(Buf)+32768) MOD 65536-32768
230   NEXT I
240   ! -- Terminate transfer --
250   EOI 7;26
260   PRINT "Local checksum: ";Checksum
270   END

Note that an integer array is used as I/O buffer instead of a character string in order to simplify the calculation of a checksum.

On the PC, getfile can receive data from the program above when executed as

getfile <output_file>

Start the getfile program before running the 9845 program. Use the -v option to obtain a checksum for comparison with the checksum on the 9845 side.

There are two versions available, one for use with the DlPortIO driver (which works also under Windows NT/2000/XP/Vista) and one for Windows 9x/ME.

HP2txt

Converts string based HP9845 text files (including BASIC files, saved with "SAVE") into DOS text files.

Syntax:

hp2txt <input_file> [<output_file>]

If <output_file> is omitted, the result will be sent to standard output.

Ima2hpi

Does the transformation from IMA disk images (esp. derived from TD0 images via Teledisk) back to hpi disc images (raw binary image format with ordered sectors). Can be used together with Sergey Erokhin's Teledisk TDCVT unpacker and Dietmar Harlos's FDI2IMA utility in order to reproduce clean binary images from Teledisk archives.

Syntax:

ima2hpi [<options>] <input_file> [<output_file>]

with the following options:

Option Description
-h Output a summary of the command line options.
-c <cylinders> Specifies cylinder count of the original medium (overrides autodetect)
-h <heads> Specifies head count of the original medium (overrides autodetect)
-s <sectors> Specifies sectors per track of the original medium (overrides autodetect)
-r <sector_size> Specifiies sector size of the original medium (overrides autodetect)
-j <track_junk> Specifies number of extra bytes at the end of each track (default is 0)
-i <interleave> Specifies n:1 interleave factor of the original medium (overrides autodetect)
-cs <cylinder_skew> Specifiies cylinder skew of the original medium (default is 0)
-hs <head_skew> Specifies head skew of the original medium (default is 0)
-sc <skewcount> Specifies the number of tracks to be skewed (default is all tracks)
-cskip <cylinder_skip> Specifies how many cylinders should be skipped in case the image was created from a medium which had been formatted first with high and then with low track density (default is 1 for no skip, chose 2 for double formatted media)
-hskip <head_skip> Specifies how many cylinders should be skipped in case the image was created from a medium which had been formatted first with more than one single head and then with lower head count (default is 1 for no skip, chose 2 for double formatted media with two heads)
-l <control_file> Use a TDCVT v0.11 output file as control file for the transformation. This should be the standard way to do the transformation because it is most reliable.
-m <match_list>

Use a list of knows address transformations of the form

<match_list> := <count> <from> <to> [<from> <to> [...]]

where <count> is the total number of pairs and <from> a record number with known byte position <to> in the input file. The more pairs are specified, the more precise will be the heuristic. Actually it is more brute force than heuristic...

-v

Produce verbose output.

The recommended way to transform Teledisk images into hpi disc images is with a small command script TD2HPI.BAT which is included in the distribution package. If the Teledisk image is ABCDEF.TD0, just execute

TD2HPI.BAT ABCDEF

in the same directory. Please note that also a couple of other programs must be present (tdunp.exe, tdcvt.exe, fdi2ima.exe, ima2hpi.exe).

Imggen

Generates image file filled with 256-byte-block test pattern. Quite useful for many test applications.

Syntax:

imggen <size> <image_file>

where <size> is the image size in bytes (must be a multiple of 256) and <image_file> is the filename of the newly created image.

Invert

Performs a bitwise negation on the whole file. Essential for 9845 ROM images.

Syntax:

invert <input_file> <output_file>

where <input_file> is the original file and <output_file> is the filename of the newly created bit-inverted file.

Rar

Simulates HP9845 BPC binary integer rotate right instructions (RAR, RBR). Useful to analyze BPC arithmetics, e.g. for building checksums.

Syntax:

rar <arg1>

where <arg1> is a signed integer between -32768 and +32767.

Romcheck

Calculates validation & identification checksums for HP9845 ROM dumps. Uses the same checksum algorithm which is used by HP for establishing ROM integrity. For each 16 kBytes or 8 kWords a separate check is performed.

Syntax:

romcheck <input_file>

where <input_file> is the ROM image which is to check (size should be multiples of 16 kBytes).

Rommerge

Combines upper & lower ROM into one ROM block & lists ROM statistics like checksum etc. Takes inverted ROM images (as produced by a ROM dump) and outputs normal executable positive logic ROM code.

Syntax:

rommerge <high_rom> <low_rom> <output_file>

where <high_rom> is the dump of the ROM with the upper byte and <low_rom> is the dump of the lower byte. The result will be merged into <output_file>.

 

Sendfile

Sends an arbitrary file to the GPIB bus. Once the program is started, it waits in device mode until it is addressed for a binary file transfer. Ahead of the file data transfer, the program can be configured to send one record with the filename and file size in bytes. By default, the file transfer is terminated either by reaching the end of the file or by being UNTALKed at the GPIB. After the file data transfer has been completed, the program can optionally send another record with an end-of-file marker string and/or a checksum to the host. File data transmission is done in 256-byte-blocks, so the fast handshake feature can be used at the 9845 side. This complies also to the actual physical file size at the 9845, where the space occupied by a file is always a multiple of 256 (the physical sector size). If the local file size is not a full multiple of 256, the remaining bytes are padded with zero. If an UNTALK happens in the middle of a block transfer, the transfer is immediately aborted (no further data is sent).

There is one speciality with the 98034A/B HP-IB interfaces: once a records has been received with an ENTER statement, the remote device keeps being addressed to talk, and data sent from the device is taken from the bus by the 9845 HP-IB interface. If the next ENTER command is not issued immediately after the previous ENTER, bytes will be dropped at the 9845 side. Since a PC is much faster than a 9845, this generally is a problem. A simple workaround is to hold off the PC until the 9845 program is ready to take over the data, which can be indicated e.g. by a trigger event on the GPIB bus. With the -trigger option, the sendfile program waits for a trigger event from the 9845 before sending any record.

Sendfile currently works only with NEC µPD7210 compatible GPIB interface cards. Future support will probably include RS232 connections and other GPIB chips.

Syntax:

sendfile [<options>][<input_file>]

If <input_file> is omitted, all file data will be grepped from standard input.

Getfile can be configured with the following options:

Option Description
-h Output a summary of the command line options.
-a <address> Use <address> as primary GPIB address (default 20).
-host Assume the first received record as filename. The record can either be terminated by CR, LF or both. Use this option if the filename shall be controlled by the remote host.
-header Send a trailing record with filename and file size before any file data ist sent. Can be used by the host to create a file of the proper size where the data can be routed.
-trailer Send a checksum to host after file data has been received. Checksum is a signed 16-bit arithmetic sum over all received data words.
-trigger Wait for a GPIB trigger before sending each data record. Simplifies sending data to the 9845.
-loop Enable multi-file mode (loops until CTRL-C is pressed). If one file has been completed and the -host option has not been used, the user will be prompted for the next filename.
-eof <string> Specifies use of special end-of-file marker string. <string> must be enclosed in double quotes. The string will be sent immediately after the last file data and can be used by the host to identify the end of the transmission.
-l <loglevel> Specify a higher detail of reporting. Normal is loglevel 2. Use 0 for quiet operation and 3 or 4 for diagnostic purposes.
-p Show transfer progress (one dot per 256 bytes, will be directed to standard error)
-v Show detailed activity reporting. At the end of a transmission, the number of received blocks and bytes, the transmission speed and the checksum will be printed.

Here is a simple 9845 program to work with the sendfile program:

100   INTEGER Buf(127)
110   Target=20         ! PC remote GPIB address
120   Target=Target+700 ! Add interface select code
130   Checksum=0
140   ! -- Receive header with filename & file size --
150   TRIGGER Target
160   ENTER Target;Filename$,Filesize$
170   Size=VAL(Filesize$)
180   Blocks=INT((Size+255)/256)
190   ! -- Recive data with fast handshake --
200   FOR I=1 TO Blocks
210     TRIGGER Target
220     ENTER Target BFHS 256 NOFORMAT;Buf(*)
230     Checksum=(Checksum+SUM(Buf)+32768) MOD 65536-32768
240   NEXT I
250   ! -- Transfer finished --
260   PRINT "Local checksum: ";Checksum
270   END

Note that an integer array is used as I/O buffer instead of a character string in order to simplify the calculation of a checksum.

On the PC, sendfile can send data to the program above when executed as

sendfile -header -trigger <output_file>

Start the sendfile program before running the 9845 program. Use the -v option to obtain a checksum for comparison with the checksum on the 9845 side.

There are two versions available, one for use with the DlPortIO driver (which works also under Windows NT/2000/XP/Vista) and one for Windows 9x/ME.

Utilities for the 9845

Here's a summary of the programs which run on the HP 9845 side, in alphabetical order.

Utility Description
MDUMP Can be used to view arbitrary memory areas including firmware as hex dump. Supports printing hex dumps on the internal printer and saving memory areas (including the complete firmware) either to mass storage or via HP-IB connection to the PC. Parts of the utility are in assembly language, so the Assembly Execution and Development option ROM is required. There is another version (MDUMP1) available with pre-compiled assembler module (MEMCPY) which can be used with the Assembly Execution option ROM.
TDUMP Can be used to perform multiple operations on tape cartridges, including tape positioning, tape verify, tape erase, and sector-by-sector duplication of tape content. Supports saving tape content on mass storage or via HP-IB connection to the PC. Gives some help on handling even partly defective tapes. See the Saving Tapes tutorial on how to preserve tape contents with the TDUMP program.

 

MDUMP Screenshot

MDUMP Screenshot

 

Screenshot TDUMP

TDUMP Screenshot

Downloads

Click here for downloading the 9845 utilities:

9845 Utilities for PC 1.0 beta Windows 9x/ME executables: 9845utilities-PC-102beta-bin-win9x.zip
9845 Utilities for PC 1.0 beta Windows NT/2000/XP/Vista executables (needs DlPortIO driver for Analyze): 9845utilities-PC-102beta-bin.zip
9845 Utilities for PC 1.0 beta source code package: 9845utilities-PC-102beta-src.zip
Getfile and Sendfile 1.01 beta Windows 9x/ME executables:

filetransfer-101beta-bin-win9x.zip

Getfile and Sendfile 1.01 beta Windows NT/2000/XP/Vista executables (needs DlPortIO driver): filetransfer-101beta-bin.zip
Getfile and Sendfile 1.01beta source code package: filetransfer-101beta-src.zip
9845 Utilities for 9845 disc image (hpi file): 9845utilities-9845-10-hpi.zip
9845 Utilities for 9845 BASIC listings: 9845utilities-9845-10-listings.zip

This first beta version may still have a couple of bugs. Please use the contact feature to let me know if something doesn't work as expected.

The DlPortIO driver package cane be downloaded here.

Please note that the utilities which are intended for execution on the 9845 side generally include binary programs which are not covered by the BASIC source code listings. So please execute the programs from the disc image and do not load the BASIC listings for execution.