                         CBM Tape Tools v1.01

                              Written by

                            Richard Storer

Introduction 
-------------

Back in 1995 I came across a really cool program in a computer magazine.
This was a Commodore 64 emulator for the PC called C64S.
I tried it out and found it really impressive with sound emulation and
graphics just like my trusty old C64.
Well I simply couldn't wait to transfer some of my most loved programs and
games but there was a small problem. The version of C64S I had was shareware
and the tape transfer program wasn't included.
I looked endlessly on the World Wide Web to see if anyone had written a
program which could convert my tapes.
My searching came to nothing so I decided that I would write my own loader
and a saver program as well.
 
You should have the following files:

C64LOAD.EXE  - tape loader 
C64SAVE.EXE  - tape saver
README.TXT   - this text
TAPEFORM.TXT - information about CBM and Turbo Tape encoding formats.

CBM Tape Tools is freeware software. You may copy it and distribute
it providing none of the files have been modified or removed. 


Disclaimer
-----------
 
Please note that there is NO WARRANTY of any sort. Under no circumstances
should I the author be held responsible for any damages or loss of data 
or damage to hardware resulting from use of any program or information 
provided.


Adapter instructions
---------------------
 
C64LOAD and C64SAVE both require the following tape adapter to be connected
between your parallel printer port and the Datassette. If you do not wish to
build the C64S tape adapter then order one from the C64S web site (see links).
A sound card can be used for handling WAV files if you do not wish to use the
C64S tape adapter method.
 
C64S TAPE ADAPTER           (Use MS-DOS EDIT to view this diagram)

 TAPE CONNECTOR                     LPT PINS                 POWER SUPPLY
    
 
 ___________GND       (pin 18-19-20-21-22-23-24-25)       ( 0v )
 ___________+5v                                           (+5v )
 Ŀ             
        
 _______|___MOTOR(+5v)
 ___________READ              (pin 10)
 ___________WRITE             (pin 3)
 ___________SENSE             (pin 12)
 

IBM LPT connector male back view (solder side)
   ______________________________
   \ 13 . . . . . . . . . . . 1 /
    \ 25. . . . . . . . . . 14 /
     \________________________/

The LPT port doesn't supply +5V, you can get it from the game port
(+5V directly from the motherboard) or you could use a 4.5V battery.
A +5V regulated voltage supply based on the LM7805 IC maybe used.


Hardware/software requirements
-------------------------------

386DX40 or faster CPU
DOS 3.1 or higher

C64LOAD will work under Windows 3.x and Windows 95 although it
is advisable to run from MS-DOS mode if using the C64S tape adapter.

C64SAVE needs to run from MS-DOS mode if using the C64S tape adapter.

To access MS-DOS mode from Windows 95 do the following:
click on "Start", "Shut Down", "Restart the computer in MS-DOS mode ?"
 

Using C64LOAD
--------------

C64LOAD allows you to load programs and games from the Datassette using
the C64S tape adapter or from WAV sample files and TAP files.
This program only supports loading for normal C64 programs and does not
support loading from Turbo Tape files for reasons later explained.
C64LOAD is also a CBM compatible loader and can load programs from other
Commodore machines such as the PET 3032 and VIC20.

Usage: C64LOAD filename [speed | -m | -a] -i[1,2,3,w,t] inputfile
   or: C64LOAD [-pc | -v | -m speed] -i[1,2,3,w,t] inputfile

Before you run C64LOAD make sure you select the correct file format.
This would depend on which emulator you use.

C64LOAD supports the following formats:

1) T64 - C64S tape image file  -  create / append only 1 - 99 entries
2) P00 - PC64 program file
3) PRG - CBM program file
4) RAW - RAW dump file  -  useful for extracting any CBM data.

The file format is automatically selected by the filename extension given.
If none of the above file extensions were used then the PRG format is assumed.

Next you have to calibrate the loader using one of three options:

1) automatic   ( -a )
2) manual      ( -m )
3) speed value ( 1 to 100 )

