💾 Archived View for uscoffings.net › retro-computing › systems › TI994a › x99tape › x99tape_src › Re… captured on 2022-06-04 at 01:07:22.

View Raw

More Information

-=-=-=-=-=-=-

x99tape: A portable TI99 tape encoder/decoder

Version 1.0

Raphael Nabet 2002



Usage:
------

help:
	x99tape -h
encode/decode:
	x99tape [-d|-e] [-m|-f] [-r|-rNNN] [-] source1 dest1 [[[-d|-e] [-b|-m] [-r|-rNNN] [-] source2 dest2] ...]

-h: display online help message
-d: decode sampled tape into data file (default)
-e: encode data file into sampled tape
-m: decode/encode as memory dump tape (default)
-f: decode/encode as multirecord file tape
-r: use default record len for multirecord file tapes (64, 128 or 192 according to number of blocks per record)
-rNNN: specify record len for multirecord file tapes (should be in [1,192])
-: force next 2 parameters to be regarded as file names (required if either file name (or both) starts with a '-')



Examples:
---------

decode memory dump tape named 'intro.wav', and save it as a binary file in TIFILE format named 'INTRO':
	x99tape -d -m intro.wav INTRO

decode a multirecord tape with 114-byte-long records, named 'grille1.wav' and save it as a binary file in TIFILE format named 'GRILLE1':
	x99tape -d -f -r114 grille1.wav GRILLE1

encode binary files in TIFILE format into tape files:
		x99tape -e INTRO test.wav
		x99tape -e GRILLE1 grille1.wav



Description:
------------

A free, open-source and portable program that serves a double purpose:
- decoding digitized TI99 tape files into binary files that can be archived on your computer, transferred over the Internet and opened by emulators
- encoding back binary files into digitized TI99 tape files

Two similar programs already exist at the time of writing (they are named tape994a and CS1er, respectively), but these programs can only decode existing tapes (and cannot encode new ones), and they are only available on the DOS/Windows platform, which leaves users of other OS (Mac, LINUX...) in the dark.  And there is the educational aspect of the source code, too.



Purpose:
--------

This program is meant to enable users to exchange data between TI99s and modern computers.

The TI99 series of computers (namely TI99/4, TI99/4a and a few prototypes, along with a few clones) was produced by Texas Instruments from 1979 to 1983.  These computers could use a tape recorder to store data.

The method of choice to transfer data is through a serial connection: however few TI99 users own the required TI99 serial controller.  Another possibility is reading TI99 floppies on a PC drive.  However, the TI99 floppy controller is, again, an optional extension.  Moreover, it usually uses 5''1/4 disks whereas 3''1/2 drives are more common in recent PCs, and some TI99 disk controllers only support FM encoding, which is seldom supported by PC controllers nowadays (they use MFM instead).

Using the tape interface instead enables us to work around most of these problems.  On the one hand, all TI99s include a tape interface.  On the other hand, any PC with a sound input should be able to digitize a TI99 tape, whether the PC is connected directly to the TI99 computer or to a tape recorder.

The only drawbacks with the tape interface are that it is relatively slow (practical data rate of 600 bits/s), and that some files (e.g. variable-length record files) cannot be saved to tape (though it should be possible to write a TI99 program which encodes a file to a flat format and saves it to tape, so that the file can be decoded once it has been transferred to the PC).



Background concepts:
--------------------

In order to decode a tape, you need to know whether it is a memory dump tape or a multirecord file tape: this should be easy to find out by listening to the tape.

Memory dump tapes are the most common type: tapes generated by a "SAVE CS1" in TI-BASIC belong to this type.  The tape DSR can use such tapes to dump and restore any area of VDP RAM: this is the most efficient way to save data to tape.  Such tapes are made of a 4-second leader, a short header, and then a variable number (255*2 (or 256*2?) at most) of 64-byte data blocks.  Each data block includes a short leader, 64 of data, and a simple 1-byte checksum. In order to improve error detection, each data record is written twice consecutively on tape, which contributes to the rhythmic sound of TI99 tapes.

