Bob’s Notebook: Disk Management Utilities

See all articles from Sinc-Link v6 n4
Author(s): Bob Mitchell
Publication: Sinc-Link
Pub Details: Sinc-Link v6 n4 (Volume 6, Issue 4)
Date: July/August 1988
Pages: 3-6

DISK MANAGEMENT UTILIIES

Utilities are programs that assist in either disk management or program development. Disk management includes: Doctor, Copy, Rename, Move, etc. Program Development includes: Assemblers, Disassemblers, Compilers, Compactors, Renumbering, Toolkits in general, etc. Of course, utilities like any programs can usually be improved or edited to suit your particular needs, whims and fancies.

This article presents some changes to existing Disk Management utilities as well as one new one.

NOTE: Reference to LKDOS below means the original LARKEN version which uses the old LDOS interface board and which allows for 1960 bytes per track.

1. RENAME. Used to change a file name on an LKDOS disk. When I converted to LKDOS from LDOS, I changed ‘rename’ to use a disk version of the LDOS EPROM, dubbed ‘LDOS64.C5’. A few minor changes to the routine made ‘rename’ do its job with the LKDOS cartridge. The next step was to do away with the use of LDOS64. To do this I wrote a short machine code routine to use the LKDOS EPROM. This has been dubbed RHMDOS.C1. Then I incorporated this into ‘rename’ and compiled it using Timachine. A short boot routine in BASIC was needed to handle the CAT function since this cannot be used in the compiled version; this became my rename boot and the two short programs are at Listings 1 & 2. In the listings below, the DATA lines hold the RHMDOS code; listing 1 is ready for Timachine.

2. DOCTOR. This has also been changed to run with RHMDOS. Note that using this moves the DOS buffer up 2000 bytes to start at 63500 vice 61500. Thus the disk name is at 65478 to 65487 instead of 63478 to 63487 on track 0.

The routine Disk Dump gives data for each track: name, start address and length up to a max 1960 bytes . This routine cannot distinguish ‘good’ from ERASEd tracks. This is useful; if all the ERASEd tracks of a file are present then it is possible to recover it for further use. This is an involved process and so listing 4 presents a short RECOVER routine to do the job. It will work fine as long as there are no redundant tracks bearing the wanted file’s name and of course as long as the wanted file is still intact and has not been partly overwritten by other material. Redundant tracks can result when a file is shortened and reSAVEd under the original name. There may be other causes.

(Listings 3 is the boot program; Listing 4 is ready for Timachine.).

Use the routine that gives name, start address and total length of each file to get a print-out of this detail and slip the copy inside the diskette cover. With this information you can, for example, SAVE a code file to another disk without the aid of COPY or MOVE utilities.

The Examine/Modify Track routine facilitates the PEEKing and POKEing of values in addresses on any track but mainly on track 0 (directory).

One change I made caters for the use of a keyword (token) in the disk name. LKDOS allows a maximum of nine characters for the disk name. Using tokens, you can come up with some interesting longer names; eg, SUPER CODE 1 (7 bytes); MAIL MERGE 88 (7 bytes). Using the tokens (CODE and MERGE in these examples) adds only one byte for each. Other possibilities: COPY AND MOVE (3 BYTES); MMI SAVE UTIL1 (9 bytes); etc, etc…

A few small changes will be needed to display a token when examining track 0 in the disk name area. Find the Track Manipulation routine in the listing and more specifically the line that goes something like : <PRINT AT 1,29;” “;AT 1,1;”addr map byte chrs$”>; add a line <LET cd=123>; then after the line <FOR x=n TO n+16> add a line <IF x>=65478 THEN LET cd=255>. In the next line (the one that starts <PRINT x;TAB 9;….etc> change the value <123> to <cd>.

3. COPYDOG. Eric Michaud‘s copydog routine is an excellent utility which will copy a disk in five sweeps (16 tracks at a time). However, it has one minor shortcoming in that an ambiguous prompt comes up on the screen from the machine code. For example. < Insert Source… OK?>. Well the OK? doesn’t make it clear that it will only accept a ‘y’ or an ‘n’. Pressing any other key can leave you thinking the program has crashed. So I dissassembled the code and found the addresses that contain this prompt and changed them to end : y/n? Here’s how: POKE 32795,13: POKE 32796, CODE “y”: POKE 32797, CODE “/”: POKE 32798, CODE “n”: POKE 32799, CODE “?”

4. COPY. The LARKEN MOVE program does a good job of COPYing files but is rather involved for LKDOS. Unless there is a need to alter a file name, I prefer the COPY utility written some time ago by George Chambers. This has been changed to incorporate the RHMDOS routine as well as the LARKEN move.Cz code. This is shown at listings 5 & 6; 6 is ready for Timachine).

