WAV-PRG 2.1 
By Fabrizio Gennari, 1998, 1999

This programs runs on Windows 95 or NT. It does two things:
- converts WAV or TAP files containing samples of Commodore 64 tape files to PC in
emulator-readable format (.PRG, .P00 or .T64), so they can be played with PC
emulators. In order to recognize different file formats, WAV-PRG uses a plug-in
architecture: each plug-in recognizes a different file format.Plug-ins for
Turbo Tape 64, kernel loader (the "slow" loader built-in in C64 ROM) and Zzap!
Megatapes are included, but plug-ins for many other formats can be written.
In order to be used by WAV-PRG, the plug-ins must be copied in the plugins
sub-directory.
- converts programs from .PRG, .P00 and .T64 files to WAV files, which can be
recorded on a tape and loaded on a Commodore 64 as Turbo Tape 64 files.

Let's see how to do this.

1. CONVERTING FROM C64 TO PC
This is done in three steps.

1.1 SAMPLING THE TAPE

1.1.1 Sampling to a WAV file
For this you need:
- a sound card
- a tape player
- a cable connecting the output of your tape player (e.g., the headphone jack
socket) to the input of your sound card (on a SoundBlaster, this is a jack
socket marked as LINE IN)
- a sampling program (e.g. WaveStudio, bundled with any SoundBlaster, or Goldwave)

