Data Transfer from APPLE2 Game Port to RS232

UP

 
At the end of the last century, I decided to take backup copies of all data I had piled up before, except the WANG 600 punch cards. Thus I switched on both my old APPLE2 computer and the Atari ST1040, which, to my surprise, both did work without the slightest problem. For the Atari ST1040, the backup was done quite easy by attaching the 80MB SCSI harddisk to a Linux driven i486 machine and ripping the disk via dd(1), cutting out the partitions, and mounting them as loopback devices.

For the APPLE2, things are different: There is no way to attach a harddisk to it, so data may be transferred to somewhere else either on floppy disk or by wire.

Floppy disks are formatted by the APPLE2 using a direct magnetising scheme (NRZ-C, I guess) with a 6+2 bit encoding scheme performed in software (the assembler routine can be found in the 256 byte boot ROM), and there is no way to read them with an IBM compatible PC, because its floppy controller hardware does implicit MFM decoding. The disks might be readable on an Amiga System, that does the decoding stuff via software, but I couldn't get hold of one. See "Horst Völz: Informationsspeicher, Grundlagen - Funktionen - Geräte; expert verlag, ISBN 3-8169-1287-7; p. 90" for details on magnetising schemes.

So I tried to get it transferred by wire. I got no serial card for the APPLE2, thus I connected the wire to the game port and wrote me a tiny driver and program to get the data transmitted over it: GND to pin 8, and the data line (i.e. TX) to pin 12, annunciator number 3.

Handshake is not needed, as the data was received by a 500 MHz Linux machine, that was otherwise idle. The result may be checked to be a multiple of 256 bytes, the APPLE2 disc sector size.

circuit diagram
To send data, I wrote a serial driver assembler routine and a simple UCSD pascal program. The driver routine takes three parameters, the anunciator port number (which shall be 3), the timing delay (which is 55 for 9600 baud), and the byte to send (8 bit character). It just sends that one byte and returns, so the effective transfer rate is much less than 9600 baud, because a long time passes from one call of the routine to the next.
The pascal program is used to transfer a full disc image via serial line. When run, it asks for the disc unit number (which is 4 for the first and 5 for the second floppy drive), for the first and last block to transfer (which is 0 and 559 for a standard 35 track disc, 16 blocks per track), for the port number (3), and for the speed delay (55).
Before starting the transfer, there is of course a receiver needed, so there is a Unix shell script called apple2tty.sh, which simply sets the first serial device to raw mode and then reads from it. Its output is to be redirected to a file, the disc image file.

When all the transfer is done, there is one thing to do left: Extract the single files from the disc image file. Linux did not provide one, so I wrote an APPLE2 filesystem driver. Alternatively, there is another small program: appledisk2file.c, which extracts all files from the disc image and saves them in the current path.

Please find here a collection of all the special programs mentioned above and information needed.