1 |
REM > SectorOp |
2 |
REM Disc sector reader and writer |
3 |
REM James Bursa - 14 Jun 2000 |
4 |
|
5 |
|
6 |
ON ERROR ON ERROR OFF: REPORT: PRINT ERL: END |
7 |
|
8 |
|
9 |
REM change these for other FSs |
10 |
describe$ = "ADFS_DescribeDisc" |
11 |
sector_op$ = "ADFS_SectorDiscOp" :REM sometimes <FS>_SectorOp |
12 |
|
13 |
|
14 |
PRINT "SectorOp - disc sector reader and writer"' |
15 |
PRINT "WARNING: This program is potentially dangerous and could" |
16 |
PRINT "cause data loss. If you do not know what you are doing," |
17 |
PRINT "press Escape now."' |
18 |
|
19 |
|
20 |
REPEAT |
21 |
INPUT "Drive number: " drive% |
22 |
IF drive% < 0 OR drive% > 8 THEN PRINT "Drive must be 0-8" |
23 |
UNTIL drive% >= 0 AND drive% <= 8 |
24 |
|
25 |
PROCread_record |
26 |
|
27 |
|
28 |
WHILE 1 |
29 |
PRINT "[R]ead sector, [W]rite sector, or [Q]uit? "; |
30 |
REPEAT |
31 |
i$ = GET$ |
32 |
UNTIL INSTR("rRwWqQ", i$) |
33 |
PRINT i$ |
34 |
CASE i$ OF |
35 |
WHEN "r", "R": |
36 |
PROCread |
37 |
WHEN "w", "W": |
38 |
PROCwrite |
39 |
WHEN "q", "Q": |
40 |
END |
41 |
ENDCASE |
42 |
ENDWHILE |
43 |
|
44 |
END |
45 |
|
46 |
|
47 |
REM-------------------------------------------------------------------------------- |
48 |
|
49 |
|
50 |
DEF PROCread |
51 |
WHILE 1 |
52 |
PRINT "Read sector number (0-" + STR$(sectors% - 1) + ", blank to end): "; |
53 |
INPUT "" sector$ |
54 |
IF sector$ = "" THEN ENDPROC |
55 |
sector% = EVAL(sector$) |
56 |
|
57 |
SYS sector_op$,, 1, drive%<<29 OR sector%, M%, secsize% |
58 |
PROCdump |
59 |
|
60 |
PRINT "Save this sector [y/n]? "; |
61 |
REPEAT |
62 |
i$ = GET$ |
63 |
UNTIL INSTR("yYnN", i$) |
64 |
PRINT i$ |
65 |
IF INSTR("yY", i$) THEN |
66 |
INPUT "Filename: " file$ |
67 |
SYS"OS_File", 10, file$, &ffd,, M%, M% + secsize% |
68 |
ENDIF |
69 |
ENDWHILE |
70 |
ENDPROC |
71 |
|
72 |
|
73 |
REM-------------------------------------------------------------------------------- |
74 |
|
75 |
|
76 |
DEF PROCread_record |
77 |
DIM R% 100 |
78 |
SYS describe$, ":" + STR$drive%, R% |
79 |
big% = (R%?&29 AND 1) = 1 |
80 |
secsize% = 2^R%?00 |
81 |
sectors% = (R%!16 / (secsize% * R%?01 * R%?02)) * R%?01 * R%?02 |
82 |
PRINT " Current disc record contents:" |
83 |
PRINT " Bytes/sector: "; secsize% |
84 |
PRINT " Sectors/head: "; R%?01 |
85 |
PRINT " Heads/track: "; R%?02 |
86 |
PRINT " Tracks/disc: "; (R%!16 / (secsize% * R%?01 * R%?02)) |
87 |
PRINT " LFAU: "; 2^R%?05 |
88 |
PRINT " Zones: "; R%?09 |
89 |
IF big% THEN |
90 |
PRINT " Disc size: &" + STR$~R%!&24 + RIGHT$("00000000" + STR$~R%!16, 8) |
91 |
sectors% = 1 |
92 |
ELSE |
93 |
PRINT " Disc size: "; R%!16 |
94 |
ENDIF |
95 |
DIM M% secsize% |
96 |
ENDPROC |
97 |
|
98 |
|
99 |
REM-------------------------------------------------------------------------------- |
100 |
|
101 |
|
102 |
DEF PROCwrite |
103 |
INPUT "Filename: " file$ |
104 |
SYS"OS_File", 23, file$ TO type%,,,, len% |
105 |
IF type% <> 1 THEN PRINT "Not a file": ENDPROC |
106 |
IF len% <> secsize% THEN PRINT "Not sector sized (should be " + STR$secsize% + " bytes)": ENDPROC |
107 |
SYS"OS_File", 16, file$, M% |
108 |
PROCdump |
109 |
PRINT "Write sector number (0-" + STR$(sectors% - 1) + "): "; |
110 |
INPUT "" sector$ |
111 |
sector% = EVAL(sector$) |
112 |
PRINT "WARNING: about to write sector " + STR$sector% + ", press O to confirm" |
113 |
i$ = GET$ |
114 |
IF INSTR("oO", i$) THEN |
115 |
SYS sector_op$,, 2, drive%<<29 OR sector%, M%, secsize% |
116 |
PRINT "Sector written" |
117 |
ELSE |
118 |
PRINT "Aborted" |
119 |
ENDIF |
120 |
ENDPROC |
121 |
|
122 |
|
123 |
REM-------------------------------------------------------------------------------- |
124 |
|
125 |
|
126 |
DEF PROCdump |
127 |
FOR a% = 0 TO (secsize% - 64) STEP 64 |
128 |
a$ = " " |
129 |
FOR b% = 0 TO 63 |
130 |
c% = M%?(a% + b%) |
131 |
IF c% < 32 OR c% = 127 THEN |
132 |
a$ += "." |
133 |
ELSE |
134 |
a$ += CHR$c% |
135 |
ENDIF |
136 |
NEXT |
137 |
PRINT a$ |
138 |
NEXT |
139 |
ENDPROC |