As previously threatened in the "Encoding of BASIC source code on punched tape"
topic, I'm working on a Python utility for manipulating paper tape images. It will be
a refactor of my previous silly paper tape renderer that I had written in C++, with added
features for the manipulations I've recently found necessary since I've become
interested in retrocomputing.
I haven't determined how I'll specify interactions with actual tape punch/reader
hardware like my GNT 4604 yet, but here is the "--help" output to show how I
anticipate the user will interact with the utility to perform useful manipulations of
paper tape images. I'd appreciate some input about what features are missing to make
it helpful with tape formats and systems that I'm not familiar with yet.
For example, I haven't yet included a feature to handle sequences like
CR-XOFF-DEL-DEL, but I have a place-holder feature to pad each CR-LF with two DEL chars. I
haven't decided the best way to cleanly handle various line-ending translations yet,
to be generally useful without being too arcane or cumbersome.
This will be written in Python, will be open-source, and will include modules and classes
to make it (hopefully) easy to re-use the code for special purposes that I didn't
implement in the command-line utility.
While the main focus here would be on 8-bit ASCII tapes, I'm also including some
support for 5-bit Baudot tape handling due to my interest in RTTY (radio teletype).
-------- 8< cut here 8< --------
...src/papertape% ./tapeutil.py --help
usage: tapeutil.py [-h] [--clear] [--load FILENAME] [--append FILENAME]
[--save FILENAME] [--hexdump] [--trim]
[--add_leader INCHES] [--add_trailer INCHES] [--strip_nul]
[--strip_del] [--set_msb] [--clear_msb] [--pad_crlf]
[--title TITLE] [--rot_title TITLE] [--ascii2baudot]
[--baudot2ascii] [--render_ascii WIDTH]
[--render_pbm WIDTH FILENAME]
Punched paper tape image utility version 2.0.0-ALPHA
Arguments are processed in the order encountered, with cumulative effects
upon the tape image buffer. The tape image buffer is discarded at program
exit, so the final argument should generally be one which outputs the
buffer to a file, the screen, or a tape punch. Arguments may be abbreviated.
optional arguments:
-h, --help show this help message and exit
--clear Clear the tape image buffer.
--load FILENAME Load tape image buffer from file, replacing previous
buffer contents.
--append FILENAME Load tape image buffer from file, appending to
previous buffer contents.
--save FILENAME Save tape image buffer to file.
--hexdump Print a hex dump to stdout. Most significant bit (bit
number ) will be ignored for the ASCII representation.
--trim Trim leader and trailer of NUL chars from buffer.
--add_leader INCHES Add NUL leader to buffer.
--add_trailer INCHES Add NUL trailer to buffer.
--strip_nul Remove all NUL chars from buffer.
--strip_del Remove all DEL chars from buffer.
--set_msb Set most significant bit (bit number 7) of all chars
in buffer.
--clear_msb Clear most significant bit (bit number 7) of all chars
in buffer.
--pad_crlf Add two DEL chars after each CR-LF sequence in buffer.
--title TITLE Add human-readable title to beginning of buffer, using
a font composed of 5x7 punched hole patterns.
--rot_title TITLE Add human-readable title to beginning of buffer, using
a font composed of 5x7 punched hole patterns. Rotate
the letters for use on a 5-bit tape.
--ascii2baudot Translate entire buffer from ASCII to Baudot coding.
--baudot2ascii Translate entire buffer from Baudot to ASCII coding.
--render_ascii WIDTH Create an ASCII art rendering of a punched tape, in a
style similar to the bcd(1) program. WIDTH specifies
the tape width in bits, and must be 5 or 8. Rendering
will be printed to stdout. Leading edge of tape will
be at top.
--render_pbm WIDTH FILENAME
Create a rendering of a punched tape in Portable
Bitmap (.pbm) format, with each pixel representing
0.01 inches. WIDTH specifies the tape width in bits,
and must be 5 or 8. Leading edge of tape will be at
top.
Example:
tapeutil.py --load myfile.txt --pad_crlf --set_msb \
--add_leader 2 --title "MY TAPE" \
--add_leader 5 --add_trailer 5 --save myfile.tap
--
Mark J. Blair, NF6X <nf6x at nf6x.net>
http://www.nf6x.net/