LISTING 1.

   1 REM ! LPRINT
2 REM ! LIST
3 REM !USR 50000
4 REM !INT +t,ct,i,k,j,l
5 REM !LEN i$<=5
8 REM ! OPEN #
10 DIM x$(9): DIM y$(9): DIM z$(9): DIM a(79)
11 CLS : PRINT AT 10,0; INVERSE 1;" RENAME "; INVERSE 0;" by Bob Mitchell 1988"
12 LET t=1
17 LET ct=23728: POKE ct,0
20 RESTORE 9800: FOR o=63000 TO 63076: READ p: POKE o,p: NEXT o
27 RANDOMIZE USR 63000
29 BEEP .05,10
30 INPUT "change name from "; LINE y$
40 FOR i=63600 TO 65440
45 IF PEEK i=255 THEN LET k=i+1: FOR j=1 TO 9: LET x$(j)=CHR$ PEEK (i+j): NEXT j: IF x$=y$ THEN BEEP .05,10: INPUT "change name to "; LINE z$: GO TO 100
50 NEXT i
60 BEEP 1,-10: PRINT ''y$;" not found": PAUSE 100: GO TO 10
100 FOR i=1 TO 9: POKE k,CODE z$(i): LET k=k+1: NEXT i
110 RANDOMIZE USR 63003
150 IF PEEK k<>253 THEN LET k=k+1: GO TO 150
155 GO TO 170
160 IF PEEK (k+1)=249 OR t>79 THEN GO TO 200
170 LET k=k+1: IF PEEK k>128 AND PEEK k<208 THEN LET a(t)=PEEK k: LET a(t)=a(t)-128
180 LET t=t+1: GO TO 160
200 LET t=1
205 POKE ct,a(t)
210 RANDOMIZE USR 63000
220 FOR l=1 TO 9: POKE 63505+l,CODE z$(l): NEXT l
225 RANDOMIZE USR 63003
230 LET t=t+1: IF a(t)<>0 THEN GO TO 205
500
510 CLS : BEEP .2,10: PRINT AT 10,0; PAPER 2; INK 7;"Program has been renamed "'"from ";y$;" to ";z$
520 INPUT "m=more q=quit "; LINE i$
530 IF i$="m" THEN GO TO 10
540 IF i$<>"m" THEN STOP
550 STOP
9800 DATA 195,40,246,195,69,246,243,205
9801 DATA 98,0,201,58,100,0,251,201
9802 DATA 205,30,246,58,176,92,50,29
9803 DATA 32,205,126,0,205,123,0,33
9804 DATA 112,32,17,16,248,1,192,7
9805 DATA 237,176,195,35,246,205,30,246
9806 DATA 58,176,92,50,29,32,33,16
9807 DATA 248,17,112,32,1,192,7,237
9808 DATA 176,205,150,0,205,126,0,205
9809 DATA 120,0,195,35,246,0,0,0
9900 REM ! CLOSE #
9910 CLEAR : RANDOMIZE USR 100: SAVE "rename.Bp" LINE 10

LISTING 2.

  10 REM rename boot
90 PAPER 7: BORDER 7: INK 9: CLS
200 RANDOMIZE USR 100: LOAD "rename.Cc"CODE
410 PRINT #1; INVERSE 1;" RENAME "; INVERSE 0;" by Bob Mitchell 1988"'"Change name routine."'"Insert Disk. [ENTER] when ready"
411 BEEP .05,1
412 PAUSE 0
415 CLS
420 RANDOMIZE USR 100: CAT "",
421 BEEP .05,1
423 PRINT #1;AT 0,0;"[ENTER]": PAUSE 0
425 BEEP .05,1
427 POKE 23658,0
430 RANDOMIZE USR 50000
500 PRINT AT 20,0;"[ENTER]=restart [STOP]=disk menu"
505 INPUT LINE i$
510 IF i$=CHR$ 225 THEN RANDOMIZE USR 100: LOAD "menu.B1"
520 IF i$<>CHR$ 226 THEN CLS : GO TO 410
550 STOP
1000 RANDOMIZE USR 100: SAVE "rename.Bb" LINE 1100
1010 STOP
1100 GO TO 1

