Home » Personal collection » Acorn ADFS disks » Greaseweazled » adfs_E00.adf » Library/BASIC/FindBadSec

Library/BASIC/FindBadSec

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Personal collection » Acorn ADFS disks » Greaseweazled » adfs_E00.adf
Filename: Library/BASIC/FindBadSec
Read OK:
File size: 0E82 bytes
Load address: FFFF1D00
Exec address: FFFF8023
File contents
   10REM  Program "FindBadSec".  Finds the bad sectors on a floppy or Winnie.
   20REM Looks for faulty sectors by reading the sectors via OSWORD &72.  
   30REM Asks for drive number, first & last sectors for search window.  
   40REM Searches a track at a time.
   50 
   55ON ERROR GOTO 960
   60MODE6
   65or% = ?&1000:  ?&1000 = 2 
   70SectorsPerTrack% = 16:  Read = 8:  OSWORD = &FFF1
   80DIM FCB 16, Buffer &1005  
   90 
  100PRINT '' "F I N D   B A D   S E C T O R  - V1.00"' 
  110 
  120REPEAT
  130INPUT "Drive 0, 1, 4 or 5?  " Drive$ 
  140IF Drive$ = "" Drive$ = "0"
  150UNTIL Drive$="0" OR Drive$ = "1" OR Drive$ = "4" OR Drive$ = "5"
  160PRINT"Reading drive "Drive$
  170Drive% = EVAL(Drive$)
  180 
  190REPEAT
  200 
  210    REPEAT
  220 
  230    INPUT '"Which sector should I start at?  Type a decimal number or a Hex number preceded by &  " FirstSector$  
  240    IF FirstSector$ = "" THEN FirstSector$ = "0"
  250    FirstSector% = EVAL(FirstSector$)
  260    PRINT "Starting   at  sector "; FirstSector% "  = &"; ~FirstSector%
  270    INPUT '"Which sector should I stop after? " LastSector$ 
  280    IF LastSector$ = "" THEN LastSector$ = "&4FF"  
  290    LastSector% = EVAL(LastSector$)
  300    IF LastSector% < FirstSector% THEN PRINT "Last sector < First sector" ELSE PRINT "Stopping after sector "; LastSector%"  = &"; ~LastSector%
  310 
  320    UNTIL LastSector% >= FirstSector%
  330 
  340PRINT '"Insert disc and press a key to start" : Junk% = GET 
  350OSCLI ("DIR:" + Drive$)
  360  REM  Reset drive else couldn't do an OSWORD &72 to drive 0 if drive 1 were selected
  370REM Now check disc size.  First set up FCB for OSWORD call.
  380 
  390!(FCB + 1) = Buffer:  ?(FCB + 10) = 0
  400REM  FCB is set up to read sector 0 in PROC ReadSector0
  410PROC_ReadSector0
  420TotalSectors% = ?(Buffer + 252) + (?(Buffer + 253))*&100 + (?(Buffer + 254))*&10000
  430IF TotalSectors% <= LastSector% THEN PRINT'"This disc only contains &"; ~TotalSectors% " sectors" 
  440 
  450UNTIL TotalSectors% > LastSector%
  460 
  480ThisSector% = FirstSector%
  490NoOfBadSectors% = 0
  500CLS
  510PRINT ''''SPC(10) "BAD SECTORS" '"    Sector         Error code"'" (Dec)   (Hex)"'
  520VDU28,2,20,39,6
  525VDU 23,1,0;0;0;0;
  530 
  540REM Now the real work - read the sectors
  550REPEAT
  560 SectorsLeftOnTrack% = SectorsPerTrack% - (ThisSector% MOD SectorsPerTrack%)
  570Temp% = LastSector% - ThisSector%
  580IF Temp% < SectorsLeftOnTrack% THEN SectorsLeftOnTrack% = Temp% + 1
  590?(FCB + 6) = (ThisSector% DIV &10000) AND &FF
  600?(FCB + 7) = (ThisSector% DIV &100) AND &FF 
  610?(FCB + 8) = (ThisSector% ) AND &FF 
  620?(FCB + 9) = SectorsLeftOnTrack%
  630 
  640vpos%=VPOS
  650VDU26   
  660PRINTTAB(4,2)"READING TRACK" ThisSector% DIV 16
  670VDU28,2,24,39,8
  680PRINTTAB(0,vpos%);
  690 
  700PROC_ReadSectors
  710ThisSector% = ((ThisSector% + SectorsPerTrack%) DIV SectorsPerTrack%) * SectorsPerTrack%
  720 
  730 
  740IF ?FCB = 0 THEN GOTO 900
  750 
  760REM  Error has occurred
  770NoOfBadSectors% = NoOfBadSectors% + 1
  780A% = &73:  X% = Buffer AND &FF:  Y% = (Buffer DIV &100) AND &FF
  790CALL OSWORD
  800ThisSector% = ?Buffer + (?(Buffer + 1))*&100 + ((?(Buffer + 2)) AND &1F)*&10000 
  810Error% = (?(Buffer + 3)) AND &7F
  820PROC_ReadSector0
  830 
  840PRINT ; ThisSector%;TAB(8) ~ ThisSector%;TAB(21) ~Error% 
  850IFNoOfBadSectors% MOD 15 = 0THEN PRINT"Continue?(Y/N) ";:  go$ = GET$ :PRINTgo$ :ELSE go$ = "y" 
  860 ThisSector% = ThisSector% + 1:    REM Start on next sector
  870IF go$ <> "Y" AND go$ <> "y" THEN GOTO 950
  880REM  End of error part
  890 
  900 
  910UNTIL ThisSector% > LastSector%
  920 
  930IF NoOfBadSectors% = 0 PRINT''"Search done, no bad sectors found"
  940IF NoOfBadSectors%  = 1 PRINT''"Search done, 1 bad sector found" 
  950IF NoOfBadSectors% > 1 PRINT''"Search done, "; NoOfBadSectors% " bad sectors found"
  960?&1000 = or%
  970VDU26
  975VDU 23,1,1;0;0;0;
  980PRINTTAB(0,23)
  990END
 1000 
 1010 
 1020DEFPROC_ReadSector0
 1030?FCB=0
 1040!(FCB + 5) = Read
 1050?(FCB + 9) = 1:         REM Read 1 sector
 1060PROC_ReadSectors
 1070ENDPROC
 1080 
 1090DEFPROC_ReadSectors
 1100A% = &72
 1110X% = FCB AND &FF:  Y% = (FCB DIV &100) AND &FF
 1120CALL OSWORD
 1130ENDPROC

J�  Program "FindBadSec".  Finds the bad sectors on a floppy or Winnie.
G� Looks for faulty sectors by reading the sectors via OSWORD &72.  
F� Asks for drive number, first & last sectors for search window.  
(!� Searches a track at a time.
2 
7� � � �d@C
<�6
Aor% = ?&1000:  ?&1000 = 2 
F5SectorsPerTrack% = 16:  Read = 8:  OSWORD = &FFF1
P� FCB 16, Buffer &1005  
Z 
d3� '' "F I N D   B A D   S E C T O R  - V1.00"' 
n 
x�
�%� "Drive 0, 1, 4 or 5?  " Drive$ 
�� Drive$ = "" Drive$ = "0"
�=� Drive$="0" � Drive$ = "1" � Drive$ = "4" � Drive$ = "5"
��"Reading drive "Drive$
�Drive% = �(Drive$)
� 
��
� 
�	    �
� 
�r    � '"Which sector should I start at?  Type a decimal number or a Hex number preceded by &  " FirstSector$  
�0    � FirstSector$ = "" � FirstSector$ = "0"
�&    FirstSector% = �(FirstSector$)
G    � "Starting   at  sector "; FirstSector% "  = &"; ~FirstSector%
<    � '"Which sector should I stop after? " LastSector$ 
3    � LastSector$ = "" � LastSector$ = "&4FF"  
"$    LastSector% = �(LastSector$)
,�    � LastSector% < FirstSector% � � "Last sector < First sector" � � "Stopping after sector "; LastSector%"  = &"; ~LastSector%
6 
@%    � LastSector% >= FirstSector%
J 
T:� '"Insert disc and press a key to start" : Junk% = � 
^� ("DIR:" + Drive$)
hW  �  Reset drive else couldn't do an OSWORD &72 to drive 0 if drive 1 were selected
r=� Now check disc size.  First set up FCB for OSWORD call.
| 
�)!(FCB + 1) = Buffer:  ?(FCB + 10) = 0
�9�  FCB is set up to read sector 0 in PROC ReadSector0
��_ReadSector0
�WTotalSectors% = ?(Buffer + 252) + (?(Buffer + 253))*&100 + (?(Buffer + 254))*&10000
�^� TotalSectors% <= LastSector% � �'"This disc only contains &"; ~TotalSectors% " sectors" 
� 
�!� TotalSectors% > LastSector%
� 
�ThisSector% = FirstSector%
�NoOfBadSectors% = 0
��
�P� ''''�(10) "BAD SECTORS" '"    Sector         Error code"'" (Dec)   (Hex)"'
�28,2,20,39,6

