CPCWiki forum

General Category => General Discussion - Introductions => Topic started by: woody.cool on 19:19, 04 November 09

Title: Copying 'header-less' files from tape to disc?
Post by: woody.cool on 19:19, 04 November 09
Hi all,

Is it possible (I'm assuming it is) to copy a header-less file from a tape onto a 3" (or 3.5" or whatever) disc? oh, and the program/game etc. still work?

I'm a bit of a noob at this, so you'll have to excuse the dumb questions.

If I have to find out extra information (such as starting address & length etc.) where should I look?

... and finally, if I record a 'header-less' file onto tape (or CDT etc.) can I load that file with BASIC/AMSDOS?

Cheers
woody.cool
Title: Re: Copying 'header-less' files from tape to disc?
Post by: arnoldemu on 22:45, 04 November 09
Hi all,

Is it possible (I'm assuming it is) to copy a header-less file from a tape onto a 3" (or 3.5" or whatever) disc? oh, and the program/game etc. still work?

I'm a bit of a noob at this, so you'll have to excuse the dumb questions.

If I have to find out extra information (such as starting address & length etc.) where should I look?

... and finally, if I record a 'header-less' file onto tape (or CDT etc.) can I load that file with BASIC/AMSDOS?

Cheers
woody.cool
Generally you don't get a headerless file on it's own unless it is called an "ASCII" file.
ASCII files are headerless files which can be saved from basic with OPENOUT"d", PRINT #9, CLOSEOUT.

I think you're talking about binary headerless files, and for these there is generally a loader before them which is a standard block loader.

And as the name implies there isn't any header to a headerless file, so the length and load address are not stored in the file, instead they are stored in the program which loads the headerless file. So the extra information will be in the loader and I expect it to be binary too. Dissassemble it and look for a CALL &BCA1. The parameters to this will be load address, length and ident byte.

If you transfered the file to disc, it would either end up as an "ASCII" file which is technically headerless on disc, but can contain binary data,or a file with a header.

I would recommend the latter if it is a headerless binary. Then to load it, you are likely to need a new loader which enables the disc rom and loads the file using the standard firmware CAS IN OPEN, CAS IN DIRECT, CAS IN CLOSE functions and then executes the code.

If the file is a headerless ASCII file (e.g. BASIC data file or a document), you can copy it to disc as an ASCII file and then read it with CAS IN OPEN, CAS IN CHAR, CAS IN CLOSE, or using BASIC's OPENIN, READ, CLOSEIN.

To transfer from tape to disc I recommend a cpc tool called "Bonzo Super Meddler". You will find the tool on the cpc wiki. I think it is "option 1". When transfered it normally adds it's own loader. It's not the best, but it works. Instructions are included on the disk.

If you record a headerless file onto tape the only way to read it is to use CAS IN OPEN, CAS IN CHAR, CAS IN CLOSE or BASIC's OPENIN etc. If you try to RUN or LOAD it you'll end up with "Invalid argument" or similar.
However, if the file was ASCII and a dump of a BASIC program, e.g. SAVE"<file>",A then BASIC will load and run it happily.

CAS IN OPEN, CAS IN DIRECT, CAS IN CLOSE, CAS IN CHAR are all cpc firmware functions (accessible through the jumpblock between &bb00-approx &be00) and you generally need assembler to call them.

Confused? I think I just confused you.

Edit: If you need example code, or maybe some more examples of what I am talking about I'll be happy to write them here.
Title: Re: Copying 'header-less' files from tape to disc?
Post by: woody.cool on 23:03, 04 November 09
This is a bit more complex that I thought it'd be.
Hmmm, I'll have a look at that tool you mentioned, but I may be back on here asking more questions.
Title: Re: Copying 'header-less' files from tape to disc?
Post by: arnoldemu on 11:50, 05 November 09
This is a bit more complex that I thought it'd be.
Hmmm, I'll have a look at that tool you mentioned, but I may be back on here asking more questions.

Headerless load from assembler (tape only):

cas_read equ &bca1

ld hl,&100  ; start
ld de,&8000 ; length
ld a,&3  ; sync char
call cas_read

Headerless save from assembler (tape only):

cas_wtite equ &bc9e

ld hl,&100 ;; start
ld de,&8000 ;; length
ld a,&3 ;; sync
call cas_write

Headerless load from BASIC (tape/disc):

10 OPENIN"data
20 WHILE NOT EOF
30 INPUT #9, a$
40 WEND
50 CLOSEIN

Headerless save from BASIC (tape/disc):

10 OPENOUT"data
20 PRINT #9,"AAAA"
30 PRINT #9,"BBBB"
40 CLOSEOUT

Headerless save from asm (tape/disc):

cas_out_open equ &bc8c
cas_out_char equ &bc95
cas_out_close equ &bc8f

ld b,end_filename-filename ; filename length
ld hl,filename ; filename location
ld de,two_k_buffer
call cas_out_open
ld hl,buffer
ld bc,length
loop: ld a,(hl)
inc hl
push hl
push bc
call cas_out_char
pop bc
pop hl
dec bc
ld a,b
or c
jr nz,loop
call cas_out_close

filename:
defb "file"
end_filename:

two_k_buffer:
defs 2048

Headerless load from asm (tape/disc)

cas_in_open equ &bc77
cas_in_char equ &bc80
cas_in_close equ &bc7a

ld b,end_filename-filename ; filename length
ld hl,filename ; filename location
ld de,two_k_buffer
call cas_in_open
ld hl,buffer
ld bc,0
loop:
call cas_test_eof
jr c,end_file
push hl
push bc
call cas_in_char
pop bc
pop hl
ld (hl),a
inc hl
inc bc
jr loop
end_file:
call cas_in_close

filename:
defb "file"
end_filename:

two_k_buffer:
defs 2048

Title: Re: Copying 'header-less' files from tape to disc?
Post by: Cholo on 20:17, 07 November 09
Arnoldemu pretty much covered it all and even tho it sounds technical it really isnt to hard if you know a bit of machine code. Perhaps a bit time consuming, but in theory a bit faster than using named files.

A good tool to help you identify record infomation is "JL-copy". It cannot copy records to disc tho (only from tape to tape), but it is a quick way to identify the record information.

Here is a example where i have loaded the first record of the game "The Duct" from the AA Christmas tape 1987 (issue 28 side 2):

http://img84.imageshack.us/img84/6814/0002x.png

Note how it tells me that the file is 4000 h long and the sync char is 2C h. This way its easy to get the data quickly identified and you can manually copy it to disc. Best is of cause to examine the loader as it usually contains all the execution and location information along with anything else you usually set in a loader (colours, mode and all that).

If you want to have a go at "The Duct" you can find it in the Cdt pack ive uploaded:
http://cholo.cpcwiki.eu/AllInOne.zip