With automatic calibration C64LOAD adjusts the tape timing accordingly to the
signals recorded on tape for each program file.
If C64LOAD fails to load anything this maybe because of poor quality tapes or
bad recordings.
If this is the case then manual calibration would be needed.

To load programs to a file called games.t64 with automatic calibration type,

C64LOAD games.t64 -a

To load with manual calibration type,

C64LOAD games.t64 -m

With manual calibration you will be presented with the message
"PRESS PLAY ON TAPE" and a red border.
Making sure you have the correct position, press the PLAY button.
When there is incoming data the border will flash red and dark red.
You will also see four red bars displayed with three white lines somewhere
in between. The white lines represent the data and the red lines define the
data boundary. Using the left and right cursor keys, try and position the red
bars evenly between the three white lines. If you can see only two white 
lines then you are looking at Turbo Tape data.
When you are satisfied that the calibration is correct, press [Esc] and
follow the on screen instructions.

To load programs to games.t64 with a speed value type,

C64LOAD -m

Use the same procedure for manual calibration. When you press [Esc] you
will be given the speed value, e.g. 58

Now type,

C64LOAD games.t64 58

If the tape adapter doesn't connect to LPT1 you need to use the -i option.

-i1 = LPT1 
-i2 = LPT2
-i3 = LPT3 

e.g. C64LOAD game.prg -a -i2

C64LOAD can load programs from WAV sample files.

Please read the section "Creating WAV files" if you are unsure on how to
make WAV files.

WAV files need to be PCM 8-bit mono at 22.050 kHz - 44.1kHz sample rate, 
preferably 44.1 kHz for better results.

To convert WAV files to T64 files type,

C64LOAD c:\games.t64 -a -iw wavfile.wav

or

C64LOAD c:\games.t64 -m -iw

With the -m option you will be presented with the same screen used for 
tape calibration.
When there is incoming data you should see 1 and then 3 white lines.
If this is not the case then maybe the signal polarity is wrong. 
Use the Numeric Pad [-] and [+] to change signal polarity.
When you have the 3 white lines and you have positioned the red lines
accordingly then press [Esc] and follow the on screen instructions.

If you experience errors with automatic calibration then try using
manual calibration instead.

C64LOAD can load programs from TAP files.

To convert TAP files to T64 files type,

C64LOAD c:\games.t64 -a -it tapfile.tap

or

C64LOAD c:\games.t64 -m -it

C64LOAD has a "-v" option which allows you to view data onto the screen.
This maybe useful if you are having problems loading from the Datassette
or if you just want to check how your WAV or TAP data looks.

To view data type,

C64LOAD -v -i2           - (view Datassette data on LPT2)

or

C64LOAD -v -iw c:\wavfile.wav          -  (view WAV data)

To abort C64LOAD press [Esc] or press [Ctrl]+[Break] if you have a ? prompt.
The -pc option allows you send data from the Datassette to the PC speaker.


Creating WAV files
-------------------

To create WAV files you will need a WAV recording program which can record 
with unlimited time.
Usually you will find that most sound cards come bundled with media software
including a WAV recorder. If you don't have any then you need to download one
from the Internet.
There are several good shareware programs available such as Cool Edit and 
GoldWave which would be suitable for this job. (see links for details)

Firstly you need to connect your tape player, e.g. a Personal Stereo, to
the "Line" input of your sound card with an appropriate cable.
Next you have to setup the volume level for recording, either with your WAV
recording program or the mixer program provided with your sound card software.
Select the recording source to  Line-In / Aux  only, and set the recording
level to maximum. 
If your tape player has tone controls or a graphic equalizer then select
midway for all settings.
Next you need to run Microsoft's Sound Recorder which will help setup the
correct signal level from the tape player.
Insert your Commodore tape into your tape player, start your tape player
and when there are audible tones, click on the red recording button to start.
If all goes well you should see green patterns inside a small black window.
This shows the incoming tape data and while you watch adjust the volume level
so that the points on the green patterns top and bottom are almost touching 
the edges of the window. 
When you have set the correct volume level quit Sound Recorder and run your 
preferred WAV recording program.