� 23,1,0;0;0;0;
 
*� Now the real work - read the sectors
&�
0N SectorsLeftOnTrack% = SectorsPerTrack% - (ThisSector% � SectorsPerTrack%)
:%Temp% = LastSector% - ThisSector%
DC� Temp% < SectorsLeftOnTrack% � SectorsLeftOnTrack% = Temp% + 1
N-?(FCB + 6) = (ThisSector% � &10000) � &FF
X,?(FCB + 7) = (ThisSector% � &100) � &FF 
b&?(FCB + 8) = (ThisSector% ) � &FF 
l$?(FCB + 9) = SectorsLeftOnTrack%
v 
�vpos%=�
�
�26   
�*�4,2)"READING TRACK" ThisSector% � 16
��28,2,24,39,8
��0,vpos%);
� 
��_ReadSectors
�ZThisSector% = ((ThisSector% + SectorsPerTrack%) � SectorsPerTrack%) * SectorsPerTrack%
� 
� 
�� ?FCB = 0 � � �tDC
� 
��  Error has occurred
)NoOfBadSectors% = NoOfBadSectors% + 1
=A% = &73:  X% = Buffer � &FF:  Y% = (Buffer � &100) � &FF
� OSWORD
 RThisSector% = ?Buffer + (?(Buffer + 1))*&100 + ((?(Buffer + 2)) � &1F)*&10000 