LISTING 3.

  90 CLS
95 LET add=55000
98 PAPER 7: INK 0: BORDER 7: CLS
100 PRINT INVERSE 1;" RECOVER I/O Routines "; INVERSE 0'"by Bob Mitchell Willowdale Ont."''"1. RUN "'"2. CATALOGUE"'"3. RESTART"'"4. QUIT"
105 PRINT '"WARNING!"'"Do NOT use this program to recover files which have either been overwritten by other material or which have been shortened or otherwise changed thereby leaving redundant tracks on the disk with the same name."
106 PRINT '"If in doubt, use DOCTOR to check first."
107 PRINT #1;"Press selection (keys 1 TO 4)"
110 LET d$=INKEY$
115 IF d$<"1" OR d$>"4" THEN GO TO 110
120 IF d$="1" THEN CLS : GO TO 300
130 IF d$="2" THEN GO TO 400
140 IF d$="3" AND PEEK add=205 THEN CLS : GO TO 500
145 IF d$="4" THEN RANDOMIZE USR 100: LOAD "menu.B1"
150 GO TO 110
300 POKE 23658,0
315 RANDOMIZE USR 100: LOAD "recovr.Cc"CODE
340 RANDOMIZE USR add
350 GO TO 10
400 CLS : RANDOMIZE USR 100: CAT "",: PRINT #1;"[ENTER]": PAUSE 0
410 CLS : GO TO 100
420 GO TO 1
510 RANDOMIZE USR add
520 CLS : GO TO 1
999 STOP
1000 RANDOMIZE USR 100: SAVE "recovr.Bb"
1005 PAPER 7: INK 9: BORDER 7: CLS
1010 RUN

LISTING 4.

 100 REM !USR 55000
102 REM !LEN $<=20
104 REM ! LIST
120 REM ! OPEN #
[illegible]0 LET curtrack=23728: POKE cu
rtrack,0
135 DIM g$(9): DIM x$(9): DIM y
$(9): DIM z$(9): DIM a(79): DIM
b(22)
140 RESTORE 5500: FOR o=63000 T
O 63102: READ p: POKE o,p: NEXT
o
145 CLS : PRINT AT 3,0;" L
ARKEN LKDOS UTILITY"''"
FILE RECOVERY"''"This program w
ill recover a filethat has been
ERASEd providing that none of i
ts tracks has beenoverwritten by
other material."''" by Bob
Mitchell 1988 "
146 LET st=0
150 INPUT "name of file to be r
ecovered? ",i$
151 IF LEN i$<9 THEN LET i$=i$+
" ": GO TO 151
152 LET y$=i$
155 RANDOMIZE USR 63000
157 CLS : BEEP .1,10: PRINT "se
arching directory track for"'y$
160 FOR i=63608 TO 65478
170 IF PEEK i=255 THEN FOR j=1
TO 9: LET x$(j)=CHR$ PEEK (i+j):
NEXT j: IF x$(2 TO )=y$(2 TO )
THEN GO TO 200
180 NEXT i
190 GO TO 2000
200 PRINT 'y$;" found"'': BEEP
.1,10: PRINT "scanning for track
s containing "'y$''"track #s are
[illegible]: FOR i=1 TO 79
[illegible]5 POKE curtrack,i
210 OUT 34,3: PAUSE 3
220 RANDOMIZE USR 63006
230 FOR j=1 TO 9: LET z$(j)=CHR
$ PEEK (j+63505): NEXT j
240 IF z$(2 TO )=y$(2 TO ) AND
i<80 THEN GO SUB 300
250 NEXT i
255 GO SUB 350
260 GO TO 400
300 IF PEEK 63505=0 THEN RETURN