Make sure your WAV files are saved with the following format,
PCM 8-bit mono at 22.050 kHz - 44.1 kHz sample rate, preferably 44.1 kHz 
for better results.


Using C64SAVE
--------------

C64SAVE allows you to save programs to the Datassette using the
C64S tape adapter or to WAV sample files and TAP files.
 
Usage: C64SAVE filename -pc | -o[1,2,3,w,t] outputfile

C64SAVE supports the following file formats:

1) T64 - C64S tape image file
2) P00 - PC64 program file
3) PRG - CBM program file

To save a program type,

C64SAVE games.t64

The -pc option allows you to record and also send data to the PC speaker.

If the tape adapter doesn't connect to LPT1 you need to use the -o option.
 
-o1 = LPT1
-o2 = LPT2
-o3 = LPT3 

e.g.  C64SAVE games.t64 -pc -o2

C64SAVE can save program files to WAV files.

e.g.  C64SAVE game.prg -ow c:\game.wav

You will be asked,

Change signal polarity (Y/N) ?

The signal polarity depends on how the signals are recorded to tape and this
would vary from recorder to recorder. The only way to find out which option
to choose is to try both ways and see which one the Commodore will load.
There can only be one way the signals are recorded and loaded.
Make sure the signal levels from your sound card are approximately the same
loudness as your tape deck when playing an original Commodore tape.
Also use either the left or right channel for recording or use both unless
you are sure the head alignment of the tape deck matches the Datassette.

Speed adjustment +/-10 ?

With some tape decks the recording speed may differ slightly from the 
recording speed of the Datassette.
Enter a number 1 to 10 to increase speed or -1 to -10 to decrease speed.
 
C64SAVE can save program files to TAP files.

e.g.  C64SAVE game.prg -ot c:\game.tap

When you have selected the program you want for writing to tape you have
the opportunity to make changes to certain settings.
This includes: filename, load address and signal encoding.
The default signal encoding is set to the C64. If you want to save files to
a different machine e.g. VIC20 with Turbo Tape VIC encoding then this option
needs selecting.
 
C64SAVE supports the following encoding:
 
- C64
- TURBO TAPE 64 - handles ($0400 - $CFFF)
- VIC20  
- TURBO TAPE VIC
- PET
- C16/+4

The coding and format for Turbo Tape 64 and Turbo Tape VIC both originated
from the COMPUTE! Gazette July 85. (see web links)

To abort C64SAVE press [Esc] or press [Ctrl]+[Break] if you have a ? prompt.


Questions and answers
----------------------

Q: Why doesn't C64LOAD support Turbo Tape files ?

A: Turbo Tape is not a CBM standard format but a method of saving and
   loading games by representing 0's and 1's of binary data using different
   pulse signals to that of the normal format. This has the advantage of
   large increases in loading speed, but this requires a small custom
   written machine code loader for it to work. Different software companies
   used different Turbo Tape routines and different pulse signals. Because of
   this fact it is almost impossible to decode them all as they are not
   compatible.
   However, with the TAP file format it is possible to use Turbo Tape games
   with emulators that support it. C64LOAD doesn't create TAP files but
   there are several tools available which do. (see links for details)

Q: Why can't I run C64LOAD and C64SAVE reliably under Windows ?

A: Windows is a multitasking operating system and because of this fact CPU
   usage has to be shared between other running applications which makes it
   difficult for accurate timing.
   C64LOAD maybe able to work under Windows 95 providing there are no other
   CPU hogging programs running in the background.
   C64SAVE however, needs to run from MS-DOS mode due to restrictions 
   imposed by Windows when using the Programmable Interval Timer chip.

Q: When I was loading my programs I had received some errors. What do the
   errors mean ?

