EUG PD


Loading Locked Files

 
Published in EUG #71

Locked tape files are those that can only be *RUN. If you try to *LOAD a locked file, the computer will abort the operation and report 'Locked'.

A locked file just has bit zero of location &3CA set for each block of data. It is a simple matter of setting up an interrupt routine to constantly mask out bit zero of &3CA, as in this program:

   10 REM Tape Unlocker (c)Mr Spock 1995
   20 P%=&50
   30 [PHA:LDA&3CA:AND#254:STA&3CA:PLA
   40 .newv:JMP&FFFF
   50 .init:SEI:LDA&204:STAnewv+1:LDA&205:STAnewv+2
   60 LDA#&50:STA&204:LDA#0:STA&205:CLI:RTS
   70 ]IF?&205>&80 CALLinit

The program should be loaded and run, perhaps CHAINed by a disc BOOT file, before tackling any locked tape files. In fact, it is best to do this every time you embark on transferring files from tape to disc.

Note that the code sits out of the way, in zero page. The primary interrupt vector is intercepted and the address of our own routine put in its place. When ours has finished, the contents of the A register are restored and we jump to the default vector address.

Incidentally a more concise (but less clear, for explanation purposes) way of clearing bit zero is to perform a Logical Shift Right immediately followed by an arithmetic shift left, effectively discarding bit zero. This saves having to preserve and restore the A r egister:

  10 REM Improved Tape Unlocker (c)Mr Spock 2004
  30 [LSR&3CA:ASL&3CA 

Line 70 checks to see if the unlocker program has already been run. If it has, the high byte of the address of the new interrupt (lo cation &205) will be in RAM, i.e. have a value below &8000 and the most significant byte of &8000 is &80.

Mr Spock 31 Mar 2004

Mr. Spock