*"Error% = (?(Buffer + 3)) � &7F
4�_ReadSector0
> 
H3� ; ThisSector%;�8) ~ ThisSector%;�21) ~Error% 
RP�NoOfBadSectors% � 15 = 0� �"Continue?(Y/N) ";:  go$ = � :�go$ :� go$ = "y" 
\= ThisSector% = ThisSector% + 1:    � Start on next sector
f&� go$ <> "Y" � go$ <> "y" � � �tvC
p�  End of error part
z 
� 
�� ThisSector% > LastSector%
� 
�@� NoOfBadSectors% = 0 �''"Search done, no bad sectors found"
�@� NoOfBadSectors%  = 1 �''"Search done, 1 bad sector found" 
�R� NoOfBadSectors% > 1 �''"Search done, "; NoOfBadSectors% " bad sectors found"
�?&1000 = or%
��26
�� 23,1,1;0;0;0;
��0,23)
��
� 
� 
���_ReadSector0

?FCB=0
!(FCB + 5) = Read
+?(FCB + 9) = 1:         � Read 1 sector
$�_ReadSectors
.�
8 
B��_ReadSectors
LA% = &72
V,X% = FCB � &FF:  Y% = (FCB � &100) � &FF
`� OSWORD
j�
�
00000000  0d 00 0a 4a f4 20 20 50  72 6f 67 72 61 6d 20 22  |...J.  Program "|
00000010  46 69 6e 64 42 61 64 53  65 63 22 2e 20 20 46 69  |FindBadSec".  Fi|
00000020  6e 64 73 20 74 68 65 20  62 61 64 20 73 65 63 74  |nds the bad sect|
00000030  6f 72 73 20 6f 6e 20 61  20 66 6c 6f 70 70 79 20  |ors on a floppy |
00000040  6f 72 20 57 69 6e 6e 69  65 2e 0d 00 14 47 f4 20  |or Winnie....G. |
00000050  4c 6f 6f 6b 73 20 66 6f  72 20 66 61 75 6c 74 79  |Looks for faulty|
00000060  20 73 65 63 74 6f 72 73  20 62 79 20 72 65 61 64  | sectors by read|
00000070  69 6e 67 20 74 68 65 20  73 65 63 74 6f 72 73 20  |ing the sectors |
00000080  76 69 61 20 4f 53 57 4f  52 44 20 26 37 32 2e 20  |via OSWORD &72. |
00000090  20 0d 00 1e 46 f4 20 41  73 6b 73 20 66 6f 72 20  | ...F. Asks for |
000000a0  64 72 69 76 65 20 6e 75  6d 62 65 72 2c 20 66 69  |drive number, fi|
000000b0  72 73 74 20 26 20 6c 61  73 74 20 73 65 63 74 6f  |rst & last secto|
000000c0  72 73 20 66 6f 72 20 73  65 61 72 63 68 20 77 69  |rs for search wi|
000000d0  6e 64 6f 77 2e 20 20 0d  00 28 21 f4 20 53 65 61  |ndow.  ..(!. Sea|
000000e0  72 63 68 65 73 20 61 20  74 72 61 63 6b 20 61 74  |rches a track at|
000000f0  20 61 20 74 69 6d 65 2e  0d 00 32 05 20 0d 00 37  | a time...2. ..7|
00000100  0e ee 20 85 20 e5 20 8d  64 40 43 0d 00 3c 06 eb  |.. . . .d@C..<..|
00000110  36 0d 00 41 1e 6f 72 25  20 3d 20 3f 26 31 30 30  |6..A.or% = ?&100|
00000120  30 3a 20 20 3f 26 31 30  30 30 20 3d 20 32 20 0d  |0:  ?&1000 = 2 .|
00000130  00 46 35 53 65 63 74 6f  72 73 50 65 72 54 72 61  |.F5SectorsPerTra|
00000140  63 6b 25 20 3d 20 31 36  3a 20 20 52 65 61 64 20  |ck% = 16:  Read |
00000150  3d 20 38 3a 20 20 4f 53  57 4f 52 44 20 3d 20 26  |= 8:  OSWORD = &|
00000160  46 46 46 31 0d 00 50 1c  de 20 46 43 42 20 31 36  |FFF1..P.. FCB 16|
00000170  2c 20 42 75 66 66 65 72  20 26 31 30 30 35 20 20  |, Buffer &1005  |
00000180  0d 00 5a 05 20 0d 00 64  33 f1 20 27 27 20 22 46  |..Z. ..d3. '' "F|
00000190  20 49 20 4e 20 44 20 20  20 42 20 41 20 44 20 20  | I N D   B A D  |
000001a0  20 53 20 45 20 43 20 54  20 4f 20 52 20 20 2d 20  | S E C T O R  - |
000001b0  56 31 2e 30 30 22 27 20  0d 00 6e 05 20 0d 00 78  |V1.00"' ..n. ..x|
000001c0  05 f5 0d 00 82 25 e8 20  22 44 72 69 76 65 20 30  |.....%. "Drive 0|
000001d0  2c 20 31 2c 20 34 20 6f  72 20 35 3f 20 20 22 20  |, 1, 4 or 5?  " |
000001e0  44 72 69 76 65 24 20 0d  00 8c 1e e7 20 44 72 69  |Drive$ ..... Dri|
000001f0  76 65 24 20 3d 20 22 22  20 44 72 69 76 65 24 20  |ve$ = "" Drive$ |
00000200  3d 20 22 30 22 0d 00 96  3d fd 20 44 72 69 76 65  |= "0"...=. Drive|
00000210  24 3d 22 30 22 20 84 20  44 72 69 76 65 24 20 3d  |$="0" . Drive$ =|
00000220  20 22 31 22 20 84 20 44  72 69 76 65 24 20 3d 20  | "1" . Drive$ = |
00000230  22 34 22 20 84 20 44 72  69 76 65 24 20 3d 20 22  |"4" . Drive$ = "|
00000240  35 22 0d 00 a0 1b f1 22  52 65 61 64 69 6e 67 20  |5"....."Reading |
00000250  64 72 69 76 65 20 22 44  72 69 76 65 24 0d 00 aa  |drive "Drive$...|
00000260  16 44 72 69 76 65 25 20  3d 20 a0 28 44 72 69 76  |.Drive% = .(Driv|
00000270  65 24 29 0d 00 b4 05 20  0d 00 be 05 f5 0d 00 c8  |e$).... ........|
00000280  05 20 0d 00 d2 09 20 20  20 20 f5 0d 00 dc 05 20  |. ....    ..... |
00000290  0d 00 e6 72 20 20 20 20  e8 20 27 22 57 68 69 63  |...r    . '"Whic|
000002a0  68 20 73 65 63 74 6f 72  20 73 68 6f 75 6c 64 20  |h sector should |
000002b0  49 20 73 74 61 72 74 20  61 74 3f 20 20 54 79 70  |I start at?  Typ|
000002c0  65 20 61 20 64 65 63 69  6d 61 6c 20 6e 75 6d 62  |e a decimal numb|
000002d0  65 72 20 6f 72 20 61 20  48 65 78 20 6e 75 6d 62  |er or a Hex numb|
000002e0  65 72 20 70 72 65 63 65  64 65 64 20 62 79 20 26  |er preceded by &|
000002f0  20 20 22 20 46 69 72 73  74 53 65 63 74 6f 72 24  |  " FirstSector$|
00000300  20 20 0d 00 f0 30 20 20  20 20 e7 20 46 69 72 73  |  ...0    . Firs|
00000310  74 53 65 63 74 6f 72 24  20 3d 20 22 22 20 8c 20  |tSector$ = "" . |
00000320  46 69 72 73 74 53 65 63  74 6f 72 24 20 3d 20 22  |FirstSector$ = "|
00000330  30 22 0d 00 fa 26 20 20  20 20 46 69 72 73 74 53  |0"...&    FirstS|
00000340  65 63 74 6f 72 25 20 3d  20 a0 28 46 69 72 73 74  |ector% = .(First|
00000350  53 65 63 74 6f 72 24 29  0d 01 04 47 20 20 20 20  |Sector$)...G    |
00000360  f1 20 22 53 74 61 72 74  69 6e 67 20 20 20 61 74  |. "Starting   at|
00000370  20 20 73 65 63 74 6f 72  20 22 3b 20 46 69 72 73  |  sector "; Firs|
00000380  74 53 65 63 74 6f 72 25  20 22 20 20 3d 20 26 22  |tSector% "  = &"|
00000390  3b 20 7e 46 69 72 73 74  53 65 63 74 6f 72 25 0d  |; ~FirstSector%.|
000003a0  01 0e 3c 20 20 20 20 e8  20 27 22 57 68 69 63 68  |..<    . '"Which|
000003b0  20 73 65 63 74 6f 72 20  73 68 6f 75 6c 64 20 49  | sector should I|
000003c0  20 73 74 6f 70 20 61 66  74 65 72 3f 20 22 20 4c  | stop after? " L|
000003d0  61 73 74 53 65 63 74 6f  72 24 20 0d 01 18 33 20  |astSector$ ...3 |
000003e0  20 20 20 e7 20 4c 61 73  74 53 65 63 74 6f 72 24  |   . LastSector$|
000003f0  20 3d 20 22 22 20 8c 20  4c 61 73 74 53 65 63 74  | = "" . LastSect|
00000400  6f 72 24 20 3d 20 22 26  34 46 46 22 20 20 0d 01  |or$ = "&4FF"  ..|
00000410  22 24 20 20 20 20 4c 61  73 74 53 65 63 74 6f 72  |"$    LastSector|
00000420  25 20 3d 20 a0 28 4c 61  73 74 53 65 63 74 6f 72  |% = .(LastSector|
00000430  24 29 0d 01 2c 84 20 20  20 20 e7 20 4c 61 73 74  |$)..,.    . Last|
00000440  53 65 63 74 6f 72 25 20  3c 20 46 69 72 73 74 53  |Sector% < FirstS|
00000450  65 63 74 6f 72 25 20 8c  20 f1 20 22 4c 61 73 74  |ector% . . "Last|
00000460  20 73 65 63 74 6f 72 20  3c 20 46 69 72 73 74 20  | sector < First |
00000470  73 65 63 74 6f 72 22 20  8b 20 f1 20 22 53 74 6f  |sector" . . "Sto|
00000480  70 70 69 6e 67 20 61 66  74 65 72 20 73 65 63 74  |pping after sect|
00000490  6f 72 20 22 3b 20 4c 61  73 74 53 65 63 74 6f 72  |or "; LastSector|
000004a0  25 22 20 20 3d 20 26 22  3b 20 7e 4c 61 73 74 53  |%"  = &"; ~LastS|
000004b0  65 63 74 6f 72 25 0d 01  36 05 20 0d 01 40 25 20  |ector%..6. ..@% |
000004c0  20 20 20 fd 20 4c 61 73  74 53 65 63 74 6f 72 25  |   . LastSector%|
000004d0  20 3e 3d 20 46 69 72 73  74 53 65 63 74 6f 72 25  | >= FirstSector%|
000004e0  0d 01 4a 05 20 0d 01 54  3a f1 20 27 22 49 6e 73  |..J. ..T:. '"Ins|
000004f0  65 72 74 20 64 69 73 63  20 61 6e 64 20 70 72 65  |ert disc and pre|
00000500  73 73 20 61 20 6b 65 79  20 74 6f 20 73 74 61 72  |ss a key to star|
00000510  74 22 20 3a 20 4a 75 6e  6b 25 20 3d 20 a5 20 0d  |t" : Junk% = . .|
00000520  01 5e 17 ff 20 28 22 44  49 52 3a 22 20 2b 20 44  |.^.. ("DIR:" + D|
00000530  72 69 76 65 24 29 0d 01  68 57 20 20 f4 20 20 52  |rive$)..hW  .  R|
00000540  65 73 65 74 20 64 72 69  76 65 20 65 6c 73 65 20  |eset drive else |
00000550  63 6f 75 6c 64 6e 27 74  20 64 6f 20 61 6e 20 4f  |couldn't do an O|
00000560  53 57 4f 52 44 20 26 37  32 20 74 6f 20 64 72 69  |SWORD &72 to dri|
00000570  76 65 20 30 20 69 66 20  64 72 69 76 65 20 31 20  |ve 0 if drive 1 |
00000580  77 65 72 65 20 73 65 6c  65 63 74 65 64 0d 01 72  |were selected..r|
00000590  3d f4 20 4e 6f 77 20 63  68 65 63 6b 20 64 69 73  |=. Now check dis|
000005a0  63 20 73 69 7a 65 2e 20  20 46 69 72 73 74 20 73  |c size.  First s|
000005b0  65 74 20 75 70 20 46 43  42 20 66 6f 72 20 4f 53  |et up FCB for OS|
000005c0  57 4f 52 44 20 63 61 6c  6c 2e 0d 01 7c 05 20 0d  |WORD call...|. .|
000005d0  01 86 29 21 28 46 43 42  20 2b 20 31 29 20 3d 20  |..)!(FCB + 1) = |
000005e0  42 75 66 66 65 72 3a 20  20 3f 28 46 43 42 20 2b  |Buffer:  ?(FCB +|
000005f0  20 31 30 29 20 3d 20 30  0d 01 90 39 f4 20 20 46  | 10) = 0...9.  F|
00000600  43 42 20 69 73 20 73 65  74 20 75 70 20 74 6f 20  |CB is set up to |
00000610  72 65 61 64 20 73 65 63  74 6f 72 20 30 20 69 6e  |read sector 0 in|
00000620  20 50 52 4f 43 20 52 65  61 64 53 65 63 74 6f 72  | PROC ReadSector|
00000630  30 0d 01 9a 11 f2 5f 52  65 61 64 53 65 63 74 6f  |0....._ReadSecto|
00000640  72 30 0d 01 a4 57 54 6f  74 61 6c 53 65 63 74 6f  |r0...WTotalSecto|
00000650  72 73 25 20 3d 20 3f 28  42 75 66 66 65 72 20 2b  |rs% = ?(Buffer +|
00000660  20 32 35 32 29 20 2b 20  28 3f 28 42 75 66 66 65  | 252) + (?(Buffe|
00000670  72 20 2b 20 32 35 33 29  29 2a 26 31 30 30 20 2b  |r + 253))*&100 +|
00000680  20 28 3f 28 42 75 66 66  65 72 20 2b 20 32 35 34  | (?(Buffer + 254|
00000690  29 29 2a 26 31 30 30 30  30 0d 01 ae 5e e7 20 54  |))*&10000...^. T|
000006a0  6f 74 61 6c 53 65 63 74  6f 72 73 25 20 3c 3d 20  |otalSectors% <= |
000006b0  4c 61 73 74 53 65 63 74  6f 72 25 20 8c 20 f1 27  |LastSector% . .'|
000006c0  22 54 68 69 73 20 64 69  73 63 20 6f 6e 6c 79 20  |"This disc only |
000006d0  63 6f 6e 74 61 69 6e 73  20 26 22 3b 20 7e 54 6f  |contains &"; ~To|
000006e0  74 61 6c 53 65 63 74 6f  72 73 25 20 22 20 73 65  |talSectors% " se|
000006f0  63 74 6f 72 73 22 20 0d  01 b8 05 20 0d 01 c2 21  |ctors" .... ...!|
00000700  fd 20 54 6f 74 61 6c 53  65 63 74 6f 72 73 25 20  |. TotalSectors% |
00000710  3e 20 4c 61 73 74 53 65  63 74 6f 72 25 0d 01 cc  |> LastSector%...|
00000720  05 20 0d 01 e0 1e 54 68  69 73 53 65 63 74 6f 72  |. ....ThisSector|
00000730  25 20 3d 20 46 69 72 73  74 53 65 63 74 6f 72 25  |% = FirstSector%|
00000740  0d 01 ea 17 4e 6f 4f 66  42 61 64 53 65 63 74 6f  |....NoOfBadSecto|
00000750  72 73 25 20 3d 20 30 0d  01 f4 05 db 0d 01 fe 50  |rs% = 0........P|
00000760  f1 20 27 27 27 27 89 28  31 30 29 20 22 42 41 44  |. ''''.(10) "BAD|
00000770  20 53 45 43 54 4f 52 53  22 20 27 22 20 20 20 20  | SECTORS" '"    |
00000780  53 65 63 74 6f 72 20 20  20 20 20 20 20 20 20 45  |Sector         E|
00000790  72 72 6f 72 20 63 6f 64  65 22 27 22 20 28 44 65  |rror code"'" (De|
000007a0  63 29 20 20 20 28 48 65  78 29 22 27 0d 02 08 11  |c)   (Hex)"'....|
000007b0  ef 32 38 2c 32 2c 32 30  2c 33 39 2c 36 0d 02 0d  |.28,2,20,39,6...|
000007c0  13 ef 20 32 33 2c 31 2c  30 3b 30 3b 30 3b 30 3b  |.. 23,1,0;0;0;0;|
000007d0  0d 02 12 05 20 0d 02 1c  2a f4 20 4e 6f 77 20 74  |.... ...*. Now t|
000007e0  68 65 20 72 65 61 6c 20  77 6f 72 6b 20 2d 20 72  |he real work - r|
000007f0  65 61 64 20 74 68 65 20  73 65 63 74 6f 72 73 0d  |ead the sectors.|
00000800  02 26 05 f5 0d 02 30 4e  20 53 65 63 74 6f 72 73  |.&....0N Sectors|
00000810  4c 65 66 74 4f 6e 54 72  61 63 6b 25 20 3d 20 53  |LeftOnTrack% = S|
00000820  65 63 74 6f 72 73 50 65  72 54 72 61 63 6b 25 20  |ectorsPerTrack% |
00000830  2d 20 28 54 68 69 73 53  65 63 74 6f 72 25 20 83  |- (ThisSector% .|
00000840  20 53 65 63 74 6f 72 73  50 65 72 54 72 61 63 6b  | SectorsPerTrack|
00000850  25 29 0d 02 3a 25 54 65  6d 70 25 20 3d 20 4c 61  |%)..:%Temp% = La|
00000860  73 74 53 65 63 74 6f 72  25 20 2d 20 54 68 69 73  |stSector% - This|
00000870  53 65 63 74 6f 72 25 0d  02 44 43 e7 20 54 65 6d  |Sector%..DC. Tem|
00000880  70 25 20 3c 20 53 65 63  74 6f 72 73 4c 65 66 74  |p% < SectorsLeft|
00000890  4f 6e 54 72 61 63 6b 25  20 8c 20 53 65 63 74 6f  |OnTrack% . Secto|
000008a0  72 73 4c 65 66 74 4f 6e  54 72 61 63 6b 25 20 3d  |rsLeftOnTrack% =|
000008b0  20 54 65 6d 70 25 20 2b  20 31 0d 02 4e 2d 3f 28  | Temp% + 1..N-?(|
000008c0  46 43 42 20 2b 20 36 29  20 3d 20 28 54 68 69 73  |FCB + 6) = (This|
000008d0  53 65 63 74 6f 72 25 20  81 20 26 31 30 30 30 30  |Sector% . &10000|
000008e0  29 20 80 20 26 46 46 0d  02 58 2c 3f 28 46 43 42  |) . &FF..X,?(FCB|
000008f0  20 2b 20 37 29 20 3d 20  28 54 68 69 73 53 65 63  | + 7) = (ThisSec|
00000900  74 6f 72 25 20 81 20 26  31 30 30 29 20 80 20 26  |tor% . &100) . &|
00000910  46 46 20 0d 02 62 26 3f  28 46 43 42 20 2b 20 38  |FF ..b&?(FCB + 8|
00000920  29 20 3d 20 28 54 68 69  73 53 65 63 74 6f 72 25  |) = (ThisSector%|
00000930  20 29 20 80 20 26 46 46  20 0d 02 6c 24 3f 28 46  | ) . &FF ..l$?(F|
00000940  43 42 20 2b 20 39 29 20  3d 20 53 65 63 74 6f 72  |CB + 9) = Sector|
00000950  73 4c 65 66 74 4f 6e 54  72 61 63 6b 25 0d 02 76  |sLeftOnTrack%..v|
00000960  05 20 0d 02 80 0b 76 70  6f 73 25 3d bc 0d 02 8a  |. ....vpos%=....|
00000970  0a ef 32 36 20 20 20 0d  02 94 2a f1 8a 34 2c 32  |..26   ...*..4,2|
00000980  29 22 52 45 41 44 49 4e  47 20 54 52 41 43 4b 22  |)"READING TRACK"|
00000990  20 54 68 69 73 53 65 63  74 6f 72 25 20 81 20 31  | ThisSector% . 1|
000009a0  36 0d 02 9e 11 ef 32 38  2c 32 2c 32 34 2c 33 39  |6.....28,2,24,39|
000009b0  2c 38 0d 02 a8 0f f1 8a  30 2c 76 70 6f 73 25 29  |,8......0,vpos%)|
000009c0  3b 0d 02 b2 05 20 0d 02  bc 11 f2 5f 52 65 61 64  |;.... ....._Read|
000009d0  53 65 63 74 6f 72 73 0d  02 c6 5a 54 68 69 73 53  |Sectors...ZThisS|
000009e0  65 63 74 6f 72 25 20 3d  20 28 28 54 68 69 73 53  |ector% = ((ThisS|
000009f0  65 63 74 6f 72 25 20 2b  20 53 65 63 74 6f 72 73  |ector% + Sectors|
00000a00  50 65 72 54 72 61 63 6b  25 29 20 81 20 53 65 63  |PerTrack%) . Sec|
00000a10  74 6f 72 73 50 65 72 54  72 61 63 6b 25 29 20 2a  |torsPerTrack%) *|
00000a20  20 53 65 63 74 6f 72 73  50 65 72 54 72 61 63 6b  | SectorsPerTrack|
00000a30  25 0d 02 d0 05 20 0d 02  da 05 20 0d 02 e4 17 e7  |%.... .... .....|
00000a40  20 3f 46 43 42 20 3d 20  30 20 8c 20 e5 20 8d 74  | ?FCB = 0 . . .t|
00000a50  44 43 0d 02 ee 05 20 0d  02 f8 19 f4 20 20 45 72  |DC.... .....  Er|
00000a60  72 6f 72 20 68 61 73 20  6f 63 63 75 72 72 65 64  |ror has occurred|
00000a70  0d 03 02 29 4e 6f 4f 66  42 61 64 53 65 63 74 6f  |...)NoOfBadSecto|
00000a80  72 73 25 20 3d 20 4e 6f  4f 66 42 61 64 53 65 63  |rs% = NoOfBadSec|
00000a90  74 6f 72 73 25 20 2b 20  31 0d 03 0c 3d 41 25 20  |tors% + 1...=A% |
00000aa0  3d 20 26 37 33 3a 20 20  58 25 20 3d 20 42 75 66  |= &73:  X% = Buf|
00000ab0  66 65 72 20 80 20 26 46  46 3a 20 20 59 25 20 3d  |fer . &FF:  Y% =|
00000ac0  20 28 42 75 66 66 65 72  20 81 20 26 31 30 30 29  | (Buffer . &100)|
00000ad0  20 80 20 26 46 46 0d 03  16 0c d6 20 4f 53 57 4f  | . &FF..... OSWO|
00000ae0  52 44 0d 03 20 52 54 68  69 73 53 65 63 74 6f 72  |RD.. RThisSector|
00000af0  25 20 3d 20 3f 42 75 66  66 65 72 20 2b 20 28 3f  |% = ?Buffer + (?|
00000b00  28 42 75 66 66 65 72 20  2b 20 31 29 29 2a 26 31  |(Buffer + 1))*&1|
00000b10  30 30 20 2b 20 28 28 3f  28 42 75 66 66 65 72 20  |00 + ((?(Buffer |
00000b20  2b 20 32 29 29 20 80 20  26 31 46 29 2a 26 31 30  |+ 2)) . &1F)*&10|
00000b30  30 30 30 20 0d 03 2a 22  45 72 72 6f 72 25 20 3d  |000 ..*"Error% =|
00000b40  20 28 3f 28 42 75 66 66  65 72 20 2b 20 33 29 29  | (?(Buffer + 3))|
00000b50  20 80 20 26 37 46 0d 03  34 11 f2 5f 52 65 61 64  | . &7F..4.._Read|
00000b60  53 65 63 74 6f 72 30 0d  03 3e 05 20 0d 03 48 33  |Sector0..>. ..H3|
00000b70  f1 20 3b 20 54 68 69 73  53 65 63 74 6f 72 25 3b  |. ; ThisSector%;|
00000b80  8a 38 29 20 7e 20 54 68  69 73 53 65 63 74 6f 72  |.8) ~ ThisSector|
00000b90  25 3b 8a 32 31 29 20 7e  45 72 72 6f 72 25 20 0d  |%;.21) ~Error% .|
00000ba0  03 52 50 e7 4e 6f 4f 66  42 61 64 53 65 63 74 6f  |.RP.NoOfBadSecto|
00000bb0  72 73 25 20 83 20 31 35  20 3d 20 30 8c 20 f1 22  |rs% . 15 = 0. ."|
00000bc0  43 6f 6e 74 69 6e 75 65  3f 28 59 2f 4e 29 20 22  |Continue?(Y/N) "|
00000bd0  3b 3a 20 20 67 6f 24 20  3d 20 be 20 3a f1 67 6f  |;:  go$ = . :.go|
00000be0  24 20 3a 8b 20 67 6f 24  20 3d 20 22 79 22 20 0d  |$ :. go$ = "y" .|
00000bf0  03 5c 3d 20 54 68 69 73  53 65 63 74 6f 72 25 20  |.\= ThisSector% |
00000c00  3d 20 54 68 69 73 53 65  63 74 6f 72 25 20 2b 20  |= ThisSector% + |
00000c10  31 3a 20 20 20 20 f4 20  53 74 61 72 74 20 6f 6e  |1:    . Start on|
00000c20  20 6e 65 78 74 20 73 65  63 74 6f 72 0d 03 66 26  | next sector..f&|
00000c30  e7 20 67 6f 24 20 3c 3e  20 22 59 22 20 80 20 67  |. go$ <> "Y" . g|
00000c40  6f 24 20 3c 3e 20 22 79  22 20 8c 20 e5 20 8d 74  |o$ <> "y" . . .t|
00000c50  76 43 0d 03 70 18 f4 20  20 45 6e 64 20 6f 66 20  |vC..p..  End of |
00000c60  65 72 72 6f 72 20 70 61  72 74 0d 03 7a 05 20 0d  |error part..z. .|
00000c70  03 84 05 20 0d 03 8e 1f  fd 20 54 68 69 73 53 65  |... ..... ThisSe|
00000c80  63 74 6f 72 25 20 3e 20  4c 61 73 74 53 65 63 74  |ctor% > LastSect|
00000c90  6f 72 25 0d 03 98 05 20  0d 03 a2 40 e7 20 4e 6f  |or%.... ...@. No|
00000ca0  4f 66 42 61 64 53 65 63  74 6f 72 73 25 20 3d 20  |OfBadSectors% = |
00000cb0  30 20 f1 27 27 22 53 65  61 72 63 68 20 64 6f 6e  |0 .''"Search don|
00000cc0  65 2c 20 6e 6f 20 62 61  64 20 73 65 63 74 6f 72  |e, no bad sector|
00000cd0  73 20 66 6f 75 6e 64 22  0d 03 ac 40 e7 20 4e 6f  |s found"...@. No|
00000ce0  4f 66 42 61 64 53 65 63  74 6f 72 73 25 20 20 3d  |OfBadSectors%  =|
00000cf0  20 31 20 f1 27 27 22 53  65 61 72 63 68 20 64 6f  | 1 .''"Search do|
00000d00  6e 65 2c 20 31 20 62 61  64 20 73 65 63 74 6f 72  |ne, 1 bad sector|
00000d10  20 66 6f 75 6e 64 22 20  0d 03 b6 52 e7 20 4e 6f  | found" ...R. No|
00000d20  4f 66 42 61 64 53 65 63  74 6f 72 73 25 20 3e 20  |OfBadSectors% > |
00000d30  31 20 f1 27 27 22 53 65  61 72 63 68 20 64 6f 6e  |1 .''"Search don|
00000d40  65 2c 20 22 3b 20 4e 6f  4f 66 42 61 64 53 65 63  |e, "; NoOfBadSec|
00000d50  74 6f 72 73 25 20 22 20  62 61 64 20 73 65 63 74  |tors% " bad sect|
00000d60  6f 72 73 20 66 6f 75 6e  64 22 0d 03 c0 10 3f 26  |ors found"....?&|
00000d70  31 30 30 30 20 3d 20 6f  72 25 0d 03 ca 07 ef 32  |1000 = or%.....2|
00000d80  36 0d 03 cf 13 ef 20 32  33 2c 31 2c 31 3b 30 3b  |6..... 23,1,1;0;|
00000d90  30 3b 30 3b 0d 03 d4 0b  f1 8a 30 2c 32 33 29 0d  |0;0;......0,23).|
00000da0  03 de 05 e0 0d 03 e8 05  20 0d 03 f2 05 20 0d 03  |........ .... ..|
00000db0  fc 12 dd f2 5f 52 65 61  64 53 65 63 74 6f 72 30  |...._ReadSector0|
00000dc0  0d 04 06 0a 3f 46 43 42  3d 30 0d 04 10 15 21 28  |....?FCB=0....!(|
00000dd0  46 43 42 20 2b 20 35 29  20 3d 20 52 65 61 64 0d  |FCB + 5) = Read.|
00000de0  04 1a 2b 3f 28 46 43 42  20 2b 20 39 29 20 3d 20  |..+?(FCB + 9) = |
00000df0  31 3a 20 20 20 20 20 20  20 20 20 f4 20 52 65 61  |1:         . Rea|
00000e00  64 20 31 20 73 65 63 74  6f 72 0d 04 24 11 f2 5f  |d 1 sector..$.._|
00000e10  52 65 61 64 53 65 63 74  6f 72 73 0d 04 2e 05 e1  |ReadSectors.....|
00000e20  0d 04 38 05 20 0d 04 42  12 dd f2 5f 52 65 61 64  |..8. ..B..._Read|
00000e30  53 65 63 74 6f 72 73 0d  04 4c 0c 41 25 20 3d 20  |Sectors..L.A% = |
00000e40  26 37 32 0d 04 56 2c 58  25 20 3d 20 46 43 42 20  |&72..V,X% = FCB |
00000e50  80 20 26 46 46 3a 20 20  59 25 20 3d 20 28 46 43  |. &FF:  Y% = (FC|
00000e60  42 20 81 20 26 31 30 30  29 20 80 20 26 46 46 0d  |B . &100) . &FF.|
00000e70  04 60 0c d6 20 4f 53 57  4f 52 44 0d 04 6a 05 e1  |.`.. OSWORD..j..|
00000e80  0d ff                                             |..|
00000e82
Library/BASIC/FindBadSec.m0
Library/BASIC/FindBadSec.m1
Library/BASIC/FindBadSec.m2
Library/BASIC/FindBadSec.m4
Library/BASIC/FindBadSec.m5