310 LET a(i)=PEEK 63505
320 RETURN
350 LET i=1: FOR t=1 TO 79
355 IF a(t)=0 THEN GO TO 370
360 LET b(i)=a(t): PRINT b(i);"
,";
365 LET i=i+1
370 NEXT t
380 PAUSE 60
400 POKE curtrack,0: RANDOMIZE
USR 63000
401 IF st THEN STOP
405 CLS : BEEP .1,10: PRINT '"c
orrecting track map"
410 FOR j=1 TO 22: FOR i=63529
TO 63607: IF PEEK i=b(j) THEN PR
INT PEEK i;" changed to: ";: POK
E i,(b(j)+128): PRINT PEEK i
420 NEXT i
430 NEXT j
500 IF st THEN STOP
502 BEEP .1,10: PRINT "restorin
[illegible]e name and tracks used."
[illegible] FOR i=63608 TO 65478 STEP 3
4
 520 IF PEEK i=255 AND PEEK (i+1
)=254 THEN FOR j=1 TO 9: LET g$(
j)=CHR$ PEEK (i+j)
535 IF j>=9 THEN GO TO 545
540 NEXT j
545 IF g$(2 TO )=y$(2 TO ) THEN
LET m=i: IF PEEK (m+1)=254 THEN
GO TO 600
550 NEXT i
560 GO TO 730
600 POKE m+1,CODE y$
605 FOR p=1 TO 22
610 IF b(p)<>0 THEN POKE m+p+10
,(b(p)+128)
615 IF b(p)=0 THEN GO TO 630
620 NEXT p
630 POKE m+p+10,249
700 POKE curtrack,0
720 RANDOMIZE USR 63003
730 CLS : LET st=1: PRINT "Task
Completed. Check Catalogue."''"
PRESS A KEY"
735 PAUSE 0
740 STOP
2000 PRINT #1;AT 0,0;"File not f
ound": BEEP .5,.1: PAUSE 100: ST
OP
5500 DATA 195,43,246,195,72,246,
195,104
5501 DATA 246,243,205,98,0,201,5
8,100
5502 DATA 0,251,221,205,33,246,5
8,176
5503 DATA 92,50,29,32,205,126,0,
205
5504 DATA 123,0,33,112,32,17,16,
248
5505 DATA 1,192,7,237,176,195,38
,246
5506 DATA 205,33,246,58,176,92,5
0,29
5507 DATA 32,33,16,248,17,112,32
,1
5508 DATA 192,7,237,176,205,150,
0,205
5509 DATA 126,0,205,120,0,195,38
,246
5510 DATA 205,33,246,205,129,0,2
05,123
5511 DATA 0,33,112,32,17,16,248,
1
5512 DATA 192,7,237,176,195,38,2
46,0
8100 REM ! CLOSE #
8999 STOP
9000 CLEAR : RANDOMIZE USR 100:
SAVE "recovr.Bp" LINE 1
9010 STOP
9100 CLEAR : SAVE "recovr.Bp"

LISTING 5.

   6 REM !USR 29000
