Newsgroups: comp.sys.sinclair
Path: ulke.hiMolde.no!trane.uninett.no!nac.no!Norway.EU.net!EU.net!sun4nl!sci.kun.nl!reneuit
From: reneuit@sci.kun.nl (R.M. Uittenbogaard)
Subject: Re: After a headerless code reader...
Message-ID: <D9Hso2.107@sci.kun.nl>
Sender: news@sci.kun.nl (News owner)
Nntp-Posting-Host: studs.sci.kun.nl
Organization: University of Nijmegen, The Netherlands
X-Newsreader: NN version 6.4.19
References: <itomkins.12.000D2FA0@pine.shu.ac.uk> <3pbm5l$l0i@post.tau.ac.il> <schmieg-2405952148580001@schmieg.actrix.gen.nz> <3qdk2d$hrd@celebrian.otago.ac.nz> <19950530.235217.59@alant.demon.co.uk>
Date: Thu, 1 Jun 1995 11:45:38 GMT
Lines: 52

In <19950530.235217.59@alant.demon.co.uk> alant@alant.demon.co.uk (Alan Trewartha) writes:


>> 32768 DI            ;this address avoids memory contention
>>       CALL 8020     ;check for BREAK key      }
>>       JR C,-5       ;loop until BREAK pressed } miss them out if you wish
>>       LD IX,16384   ;start address, this ones for the screen
>>       LD DE,6912    ;length, again for the screen

>>       LD A,255      ;umm, I don't know what this is for
>        ^^^^^^^^


>Well as I recall it was to do with either an initial identifier byte or to check a final checksum byte. I certainly remember writing a generic data reader which told me what it was in the just loaded data.

That is true, the first byte of a tape block is either #00 for a header or #FF
for a data block. At the end of each block, there is a parity byte, which should
make exactly zero when XOR'ed with all other bytes in the block. So, if you
SAVE "name" CODE 50000,100 you will have a data block of exactly 502 bytes.
  What's more, some headerless SAVE/LOAD routines made use of this feature
and placed an initial byte of, say, #13 in front of the code in order
to make it impossible for a hacker to make a header on another tape and use this 
as header for the headerless block. The ROM load routine expects the leader byte
of the data block to be #FF or it will give a Tape loading error

(heck, why wasn't this the list of requirements "are you a TRUE spectrummer?"
Q. The real spectrummer knows all the error messages 0-9 and A-R by heart. ;-)


>>       JP 1218       ;ROM save. crikey, shouldn't this be a CALL?
>>       RET           ;hey, haven't we forgotten to enable interupts?

>A slightly more obvious way of doing it was to forget the DI and just CALL the right routine.

Yes, the ROM routine takes care of both the disabling and enabling of the
interrupts.

Also see "The complete Spectrum ROM disassembly" from  Ian Logan an Frank
o'Hara. 

About the leaderless loader: it would be quite possible to simply copy the 
beginning of the ROM load routine and leave out the part which searches for the
leader signal (the red-and-cyan part), and just starts reading when a sync
pulse is encountered, but this routine would be quite sensitive to noises and
cracks on the tape. You would have to adjust your tape recorder volume very
carefully, as any ticks or cracks could suggest a sync pulse, and since there is
no data signal after it, whammo! R Tape loading error.

It is possible, though.

Greetings, Rene (reneuit@sci.kun.nl)