Multirecord file tapes are a bit less common: they are the kind of tape generated by an 'OPEN #N:"CS1"'.  These tapes supports sequential file I/O on fixed-len records.  In such tapes, each record is written independently, in a format identical to memory dump tapes.  That is to say, each record starts with a 4-second leader, followed by a number (1*2, 2*2 or 3*2) of data blocks.  There is a short silence before two consecutive records.  Hence, it is easy to recognize load/save tapes from sequential file tapes simply by hearing them.  Note that the ROM routines can support any logical record size from 1 to 192 bytes.  According to the record size, each logical record is written as one, two or three 64-byte data blocks (the last block is padded with 0s or spaces if the record length is not a multiple of 64).


Another issue you may need to know is that the logical length of the tape (for load/save tapes) or of the record (for sequential file tapes) is not written anywhere in the tape.  That is to say the tape or record size can only be expressed as the multiply of 64 bytes immediately greater than the logical value.

This is not an issue if you just want to store data in an efficient format, and intend to re-encode them as a tape later.  It is unlikely to be an issue, either, if you are decoding memory dump tape.

However, it will be an issue if you are decoding a multirecord tape, and intend to transfer it to a ti99/4a disk (whether it is a real floppy disk or a disk image for use with an emulator).  To do so, you need to know the record size when decoding the tape image (there would be a similar problem if you wanted to copy the file from tape to floppy on an actual ti99/4a).  To figure out the record size, you may create or find a similar file on a floppy, and look up the file record size under any decent disk manager.  Or, if the file is created under TI-BASIC, you may look for the OPEN instruction: it should include the keyword "FIXED NNN", where NNN is the record len (if either "NNN" or "FIXED NNN" is missing, the record size is 64).



Instructions for use:
---------------------

Tape file format:

x99tape uses PCM-encoded WAVE files (WAVE file with other encodings (e.g. mu-law, a-law, ADPCM...) are NOT supported).  x99tape can cope with any sample size, sample rate or number of channels (though it internally mixes multi-channel files to one monophonic source).  Any sound conversion utility and most sound recording and editing programs should be able to save files in this format.  Also, the MESS emulator can use WAVE PCM files to read and save tapes under the TI99 drivers.


Binary file format:

x99tape supports files in TIFILE format.  TIFILE format is supported by most TI99 terminal emulators.  V9T9 utils can convert TIFILE format to and from FIAD format, and can do further manipulations once the file is in FIAD format.  MESS imgtool can both extract TIFILE files from a disk image and write a TIFILE file to a disk image.


Recording data from TI99 to a wave file:

You need a computer with a sound input.  Connect your sound source (either your TI99 or a cassette player) to your computer sound input.

Launch a sound recording program.  Adjust the recording level: a high level is better, you must make sure there is NO CLIPPING.  You may use Mono, 16-bit, 44.1kHz as the recording settings: Stereo should be fine, but is a waste of valuable disk space; 8-bit should be OK and save some disk space, but requires you to adjust recording level correctly; lower bitrates (e.g. 22kHz) should still work, save some disk space, and make tape decoding by x99tape quite faster.  (As a side note, note that you will probably get better results if you record @44kHz 16-bit first and them downsample the data @22kHz 8-bit than if you record the data @22kHz 8-bit in the first place.)

Record the tape files to your computer.  You should only record one tape file per sound file, as x99tape will only decode the first tape file it finds in a sound file.  Don't worry if you did not record the first second of the tape leader, as it is not a problem.


Remember that the decoding process depends heavily on the quality of the sampled tape.  If x99tape is complaining about tape errors, you should try to record the wave file again in better conditions:


If you definitively cannot decode a tape, and you think it could be salvaged, you can write to me to ask for assistance.


Decoding/encoding wave files:

See the examples at the top of this README.


Recording data from wave file to TI99:

Connect the cassette recorder or the TI99 to the sound output of your computer.  Adjust the volume of the sound recorder: the volume should be high, but you must make sure that there is no clipping.  Run any sound player program and play the wave file.



Todo:
-----

- Rewrite error correction code.
- Support FIAD files, raw binary files, etc.
- Add raw bit-stream output to enable manual data salvage.
- Add high-pass filter.



Contacting the author:
----------------------

I can be reached at:
<pytheas@club-internet.fr>



Legalties:
----------

I have used this program myself for my own usage, and I release it in the hope that it will serve the needs of other users.  Still, I cannot make any guarantee that it will do anything useful with your setup, that it won't destroy data, or that it will not do anything harmful.  I cannot afford either to take civil responsability with any fault in this program.  You should therefore use this program at your own risk, if at all.



History:
--------

03 October 2002: Initial release (1.0)