A: There are three different types of errors you can have with C64LOAD,
   they are: read error, chksum error and comp error. 
   Read errors appear when the incoming signals occur outside the defined
   data boundary. This error usually happens if the speed value is slightly
   wrong or the tape recording quality is poor. C64LOAD tries to correct
   this and if it fails a chksum error would occur. Usually chksum errors
   doesn't mean that a byte of data is loaded wrong, but that the chksum
   evaluation doesn't match the chksum bit written to tape. If a chksum
   has proven to be incorrect then the bad bit is toggled from the byte.
   If you had received comp errors then you have some bad bytes of data.
   READ!S indicates that C64LOAD had lost byte synchronisation due to a
   serious read error from tape.

Q: I had saved some programs as P00 files. When I tried to load them from
   the PC64 emulator I had received the message "?FILE NOT FOUND ERROR".
   I know the files exist because it shows up when I check the directory.
   What's wrong, how can I load my files ?

A: When PC64 loads a file during the C64 emulation it convents the C64 16
   character filename to a PC 8 character filename and checks for this file
   on the hard drive. If this file doesn't exist then the error appears.
   One easy solution to this problem is to use wildcards * or ? when you use 
   the LOAD command.  e.g.  LOAD"MY WORK*",8   and   LOAD"MY W?RK",8

Q: I'm having problems loading from WAV files. I had followed the instructions
   given and no matter which key I press I cannot get the three white lines.

A: If you can, try adjusting the volume level and tone controls when you
   create your WAV files. Also make sure the signals you record are coming
   from the left channel. This is important because mono WAV files only use
   the left channel input and some games are recorded in the right channel.

Q: I had built / using the C64S tape adapter and for some reason C64LOAD 
   and C64SAVE think that I have pressed PLAY on tape when I have not.
   Is there a problem with my adapter or computer ?  

A: There is nothing wrong with your computer or adapter. This problem occurs
   because with some LPT ports on different motherboards there should be
   electrical current present at the input pins which changes the logic state 
   from 0 to 1. To solve this you need to modify your C64S tape adapter
   and solder on a 100K ohm resistor (brown black yellow gold) from pin 12
   of the LPT connector to the +5V supply used to power the Datassette.

Q: If I can use my sound card to create WAV files for C64LOAD, is there any
   point buying or building the C64S tape adapter ?

A: If you can obtain this adapter then yes there would be good reasons for
   using it. The Datassette is a lot more reliable than WAV files because
   it contains amplifiers, filters and pulse shape enhancing circuitry which
   provides better reading stability. This circuitry also prevents load errors
   due to drops in tape signal loudness which are caused by poor quality tapes
   or bad recordings. It is this problem with signal drops that in most cases
   will cause failures when converting from WAV files.


History of changes
-------------------

Changes from version 1.00

- Improved timing method for reading the C64S tape adapter and WAV files.
- Added Turbo Tape encoding for the C64 and VIC20.
- TAP format support for CBM data encoding and decoding.
- Added support for creating WAV files.
- Several bug fixes and coding improvements.
 

Plans for the future
---------------------

- Support for decoding C16/+4 CBM files.
- Encoding and decoding archiving Turbo Tape formats.
- Support for VOC files.
- D64 support.


Web links and useful sites
---------------------------

http://www.phs-edv.de/c64s/doc/lpt64.htm    -  C64S tape adapter information
ftp://arnold.c64.org/pub/games/                                     -  games
http://www.funet.fi/pub/cbm/transfer/                           -  utilities
http://www.funet.fi/pub/cbm/crossplatform/emulators/            -  emulators

COMPUTE! Gazette July 85 (TURBOTAPE 64 + VIC),
ftp://arnold.c64.org/pub/magazines/compute/gaz015.d64


WAV recording programs:

http://www.syntrillium.com/cooledit/ -  Cool Edit
http://www.goldwave.com/             -  GoldWave


Datassette and tape related software:

http://members.tripod.com/rstorer/c64/
http://www.funet.fi/pub/cbm/transfer/datassette/
http://arnold.c64.org/~minstrel/
http://cia.C64.org/tools/


E-mail
-------

If you have questions or comments to make mail me at,

           rstorer@cyberspace.org

