REPAIR: A Larken Disk Repair Utility

See all articles from Sinc-Link v6 n1
Author(s): George Chambers
Publication: Sinc-Link
Pub Details: Sinc-Link v6 n1 (Volume 6, Issue 1)
Date: January/February 1988
Pages: 12-13

One of the things that I have experienced with the LARKEN disk system, particularly the earlier vintage was the occasional overwriting of the Directory track. This would result in the loss of all the programs on the disk. Now, these programs were not really lost, just inaccessible because of a messed-up track 0. I was always able to reconstruct the Directory manually, and after a while I wrote “DOCTOR” to make it easier.

There had to be a simpler way to do this. After all, the LARKEN system places a program name at the start of every used track. What could be more simple than to look at these track headers and use them to make up a new directory. That is just what “REPAIR” does.

The listing shown here is suitable for the earlier LARKEN systems (the ones that save 1960 bytes per track). This listing is given because the majority of LARKEN owners in our club have this vintage. I have also modified this program to work on the current vintage i.e. saves 5090 bytes per track. Both programs are available from our LARKEN tape library.

 100 REM  Disk Directory Repair for the LARKEN system
110 REM By G. Chambers 14 Richome Court Scarborough, Ont. CANADA MiK 2Y1
120 REM Use to reconstruct a damaged Directory(Track 0)
130 REM Data statements contain the "RMHDOS.C2" Code.
135 REM For disks made prior to the Larken cartridge DOS,modify lines 720 and 830, replacing the 34 in each line with a 33.
136 REM Use only with the LKDOS system i.e. 1960 bytes/track.
140 GO TO 160
150 RANDOMIZE USR 100: SAVE "repair.B1" LINE 160
160 RESTORE 210
170 FOR n=63000 TO 63104
180 READ a: POKE n,a
190 NEXT n
200 GO TO 290
210 DATA 195,43,246,195,72,246,195,104,246,243,205,98,0,201,58
220 DATA 100,0,251,201,205,33,246,58,176,92,50,29,32,205,126
230 DATA 0,205,123,0,33,112,32,17,16,248,1,192,7,237,176
240 DATA 195,38,246,205,33,246,58,176,92,50,29,32,33,16,248
250 DATA 17,112,32,1,192,7,237,176,205,150,0,205,126,0,205
260 DATA 120,0,195,38,246,205,33,246,205,129,0,205,123,0,33
270 DATA 112,32,17,16,248,1,192,7,237,176,195,38,246,201,0
290 DIM a$(79,9): DIM c$(79,9): DIM b$(9): DIM d$(256)
300 LET trac=23728: LET nexttrack=63006: LET loadbuf=63000: LET savebuf=63003
310 LET D=79: LET e=1: LET f=1: LET buffer=63500: LET name=63608: LET trackno=63618
312 BORDER 1: PAPER 1: CLS
320 PRINT AT 2,7; INK 2; PAPER 6;"LARKEN DISK UTILITY"; PAPER 1;,,TAB 2; PAPER 6;" Directory (Track 0) Recovery"; PAPER 1,,TAB 7; PAPER 6;"By George Chambers"
325 INK 3: PLOT 0,108: DRAW 0,62: DRAW 255,0: DRAW 0,-62: DRAW -255,0
326 INK 6: PLOT 8,114: DRAW 0,50: DRAW 238,0: DRAW 0,-50: DRAW -238,0: INK 7
330 PRINT '''TAB 2;"Install newly-formatted disk"''TAB 6;"and press any key": PAUSE 0
340 POKE trac,0: RANDOMIZE USR loadbuf
350 PRINT AT 10,0;d$;AT 14,1;"Now insert your defective disk"''TAB 2;"and Press any key to start": PAUSE 0
360 REM Picking program names off each successive track
370 POKE trac,1: RANDOMIZE USR loadbuf
380 PRINT AT 10,0;d$
390 PRINT AT 10,0;d$;AT 10,1;"Lifting names off disk tracks";AT 13,8;"Track Program"
400 PRINT AT 14,9;"No. Name"
410 FOR n=1 TO 79
415 IF n>1 AND PEEK 63518=0 AND PEEK 63519=0 THEN LET n=79: GO TO 490
420 LET d=n
430 FOR m=1 TO 9
440 LET a$(n,m)=CHR$ PEEK (63505+M)
450 NEXT m
460 PRINT AT 16,9;n;" ";a$(n)
480 IF n<79 THEN RANDOMIZE USR nexttrack
490 NEXT n
500 REM Placing Used/Free track record in buffer (Track 0)
510 POKE trac,0: RANDOMIZE USR loadbuf
520 FOR n=1 TO d
530 POKE 63527+n,n+127
540 NEXT n
550 REM Compile the program names into C$ array
560 PRINT AT 9,0;d$;AT 9,0;"Reconstruction of the directory will take a couple of minutes"''TAB 10;"Please wait"''TAB 4;"Compiling program names"
570 LET c$(1)=a$(1)
580 FOR n=2 TO d
590 LET b$=a$(n)
600 LET f=0
610 FOR m=1 TO e
620 IF b$=c$(m) THEN LET f=1
630 NEXT m
640 IF f=0 THEN LET e=e+1: LET c$(e)=b$
650 PRINT AT 16,11;c$(e)
660 NEXT n
670 REM Poke pgm names into buffer(Track 0)
675 PRINT AT 13,0;d$;AT 14,0;"Placing track names in directory"
680 FOR n=1 TO e
685 PAUSE 30
690 FOR m=1 TO 9
700 POKE name+m,CODE c$(n,m)
710 NEXT m
720 LET name=name+34
730 PRINT AT 16,11;c$(n)
740 NEXT n
750 REM Poke track numbers into buffer (Track 0)
760 LET f=1
770 PRINT AT 13,0;d$;AT 14,0;"Putting Track No's in Directory"
780 FOR n=1 TO e
790 LET f=1
800 FOR k=1 TO 79
810 IF c$(n)=a$(k) THEN POKE trackno+f,k+128: LET f=f+1: POKE trackno+f,249
820 NEXT k
830 LET trackno=trackno+34
840 PRINT AT 16,11;c$(n)
850 NEXT n
860 PRINT AT 9,0;d$;AT 10,1;"The directory has been rebuilt"'''' PAPER 5; INK 2;"Remove WRITE-PROTECT label from defective disk and install. "''''" Press a key to save to track 0 ": PAUSE 0
870 POKE trac,0: RANDOMIZE USR savebuf
880 PRINT AT 11,0;d$;AT 13,9;"JOB COMPLETED": PAUSE 0
890 STOP
1000: SAVE "repair" LINE 10