Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/format.asm @ 1656:5b5390b7333a
exmode replaces xmode as the ideal utility. makefiles and help updated accordingly
author | boisy |
---|---|
date | Sat, 17 Jul 2004 13:20:48 +0000 |
parents | 6c53cd87473a |
children | b4b97d35fda1 |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
312 | 2 * Format - Disk format program |
0 | 3 * |
4 * $Id$ | |
5 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
7 * Comment |
0 | 8 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
9 * 22 ????/??/?? |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
10 * From Tandy OS-9 Level Two VR 02.00.01. |
926 | 11 * |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
12 * 23 2003/01/06 JC |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
13 * Format incorrect/clusters summary: now, specifying cluster size works. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
14 * Fixed bug where format showed an improper number of sectors formatted |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
15 * at the summary if the number of sectors was a large number. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
16 * This was most notable when formatting large disks, such as hard drives. |
0 | 17 |
18 nam Format | |
312 | 19 ttl Disk format program |
0 | 20 |
312 | 21 * Disassembled 02/07/17 11:00:13 by Disasm v1.6 (C) 1988 by RML |
0 | 22 |
23 ifp1 | |
960
ea69ed12af12
Added OS9FORMAT macros which inherently specify the disk format, so that
boisy
parents:
952
diff
changeset
|
24 use defsfile |
0 | 25 endc |
119 | 26 |
926 | 27 DOHELP set 0 |
961
53b612a9ef45
Added a conditional check to the roll message, so you can build format
johncollyer
parents:
960
diff
changeset
|
28 DOROLL set 0 |
926 | 29 |
0 | 30 tylg set Prgrm+Objct |
31 atrv set ReEnt+rev | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
32 rev set $00 |
926 | 33 edition set 23 |
119 | 34 |
0 | 35 mod eom,name,tylg,atrv,start,size |
119 | 36 |
926 | 37 ******************************************************************** |
38 * begin our data area, starts on direct page | |
39 ******************************************************************** | |
40 | |
41 savedu rmb 2 save the u register | |
1614 | 42 totsects rmb 3 |
43 sectmode rmb 1 | |
926 | 44 diskpath rmb 1 disk path number |
45 currtrak rmb 2 current track on | |
1614 | 46 currside rmb 2 |
926 | 47 currsect rmb 1 current sector on |
1614 | 48 sectcount rmb 1 counted sectors |
0 | 49 u0009 rmb 1 |
312 | 50 u000A rmb 2 |
0 | 51 u000C rmb 2 |
312 | 52 u000E rmb 2 |
926 | 53 mfm rmb 1 denisity (double/single) |
0 | 54 u0011 rmb 1 |
1614 | 55 tpi rmb 1 |
56 numsides rmb 1 | |
312 | 57 u0014 rmb 1 |
926 | 58 ncyls rmb 2 total number of cylinders |
0 | 59 u0017 rmb 1 |
60 u0018 rmb 1 | |
926 | 61 sectors rmb 1 total number of sectors |
62 u001A rmb 1 total number of sectors | |
1614 | 63 sectors0 rmb 2 total number of sectors |
64 bps rmb 1 bytes per sector (returned from SS.DSize) | |
926 | 65 dtype rmb 1 disk device type (5", 8", hard disk) |
66 ready rmb 1 ready to proceed, skip warning | |
67 dresult rmb 2 decimal number in binary | |
68 interlv rmb 1 sector interleave value | |
312 | 69 u0022 rmb 2 |
926 | 70 clustsiz rmb 1 cluster size |
71 ClustSz rmb 1 cluster size | |
0 | 72 u0029 rmb 1 |
73 u002A rmb 1 | |
74 u002B rmb 1 | |
75 u002C rmb 1 | |
312 | 76 u002D rmb 1 |
77 u002E rmb 1 | |
0 | 78 u002F rmb 1 |
79 u0030 rmb 1 | |
80 u0031 rmb 1 | |
81 u0032 rmb 1 | |
82 u0033 rmb 1 | |
312 | 83 u0034 rmb 1 |
84 u0035 rmb 1 | |
926 | 85 oksects rmb 3 |
0 | 86 u0038 rmb 2 |
312 | 87 u003A rmb 2 |
88 u003C rmb 1 | |
0 | 89 u003D rmb 2 |
312 | 90 u003F rmb 2 |
91 u0041 rmb 2 | |
0 | 92 u0043 rmb 1 |
312 | 93 u0044 rmb 1 |
926 | 94 dovfy rmb 1 |
924 | 95 dtentry rmb 2 |
312 | 96 u0048 rmb 1 |
924 | 97 stoff rmb 2 |
312 | 98 u004B rmb 1 |
99 u004C rmb 1 | |
100 u004D rmb 1 | |
1614 | 101 dolog rmb 1 logical format |
102 prmbuf rmb 2 | |
103 u0051 rmb 4 | |
0 | 104 u0055 rmb 15 |
312 | 105 u0064 rmb 7 |
106 u006B rmb 4 | |
926 | 107 dskname rmb 32 quoted delimited disk name buffer |
312 | 108 u008F rmb 40 |
1614 | 109 LSN0 rmb 256 LSN0 build buffer |
924 | 110 optbuf rmb 256 |
926 | 111 fdtbuf1 rmb 3 |
112 fdtbuf2 rmb 9924 | |
312 | 113 u297E rmb 451 |
0 | 114 size equ . |
119 | 115 |
116 name fcs /Format/ | |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
168
diff
changeset
|
117 fcb edition |
119 | 118 |
1614 | 119 *val1 fdb $0000 |
120 *val2 fdb $0000 | |
121 *val3 fdb $0000 | |
926 | 122 hdsdat fdb $80E5,$80E5,$0000 |
123 sgtdat fdb $0100,$28FF,$0600,$01FC,$0CFF,$0000 | |
124 sgsdat fdb $0600,$01FE,$0400,$01F7,$0AFF,$0600 | |
125 fdb $01FB,$80E5,$80E5,$01F7,$0AFF,$0000 | |
126 fcb $FF | |
127 sgfidp fdb $0043 | |
128 sgsize fdb $0128 | |
1614 | 129 |
130 * Double Density Data | |
926 | 131 dbtdat fdb $504E,$0C00,$03F6,$01FC,$204E,$0000 |
132 dbsdat fdb $0C00,$03F5,$01FE,$0400,$01F7,$164E | |
133 fdb $0C00,$03F5,$01FB,$80E5,$80E5,$01F7 | |
134 fdb $164E,$0000 | |
312 | 135 fcb $4E |
926 | 136 dbfidp fdb $0090 |
137 dbsize fdb $0152 | |
138 dctdat fdb $204E,$0000,$0C00,$03F5,$01FE,$0400 | |
139 fdb $01F7,$164E,$0C00,$03F5,$01FB,$80E5 | |
140 fdb $80E5,$01F7,$184E,$0000 | |
141 fcb $4E | |
142 dcfidp fdb $0030 | |
143 dcsize fdb $0154 | |
312 | 144 |
926 | 145 ******************************************************************** |
146 * format module execution start address | |
147 ******************************************************************** | |
148 | |
149 start stu <savedu save our data pointer | |
150 bsr ClrWork clear the work area | |
151 bsr OpenDev get device name and open it | |
152 bsr Default handle all the options | |
153 lbsr GetDTyp initialize the device | |
154 lbsr Format physically format device | |
1614 | 155 lbsr InitLSN0 initialize LSN0 |
156 lbsr ReadLSN0 attempt to read back LSN0 | |
689
92b575ffa143
Folded pxd.asm and pwd.asm into pd.asm for simplicity since almost all code
boisy
parents:
312
diff
changeset
|
157 lbsr Stamps |
1614 | 158 lbsr MkRootFD file descriptor |
926 | 159 ldu <dtentry device table entry |
160 os9 I$Detach detach the device | |
161 clrb flag no error | |
162 Exit os9 F$Exit exit module | |
163 | |
164 ******************************************************************** | |
165 * clear our working memory area | |
166 ******************************************************************** | |
167 | |
168 ClrWork leay diskpath,u point to work area | |
169 pshs y save that | |
1614 | 170 leay >LSN0,u get size of area |
926 | 171 ClrOne clr ,-y clear it down |
172 cmpy ,s at begin? | |
173 bhi ClrOne not yet, | |
174 puls pc,y done | |
175 | |
176 ******************************************************************** | |
177 * get rbf device name and open it | |
178 ******************************************************************** | |
162 | 179 |
926 | 180 OpenDev lda ,x+ get char at X |
181 cmpa #PDELIM pathlist delimiter? | |
182 beq PrsPrm branch if so | |
183 BadPath ldb #E$BPNam else set bad pathname | |
184 lbra PrtError and print error | |
185 PrsPrm os9 F$PrsNam parse pathname | |
186 lbcs PrtError branch if illegal (has additional pathlist element) | |
187 lda #PDELIM get pathlist name separator | |
188 cmpa ,y another pathlist separator? | |
189 beq BadPath yes, set bad pathname | |
190 sty <u0022 no, save end of pathname | |
1614 | 191 leay <prmbuf,u point to pathname buffer |
926 | 192 MovNam sta ,y+ save pathname character |
193 lda ,x+ get next pathname character | |
194 decb decrement pathname size | |
195 bpl MovNam got full pathname? | |
1614 | 196 leax <prmbuf+1,u get pathname for I$Attach |
926 | 197 lda #C$SPAC space character |
198 sta ,y delimit pathname | |
199 clra get access mode | |
200 os9 I$Attach attach the rbf device | |
201 lbcs PrtError if error print error and exit | |
202 stu <dtentry save device table entry | |
203 ldu <savedu get data pointer | |
204 lda #PENTIR delimit pathname | |
205 ldb #C$SPAC for os9 I$Open | |
206 std ,y do it now | |
207 lda #WRITE. get access mode | |
1614 | 208 leax <prmbuf,u get pathname |
926 | 209 os9 I$Open open the rbf device |
210 bcs Exit exit if could not open it | |
211 sta <diskpath save path number | |
212 rts return | |
213 | |
214 ******************************************************************** | |
215 * get geometry and options, proceed (Y/N) | |
216 ******************************************************************** | |
217 | |
218 Default bsr Geometry | |
1614 | 219 lbsr DoOpts |
926 | 220 lbsr Proceed |
0 | 221 rts |
162 | 222 |
926 | 223 ******************************************************************** |
224 * get rbf device geometry | |
225 ******************************************************************** | |
312 | 226 |
926 | 227 Geometry leax >optbuf,u status packet address |
228 clrb SS.OPT function | |
229 os9 I$GetStt get status packet | |
230 bcs Exit exit if error | |
231 ldb PD.SID-PD.OPT,x number of surfaces | |
1614 | 232 stb <numsides save it |
926 | 233 stb <u0014 save it |
234 ldb PD.SToff-PD.OPT,x foreign disk format? | |
235 beq L0143 no, | |
236 tfr b,a yes, get copy | |
237 anda #$0F foreign low nibble | |
238 sta <stoff save it | |
239 lsrb | |
240 lsrb | |
241 lsrb | |
242 lsrb foreign high nibble | |
243 stb <u004B save it | |
244 L0143 ldb PD.DNS-PD.OPT,x density capability | |
245 pshs b save it | |
246 andb #DNS.MFM check double-density | |
247 stb <mfm save double-density (Yes/No) | |
248 stb <u0011 save it again | |
1614 | 249 ldb ,s get saved PD.DNS byte |
926 | 250 lsrb checking |
251 pshs b save it | |
1614 | 252 andb #$01 tpi (0=48, 1=96/135) |
253 stb <tpi save it | |
926 | 254 puls b get checking |
255 lsrb | |
312 | 256 andb <u0011 |
257 stb <u004C | |
258 puls b | |
0 | 259 ldb #$01 |
1614 | 260 stb <bps assume 256 byte/sector |
312 | 261 stb <u004D |
262 beq L0169 | |
263 stb <u004B | |
924 | 264 clr <stoff |
926 | 265 L0169 ldd PD.CYL-PD.OPT,x number of cylinders |
266 std <ncyls save it | |
267 ldb PD.TYP-PD.OPT,x disk device type | |
268 stb <dtype save it | |
269 ldd PD.SCT-PD.OPT,x default sectors/track | |
270 std <sectors save it | |
271 ldd PD.T0S-PD.OPT,x default sectors/track tr00,s0 | |
272 std <sectors0 save it | |
273 ldb PD.ILV-PD.OPT,x sector interleave offset | |
274 stb <interlv save it | |
275 ldb #$01 default cluster size | |
276 stb <clustsiz save it | |
1614 | 277 stb <sectmode and sector mode |
278 | |
279 *** ADDED CODE -- BGP. CHECK FOR PRESENCE OF SS.DSIZE | |
280 lda PD.TYP-PD.OPT,x get type byte | |
281 bita #TYPH.DSQ drive size query bit set? | |
282 beq nogo@ no, don't bother querying the drive for its size | |
283 lda <diskpath get disk path number | |
284 ldb #SS.DSize disk size getstat | |
285 os9 I$GetStt attempt | |
286 bcs nogo@ | |
287 sta <bps save bytes/sector | |
288 stb <sectmode | |
289 tstb LBA mode? | |
290 bne chs@ | |
291 tfr x,d | |
292 stb <totsects save result... | |
293 sty <totsects+1 | |
294 bra nogo@ | |
295 chs@ | |
296 stx <ncyls save cylinders | |
297 stb <numsides save sides | |
298 stb <u0014 ???? | |
299 sty <sectors save sectors/track | |
300 sty <sectors0 save sectors/track 0 | |
301 nogo@ | |
926 | 302 clrb no error |
303 rts return | |
304 | |
305 ******************************************************************** | |
306 * find a option and call, until all options are processed | |
307 ******************************************************************** | |
308 | |
309 DoOpts ldx <u0022 option buffer | |
310 L0185 leay >OptTbl,pcr point to table | |
311 bsr L019C check for match? | |
312 bcs L01A5 no, match | |
313 pshs b,a save d register | |
314 ldd $02,y get offset value | |
315 leay d,y make function address | |
316 puls b,a restore d register | |
317 jsr ,y call function | |
318 bcc L0185 finished good? | |
319 lbra Exit no, exit | |
320 L019C lda ,x+ get option character | |
321 L019E cmpa ,y is it in the table? | |
322 bne L01A6 no, try the next one | |
323 ldb $01,y get return value | |
324 clra flag good | |
325 L01A5 rts return | |
326 L01A6 leay $04,y get next table location | |
327 tst ,y is it the end of the table? | |
328 bne L019E no, try next location | |
329 coma yes, flag bad | |
330 rts return | |
331 | |
332 ******************************************************************** | |
333 * option command table | |
334 ******************************************************************** | |
119 | 335 |
312 | 336 OptTbl |
337 opt.1 fcc /R/ | |
338 fcc /Y/ | |
339 fdb DoReady-opt.1 | |
340 opt.2 fcc /r/ | |
341 fcc /Y/ | |
342 fdb DoReady-opt.2 | |
926 | 343 opt.3 fcc /S/ |
344 fcc / / | |
345 fdb DoDsity-opt.3 | |
346 opt.4 fcc /s/ | |
347 fcc / / | |
348 fdb DoDsity-opt.4 | |
349 opt.5 fcc /D/ | |
350 fcc /M/ | |
351 fdb DoDsity-opt.5 | |
352 opt.6 fcc /d/ | |
353 fcc /M/ | |
354 fdb DoDsity-opt.6 | |
355 opt.7 fcc /"/ | |
312 | 356 fcb $00 |
926 | 357 fdb DoQuote-opt.7 |
358 opt.8 fcc /:/ | |
359 fcb $00 | |
360 fdb DoColon-opt.8 | |
361 opt.9 fcc "/" | |
362 fcb $00 | |
363 fdb DoClust-opt.9 | |
364 opt.10 fcc /1/ | |
312 | 365 fcb $01 |
926 | 366 fdb Do1-opt.10 |
367 opt.11 fcc /2/ | |
368 fcb $02 | |
369 fdb Do2-opt.11 | |
370 opt.12 fcc /'/ | |
371 fcb 0 | |
372 fdb DoSQuote-opt.12 | |
373 opt.13 fcc /L/ | |
374 fcb $01 | |
375 fdb DoL-opt.13 | |
376 opt.14 fcc /l/ | |
312 | 377 fcb 01 |
926 | 378 fdb DoL-opt.14 |
379 opt.15 fcc /(/ | |
312 | 380 fcb $00 |
926 | 381 fdb DoLParen-opt.15 |
382 opt.16 fcc /)/ | |
312 | 383 fcb $00 |
926 | 384 fdb DoRParen-opt.16 |
385 opt.17 fcc /,/ | |
386 fcb $00 | |
387 fdb DoComa-opt.17 | |
388 opt.18 fcb C$SPAC | |
312 | 389 fcb 00 |
926 | 390 fdb DoSpace-opt.18 |
312 | 391 fcb $00 |
392 | |
926 | 393 ******************************************************************** |
394 * S/D - density; single or double | |
395 ******************************************************************** | |
396 | |
397 DoDsity cmpb <u0011 | |
398 bgt OptAbort | |
312 | 399 cmpb <u004C |
926 | 400 blt OptAbort |
924 | 401 stb <mfm |
312 | 402 clrb |
403 | |
926 | 404 ******************************************************************** |
405 * skip white space | |
406 ******************************************************************** | |
407 | |
312 | 408 DoComa |
409 DoRParen | |
410 DoLParen | |
411 DoSpace rts | |
412 | |
926 | 413 ******************************************************************** |
414 * set ready flag - skip warn messages | |
415 ******************************************************************** | |
416 | |
417 DoReady stb <ready set and save ready | |
418 rts return | |
419 | |
420 ******************************************************************** | |
421 * 1/2 - number of sides | |
422 ******************************************************************** | |
312 | 423 |
424 Do2 | |
1614 | 425 Do1 cmpb <numsides |
926 | 426 bgt OptAbort |
1614 | 427 stb <numsides |
312 | 428 clrb |
429 rts | |
430 | |
926 | 431 ******************************************************************** |
432 * only do a logical format on the rbf device | |
433 ******************************************************************** | |
434 | |
1614 | 435 DoL stb <dolog do a logical format |
926 | 436 clrb did option |
437 rts return | |
312 | 438 |
926 | 439 ******************************************************************** |
440 * not a option - show abort message and exit | |
441 ******************************************************************** | |
442 | |
443 OptAbort leax >AbortOp,pcr Option not allowed message | |
444 lbra PExit print message and exit | |
445 | |
446 ******************************************************************** | |
447 * double quoted option "disk name" save name in dskname | |
448 ******************************************************************** | |
312 | 449 |
926 | 450 DoQuote leay <dskname,u delimited buffer |
451 ldb #C$SPAC delimited size | |
452 koQuote lda ,x+ delimited character | |
453 cmpa #'" is end quote? | |
454 beq L0221 must be done | |
455 sta ,y+ no, save character | |
456 decb decrement name size | |
457 bne KoQuote get all 32 of them or quote | |
458 L0215 ldb ,x+ next delimited character | |
459 cmpb #'" find end quote? | |
460 beq L0227 yes, back up and mark it | |
461 cmpb #C$SPAC skip space character? | |
462 bcc L0215 yes, get next one | |
463 bra L0227 no, mark it's end | |
464 L0221 lda #C$SPAC get space character | |
465 cmpb #C$SPAC any delimited characters? | |
466 beq L022B no, mark it's end | |
467 L0227 leay -$01,y yes, back up | |
468 lda ,y get saved character | |
469 L022B adda #$80 make it negative | |
470 sta ,y mark it's end | |
471 clrb did option | |
472 rts return | |
312 | 473 |
926 | 474 ******************************************************************** |
475 * single quoted option 'number of cylinders' save number in ncyls | |
476 ******************************************************************** | |
477 | |
478 DoSQuote lbsr Decimal procces number of cylinders | |
479 ldd <dresult get it | |
480 std <ncyls save it | |
481 rts return | |
312 | 482 |
926 | 483 ******************************************************************** |
484 * colon quoted option :interleave value: save value in interlv | |
485 ******************************************************************** | |
486 | |
487 DoColon lbsr Decimal proccess interleave value | |
488 ldd <dresult get it | |
489 tsta answer out of bounds? | |
490 beq L0243 no, save it | |
491 ldb #$01 yes, default size | |
492 L0243 stb <interlv save it | |
493 rts return | |
494 | |
495 ******************************************************************** | |
496 * quoted option /cluster size/ save size in clustsiz | |
952 | 497 * cluster size is in decimal. The number of sectors |
498 * in a cluster must be a power of 2 and the number | |
499 * should max out at 32 for coco os9 | |
926 | 500 ******************************************************************** |
501 | |
502 DoClust lbsr Decimal proccess cluster size | |
503 ldd <dresult get it | |
504 tsta answer out of bounds? | |
505 beq L0250 no, save it | |
506 ldb #$01 yes, default size | |
507 L0250 stb <clustsiz save it | |
952 | 508 negb get two's complement |
926 | 509 decb power of 2 |
510 andb <clustsiz in range? | |
511 beq L025C yes, skip ahead | |
512 ldb #$01 no, default size | |
513 stb <clustsiz save it | |
514 L025C clrb did option | |
515 L025D rts return | |
516 | |
517 ******************************************************************** | |
1614 | 518 * print title, format (Y/N), and get response |
926 | 519 ******************************************************************** |
520 | |
521 Proceed leax >Title,pcr coco formatter message | |
522 lbsr PrintLn print it | |
523 leay >optbuf,u point to option buffer | |
524 ldx PD.T0S-PD.OPT,y default sectors/track tr00,s0 | |
525 tst <mfm double-density? | |
526 beq L0271 no, | |
527 ldx PD.SCT-PD.OPT,y default sectors/track | |
528 L0271 stx <sectors save it | |
529 leax >FmtMsg,pcr formatting drive message | |
530 ldy #FmtMLen length of message | |
531 lbsr Print print it | |
1614 | 532 leax <prmbuf,u input buffer |
926 | 533 tfr x,y put it in y |
534 L0283 lda ,y+ get input | |
535 cmpa #PENTIR proceed (y/n)? | |
536 bne L0283 no, wait for yes | |
537 pshs y save input pointer | |
538 lda #C$CR carriage return | |
539 sta -$01,y store it over input | |
540 lbsr PrintLn print line | |
541 puls y get pointer | |
312 | 542 lda #PENTIR |
0 | 543 sta -$01,y |
926 | 544 lda <ready ok to proceed? ready |
545 bne L02BC yes, were ready skip ahead | |
546 tst <dtype is this a floppy or hard drive? | |
547 bpl L02AB it is a floppy | |
548 leax >HDFmt,pcr it is a hard drive | |
549 ldy #$002A length of message | |
550 lbsr Print print message | |
551 L02AB leax >Query,pcr query message | |
552 ldy #QueryLen length of message | |
1614 | 553 lbsr Input show it and get response (Y/N) |
926 | 554 anda #$DF make it upper case |
555 cmpa #'Y answered yes? | |
556 bne L02D5 no, check for no? | |
557 L02BC tst <dtype formatting hard drive? | |
558 bpl L025D no, return skip hard disk warn message | |
559 leax >HDFmt,pcr show hard disk warn message | |
560 ldy #HDFmtLen size of the message | |
1614 | 561 lbsr Input show it and get response (Y/N) |
926 | 562 anda #$DF make it upper case |
563 cmpa #'Y answered yes? | |
564 beq L025D yes, return | |
565 clrb clear error | |
566 lbra Exit exit | |
567 L02D5 clrb clear error | |
568 cmpa #'N answered no? | |
569 lbeq Exit yes, exit | |
570 bra L02AB no, get a (Y/N) answer | |
571 | |
572 ******************************************************************** | |
573 * print usage message and return | |
574 ******************************************************************** | |
162 | 575 |
926 | 576 LineFD leax >HelpCR,pcr point to line feed |
577 PrintLn ldy #80 size of message | |
1614 | 578 Print lda #$01 standard output path |
926 | 579 os9 I$WritLn print line |
580 rts return | |
581 | |
582 ******************************************************************** | |
1614 | 583 * print message and get response |
926 | 584 * entry: x holds data address y holds data size |
1614 | 585 * exit: a holds response (ascii character) |
926 | 586 ******************************************************************** |
587 | |
588 Input pshs u,y,x,b,a save registers | |
589 bsr Print print line | |
590 leax ,s get data address | |
591 ldy #$0001 data size | |
592 clra standard input | |
593 os9 I$Read read it | |
594 lbcs Exit exit on error | |
595 bsr LineFD print line feed | |
596 puls u,y,x,b,a restore stack | |
597 anda #$7F make it ascii | |
598 rts return | |
599 | |
600 ******************************************************************** | |
601 * get capability of the rbf device | |
602 ******************************************************************** | |
603 | |
1614 | 604 GetDTyp leax >hdsdat,pcr assume hard drive data for now |
926 | 605 stx <u000A sector data pointer |
606 ldb <dtype get disk drive type | |
1614 | 607 bitb #TYP.HARD+TYP.NSF hard disk or non-standard type? |
926 | 608 bne L0323 no, check track data |
609 tst <u004D | |
312 | 610 beq L031B |
926 | 611 leax >dctdat,pcr |
312 | 612 bra L032D |
926 | 613 L031B leax >sgtdat,pcr |
614 tst <mfm double-density? | |
615 beq L032D no, | |
312 | 616 L0323 stx <u000A |
926 | 617 leax >dbtdat,pcr |
312 | 618 tst <u004C |
619 beq L032F | |
620 L032D stx <u000A | |
621 L032F stx <u000C | |
1614 | 622 tst <sectmode LBA values already in place? |
623 beq ack@ | |
624 * Compute total sectors from C/H/S | |
0 | 625 clra |
1614 | 626 ldb <numsides get number of sides |
0 | 627 tfr d,y |
1614 | 628 clrb D = 0 |
924 | 629 ldx <ncyls |
1614 | 630 bsr Mulbxty multiply B,X*Y |
631 * B,X now is numsides * numcyls | |
632 * Subtract one from B,X because t0s will be added later | |
0 | 633 exg d,x |
634 subd #$0001 | |
312 | 635 bcc L0344 |
0 | 636 leax -$01,x |
312 | 637 L0344 exg d,x |
924 | 638 ldy <sectors |
1614 | 639 bsr Mulbxty multiply B,X*Y |
640 * B,X now is numsides * numcyls * sectors | |
0 | 641 exg d,x |
1614 | 642 * Add in sectors/track0 |
924 | 643 addd <sectors0 |
1614 | 644 std <totsects+1 |
0 | 645 exg d,x |
646 adcb #$00 | |
1614 | 647 stb <totsects |
648 ack@ | |
649 **** We now multiply totsects * the bytes per sector | |
650 dec <bps decrement bytes per sector (8=7,4=3,2=1,1=0) | |
651 beq mlex@ exit out ofloop if zero | |
652 ml@ lsl <totsects+2 else multiply by 2 | |
653 rol <totsects+1 | |
654 rol <totsects | |
655 lsr <bps shift out bits | |
656 tst <bps | |
657 bne ml@ | |
658 mlex@ | |
659 ************************************************ | |
0 | 660 lda #$08 |
661 pshs a | |
1614 | 662 ldx <totsects+1 |
663 ldb <totsects | |
664 bsr Div24by8 divide totsects by 8 | |
926 | 665 lda <clustsiz get cluster size |
666 pshs a save it | |
1614 | 667 bsr Div24by8 |
668 tstb B = 0? | |
669 beq L0374 branch if so | |
670 * Too small a cluster size comes here | |
926 | 671 leax >ClustMsg,pcr cluster size mismatch message |
672 lbsr PrintLn print mismatch message | |
673 lbra L05B1 abort message and exit | |
312 | 674 L0374 leas $02,s |
926 | 675 stx <ClustSz |
676 rts return | |
677 | |
678 ******************************************************************** | |
679 * multiply (mlbxty) | |
680 ******************************************************************** | |
681 | |
682 Mulbxty lda #$08 make stack space | |
683 MulClr clr ,-s clear the space | |
684 deca cleared? | |
685 bne MulClr no, | |
0 | 686 sty ,s |
687 stb $02,s | |
688 stx $03,s | |
926 | 689 MulLoop ldd ,s we done? |
690 beq MulZer yes, clean up | |
0 | 691 lsra |
692 rorb | |
693 std ,s | |
926 | 694 bcc MulNoC |
0 | 695 ldd $03,s |
696 addd $06,s | |
697 std $06,s | |
698 lda $02,s | |
699 adca $05,s | |
700 sta $05,s | |
926 | 701 MulNoC ldd $03,s |
0 | 702 lslb |
703 rola | |
704 std $03,s | |
705 lda $02,s | |
706 rola | |
707 sta $02,s | |
926 | 708 bra MulLoop continue rest |
709 MulZer leas $05,s clean up space | |
710 puls pc,x,b pop results, return | |
711 | |
712 ******************************************************************** | |
1614 | 713 * 24 bit divide (2,s = divisor, B/X = dividend) |
926 | 714 ******************************************************************** |
715 | |
1614 | 716 L03AE pshs x,b save X,B on stack |
717 lsr ,s divide X,B by 2 | |
0 | 718 ror $01,s |
719 ror $02,s | |
1614 | 720 puls x,b retrieve X,B |
721 exg d,x exchange bits 15-0 in D,X | |
0 | 722 adcb #$00 |
723 adca #$00 | |
724 exg d,x | |
725 adcb #$00 | |
1614 | 726 Div24by8 lsr $02,s |
312 | 727 bne L03AE |
0 | 728 rts |
689
92b575ffa143
Folded pxd.asm and pwd.asm into pd.asm for simplicity since almost all code
boisy
parents:
312
diff
changeset
|
729 |
926 | 730 ******************************************************************** |
731 * format rbf device | |
732 ******************************************************************** | |
733 | |
1614 | 734 Format tst <dolog doing a logical format? |
926 | 735 bne L03E4 yes, don't do this then |
1614 | 736 tst <dtype test for hard drive from PD.TYP |
737 bpl L03E5 branch if floppy | |
926 | 738 leax >Both,pcr PHYSICAL and LOGICAL? message |
739 ldy #BothLen length of message | |
740 lbsr Input print and get input | |
741 anda #$DF make it upper case | |
742 cmpa #'Y is it yes? | |
743 beq L03E5 yes, | |
744 cmpa #'N is it no? | |
745 bne Format no, | |
746 L03E4 rts return | |
747 L03E5 lda <diskpath device path number | |
748 ldb #SS.Reset reset device | |
749 os9 I$SetStt at track zero | |
750 lbcs Exit exit if error | |
751 ldd #$0000 get current track | |
752 std <currtrak save it | |
753 inca get current sector | |
942 | 754 sta <currsect save it |
1614 | 755 L03F8 clr <currside clear current side |
312 | 756 L03FA bsr L045C |
1614 | 757 leax >LSN0,u point to our LSN0 buffer |
924 | 758 ldd <currtrak |
312 | 759 addd <u0048 |
760 tfr d,u | |
0 | 761 clrb |
312 | 762 tst <u004D |
763 bne L041B | |
1614 | 764 tst <mfm single density? |
765 beq L041D branch if so | |
312 | 766 tst <u004C |
767 bne L041B | |
924 | 768 tst <currtrak+1 |
312 | 769 bne L041B |
1614 | 770 tst <currside side? |
771 beq L041D branch if 0 | |
772 L041B orb #$02 else set side 1 | |
773 L041D tst <tpi 48 tpi? | |
774 beq L0423 branch if so | |
775 orb #$04 else set 96/135 tpi bit | |
776 L0423 lda <currside get current side | |
777 beq L0429 branch if 0 | |
0 | 778 orb #$01 |
926 | 779 L0429 tfr d,y get side/density bits |
780 lda <diskpath rbf device path number | |
781 ldb #SS.WTrk format (write) track | |
782 os9 I$SetStt do format it | |
783 lbcs Exit exit if error | |
784 ldu <savedu get u pointer | |
1614 | 785 ldb <currside get current side |
786 incb increment | |
787 stb <currside and store | |
788 cmpb <numsides compare against number of sides | |
789 bcs L03FA branch if greater than | |
926 | 790 ldd <currtrak get current track |
791 addd #$0001 increment it | |
792 std <currtrak save it | |
793 cmpd <ncyls did all tracks? | |
794 bcs L03F8 no, | |
795 rts yes, return | |
796 | |
797 ******************************************************************** | |
798 * | |
799 ******************************************************************** | |
800 | |
312 | 801 L044E ldy <u000E |
802 L0451 ldd ,y++ | |
803 beq L046B | |
804 L0455 stb ,x+ | |
0 | 805 deca |
312 | 806 bne L0455 |
807 bra L0451 | |
1614 | 808 L045C lda <dtype get drive's PD.TYP |
809 bita #TYP.HARD+TYP.NSF hard disk or non-standard format? | |
810 beq L046C branch if neither | |
0 | 811 ldy <u000C |
1614 | 812 leax >LSN0,u point to the LSN0 buffer |
312 | 813 bsr L0451 |
814 L046B rts | |
926 | 815 |
816 ******************************************************************** | |
817 * | |
818 ******************************************************************** | |
819 | |
312 | 820 L046C ldy <u000C |
821 ldb <u001A | |
924 | 822 tst <currtrak+1 |
312 | 823 bne L047E |
1614 | 824 tst <currside |
312 | 825 bne L047E |
0 | 826 ldy <u000A |
1614 | 827 * ldb <u001C |
828 ldb <sectors0+1 | |
312 | 829 L047E sty <u000E |
0 | 830 stb <u0009 |
312 | 831 stb <u0018 |
832 bsr L04EC | |
1614 | 833 leax >LSN0,u |
312 | 834 bsr L0451 |
0 | 835 sty <u000E |
312 | 836 L0490 bsr L044E |
0 | 837 dec <u0009 |
312 | 838 bne L0490 |
0 | 839 lda ,y+ |
840 sty <u000E | |
312 | 841 stx <u003D |
842 leay >u297E,u | |
926 | 843 sty <dresult |
0 | 844 tfr a,b |
312 | 845 L04A6 std ,x++ |
926 | 846 cmpx <dresult |
312 | 847 bcs L04A6 |
0 | 848 ldy <u000E |
849 ldd ,y++ | |
312 | 850 std <u003F |
0 | 851 ldd ,y |
312 | 852 std <u0041 |
0 | 853 clr <u0009 |
1614 | 854 leax >LSN0,u |
312 | 855 ldd <u003F |
856 leay >u008F,u | |
857 L04C3 leax d,x | |
924 | 858 ldd <currtrak+1 |
859 adda <stoff | |
0 | 860 std ,x |
861 ldb <u0009 | |
862 lda b,y | |
863 incb | |
864 stb <u0009 | |
924 | 865 ldb <currsect |
312 | 866 adda <u004B |
867 bcs L04E5 | |
868 std $02,x | |
0 | 869 lda <u0009 |
312 | 870 cmpa <u0018 |
871 bcc L04E4 | |
872 ldd <u0041 | |
873 bra L04C3 | |
874 L04E4 rts | |
926 | 875 |
876 ******************************************************************** | |
877 * | |
878 ******************************************************************** | |
879 | |
880 L04E5 leax >AbortSct,pcr sector number out of range message | |
881 lbra PExit print message and exit | |
882 | |
883 ******************************************************************** | |
884 * | |
885 ******************************************************************** | |
886 | |
312 | 887 L04EC pshs y,b |
0 | 888 tfr b,a |
924 | 889 ldb <currtrak+1 |
0 | 890 cmpb #$01 |
312 | 891 bhi L0518 |
892 leax >u008F,u | |
0 | 893 leay a,x |
924 | 894 ldb <interlv |
312 | 895 bne L0507 |
926 | 896 L0500 leax >AbortIlv,pcr Interleave out of range message |
897 lbra PExit print message and exit | |
312 | 898 L0507 cmpb <u0018 |
899 bhi L0500 | |
0 | 900 nega |
901 pshs y,x,b,a | |
902 clra | |
312 | 903 L050F sta ,x |
0 | 904 inca |
312 | 905 cmpa <u0018 |
906 bne L051A | |
0 | 907 leas $06,s |
312 | 908 L0518 puls pc,y,b |
924 | 909 L051A ldb <interlv |
0 | 910 abx |
911 cmpx $04,s | |
312 | 912 bcs L0525 |
0 | 913 ldb ,s |
914 leax b,x | |
312 | 915 L0525 cmpx $02,s |
916 bne L050F | |
0 | 917 leax $01,x |
918 stx $02,s | |
312 | 919 bra L050F |
926 | 920 |
921 ******************************************************************** | |
1614 | 922 * initialize sector 0 |
926 | 923 ******************************************************************** |
924 | |
1614 | 925 InitLSN0 lbsr ClrBuf clear the sector buffer |
926 ldd <totsects+1 get total sectors bits 15-0 | |
927 std DD.TOT+1,x save | |
928 ldb <totsects get bits 23-16 | |
929 stb DD.TOT,x save | |
930 ldd <sectors get sectors/track | |
931 std <DD.SPT,x save | |
932 stb DD.TKS,x save | |
926 | 933 lda <clustsiz get cluster size |
1614 | 934 sta DD.BIT+1,x save |
0 | 935 clra |
1614 | 936 ldb <ClustSz get cluster size |
312 | 937 tst <u0029 |
938 beq L054F | |
0 | 939 addd #$0001 |
312 | 940 L054F addd #$0001 |
1614 | 941 std DD.DIR+1,x save directory sector |
0 | 942 clra |
1614 | 943 tst <mfm single density? |
944 beq L0561 branch if so | |
945 ora #FMT.DNS else set double density bit | |
312 | 946 tst <u004C |
947 beq L0561 | |
948 ora #$08 | |
1614 | 949 L0561 ldb <numsides get number of sides |
950 cmpb #$01 just 1? | |
951 beq L0569 branch if so | |
952 ora #FMT.SIDE else set double-sided bit | |
953 L0569 tst <tpi 48tpi? | |
954 beq L056F branch if so | |
955 ora #FMT.TDNS else set 96/135 tpi | |
956 L056F sta <DD.FMT,x save | |
957 ldd <ClustSz get cluster size | |
958 std DD.MAP,x save number of bytes in allocation bit map | |
959 lda #$FF attributes | |
960 sta DD.ATT,x save | |
961 leax >LSN0+DD.DAT,u point to time buffer | |
962 os9 F$Time get current time | |
963 leax >LSN0+DD.NAM,u | |
926 | 964 leay <dskname,u quote delimited disk name buffer |
1614 | 965 tst ,y name in buffer? |
966 beq L0594 branch if not | |
967 L058C lda ,y+ get character of name | |
968 sta ,x+ and save in name area of LSN0 | |
312 | 969 bpl L058C |
970 bra L05C7 | |
1614 | 971 * Here we prompt for a disk name |
312 | 972 L0594 leax >DName,pcr |
119 | 973 ldy #DNameLen |
1614 | 974 lbsr Print print disk name prompt |
975 leax >LSN0+DD.NAM,u point to new name | |
976 ldy #33 read up to 33 characters | |
0 | 977 clra |
1614 | 978 os9 I$ReadLn from standard input |
979 bcc L05B8 branch if ok | |
980 cmpa #E$EOF end of file? | |
981 bne L0594 branch if not | |
926 | 982 L05B1 leax >Aborted,pcr format aborted message |
983 lbra PExit print message and exit | |
1614 | 984 L05B8 tfr y,d copy number of chars entered into D |
985 leax d,x point to last char + 1 | |
0 | 986 clr ,-x |
1614 | 987 decb decrement chars typed |
988 beq L0594 branch if zero (go ask again) | |
989 lda ,-x get last character | |
990 ora #$80 set hi bit | |
991 sta ,x and save | |
992 L05C7 leax >LSN0+DD.DAT,u point to time | |
0 | 993 leay <$40,x |
994 pshs y | |
995 ldd #$0000 | |
312 | 996 L05D3 addd ,x++ |
0 | 997 cmpx ,s |
312 | 998 bcs L05D3 |
0 | 999 leas $02,s |
1614 | 1000 std >LSN0+DD.DSK,u save disk ID |
1001 * Not sure what this code is for... | |
1002 * ldd >val1,pcr | |
1003 * std >u01A7,u | |
1004 * ldd >val2,pcr | |
1005 * std >u01A9,u | |
1006 * ldd >val3,pcr | |
1007 * std >u01AB,u | |
924 | 1008 lda <diskpath |
119 | 1009 ldb #SS.Opt |
1614 | 1010 leax >LSN0+DD.OPT,u point to disk options |
1011 os9 I$GetStt get options | |
1012 ldb #SS.Reset reset head to track 0 | |
1013 os9 I$SetStt do it! | |
1014 lbcs Exit branch if error | |
1015 leax >LSN0,u point to LSN0 | |
1016 lbra WritSec and write it! | |
926 | 1017 |
1018 ******************************************************************** | |
1614 | 1019 * read in sector 0 of device |
926 | 1020 ******************************************************************** |
924 | 1021 |
1614 | 1022 ReadLSN0 lda <diskpath get disk path |
1023 os9 I$Close close it | |
1024 leax <prmbuf,u point to device name | |
162 | 1025 lda #READ. |
1614 | 1026 os9 I$Open open for read |
1027 lbcs BadSect branch if problem | |
1028 sta <diskpath save new disk path | |
1029 leax >LSN0,u | |
312 | 1030 ldy #256 |
1614 | 1031 os9 I$Read read first sector |
1032 lbcs BadSect branch if problem | |
1033 lda <diskpath get disk path | |
1034 os9 I$Close close path to device | |
1035 leax <prmbuf,u re-point to device name | |
162 | 1036 lda #UPDAT. |
1614 | 1037 os9 I$Open open in read/write mode |
1038 lbcs BadSect branch if error | |
1039 sta <diskpath else save new disk path | |
1040 rts and return | |
924 | 1041 |
926 | 1042 ******************************************************************** |
1043 * | |
1044 ******************************************************************** | |
1045 | |
942 | 1046 Stamps lda <dtype get device type in A |
1614 | 1047 clr <dovfy clear verify flag |
942 | 1048 bita #TYP.HARD hard drive? |
1614 | 1049 beq nothd branch if not |
1050 * Hard drives are asked for physical verification here | |
1051 askphys leax >Verify,pcr | |
312 | 1052 ldy #VerifyL |
1614 | 1053 lbsr Input prompt for physical verify of hard drive |
0 | 1054 anda #$DF |
1614 | 1055 cmpa #'Y yes? |
1056 beq nothd branch if so | |
1057 cmpa #'N no? | |
1058 bne askphys not not, ask again | |
1059 sta <dovfy else flag that we don't want physical verify | |
1060 nothd ldd <sectors0 get sectors/track at track 0 | |
1061 std <u0017 save | |
1062 clra D = 0 | |
0 | 1063 clrb |
1614 | 1064 sta <oksects clear OK sectors |
926 | 1065 std <oksects+1 |
1614 | 1066 std <currtrak clear current rack |
1067 std <sectcount clear counted sectors | |
312 | 1068 std <u0032 |
1069 stb <u0031 | |
1070 sta <u003C | |
924 | 1071 leax >optbuf,u |
312 | 1072 stx <u0038 |
926 | 1073 lbsr ClrSec |
0 | 1074 leax >$0100,x |
312 | 1075 stx <u003A |
0 | 1076 clra |
1614 | 1077 ldb #$01 D = 1 |
312 | 1078 std <u0034 |
926 | 1079 lda <clustsiz get cluster size |
942 | 1080 sta <u002B store in cluster counter |
312 | 1081 clr <u002A |
0 | 1082 clra |
926 | 1083 ldb <ClustSz |
312 | 1084 tst <u0029 |
1085 beq L069D | |
0 | 1086 addd #$0001 |
312 | 1087 L069D addd #$0009 |
1088 std <u002D | |
926 | 1089 lda <clustsiz get cluster size |
312 | 1090 L06A4 lsra |
1091 bcs L06B5 | |
1092 lsr <u002D | |
1093 ror <u002E | |
1094 bcc L06A4 | |
1095 inc <u002E | |
1096 bne L06A4 | |
1097 inc <u002D | |
1098 bra L06A4 | |
1099 L06B5 ldb <u002E | |
1100 stb <u002F | |
926 | 1101 lda <clustsiz get cluster size |
0 | 1102 mul |
312 | 1103 std <u002D |
0 | 1104 subd #$0001 |
926 | 1105 subb <ClustSz |
0 | 1106 sbca #$00 |
312 | 1107 tst <u0029 |
1108 beq L06CC | |
0 | 1109 subd #$0001 |
312 | 1110 L06CC stb <u002C |
1614 | 1111 L06CE tst <dovfy do we verify? |
1112 bne OutScrn no, output screen display | |
952 | 1113 lda <diskpath yes, get rbf device path |
1614 | 1114 leax >LSN0,u get sector buffer |
952 | 1115 ldy #256 sector size |
1614 | 1116 os9 I$Read read of sector successful? |
1117 bcc OutScrn yes, output screen display | |
926 | 1118 os9 F$PErr no, print error message |
952 | 1119 lbsr NextSec get next sector |
0 | 1120 lda #$FF |
312 | 1121 sta <u002A |
1122 tst <u0031 | |
1614 | 1123 bne OutScrn output screen display |
312 | 1124 ldx <u0032 |
1125 cmpx <u002D | |
1614 | 1126 bhi OutScrn output screen display |
926 | 1127 BadSect leax >BadSectM,pcr bad system sector message |
1128 PExit lbsr PrintLn print message | |
1129 clrb clear error | |
1130 lbra Exit exit no error | |
1131 | |
1132 ******************************************************************** | |
1614 | 1133 * output screen display scrolling track counter |
926 | 1134 ******************************************************************** |
1135 | |
1614 | 1136 OutScrn ldd <sectcount get counted sectors |
926 | 1137 addd #$0001 increment it |
1614 | 1138 std <sectcount save counted sectors |
942 | 1139 cmpd <u0017 good sector count? |
926 | 1140 bcs L0745 next segment |
1614 | 1141 clr <sectcount clear counted sectors |
926 | 1142 clr <u0009 |
952 | 1143 tst <dovfy are we verifying? |
1144 bne L073A no, | |
1145 lda #C$SPAC yes, get space | |
1146 pshs a save it | |
1147 lda <currtrak+1 track high byte | |
1148 lbsr HexDigit make it ascii | |
1149 L0724 pshs b,a save two ascii digits | |
1150 lda <currtrak track low byte | |
1151 lbsr HexDigit make it ascii | |
1152 pshs b save two ascii digits | |
1153 tfr s,x get output from stack | |
1614 | 1154 ldy #$0004 length of output |
952 | 1155 lbsr Print print it |
0 | 1156 lda $02,s |
952 | 1157 cmpa #$46 end of line? |
1158 bne L0738 skip line feed | |
1159 lbsr LineFD print linefeed | |
1614 | 1160 L0738 leas $04,s pop output off stack |
952 | 1161 L073A ldd <currtrak get current track |
1162 addd #$0001 increment it | |
1163 std <currtrak save it back | |
1164 ldd <sectors get number of sectors | |
1165 std <u0017 save it | |
1166 L0745 dec <u002B decrement cluster counter | |
312 | 1167 bne L075B |
1168 bsr L0784 | |
1169 tst <u002A | |
1170 bne L0755 | |
952 | 1171 ldd <oksects+1 increment good sectors |
926 | 1172 addd #$0001 |
1173 std <oksects+1 | |
1174 bcc L0755 | |
1175 inc <oksects | |
312 | 1176 L0755 clr <u002A |
926 | 1177 lda <clustsiz get cluster size |
942 | 1178 sta <u002B save in cluster counter |
312 | 1179 L075B ldb <u0031 |
1180 ldx <u0032 | |
0 | 1181 leax $01,x |
312 | 1182 bne L0764 |
0 | 1183 incb |
1614 | 1184 L0764 cmpb <totsects |
312 | 1185 bcs L076C |
1614 | 1186 cmpx <totsects+1 |
312 | 1187 bcc L0773 |
1188 L076C stb <u0031 | |
1189 stx <u0032 | |
1190 lbra L06CE | |
1191 L0773 lda #$FF | |
1192 sta <u002A | |
924 | 1193 leay >optbuf,u |
312 | 1194 L077B cmpy <u0038 |
926 | 1195 beq GoodSect number of good sectors summary |
312 | 1196 bsr L0784 |
1197 bra L077B | |
1198 L0784 ldx <u0038 | |
1199 lda <u002A | |
0 | 1200 rora |
1201 rol ,x+ | |
312 | 1202 inc <u003C |
1203 lda <u003C | |
0 | 1204 cmpa #$08 |
312 | 1205 bcs L07A6 |
1206 clr <u003C | |
1207 stx <u0038 | |
1208 cmpx <u003A | |
1209 bne L07A6 | |
926 | 1210 bsr WrtSecs |
924 | 1211 leax >optbuf,u |
312 | 1212 stx <u0038 |
926 | 1213 lbsr ClrSec |
1214 L07A6 rts return | |
1215 | |
1216 ******************************************************************** | |
1217 * convert byte to ascii hexadecimal and return it in d register | |
1218 ******************************************************************** | |
1219 | |
1220 HexDigit tfr a,b get byte again | |
1221 lsra shift upper digit | |
1222 lsra | |
1223 lsra | |
1224 lsra | |
1225 andb #$0F mask lower digit | |
1226 addd #$3030 make it ascii | |
1227 cmpa #$39 upper digit > 9 | |
1228 bls L07B8 no, | |
1229 adda #$07 yes, make hexadecimal | |
1230 L07B8 cmpb #$39 lower digit > 9 | |
1231 bls L07BE no, | |
1232 addb #$07 yes, make hexadecimal | |
1233 L07BE rts return | |
1234 | |
1235 ******************************************************************** | |
1236 * number of good sectors message | |
1237 ******************************************************************** | |
1238 | |
1239 GoodSect lbsr LineFD print line feed | |
1240 leax >NumGood,pcr number of good sectors | |
952 | 1241 ldy #NGoodLen length of message |
926 | 1242 lbsr Print print it |
1243 ldb <clustsiz get cluster size | |
1244 lda <oksects get 24 bit counter | |
1245 ldx <oksects+1 | |
1246 pshs x,a save 24 bit counter | |
1247 L07D4 lsrb carry set 0xxx xxxx -> X ? | |
1248 bcs L07DF yes, | |
1249 lsl $02,s <u0036 1 X <- nnnn nnnn X <- xxxx xxx0 | |
1250 rol $01,s <u0036 2 N <- nnnn nnnX N <- xxxx xxx0 | |
1251 rol ,s <u0036 3 N <- nnnn nnnN | |
1252 bra L07D4 did all sectors? | |
1253 L07DF puls x,a get counted sectors | |
1254 ldb #C$CR | |
1255 pshs b save enter | |
1256 tfr d,y get size | |
1257 tfr x,d get | |
1258 tfr b,a get convert byte | |
1259 bsr HexDigit convert it BYTE 1 | |
1260 pshs b,a save in buffer | |
1261 tfr x,d get convert byte | |
1262 bsr HexDigit convert it BYTE 2 | |
1263 pshs b,a save in buffer | |
1264 tfr y,d get convert byte | |
1265 bsr HexDigit convert it BYTE 3 | |
1266 pshs b,a save it buffer | |
1267 tfr s,x get output buffer | |
1268 lbsr PrintLn print it | |
1269 leas $07,s fix stack | |
1270 rts return | |
1271 | |
1272 ******************************************************************** | |
1273 * get allocation bit map and write sectors | |
1274 ******************************************************************** | |
1275 | |
1276 WrtSecs pshs y save register | |
1277 clra set number | |
1278 ldb #$01 bits to set | |
1279 cmpd <u0034 map sector? | |
1280 bne L081E yes, write sector | |
1281 leax >optbuf,u allocation bit map | |
1282 clra get number | |
1283 ldb <u002F system sectors | |
1284 tfr d,y into register | |
1285 clrb first bit to set | |
1286 os9 F$AllBit set allocation bit map | |
1287 lbcs BadSect if there a error | |
1288 L081E lbsr GetSec get sector | |
1289 leax >optbuf,u allocation bit map | |
1290 lbsr WritSec write sector | |
1614 | 1291 ldd <totsects get total sectors |
926 | 1292 cmpd <u0031 lsn sector count? |
1293 bcs AdvSec advance to mapped sectors | |
1294 bhi NxtSec get next sector | |
1614 | 1295 ldb <totsects+2 get LSB total sectors |
926 | 1296 cmpb <u0033 good sector count? |
1297 bcc AdvSec advance to mapped sectors | |
1298 NxtSec lbsr NextSec skip to next sector | |
1299 AdvSec ldd <u0034 get mapped sectors | |
1300 addd #$0001 count from one | |
1301 std <u0034 save mapped sectors count | |
1302 puls pc,y restore and return | |
1303 | |
1304 ******************************************************************** | |
1614 | 1305 * create root directory file descriptor |
926 | 1306 ******************************************************************** |
1307 | |
1614 | 1308 MkRootFD bsr GetSec get sector |
926 | 1309 leax >fdtbuf1,u sector buff |
1310 bsr ClrSec clear sector | |
1311 leax >fdtbuf2,u get date last modified | |
1312 os9 F$Time get system time | |
1313 leax >fdtbuf1,u get file descriptor | |
1314 lda #DIR.+PEXEC.+PWRIT.+PREAD.+EXEC.+UPDAT. | |
1315 sta FD.ATT,x save in FD.ATT | |
1316 lda #$02 get link count | |
1317 sta FD.LNK,x save in FD.LNK | |
1318 clra directory size | |
1319 ldb #DIR.SZ*2 directory entries (DIR.SZ*2) | |
1320 std FD.SIZ+2,x save it (FD.SIZ+2) | |
312 | 1321 ldb <u002C |
926 | 1322 decb |
952 | 1323 stb <FD.SEG+FDSL.B+1,x save it (FD.SEG+FDSL.B+1) |
312 | 1324 ldd <u0034 |
0 | 1325 addd #$0001 |
952 | 1326 std <FD.SEG+FDSL.A+1,x save it (FD.SEG+FDSL.A+1) |
926 | 1327 bsr WritSec |
1328 bsr ClrBuf | |
1329 ldd #$2EAE (#'.*256+'.+128) | |
1330 std DIR.NM,x (DIR.NM) | |
1331 stb <DIR.SZ+DIR.NM,x (DIR.NM+DIR.SZ) | |
312 | 1332 ldd <u0034 |
926 | 1333 std <DIR.FD+1,x |
1334 std <DIR.SZ+DIR.FD+1,x | |
1335 bsr WritSec | |
1336 bsr ClrBuf | |
312 | 1337 ldb <u002C |
942 | 1338 decb make zero offset (0 - 255) |
1339 NextCnt decb decrement sector count | |
1340 bne NextWrt if more to do | |
1341 rts else return | |
1342 NextWrt pshs b save sector count | |
1343 bsr WritSec write the sector | |
1344 puls b get count back | |
1345 bra NextCnt do until done | |
926 | 1346 |
1347 ******************************************************************** | |
1348 * clear the 256 byte sector buffer | |
1349 ******************************************************************** | |
1350 | |
1614 | 1351 ClrBuf leax >LSN0,u sector buffer |
926 | 1352 ClrSec clra store mask |
1353 clrb sector count | |
1354 ClrLop sta d,x clear the buffer | |
1355 decb decrement sector count | |
1356 bne ClrLop clear sector buffer | |
1357 rts return when done | |
1358 | |
1359 ******************************************************************** | |
1360 * write physical 256 byte sector to the diskette | |
1361 ******************************************************************** | |
1362 | |
1363 WritSec lda <diskpath get path number | |
1364 ldy #256 get sector size | |
1365 os9 I$Write write the sector | |
1366 lbcs Exit exit on error | |
1367 rts return | |
1368 | |
1369 ******************************************************************** | |
1370 * get sector file position | |
1371 ******************************************************************** | |
1372 | |
1373 GetSec clra | |
1374 ldb <u0034 get map sectors high word | |
1375 tfr d,x save it | |
312 | 1376 lda <u0035 |
926 | 1377 clrb get map sectors low word |
1378 tfr d,u save it | |
1379 | |
1380 ******************************************************************** | |
1381 * seek to physical sector | |
1382 ******************************************************************** | |
1383 | |
1384 SeekSec lda <diskpath get path number | |
1385 os9 I$Seek seek to sector | |
1386 ldu <savedu get data pointer | |
1387 lbcs Exit exit if error | |
1388 rts return | |
1389 | |
1390 ******************************************************************** | |
1391 * skip to the next sector | |
1392 ******************************************************************** | |
1393 | |
1394 NextSec ldx <u0031 lsn count | |
1395 lda <u0033 good sector count | |
1396 clrb add this | |
1397 addd #$0100 sector | |
1398 tfr d,u lsn count | |
1399 bcc SeekSec seek it? | |
1400 leax $01,x next sector | |
1401 bra SeekSec seek it | |
1402 | |
1403 ******************************************************************** | |
1404 * the format module never gets to this code? | |
1405 ******************************************************************** | |
1406 | |
0 | 1407 ldd ,y |
1614 | 1408 leau >LSN0,u |
926 | 1409 leax >dcnums,pcr decimal number conversion table |
0 | 1410 ldy #$2F20 |
926 | 1411 |
1412 ******************************************************************** | |
1413 * | |
1414 ******************************************************************** | |
1415 | |
312 | 1416 L08E6 leay >$0100,y |
0 | 1417 subd ,x |
312 | 1418 bcc L08E6 |
0 | 1419 addd ,x++ |
1420 pshs b,a | |
1421 ldd ,x | |
1422 tfr y,d | |
312 | 1423 beq L090E |
0 | 1424 ldy #$2F30 |
1425 cmpd #$3020 | |
312 | 1426 bne L0908 |
0 | 1427 ldy #$2F20 |
1428 tfr b,a | |
312 | 1429 L0908 sta ,u+ |
0 | 1430 puls b,a |
312 | 1431 bra L08E6 |
1432 L090E sta ,u+ | |
1433 lda #C$CR | |
0 | 1434 sta ,u |
924 | 1435 ldu <savedu |
0 | 1436 leas $02,s |
1614 | 1437 leax >LSN0,u |
926 | 1438 lbsr PrintLn |
1439 rts | |
119 | 1440 |
926 | 1441 dcnums fdb 10000,1000,100,10,1,0 |
1442 | |
1443 ******************************************************************** | |
1444 * process decimal number input (65535) | |
1445 ******************************************************************** | |
119 | 1446 |
926 | 1447 Decimal ldd #$0000 start at zero |
1448 L092F bsr DecBin get first digit | |
1449 bcs L0939 if overflow | |
1450 bne L092F get next digit | |
1451 std <dresult save decimal as binary | |
1452 bne L093E if no error return | |
1453 L0939 ldd #$0001 flag error | |
1454 std <dresult save it | |
1455 L093E rts return | |
1456 | |
1457 ******************************************************************** | |
1458 * process decimal number into it's binary representation | |
1459 * return with binary in the d register | |
1460 ******************************************************************** | |
1461 | |
1462 DecBin pshs y,b,a save registers | |
1463 ldb ,x+ get digit | |
1464 subb #$30 make it binary | |
1465 cmpb #$0A bla bla bla! | |
312 | 1466 bcc L095D |
0 | 1467 lda #$00 |
1468 ldy #$000A | |
312 | 1469 L094F addd ,s |
1470 bcs L095B | |
0 | 1471 leay -$01,y |
312 | 1472 bne L094F |
0 | 1473 std ,s |
203 | 1474 andcc #^Zero |
312 | 1475 L095B puls pc,y,b,a |
1476 L095D orcc #Zero | |
0 | 1477 puls pc,y,b,a |
926 | 1478 |
1479 ******************************************************************** | |
1480 * print error, usage message, and exit | |
1481 ******************************************************************** | |
1482 | |
1483 PrtError lda #$02 standard error | |
1484 os9 F$PErr print error | |
1485 IFNE DOHELP | |
1486 leax <HelpMsg,pcr point to usage | |
1487 ldy #HelpLen usage size | |
1488 lda #$02 standard error | |
1489 os9 I$WritLn print usage | |
1490 ENDC | |
1491 clrb no error | |
1492 os9 F$Exit exit module | |
1493 | |
1494 ******************************************************************** | |
1495 * messages | |
1496 ******************************************************************** | |
312 | 1497 |
119 | 1498 Title fcb C$LF |
1499 fcc "COLOR COMPUTER FORMATTER" | |
1500 HelpCR fcb C$CR | |
926 | 1501 IFNE DOHELP |
119 | 1502 HelpMsg fcc "Use: FORMAT /devname <opts>" |
1503 fcb C$LF | |
312 | 1504 fcc " opts: R - Ready" |
1505 fcb C$LF | |
926 | 1506 fcc " S/D - density; single or double" |
1507 fcb C$LF | |
312 | 1508 fcc " L - Logical format only" |
119 | 1509 fcb C$LF |
1510 fcc / "disk name"/ | |
312 | 1511 fcb C$LF |
1512 fcc " 1/2 - number of sides" | |
1513 fcb C$LF | |
1514 fcc " 'No. of cylinders' (in decimal)" | |
1515 fcb C$LF | |
1516 fcc " :Interleave value: (in decimal)" | |
926 | 1517 fcb C$LF |
1518 fcc " /Cluster size/ (in decimal)" | |
312 | 1519 fcb C$CR |
1520 HelpLen equ *-HelpMsg | |
926 | 1521 ENDC |
119 | 1522 FmtMsg fcc "Formatting drive " |
1523 FmtMLen equ *-FmtMsg | |
1524 Query fcc "y (yes) or n (no)" | |
1525 fcb C$LF | |
1526 fcc "Ready? " | |
1527 QueryLen equ *-Query | |
312 | 1528 AbortIlv fcc "ABORT Interleave value out of range" |
1529 fcb C$CR | |
1530 AbortSct fcc "ABORT Sector number out of range" | |
1531 fcb C$CR | |
1532 AbortOp fcc "ABORT Option not allowed on Device" | |
119 | 1533 fcb C$CR |
1534 DName fcc "Disk name: " | |
1535 DNameLen equ *-DName | |
1536 fcc "How many Cylinders (Tracks?) : " | |
926 | 1537 BadSectM fcc "Bad system sector, " |
1538 Aborted fcc "FORMAT ABORTED" | |
119 | 1539 fcb C$CR |
1540 ClustMsg fcc "Cluster size mismatch" | |
1541 fcb C$CR | |
1542 fcc "Double density? " | |
312 | 1543 fcc "Track 0 Double density? " |
119 | 1544 TPIChg fcc "Change from 96tpi to 48tpi? " |
1545 DSided fcc "Double sided? " | |
1546 NumGood fcc "Number of good sectors: $" | |
952 | 1547 NGoodLen equ *-NumGood |
312 | 1548 HDFmt fcc "WARNING: You are formatting a HARD Disk.." |
1549 fcb C$LF | |
1550 fcc "Are you sure? " | |
1551 HDFmtLen equ *-HDFmt | |
119 | 1552 Both fcc "Both PHYSICAL and LOGICAL format? " |
1553 BothLen equ *-Both | |
1554 Verify fcc "Physical Verify desired? " | |
312 | 1555 VerifyL equ *-Verify |
961
53b612a9ef45
Added a conditional check to the roll message, so you can build format
johncollyer
parents:
960
diff
changeset
|
1556 IFNE DOROLL |
952 | 1557 RollMsg fcc " Recording Format: FM/MFM" |
1558 fcb C$LF | |
1559 fcc " Track density in TPI: 48/96" | |
1560 fcb C$LF | |
1561 fcc " Number of Cylinders: 0000" | |
1562 fcb C$LF | |
1563 fcc " Number of Surfaces: 0000" | |
1564 fcb C$LF | |
1565 fcc "Sector Interleave Offset: 0000" | |
1566 fcb C$LF | |
1567 fcc " Disk type: 0000" | |
1568 fcb C$LF | |
961
53b612a9ef45
Added a conditional check to the roll message, so you can build format
johncollyer
parents:
960
diff
changeset
|
1569 fcc " Sectors/Cluster: 0000" |
952 | 1570 fcb C$LF |
1571 fcc " Sectors/Track: 0000" | |
1572 fdb $0A0A | |
1573 fcc "Sector: 00 Track: 00 Side: 00" | |
1574 RollLen equ *-RollMsg | |
961
53b612a9ef45
Added a conditional check to the roll message, so you can build format
johncollyer
parents:
960
diff
changeset
|
1575 ENDC |
0 | 1576 emod |
1577 eom equ * | |
119 | 1578 end |