Save Protection For DFS

By Ross Little

Originally published in EUG #20

In EUG #19, the version of the Safe utility for ADFS users was published, version 2.00. Here I am about to discuss the problems I have had with it, introduce a routine to disable it and (most importantly) present a new version for DFS users. Also I would like to credit the idea to Gus Donnachaidh, who suggested the program in the Editorial of EUG #18. I forgot to do that in my original write up.

Firstly, if you use certain programs for the ADT ROM (or maybe some other ROMs), then when the Safe Safe routine is next accessed, your Elk will most likely hang up. The reason for this is that some of ADT's utilities use Page 9 which is the same page that the Safe routine uses. The Safe routine makes the computer execute the code in this page when any star command is issued or disk access is to be carried out. If the code has been corrupted by any program, the computer will probably crash. To avoid this, the choices are firstly not to use any culprit program while the Safe application is installed or, secondly, to relocate the Safe code to some other memory address. To do the latter, you will have to change line 170 in the source code to P%=&(start address), RUN the program to assemble the assembly language then *SAVE the resulting code on any disk to overwrite the original (other than your EUG #19 disk, of course). The source code is on EUG #19 under the filename "U.SAFESrc".

Incidentally, version 2.00 is 342 decimal bytes in length. The exact command you should use to save the original version is:

      >*SAVE SAFE (start address) +152 (RETURN)

The second problem with this version was the fact that if the *SAFE command was executed twice, then on the next star command an endless recursive loop would start and the computer would therefore hang. To stop this, only four extra bytes have to be entered into the source code. Simply follow the procedure given about to update your version, but when saving, substitute the '+152' with '+156'. The new bytes will check to see if the relevant vector is already pointing to a copy of the routine in memory, and if so quit. The introductory message, in this case, will not be given.

      >224 CMP #newv DIV 256
      >226 BEQ end

Please note that this only works on the ADFS version, and not on the DFS one I'm about to unveil. Although it doesn't cause an error in itself (It is, in fact, included in the DFS version), it doesn't work properly. I don't know why this is, but if you do execute the *SAFE (DFS) routine twice, then when you answer YES to the question of whether you wish to overwrite the file, it will just prompt you again.

There do seem to be some other bugs in this utility. I don't know exactly when they occur and therefore can't do much about them. Maybe someone out there can help...

Also on this disk is the source code for a utility to disable the Safe utility. To operate it, load the BASIC file "U.DISASrc", switch to the directory you wish to have it saved (on a separate disk) and then RUN the program. It will automatically assemble the code and *SAVE it under the filename DISABLE. When in the future you wish to disable the Safe utility without pressing BREAK, simply switch to this directory and type *DISABLE. It will reset the two machine vectors used, and allow you to use Page 9 for other purposes.

As promised earlier on, here's another version of this utility. Safe Protection For DFS v1.00. To enable it, type *SAFEDFS whilst in the $ directory. You'll also find the source code used to create it in the Utilities Directory. Although this is intended for the original Disk Filing System, it can also be used on the Advanced DFS one. It operates slightly differently to the ADFS-specific version. The theory it works on is that if, when a file is opened with the OPENIN or OPENUP commands, the channel number returned is zero, then the file is non-existent. In this case the file hasn't actually been opened (and therefore the program doesn't close it) but an error will only occur if access is attempted.

So the program will attempt to OPENIN the file you're trying to save and, if the channel number returned is anything other than zero, then it will inform you that the file exists and prompt you whether to overwrite it.

Because of this different operation, there are a couple of points to note about it. Firstly, because the file is OPENINed, the program has to access the disk to find if the file exists. On the ADFS version, this is not necessary, because it searches through the RAM (which is the faster alternative). This is, I think, the major advantage with the ADFS version. Secondly, the methods which can be used to bypass the newer routine are different. Or, should I say, non-existent as far as I am aware. It seems that whenever the routine is operational, it will either work 100% prompting about all files that are about to overwritten, or the micro will hang up!

Ross Little, EUG #20