First of all, connect the tape player to the sound card. You should hear the
sounds emitted by the player from the speakers of your sound card. Set the
volume of your player to a reasonably high level (half the maximum should be
fine). Set the mixing options of your sound card so the recording level of the
external output is the highest, and the other recording sources are disabled
(this is done using Windows' Volume Control application). Set the volume of your
computer speakers low, so you will not be made deaf by the grating sound coming
from the tape. Now, run the sampling program amd set the recording options as it
follows: Sampling frequency: 44100 Hz Sample size: 8 bits Format: PCM
uncompressed, mono WAV-PRG will not recognize files in a different format than
this. Now, sample the file and save it in WAV format. Some sound programs (e.g.
Goldwave or CoolEdit) show the waveforms in WAV files: if you can see a nice
sinusoidal waveform of reasonable amplitude, everything should work.

1.1.2 Sampling to a TAP file
This is more difficult. One way is to convert to WAV first, using the above procedure, then converting the WAV to VOC and using 64VOCTAP (http://cia.c64.org/tools/ 64util05.zip) to create a TAP. Another way is to connect the datassette to your PC's parallel port and use mtap (http://arnold.c64.org/~minstrel).

1.2 CONVERTING THE FILE
This is what WAV-PRG does. Run WAV-PRG and select the page "From C64 to PC".
Now look for your file and click on its name. If it is not a WAV
file, the message "This is not a wave file" should appear. If it is a WAV file,
but the format is not as mentioned before (44100 Hz, 8 bits, PCM mono), the
message "The format of this wave file differs from the required one" should
appear. If the file is recognized, the message "This is a convertable file" will
appear. Choose the format you want to converted to (.PRG, .P00 or .T64). If you
choose .T64, you must type the .T64 file name and, optionally, the T64 internal
name in the respective boxes. Choose the plug-in according to the original file
format. If your sound card inverts waveforms, tick the "Inverted waveform" box.
Now, press OK. Some plug-ins could ask for the start and/or the end addresses.
The conversion process will start, and information messages will
appear in a box. The WAV file will be scanned, and for each C64 file found in it,
a .PRG or .P00 file or an entry in the T64 will be created. If the chosen
format is .PRG, its name will be the same as on the C64 (if it is not unique, a
postfix will be appended) with the .PRG extension added. If it is .P00, the C64
name will be shrunk to 8 characters using the PC64 rules, and an extension
ranging from .P00 to .P99 will be appended.

What if nothing is recognized? A number of causes can be behind this:
- your sound card inverts waveforms. If this is true, toggle the "Inverted
waveform" box and try again.
- the file cannot be loaded with the chosen plug-in because the formats are 
different. Try using a different plug-in
- the header (the initial part) is corrupted or recorded at a too high or too 
low volume: try sampling the file again, adjusting the volume of your player, 
and retry.

At the end of the conversion, the message "The file <WAV filename>
unexpectedly ended while converting" could appear: either the final part of the
tape was not sampled, or the recording quality was low. In the first case, try
sampling for a longer time, in the second case, try adjusting the volume of your
player, or regenerating the signal.

1.3 PLAYING THE GAME
You need a C64 emulator for this. All the most popular emulators should
recognize all or some of the formats supported by WAV-PRG (CCS64 and VICE do, PC64
does .P00, C64S does .T64).

2. CONVERTING FROM PC TO C64
This too is done in three steps.

2.1 CREATING THE .WAV FILE
This is done by WAV-PRG. Just select the page "From PC to C64" and choose if
you want to generate an inverted waveform (if your C64 does not load the game
if the box is unchecked, try again with the box checked). Choose if you want to generate a Turbo Tape file alone (you wil need Turbo Tape 64 or another suitable loader to load it on your C64) or create a loader (this will be prepended to the Turbo Tape file, so you won't need to load Turbo Tape 64). Now look for the
file you want to convert and click on its name. If it is a valid .PRG or .P00
file, you will see the message "This is a convertable file" followed by the
start and end addresses (the former is 2049 in 99% cases, the latter should
never exceed 65536) and, in the case of .P00, the C64 filename. To convert these
files, click on OK. If it is a valid .T64 file, WAV-PRG will show the number of
total and used entries in that file. Click on OK, and the T64 dialog box
appears: for each entry, the start and end addresses and the offset inside the
T64 file are shown. Click on an entry and press OK. Now another dialog box is
shown. Type the filename you want to appear when loading the game on the C64
(next to FOUND). If a file with the name filename.WAV already exists, a window
allows you to choose whether to overwrite it or keep it. Then, the .WAV file
will be written.

2.2 RECORDING THE .WAV FILE ON A TAPE
You need:
- a sound card
- a tape recorder with a sound input (generally marked with AUX, CD or PHONO)
- a suitable cable
- a program which allows you to play .WAV files
Connect the input of your recorder to the output of your sound card (on a
SoundBlaster, there are two outputs, LINE OUT and SPK OUT: the latter is better
because of the louder output). Now you should hear the sounds emitted by the
sound card from the speakers of your tape recorder. Set the output volume of the
sound card as high as possible, disable all the sound sources but the Wave
output, keep the output volume of your tape recorder low (the .WAV files created
by WAV-PRG aren't nice to be heard), press RECORD on the recorder and play the
.WAV file.

2.3 PLAYING THE GAME

2.3.1 Stand-alone files
If the box "Create a loader" was checked, a stand-alone file has been created. To load these files, you will just need to load the game with SHIFT+RUN STOP.

To disable the autostart feature, just load the game with LOAD (not SHIFT+RUN STOP) and, at the READY. prompt, type
POKE2191,13
RUN

2.3.2 Files that need Turbo Tape 64
If the box "Create a loader" was not checked, you will need to use Turbo Tape 64 (it can be downloaded at WAV-PRG's homepage). Load it, then load the game with
(left arrow)L.

Some games interfere with Turbo Tape 64 (e.g. the ones from the Blast from the
Past disks): to get around this, load the game, type
POKE 50001,228
POKE 50006,167
SYS50000
then RUN as usual.

If the end address exceeds 40960, a fake ?LOAD  ERROR message appears, but the
game should run fine. If it still doesn't, you have two alternatives:
- load the game, type POKE 46,<end-address>/256 POKE 45,<end-address>-PEEK(46)*256
then RUN as usual.
- load Turbo Tape, then, before loading the game, turn off the fake message by typing
POKE 50566,234
POKE 50567,234

If the end address exceeds 50400, the program which is being loaded overwrites
the loader, and the C64 will crash. You will need to use Loader Generator
(downloadable at WAV-PRG's homepage).

3. DISCLAIMER
This program comes with NO WARRANTY whatsoever. The programmer
cannot be held responsible for any damages caused by the use of this program.
Use it at your own risk.

4. DISTRIBUTION
This program is freeware. You can use it without paying any fee, and
redistribute it as you like. Just do not charge anything for it, and do not
modify it without asking the author first.

5. HISTORY

1.0 (29th July, 1998)

First release.

1.1 (14th January, 1999)

Additions:
- Added support for .P00 and .T64 files when converting to C64.
- Added support for .P00 when converting to PC.

Refinements:
- When a new window is shown, other windows are disabled.
- Some minor graphical enhancements have been made.

Bug fixes:
- Sometimes, the message "An error occurred while opening this file" was not shown.
- A bug which caused .WAV files to be read sometimes incorrectly (the Turbo
Tape header could not be found even if it was present) has been fixed.

2.0 (6th November, 1999)

Additions:
- Plug-in architecture, which allows to converts many file formats
- Added support for .T64 files when converting to PC
- Ability to invert waveforms when converting to C64

Refinements:
- The program can (should) be fully useable with keys only now.
- Some WAV files not conforming to the RIFF-WAVE standard (e.g. the ones
created by Windows' Sound Recorder) are now recognized as valid

2.1 (5th December, 1999)

Additions
- Conversions C64->PC can be done from TAP files as well as WAV files
- When converting from PC to C64, a stand-alone file can be created, which does not need Turbo Tape 64.

Bugfixes
- A bug which forbid T64s to be converted to WAV (a box "Range check error" appeared) has been fixed.

6. LATEST VERSION
The latest version of the program is available at
http://www.geocities.Com/SiliconValley/Platform/8224/wavprg.html .

7. KNOWN BUGS
None.

8. UNKNOWN BUGS
Loads :)

9. CREDITS
Written by Fabrizio Gennari.
This program uses algorithms developed by Janne Veli Kujala and Wolfgang Lorenz.

10. CONTACTING THE AUTHOR
If you have suggestions, bug reports etc., you can send
mail to the author at: fabrizio.ge@tiscalinet.it

Enjoy!