Disk Doctor

Author(s): George Chambers
Publication: ZXir QLive Alive!
Pub Details: ZXir QLive Alive! v6 n3 (Volume 6, Issue 3)
Date: Autumn 1996
Pages: 11-13

Disk Doctor (doctor.Bl) is a program which will be found useful in the inspection, analysis, and correction of errors on disks used on the LarKen Disk Drive System (DSK400). The following notes will explain the various features of this program and describe how to make best use of theme

The program is menu-driven. That is to say, there is a main menu to which one can always return to at any point in the operation of the program.

As each of the menu items are in use a sub-menu will appear at the bottom of the screen indicating what options are now available. Usually they offer the opportunity to COPY the screen, or to return to the main menu. The sub-menu of Option 4 is more extensive, and will be described elsewhere

We shall review the options on the main menu:

Option 1. “TRACKS USED/FREE”. By selecting this item you will obtain a display of the ‘Used/Free’ status of each of the 80 or 160 tracks of the disk.

Option 2. “Program Header Reader” Does a track by track inspection of the disk and outputs an screen details of the program segment on each track. The information includes the Track Number, the program/file name, the starting address in memory of that particular track, and the full length of the program. It also gives the starting address if it is a program.

Option 3. “DIRectory ANALYSIS” Will provide information an each program contained on the disk, such as program name, tracks used.

Option 4. “EXAMINE/MODIFY A TRACK” This is really the heart of the DOCTOR program. With this option you can inspect the contents of each track, modify the data as desired, and save the modified track contents to the same track or to another track.

Option 5. “PROGRAM START/LENGTHS” This option provides details on each program on the disk. Details include program/ file name, it’s starting address and length, and the starting line Number, if a program.

Option 6. “RENAME A PROGRAM” Is a sub-routine which enables one to rename a program. This routine will rename the program on the directory track, and also the name label on each track where the program is stored.

Option 7. “SELECT DRIVE” Lets one select a drive 0 to 3. It initially reflects the system default drive value of “0”.

Option 8. “RETURN TO RAMDISK MENU” Allows you to exit from this program.

Option 9. “SAVE THIS PROGRAM” A way of saving this program to disk or optionally to tape. Select the correct drive first.

HEADER READER (Menu Option 2)

The Header information displayed onscreen includes the track number, the program name, the program starting address (START), program length (LENGTH), and starting line Number. The Starting address can be either the start of a BASIC program or the start of a block of codes –

The LENGTH refers to the length of the program, whether it be a BASIC program, code, or arrays.

The ST refers to the starting line of the program. Where the entry shows a figure of -1 this is an indication it is not an AUTOSTART program.

EXAMINE/MODIFY A TRACK (Menu Option 4)

Track 0 in the LarKen system is the DIRectory track; that is to say, it is the track which contains all the information required by the LarKen system to manage the storage and retrieval of programs/data an the disk. The make-up of this track is shown in the LarKen operating manual.

When menu Option 4 (EXAMINE/MODIFY TRACK) is selected you will be asked which track you wish to have LOADed into the computer memory. Usually this will be track 0, and initially we shall confine our discussion to the procedures likely to be used on this track.

As soon as track selection has been made you will be presented with a display of the contents of track 0 (assuming track 0 was selected), starting at byte “0” of the track. The first part of the directory track has no immediate interest, so press the “N” key.

Now, before proceeding any further let us explore the sub-menu that appears at the bottom of your screen. Although the menu on the screen has been arranged in alphabetical order we shall discuss them in the sequence they are most likely to be used.

Name — we have already pressed this command in the previous paragraph. Pressing the “N” key advances the scan to the start of the program name cell area.

Cont — Pressing the “C” key will advance the display by 17 addresses, or exactly half of a name cell of 34 addresses as stored in the directory track.

Etc — The “E” key advances the scan by exactly 34 bytes or a full name cell. Because the first 17 line screen contains the most-often wanted data, pressing the “E” key expedites movement through the file.

Jump5 — Pressing the “J” key advances the scan by six name blocks, Most useful when the desired program name cell is far along the directory.

Back — The “B” key permits a backwards movement of one frame of 17 addresses (one half a name cell)

Dirc — The “D” key moves the scan forward to where the disk name is stored on the directory track. Useful when it is desired to change the disk name.

Zend — The DIRectory track has a marker “250” to indicate the end of the file name area. Pressing the Z key moves the scan to that point in the file.

Top — Pressing the “T” key will restore the scan to its initial position; at the start of the buffer.

Alter — The “A” key is pressed when it is desired to make a change in the contents of the buffer.

Save — Pressing the “S” key is done when it is desired to save the buffer to a disk track.

Load — The “L” key is used to call up another track for inspection. You will be asked to input the new track number. Using this key avoids the need to return to the main menu to select a new track.

Menu — The “M” key is used to return to the main menu.

When the buffer is being displayed per Option 4 there are some column headers which bear explanation. addr refers to the address in the computer memory where the buffer is being stored. There are circumstances where it is desirable to break into the “doctor” program to make a direct POKE into the buffer. The information in this column will help to locate the desired address.

Map — is a buffer address, which somewhat parallels the address information, but represents the address where this data is held on the disk track. Do not confuse a ‘map’ address with the address in the computer memory where this track data is being temporarily stored.

Byte — The value contained in the corresponding address.

