Building a tape image with several files / parts ?

You need an actual VIC.

Moderator: Moderators

Post Reply
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Building a tape image with several files / parts ?

Post by AndyH »

I am trying to create a tape image that is made up of three files. The first would be a small loader program (a little bit of machine code) that would then load in part 2 at a memory address. Later, I would load in part 3 at a memory address.

I want to create a single TAP image that conatins: Loader -- Part 2 -- Part 3

Loader, Part 2 and Part 3 are currently PRG files.

I've found loads of tools that let you do things with tape but so far none that will let me do what I need, they mostly focus on single PRG's or extraction and cleaning up. Can anyone recommend a tool for Windows that would let me build up a tape file from three prgs?
--
AndyH
HEWCO | Vic 20 blog
User avatar
srowe
Vic 20 Scientist
Posts: 1340
Joined: Mon Jun 16, 2014 3:19 pm

Re: Building a tape image with several files / parts ?

Post by srowe »

I've been experimenting with Python scripts to extract files from .tap files. Doing the reverse shouldn't be that hard.
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: Building a tape image with several files / parts ?

Post by nippur72 »

If it's a one-time only, you can put them to disk (.D64) and then save to tape one the VICE emulator and then get the .tap file.

If you want to a generic concatenation tool, I'm afraid you have to write your own. It's not that difficult, .TAP files have a small and simple header, you can skip the headers, join the three data blocks and then build a new header. See here
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Building a tape image with several files / parts ?

Post by AndyH »

Thanks both!

Nippur72 - after that header comes the file data, but I'm not sure what it is saying. There's an explanation of each version $00 or $01 but how do you determine what to actually write to the file?

ie:

Code: Select all

 Therefore, a data value of $2F (47 in decimal) would be:

    (47 * 8) / 985248 = .00038975 seconds.
So my byte of data is 47, what do I need to write into the TAP file to represent it?
--
AndyH
HEWCO | Vic 20 blog
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Building a tape image with several files / parts ?

Post by AndyH »

Another approach I have tried is to save from the VICE monitor. I can save to device 0 to save a block of memory to my Windows file system and that works, but swap out for device 1 and I get the Cannot open error:

(C:$a34e) s "P2" 1 a000 bfff
Cannot open P2.

This is with a newly created TAP image created and attached via VICE.
--
AndyH
HEWCO | Vic 20 blog
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: Building a tape image with several files / parts ?

Post by nippur72 »

AndyH wrote: Wed Jul 22, 2020 5:48 am So my byte of data is 47, what do I need to write into the TAP file to represent it?
Ok I think I have misunderstood your original question, I thought you had 3 .TAP files and wanted to make a single one.

If you instead have three data files (e.g. normal bytes) and want to create a TAP file, then the process is a lot more complex.

Every byte has to be split into bits, and every bit turn into pulses of various lengths. What you actually write on the output file is the length of each single pulse. It's not difficult, only tedious. But you have to strictly adhere to the protocol otherwise your file won't load. I suggest you to generate the .TAP files with one of the existing tools and then concatenate them.
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Building a tape image with several files / parts ?

Post by AndyH »

Understood, and yes I was wondering about that when reading about the pulses.

Some success ... with WAV-PRG and AudioTap I can convert to various formats including TAP. So I can construct the header and copy raw data for each converted PRG. Examining the data in a hex editor I can see the corresponding patterns.

Perhaps making it easier (in a way) is this tool supports export/import to WAV sound files, so just a case of splicing three WAV files together, before converting back to a long TAP file.

Conversion to WAV and back to TAP is working, so just need to test my code to see if it all works together.
--
AndyH
HEWCO | Vic 20 blog
User avatar
Mike
Herr VC
Posts: 4841
Joined: Wed Dec 01, 2004 1:57 pm
Location: Munich, Germany
Occupation: electrical engineer

Re: Building a tape image with several files / parts ?

Post by Mike »

Building a multi-file tape can be done with the native tool set. In VICE, attach both a source *.d64 and an empty target *.tap file and then run the following small program:

Code: Select all

10 READN$
11 IFN$=""THENEND
12 OPEN2,8,0,N$
13 GET#2,A$,B$
14 CLOSE2:PRINTN$
15 S0=ASC(A$+CHR$(0))
16 S1=ASC(B$+CHR$(0))
17 SYS57809(N$),8,1
18 POKE780,0:SYS65493
19 E0=PEEK(781)
20 E1=PEEK(782)
21 SYS57809(N$),1,0
22 POKE193,S0
23 POKE194,S1
24 POKE780,193
25 POKE781,E0
26 POKE782,E1
27 SYS65496:GOTO10
28 :
29 DATA "FILE1"
30 DATA "FILE2"
31 DATA "FILE3"
32 DATA ""
Replace the file names in the DATA lines as appropriate. The program (plus its variables) need to run in a place that's not used by the data being transferred from disk to tape. If, for example, BLK5 is spare, issue the following POKEs to relocate the BASIC workspace to BLK5:

POKE43,1:POKE44,160:POKE40960,0:POKE55,0:POKE56,192:NEW

After the first file has been loaded from disk, you'll be prompted to PRESS RECORD & PLAY ON TAPE. From then, all files will continuously be written into the *.tap file.


Note: this program only works for PRG files (i.e. memory dumps in the farthest sense). Tape SEQ files are recorded in another format and need a different handling.
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Building a tape image with several files / parts ?

Post by AndyH »

WOW thanks Mike.

This looks perfect. As I will be making a disk version also (and that part is easy), this will speed things up somewhat. My files are all prg's (or prg-like).

I've just been testing my loader with part 2 coming from tape so will be ready to put the two together.
--
AndyH
HEWCO | Vic 20 blog
nippur72
de Lagash
Posts: 574
Joined: Thu Sep 07, 2006 8:35 am

Re: Building a tape image with several files / parts ?

Post by nippur72 »

Mike's code is pure wizardry :o
User avatar
orion70
VICtalian
Posts: 4341
Joined: Thu Feb 02, 2006 4:45 am
Location: Piacenza, Italy
Occupation: Biologist

Re: Building a tape image with several files / parts ?

Post by orion70 »

This guy never ceases to amaze! :D
User avatar
AndyH
Vic 20 Afficionado
Posts: 364
Joined: Thu Jun 17, 2004 5:51 am
Website: https://www.hewco.uk
Location: UK
Occupation: Developer

Re: Building a tape image with several files / parts ?

Post by AndyH »

The above would be a great topic for the Denial Journal.
--
AndyH
HEWCO | Vic 20 blog
Post Reply