7 REM !INT +i,f,a,tlen,pass,r
,n,z,q,y,mem,owka,dwka,onam,dna
m,indir,ld1,ld2,svnam,svdata,sve
nd,nbcs,bsize
8 REM !LEN $<=20
10 REM ! OPEN #
13 GO SUB 7000: GO SUB 9700
14 PAPER 7: INK 9: BORDER 7: C
LS
15 POKE 23658,0
16 PRINT AT 8,0;"Insert disk t
o be copied and"'" press any k
ey": PAUSE 0: CLS
20 POKE 23728,0: RANDOMIZE USR
63000
25 CLS
30 FOR n=63608 TO 65478
40 IF PEEK n=255 AND PEEK (n+1
)<>254 THEN GO SUB 100
42 POKE 23692,255
45 IF PEEK n=250 THEN PRINT '"
End of Disk Directory"''"[m]=Dis
k Menu; [ENTER]=next disk": PAUSE
0: GO TO 180
50 NEXT n
100 LET a$=" "
105 LET z=0
110 FOR y=1 TO 9
113 IF PEEK (n+1)=46 THEN LET z
=1
115 IF PEEK (n+1)=32 AND z=1 TH
EN LET y=9: GO TO 130
120 LET a$(y)=CHR$ PEEK (n+1):
PRINT INK 1;CHR$ PEEK (n+1); INK
0;
125 LET n=n+1
130 NEXT y
137 PRINT " Copy? (y/n)"
138 PAUSE 0
139 IF INKEY$="n" THEN RETURN
140 IF INKEY$="y" THEN GO TO 10
00
141 GO TO 138
180 STOP
1000 DIM f$(9): GO SUB 7000
1005 LET f$=a$
1010 FOR f=1 TO 9: POKE Onam,COD
E f$(f): LET Onam=Onam+1: NEXT f
1130 FOR a=1 TO 9: POKE Dnam,COD
E f$(a): LET Dnam=Dnam+1: NEXT a
1140 PRINT #1;AT 0,0;"Copying ";
f$
1200 LET rt=USR indir
2000:[illegible]rt=USR Ld1
2010 LET Tlen=PEEK 34002: LET pa
ss=1: IF Tlen>(PEEK Nbcs)-1 THEN
LET pass=2
2100 GO SUB 7400
2200 LET rt=USR Svnam
2300 LET rt=USR Svdata
2400 IF pass=1 THEN GO TO 5000
2500 GO SUB 7300: LET rt=USR Ld2
2700 GO SUB 7400: LET rt=USR Svd
ata
5000 LET rt=USR Svend
5050 PRINT #0;AT 0,0;"File copie
d": BEEP .1,10: BEEP .1,10: PAUS
E 200: GO SUB 7300: RETURN
6500 BEEP .5,5: BEEP .5,1: PAUSE
60: GO TO 14
7000 LET Mem=34000: LET Owka=347
[illegible]0: LET Dwka=34750: LET Onam=346
0: LET Dnam=34650
7100 LET indir=32000: LET Ld1=32
003: LET Ld2=32006: LET Svnam=32
009: LET Svdata=32012: LET Svend
=32015: LET Renam=320[illegible]
7150 LET Nbcs=34003: LET Bsize=3
4004
7170 POKE Nbcs,14: POKE Bsize,2:
POKE Bsize+1,3
7200 RETURN
7300 INPUT "Insert Original Disk
";a$: RETURN
7400 INPUT "Insert Destination D
isk";a$: RETURN
7990 RETURN
9700 RESTORE 9800: FOR i=63000 T
O 63076: READ o: POKE i,o: NEXT
i: RETURN
9800 DATA 195,40,246,195,69,246,
243,205
9801 DATA 98,0,201,58,100,0,251,
201
9802 DATA 205,30,246,58,176,92,5
0,29
9803 DATA 32,205,126,0,205,123,0
,33
9804 DATA 112,32,17,16,248,1,192
,7
9805 DATA 237,176,195,35,246,205
,30,246
9806 DATA 58,176,92,50,29,32,33,
16
9807 DATA 248,17,112,32,1,192,7,
237
9808 DATA 176,205,150,0,205,126,
0,205
9809 DATA 120,0,195,35,246,0,0,0
9899 REM ! CLOSE #
9900 RANDOMIZE USR 100: SAVE "co
py.Bp" LINE 1

LISTING 6.

  90 CLS
95 LET add=29000
98 PAPER 7: INK 0: BORDER 7: CLS
100 PRINT "COPY I/O Routines"'''"1. RUN "'"2. CATALOGUE"'"3. RESTART"'"4. QUIT"
105 PRINT ''"Press selection"
110 LET d$=INKEY$
115 IF d$<"1" OR d$>"4" THEN GO TO 110
120 IF d$="1" THEN CLS : GO TO 300
130 IF d$="2" THEN GO TO 400
140 IF d$="3" AND PEEK add=205 THEN CLS : GO TO 500
145 IF d$="4" THEN RANDOMIZE USR 100: LOAD "menu.B1"
150 GO TO 110
300 POKE 23658,0
315 RANDOMIZE USR 100: LOAD "copy.Cc"CODE
320 RANDOMIZE USR 100: LOAD "move.Cz"CODE
340 RANDOMIZE USR add
350 GO TO 10
400 CLS : RANDOMIZE USR 100: CAT "",: PRINT #1;"[ENTER]": PAUSE 0
410 CLS : GO TO 100
420 GO TO 1
510 RANDOMIZE USR add
520 CLS : GO TO 1
999 STOP
1000 RANDOMIZE USR 100: SAVE "copyio.B2"
1005 PAPER 7: INK 9: BORDER 7: CLS
1010 RUN

Note: You will need a copy of LARKEN “move.Cz” to make this work

Note: Type-in program listings on this website use ZMAKEBAS notation for graphics characters.