CHR$ — The character corresponding to the byte, Also, where the byte number corresponds to a file marker, the program prints out an asterisk as a visual signal. Primarily, this column is useful in displaying the program name; the CHR$ elsewhere serve no useful purpose.

@track — Shows the track number selected.

TRACK “0” (DIRectory Track)

It is probably appropriate at this time to talk about the make-up of the DIRectory track “0”. In the operation of the LarKen Disk Operating System (LKDOS), track 0 contains all the information required to store and retrieve data from the other 79 tracks on the disk. The make-up of track 0 follows very precise rules, and this makes it possible to go into the track and make changes/corrections if necessary.

There are 5128 bytes on a track. Of these, the first 20 bytes (O to 19) are reserved and used for DOS variables and as DOS work space. These bytes are not significant for our purposes.

At address 20 we start the Track Map Area. This address holds figure of I or 2 corresponding to the number of sides that have been FORMATted. The next address, 21, holds a value corresponding to the numb4r of tracks formatted per side on this disk.

Map addresses 24 to 187 are used to store the track used/free status. When first formatted addresses starting at 24 are filled with values starting with 1. The numerical sequence continues until the number of tracks the disk has been formatted to is reached, 80 in the case of a DSDD format. The remaining addresses are filled with a value of 245.

Whenever a program is SAVEd or erased a “245” marker is placed in the appropriate location by the DOS. The DOS checks this Track Map area to locate free tracks to hold a program to be SAVEd. Likewise, Option 1 of “doctor.Bl” Main Menu inspects this area to determine track status.

When we get to map address 188 we find the start of the DIRectory Name Cell area. Each name cell consists of 34 bytes of information. The first byte contains a marker, “255”. Then follows the familiar 6-character program name/3-character suffix in the next 9 addresses. Note that if a name is less than 6 characters long the empty spaces after the 3-character suffix are occupied by values of 32.

An end-of-name marker “253” follows the name. The next map addresses contain the track numbers assigned to this program. The last assigned track number is followed by a (floating) end-of-tracks file marker “249”. In an unused Name Cell the “249” immediately follows the “253” marker (since no tracks have been assigned to this name cell).

When a program has been removed from the disk by the DOS “erase” command the material on the disk is not removed. Instead, a marker “254” is placed in the address succeeding the name cell marker “255”.

A name cell is designed to hold a maximum record of 22 tracks. If a program occupies less than 22 tracks, the unused map addresses remain in place unused.

There are 100 Name Cells in Track 0. At the end of the track, at map address, you will find a value of 250. This is the end-of-DIRectory marker, and indicates to the DOS that the search of Name Cells has finished.

Once a track has been loaded into memory using Option 4, one can then scan through it using the sub-menu options ‘c’, ‘e’, ‘j’, and ‘b’. When it is desired to change a value in a particular address press key ‘a’. This will bring up the query “Change Number or Char”. If it is a numerical value to be changed press the “N” keys. If it is a name change (characters) then press the “C” key.

You will see a black cursor opposite the bytes column, at the top of the screen. The position of this cursor can be controlled by the “Q” and “A” keys. An instruction to this effect will appear on the lower section of the screen. Using the Q and A keys position the cursor opposite the first address (byte) to be altered, then press the ENTER key.

When the ENTER key is pressed you will be asked for an input. If a name change is required enter the required string, it can be anything from I to 9 characters as desired. When the string is ENTERed the screen will be recycled showing the changes that have been effected.

In the event that a numerical input was requested, i.e. the “T” key was pressed you will be asked to input one or more numerical values. These of course must fall within the range of 2 to 255. When working on the track information on track 1 the numerical sequence will normally terminate with a “249”. The program when it senses an input of 249 will automatically terminate the sequence, recycling the screen to show revision.

Now, there doubtless will be occasions when you wish to terminate a numerical sequence without the number 249. In this case, ENTERing the number 2068 will terminate the sequence. The 2068 is treated as an indicator and is not used in the sequence,

There may be other occasions when you wish to enter the 249 outside it’s use as a program marker. On these relatively rare occasions it will be necessary to break into the program, POKE the number into place, then continue by pressing the “C”, then the ENTER keys.

When all the changes required have been made to the track, you will want to re-save the corrected version. Keep in mind you will be replacing the existing track record with your new copy; the original will be lost. Press key ‘S’. You will see on screen the message ‘Save to same track or new track’. Normally you will want to save it to the same track. In this event press the ‘S’ key. The drive will run momentarily, and the track is SAVEd. This presumes that you have removed the write protect label!

If you wish to save the data to another track, enter ‘n’ and you will be asked for a new track number. Enter the new track number and the SAVE will proceed as before, but to the designated track.

While most of your efforts with DOCTOR will be directed to track 0, it is possible to perform the same functions on any track. Mostly the information on the other tracks will not be intelligible. However it is possible, by pressing the ‘T’ key to get to the start of the track, and at map addresses 2 to 11 see the program name stored on that track. Also, at map addresses 12 and 13 you will find the starting address of this track’s portion of the program (where it is placed in the 2068 memory). For a BASIC program these addresses will hold values of 104 and 86, representing 26710. For Spectrum programs the corresponding values would be 203 and 92 (23755). For an NMI-type program they would be 218 and 87 (22490)

We noted earlier that one could find the name of the program at the start of every track map #1 to #79. This information is not used by the DOS in any particular way but it is useful to be able to look at a track to see if the program name on that track corresponds to the record in the DIRectory track>