|★ CODING ★ LISTINGS ★ HEADER READER ★|
|Disc - Header Reader (Your Computer)||Coding Listings|
I HAVE WRITTEN' a program similar to ones published previously for other computers e.g. the ZX Spectrum or the Amstrad CPC-464. It is a program written in Basic with a short accompanying Z-80 machine-code routine which reads the header at the beginning of a file on tape and interprets this to give the user the information recorded there, which is normally inaccessible to the user.
On running, the program first returns the screen display to its default conditions as at startup when switching on. This is achieved by the two calls to the firmware jumpblock: Call &BBFF and Call &BB4E. Using these two simple calls avoids having to reset all the seperate aspects of the screen display i.e. the Mode, Pen, Paper, Ink settings etc. These two calls are in fact quite useful in any program at the beginning to make sure that the effect of printing on the screen can be entirely predictable.
It then calls the subroutine at line 230 and onwards which simply pokes in the short machine code routine at 41000 onwards. It also lowers Himem to 39999 to give space for the routine and for the storage of the data obtained from the header, the amount of space allocated being in fact more than adequate, though this fact is unlikely to mean that there is unsufficient memory left for use by any program residing in memory, mainly because it is unlikely that any program other than the header reader would be in the memory.
The program then calls the machine code routine which starts the tape and searches for the header at the beginning of a file. Since the routine uses quite a low level ROM routine which does not give the user a prompt to press Play on the tape recorder, it is a good idea to the cassette installed in the datacorder and to have Play depressed before running the program though this is not essential. The actual machine code routine is as follows:
The Basic program then checks by Peeking location 40030 whether the routine called has been successful or whether an error has occurred. It also checks whether the user hit the Escape key during the ROM routine which halts its action, and acts accordingly. If the routine has run correctly then the program interprets the data stored at locations 40000 to 40063. In fact only the locations from 40000 to 40027 contain useful information, although the bytes in the header stored from 4028 to 40063 can contain useful information when the file is not created by Basic tape commands. In any case, whatever information this may be, it cannot be interpreted in terms such as block number or similar in the same way as the other bytes. Indeed, the information stored here is likely to have a unique purpose for every program in which they are used at all. The program displays the information under the headings Filename, Block Number, File type, Length of Data in Block, Address from which the file was written, Total length of file, the Entry Address in the case of machine code programs, and also says whether the block being read is the first or the last block or not and whether or not the program is protected.
Once the information has been displayed, the program pauses and asks whether the user wishes to continue to read another header. Any key other than n is taken to mean yes, while if n is pressed, the program ends. Otherwise, the program repeats the process, searching for another header. The time between when the Continue . . . ? message is displayed and when a key is pressed is a good time to change tapes, fast forward etc.
It would also probably be convenient, if the user owns a printer to change the appropriate Print statements to Print 8 statements to obtain a hard copy of the header information for later use.
I should be most happy to answer reader's inquiries about the program should any arise providing that the inquirer encloses an sae with any questions sent to me. I also am willing to provide a tape copy of this program to any reader if they send a blank tape and a cheque/PO for £1.00 inclusive of p&p to H.V. Smith.