A quick tape question

Basic and Machine Language

Moderator: Moderators

Post Reply
Iltanen
Vic 20 Devotee
Posts: 200
Joined: Tue Jul 17, 2007 6:08 pm

A quick tape question

Post by Iltanen »

Does anyone have a great idea about how to read a tape byty by byte into the VIC's memory? (and write to tape similarly). Just any random bytes from the tape. I'm trying to rescue some old programs but I haven't found a method that wouldn't kill me with frustration.. maybe there isn't one, but at least it could make things easier

I don't exactly understand what is the purpose of all those tape-related memory locations in the Reference Guide. "Tape timing constants" - what does that do?? There are other confusing ones to me too.
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Post by nippur72 »

First you need to know that bits on the tape are encoded as pulse width modulation, meaning that bit 0 is a pulse with a certain duration and bit 1 is a pulse 3 times long. Reading bits and assembling them into bytes is a quite complex task involving VIC timers to precisely count the duration of a single pulse.

If you goal is rescuing a tape, then you might sample it with PC's soundcard into a .wav file and then convert into a .TAP file.

A .tap file is a raw image of pulses and their durations as seen by the datasette reading head. Tap files can be feed into VICE emulator in place of real tapes.

Try different tape recordings, with different filtering, stereo/mono and so on. Keep also in mind that a standard vic-20 tape recording is repeated twice for checking purposes (?load error) so you might want to rescue the second image of the saved program.
Iltanen
Vic 20 Devotee
Posts: 200
Joined: Tue Jul 17, 2007 6:08 pm

Post by Iltanen »

Repeated twice? That's very interesting. So does it record each bit twice or how is it done?
So, reading tape byte by byte isn't that easy after all?
carlsson
Class of '6502
Posts: 5516
Joined: Wed Mar 10, 2004 1:41 am

Post by carlsson »

The program is stored in its entirety, followed by a hopefully identical copy. What Nippur suggests is some custom loader routine that ignores either the first or second half of the program, and you get a program loaded that you can't determine if it contains load errors or not.
Anders Carlsson

Image Image Image Image Image
Iltanen
Vic 20 Devotee
Posts: 200
Joined: Tue Jul 17, 2007 6:08 pm

Post by Iltanen »

Now I get it, thanks. The program might however be stored with an own loader, without saving it twice.. I have managed to load it with many minor errors when running, but haven't got a load error
Iltanen
Vic 20 Devotee
Posts: 200
Joined: Tue Jul 17, 2007 6:08 pm

Post by Iltanen »

If anyone's interested, I found this:

"Each byte of data or program is encoded by the operating system using pulses of three distinct audio frequencies, these are long pulses with a frequency of 1488 Hz, medium pulses at 1953 Hz and short pulses at 2840 Hz. All these pulses are square waves with a mark space ratio of 1:1, one cycle os a medium frequency is 256 microseconds in the high state and 256 microseconds in the low state. The operating system takes 8.96 milliseconds to record a byte of data consisting of the eight data bits, a word marker bit and an odd parity bit. The data bits are either ones or zeros and are encoded by a sequence of medium and short pulses: a "1" is one cycle of a medium lenght pulse followed by one cycle of a short lenght pulse and "0" is one cycle of a short lenght pulse followed by one cycle of a medium lenght pulse. Each bit consists of two square wave pulse cycles, one short and one medium with a total duration of 864 microseconds."

That was from "VIC Revealed" by Nick Hampshire, a book I got yesterday.
bokvamme
Vic 20 Afficionado
Posts: 311
Joined: Tue Dec 26, 2006 11:22 am

Post by bokvamme »

Check out this for info on tape pulses and loaders:
http://c64tapes.org/dokuwiki/doku.php?i ... a_encoding
Post Reply