Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/format.asm @ 2798:b70d93f8d7ce lwtools-port
Updated coco1/modules/makefile and coco3/modules/makefile to help resolve issues with i(x) and s(x) descriptors.
Updated level1/coco1/modules/makefile & level2/coco3/modules/makefile
so that correct values would be sent to assembler when
building superdesc.asm for s(x).dd and i(x).dd descriptors.
author | drencor-xeen |
---|---|
date | Mon, 28 Jan 2013 16:13:05 -0600 |
parents | c58baa9276c8 |
children | 86f00c7593bc |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
1697 | 2 * Format - RBF Disk format program |
0 | 3 * |
4 * $Id$ | |
5 * | |
1683
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
6 * Notes: |
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
7 * 1. If the TYP.DSQ bit in IT.TYP is clear, then the total number |
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
8 * of sectors is NOT multiplied by the bytes per sector. This |
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
9 * means that descriptors using partition offsets will need to |
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
10 * fill IT.CYL, IT.SID and IT.SCT with values that reflect the |
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
11 * number of 256 byte sectors on the disk. |
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
12 * |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
13 * 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
|
14 * Comment |
0 | 15 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
16 * 22 ????/??/?? |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
17 * From Tandy OS-9 Level Two VR 02.00.01. |
926 | 18 * |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
19 * 23 2003/01/06 JC |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
961
diff
changeset
|
20 * 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
|
21 * 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
|
22 * 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
|
23 * This was most notable when formatting large disks, such as hard drives. |
1664 | 24 * |
1675 | 25 * 24 2004/07/20 Boisy G. Pitre |
1664 | 26 * Revamped to display summary similar to OS-9/68K. Also, format now |
27 * checks the TYPH.DSQ bit in order to query the drive for its size. | |
1697 | 28 * A rolling track counter that stays on the same line is now used |
29 * instead of the scrolling track counter, and 4 byte track numbers | |
30 * are now shown instead of 3 byte track numbers. | |
1664 | 31 * Also, if a cluster size is not specified on the command line, |
32 * the best one is automatically calculated. | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
33 * |
1907 | 34 * 2005-10-25 P.Harvey-Smith. |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
35 * Added support for formatting Dragon floppies, this is required because |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
36 * dragon floppies are aranged thus :- |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
37 * LSN Purpose |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
38 * 0 Standard LSN0 |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
39 * 1 Blockmap |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
40 * 2-17 Boot area (as on track 35 of CoCo disk). |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
41 * 18 Begining of root dir |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
42 * 19+ Continuation of root dir ? and data sectors. |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
43 * |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
44 * Note as a limitation of this scheme, is that disks with more than 2048 |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
45 * sectors, need to have a cluster size of 2 as only one sector is available |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
46 * for the block map. |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
47 * |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
48 * To format a floppy with dragon format, you need to use the command line |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
49 * parameter 'FD' (format, Dragon). |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
50 * |
1907 | 51 * 2005-10-26 P.Harvey-Smith |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
52 * Determined the purpose and commented some of the unknown memory vars, |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
53 * also renamed others to more closeley represent their purpose, e.g. |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
54 * there where two 'cluster size' vars, one was inface number of bytes in |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
55 * bitmap, so that got renamed :) |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
56 * Format can now correctly build a DragonData OS-9 compatible disk |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
57 * that can have (under OS-9) cobbler run on it, and will subsequently then |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
58 * boot. |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
59 * |
1907 | 60 * 25 2005-10-26 Boisy G. Pitre |
61 * Fixed an issue where the bitmap sector wasn't being properly set up | |
62 * due to some incorrect assumptions. The result was that copying a file | |
63 * to a newly formatted hard drive would, in cases where the drive was | |
64 * large, wipe out the bitmap sector and root directory area. | |
65 | |
66 nam Format | |
1697 | 67 ttl RBF Disk format program |
1907 | 68 |
312 | 69 * Disassembled 02/07/17 11:00:13 by Disasm v1.6 (C) 1988 by RML |
1907 | 70 |
71 ifp1 | |
72 use defsfile | |
73 endc | |
74 | |
75 DOHELP set 0 | |
76 DOROLL set 0 | |
77 | |
78 tylg set Prgrm+Objct | |
79 atrv set ReEnt+rev | |
80 rev set $00 | |
81 edition set 25 | |
82 | |
0 | 83 mod eom,name,tylg,atrv,start,size |
1907 | 84 |
926 | 85 ******************************************************************** |
86 * begin our data area, starts on direct page | |
87 ******************************************************************** | |
1907 | 88 |
89 savedu rmb 2 save the u register | |
90 totsects rmb 3 | |
91 tmpnum rmb 4 | |
92 sectmode rmb 1 | |
93 diskpath rmb 1 disk path number | |
94 currtrak rmb 2 current track on | |
95 currside rmb 2 | |
96 currsect rmb 1 current sector on | |
97 sectcount rmb 2 counted sectors | |
98 trk0data rmb 2 track 0 data pointer | |
99 trkdata rmb 2 track !0 data pointer | |
100 u000E rmb 2 | |
101 mfm rmb 1 denisity (double/single) | |
102 maxmfm rmb 1 | |
103 tpi rmb 1 | |
104 numsides rmb 1 | |
105 ncyls rmb 2 total number of cylinders | |
106 u0017 rmb 1 | |
107 u0018 rmb 1 | |
108 sectors rmb 2 total number of sectors | |
109 sectors0 rmb 2 total number of sectors | |
110 bps rmb 1 bytes per sector (returned from SS.DSize) | |
111 dtype rmb 1 disk device type (5", 8", hard disk) | |
112 dns rmb 1 density byte | |
113 sas rmb 1 density byte | |
114 ready rmb 1 ready to proceed, skip warning | |
115 dresult rmb 2 decimal number in binary | |
116 interlv rmb 1 sector interleave value | |
117 u0022 rmb 2 | |
118 clustsiz rmb 1 cluster size (specified or default) | |
119 clustspecified rmb 1 cluster size specified on command line | |
120 NumBitmapBytes rmb 2 Number of bytes in cluster allocation bitmap | |
121 u002A rmb 1 | |
122 clustcnt rmb 1 | |
123 NoRootFDSecs rmb 1 Number of sectors in Root FD (normally 8 ?) | |
124 NoSysSectors rmb 2 Number of Sectors at beginning of disk reserved for system | |
125 NoSysClusters rmb 2 Number of system Clusters to allocate | |
126 u0030 rmb 1 | |
127 u0031 rmb 1 | |
128 u0032 rmb 1 | |
129 u0033 rmb 1 | |
130 u0034 rmb 1 | |
131 u0035 rmb 1 | |
132 oksects rmb 3 | |
133 u0038 rmb 2 | |
134 u003A rmb 2 | |
135 u003C rmb 1 | |
136 u003D rmb 2 | |
137 u003F rmb 2 | |
138 u0041 rmb 2 | |
139 u0043 rmb 1 | |
140 u0044 rmb 1 | |
141 dovfy rmb 1 | |
142 dtentry rmb 2 | |
143 u0048 rmb 1 | |
144 toffs rmb 1 track offset (derived from PD.SToff) | |
145 soffs rmb 1 sector offset (derived from PD.SToff) | |
146 t0sngdns rmb 1 track 0 single density flag | |
147 cocofmt rmb 1 COCO disk format flag (1 = yes) | |
148 dolog rmb 1 logical format | |
149 prmbuf rmb 2 | |
150 u0051 rmb 4 | |
151 u0055 rmb 15 | |
152 u0064 rmb 7 | |
153 u006B rmb 4 | |
154 dskname rmb 32 quoted delimited disk name buffer | |
155 u008F rmb 40 | |
156 IsDragon rmb 1 Is this a dragon disk ? | |
157 SaveRootLSN rmb 3 Saved copy of DD.DIR | |
158 AddedSysSecs rmb 2 Additional system sectors (0 for CoCo, $10 for Dragon boot area) | |
159 LSN0 rmb 256 LSN0 build buffer | |
160 optbuf rmb 256 | |
161 numbuf rmb 32 | |
162 fdtbuf1 rmb 3 | |
163 fdtbuf2 rmb 9924 | |
164 u297E rmb 451 | |
165 size equ . | |
166 | |
167 name fcs /Format/ | |
168 fcb edition | |
169 | |
1614 | 170 *val1 fdb $0000 |
171 *val2 fdb $0000 | |
172 *val3 fdb $0000 | |
1907 | 173 |
1707
3911533043d3
Some additional changes to address formatting 80 track drives.
boisy
parents:
1697
diff
changeset
|
174 * Hard drive sector data: 128 bytes of $E5, and another 128 bytes of $E5 |
926 | 175 hdsdat fdb $80E5,$80E5,$0000 |
1907 | 176 |
1707
3911533043d3
Some additional changes to address formatting 80 track drives.
boisy
parents:
1697
diff
changeset
|
177 * Single Density Floppy Track Data |
926 | 178 sgtdat fdb $0100,$28FF,$0600,$01FC,$0CFF,$0000 |
1683
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
179 * Single Density Sector Data |
926 | 180 sgsdat fdb $0600,$01FE,$0400,$01F7,$0AFF,$0600 |
181 fdb $01FB,$80E5,$80E5,$01F7,$0AFF,$0000 | |
1907 | 182 fcb $FF |
183 sgfidp fdb $0043 | |
184 sgsize fdb $0128 | |
185 | |
1707
3911533043d3
Some additional changes to address formatting 80 track drives.
boisy
parents:
1697
diff
changeset
|
186 * Double Density Floppy Track Data |
926 | 187 dbtdat fdb $504E,$0C00,$03F6,$01FC,$204E,$0000 |
1683
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
188 * Double Density Sector Data |
926 | 189 dbsdat fdb $0C00,$03F5,$01FE,$0400,$01F7,$164E |
190 fdb $0C00,$03F5,$01FB,$80E5,$80E5,$01F7 | |
191 fdb $164E,$0000 | |
1907 | 192 fcb $4E |
193 dbfidp fdb $0090 | |
194 dbsize fdb $0152 | |
195 | |
1721 | 196 * Double Density Color Computer Format |
926 | 197 dctdat fdb $204E,$0000,$0C00,$03F5,$01FE,$0400 |
198 fdb $01F7,$164E,$0C00,$03F5,$01FB,$80E5 | |
199 fdb $80E5,$01F7,$184E,$0000 | |
1907 | 200 fcb $4E |
201 dcfidp fdb $0030 | |
202 dcsize fdb $0154 | |
203 | |
2677
c58baa9276c8
Fix string constants used as numbers
William Astle <lost@l-w.ca>
parents:
2108
diff
changeset
|
204 DragonFlag equ 'd Flag that we are formatting dragon formatted disk. |
1907 | 205 DragonRootSec equ $12 Dragon root sector is always LSN 18 |
206 DragonBootSize equ $10 Size of dragon boot area | |
207 | |
926 | 208 ******************************************************************** |
209 * format module execution start address | |
210 ******************************************************************** | |
1907 | 211 |
212 start stu <savedu save our data pointer | |
213 bsr ClrWork clear the work area | |
214 bsr OpenDev get device name and open it | |
215 lbsr Default handle all the options | |
216 lbsr GetDTyp initialize the device | |
217 lbsr Proceed | |
218 lbsr Format physically format device | |
219 lbsr InitLSN0 initialize LSN0 | |
220 lbsr ReadLSN0 attempt to read back LSN0 | |
221 lbsr MkBMap make bitmap sectors | |
222 lbsr MkRootFD file descriptor | |
223 ldu <dtentry device table entry | |
224 os9 I$Detach detach the device | |
225 clrb flag no error | |
226 Exit os9 F$Exit exit module | |
227 | |
926 | 228 ******************************************************************** |
229 * clear our working memory area | |
230 ******************************************************************** | |
1907 | 231 |
232 ClrWork leay diskpath,u point to work area | |
233 pshs y save that | |
234 leay >LSN0,u get size of area | |
235 ClrOne clr ,-y clear it down | |
236 cmpy ,s at begin? | |
237 bhi ClrOne not yet, | |
238 clr IsDragon,u Assume we are not formatting a dragon disk | |
239 clr AddedSysSecs,u Clear aditional system sectors | |
240 clr AddedSysSecs+1,u | |
241 puls pc,y done | |
242 | |
926 | 243 ******************************************************************** |
244 * get rbf device name and open it | |
245 ******************************************************************** | |
1907 | 246 |
247 OpenDev lda ,x+ get char at X | |
248 cmpa #PDELIM pathlist delimiter? | |
249 beq PrsPrm branch if so | |
250 BadPath ldb #E$BPNam else set bad pathname | |
251 lbra PrtError and print error | |
252 PrsPrm os9 F$PrsNam parse pathname | |
253 lbcs PrtError branch if illegal (has additional pathlist element) | |
254 lda #PDELIM get pathlist name separator | |
255 cmpa ,y another pathlist separator? | |
256 beq BadPath yes, set bad pathname | |
257 sty <u0022 no, save end of pathname | |
258 leay <prmbuf,u point to pathname buffer | |
259 MovNam sta ,y+ save pathname character | |
260 lda ,x+ get next pathname character | |
261 decb decrement pathname size | |
262 bpl MovNam got full pathname? | |
263 leax <prmbuf+1,u get pathname for I$Attach | |
264 lda #C$SPAC space character | |
265 sta ,y delimit pathname | |
266 clra get access mode | |
267 os9 I$Attach attach the rbf device | |
268 lbcs PrtError if error print error and exit | |
269 stu <dtentry save device table entry | |
270 ldu <savedu get data pointer | |
271 lda #PENTIR delimit pathname | |
272 ldb #C$SPAC for os9 I$Open | |
273 std ,y do it now | |
274 lda #WRITE. get access mode | |
275 leax <prmbuf,u get pathname | |
276 os9 I$Open open the rbf device | |
277 bcs Exit exit if could not open it | |
278 sta <diskpath save path number | |
279 rts return | |
280 | |
926 | 281 ******************************************************************** |
282 * get geometry and options, proceed (Y/N) | |
283 ******************************************************************** | |
1907 | 284 |
285 Default bsr Geometry | |
286 lbsr DoOpts | |
1664 | 287 * lbsr Proceed |
1907 | 288 rts |
289 | |
926 | 290 ******************************************************************** |
291 * get rbf device geometry | |
292 ******************************************************************** | |
1907 | 293 |
1664 | 294 ssztbl fcb $1,$2,$4,$8 |
1907 | 295 |
296 Geometry leax >optbuf,u status packet address | |
297 clrb SS.OPT function | |
298 os9 I$GetStt get status packet | |
299 bcs Exit exit if error | |
300 ldb PD.SID-PD.OPT,x number of surfaces | |
301 stb <numsides save it | |
1721 | 302 ldb PD.SToff-PD.OPT,x get track/sector offset values |
1907 | 303 beq L0143 branch if they are zero |
304 tfr b,a yes, make copy | |
305 anda #$0F isolate track offset (lower 4 bits) | |
306 sta <toffs save it | |
307 lsrb | |
308 lsrb | |
309 lsrb | |
310 lsrb isolate sector offset | |
311 stb <soffs save it | |
312 L0143 ldb PD.DNS-PD.OPT,x density capability | |
313 stb <dns | |
1721 | 314 * pshs b save it |
1907 | 315 andb #DNS.MFM check double-density |
316 stb <mfm save double-density (Yes/No) | |
317 stb <maxmfm save it again as maximum mfm | |
318 ldb <dns get saved PD.DNS byte | |
319 lsrb now 96 TPI bit is in bit pos 0 | |
320 pshs b save it | |
321 andb #$01 tpi (0=48/135, 1=96) | |
322 stb <tpi save it | |
323 puls b get byte with bit shifted right once | |
324 lsrb shift original bit #2 into bit #0 | |
325 andb <maxmfm AND with mfm bit (1 = MFM, 0 = FM) | |
326 stb <t0sngdns save as track 0 single density flag | |
1721 | 327 * puls b get original PD.DNS byte |
328 * NOTE: We check the TYP.CCF at this point | |
1907 | 329 ldb PD.TYP-PD.OPT,x disk device type |
330 stb <dtype | |
331 andb #TYP.CCF | |
332 stb <cocofmt store it | |
333 beq L0169 branch if not CoCo format | |
334 ldb #$01 | |
335 stb <soffs CoCo has a sector offset of 1 | |
336 clr <toffs and no track offset | |
337 L0169 ldd PD.CYL-PD.OPT,x number of cylinders | |
338 std <ncyls save it | |
1721 | 339 * ldb PD.TYP-PD.OPT,x disk device type |
1907 | 340 ldb <dtype get IT.TYP byte |
341 andb #TYPH.SSM mask out all but sector size | |
1664 | 342 leay ssztbl,pcr |
1907 | 343 ldb b,y |
344 stb <bps and save bytes per sector | |
345 ldd PD.SCT-PD.OPT,x default sectors/track | |
346 std <sectors save it | |
347 ldd PD.T0S-PD.OPT,x default sectors/track tr00,s0 | |
348 std <sectors0 save it | |
349 ldb PD.ILV-PD.OPT,x sector interleave offset | |
350 stb <interlv save it | |
351 ldb PD.SAS-PD.OPT,x minimum sector allocation | |
352 stb <sas save it | |
353 ldb #$01 default cluster size | |
354 stb <clustsiz save it | |
355 stb <sectmode and sector mode | |
1614 | 356 *** ADDED CODE -- BGP. CHECK FOR PRESENCE OF SS.DSIZE |
1907 | 357 lda <dtype get type byte |
358 bita #TYPH.DSQ drive size query bit set? | |
359 beq nogo@ no, don't bother querying the drive for its size | |
360 lda <diskpath get disk path number | |
361 ldb #SS.DSize disk size getstat | |
362 os9 I$GetStt attempt | |
363 bcs err@ | |
364 sta <bps save bytes/sector | |
365 stb <sectmode | |
366 tstb LBA mode? | |
367 bne chs@ | |
368 tfr x,d | |
369 stb <totsects save result... | |
1614 | 370 sty <totsects+1 |
1907 | 371 bra nogo@ |
372 chs@ | |
373 stx <ncyls save cylinders | |
374 stb <numsides save sides | |
375 sty <sectors save sectors/track | |
376 sty <sectors0 save sectors/track 0 | |
377 nogo@ | |
378 clrb no error | |
379 rts return | |
380 err@ pshs b | |
1664 | 381 leax CapErr,pcr |
1907 | 382 lda #$02 |
383 ldy #100 | |
384 os9 I$WritLn | |
385 puls b | |
386 lbra PrtError | |
387 | |
926 | 388 ******************************************************************** |
389 * find a option and call, until all options are processed | |
390 ******************************************************************** | |
1907 | 391 |
392 DoOpts ldx <u0022 option buffer | |
393 L0185 leay >OptTbl,pcr point to table | |
394 bsr L019C check for match? | |
395 bcs L01A5 no, match | |
396 pshs b,a save d register | |
397 ldd $02,y get offset value | |
398 leay d,y make function address | |
399 puls b,a restore d register | |
400 jsr ,y call function | |
401 bcc L0185 finished good? | |
402 lbra Exit no, exit | |
403 L019C lda ,x+ get option character | |
404 L019E cmpa ,y is it in the table? | |
405 bne L01A6 no, try the next one | |
406 ldb $01,y get return value | |
407 clra flag good | |
408 L01A5 rts return | |
409 L01A6 leay $04,y get next table location | |
410 tst ,y is it the end of the table? | |
411 bne L019E no, try next location | |
412 coma yes, flag bad | |
413 rts return | |
414 | |
926 | 415 ******************************************************************** |
416 * option command table | |
417 ******************************************************************** | |
1907 | 418 |
419 OptTbl | |
420 opt.1 fcc /R/ | |
421 fcc /Y/ | |
312 | 422 fdb DoReady-opt.1 |
1907 | 423 opt.2 fcc /r/ |
424 fcc /Y/ | |
312 | 425 fdb DoReady-opt.2 |
1907 | 426 opt.3 fcc /S/ |
427 fcc / / | |
926 | 428 fdb DoDsity-opt.3 |
1907 | 429 opt.4 fcc /s/ |
430 fcc / / | |
926 | 431 fdb DoDsity-opt.4 |
1907 | 432 opt.5 fcc /D/ |
433 fcc /M/ | |
926 | 434 fdb DoDsity-opt.5 |
1907 | 435 opt.6 fcc /d/ |
436 fcc /M/ | |
926 | 437 fdb DoDsity-opt.6 |
1907 | 438 opt.7 fcc /"/ |
439 fcb $00 | |
926 | 440 fdb DoQuote-opt.7 |
1907 | 441 opt.8 fcc /:/ |
442 fcb $00 | |
926 | 443 fdb DoColon-opt.8 |
1907 | 444 opt.9 fcc "/" |
445 fcb $00 | |
926 | 446 fdb DoClust-opt.9 |
1907 | 447 opt.10 fcc /1/ |
448 fcb $01 | |
926 | 449 fdb Do1-opt.10 |
1907 | 450 opt.11 fcc /2/ |
451 fcb $02 | |
926 | 452 fdb Do2-opt.11 |
1907 | 453 opt.12 fcc /'/ |
454 fcb 0 | |
926 | 455 fdb DoSQuote-opt.12 |
1907 | 456 opt.13 fcc /L/ |
457 fcb $01 | |
926 | 458 fdb DoL-opt.13 |
1907 | 459 opt.14 fcc /l/ |
460 fcb 01 | |
926 | 461 fdb DoL-opt.14 |
1907 | 462 opt.15 fcc /(/ |
463 fcb $00 | |
926 | 464 fdb DoLParen-opt.15 |
1907 | 465 opt.16 fcc /)/ |
466 fcb $00 | |
926 | 467 fdb DoRParen-opt.16 |
1907 | 468 opt.17 fcc /,/ |
469 fcb $00 | |
926 | 470 fdb DoComa-opt.17 |
1907 | 471 opt.18 fcb C$SPAC |
472 fcb 00 | |
926 | 473 fdb DoSpace-opt.18 |
1907 | 474 |
2677
c58baa9276c8
Fix string constants used as numbers
William Astle <lost@l-w.ca>
parents:
2108
diff
changeset
|
475 opt.19 fcb 'F |
1907 | 476 fcb ' ' |
477 fdb DoFormat-opt.19 | |
2677
c58baa9276c8
Fix string constants used as numbers
William Astle <lost@l-w.ca>
parents:
2108
diff
changeset
|
478 opt.20 fcb 'f |
1907 | 479 fcb ' ' |
480 fdb DoFormat-opt.20 | |
481 | |
482 | |
483 fcb $00 | |
484 | |
926 | 485 ******************************************************************** |
486 * S/D - density; single or double | |
487 ******************************************************************** | |
1907 | 488 |
489 DoDsity cmpb <maxmfm compare against maximum | |
490 bgt OptAbort if greater than, abort | |
491 cmpb <t0sngdns | |
492 blt OptAbort | |
493 stb <mfm | |
494 clrb | |
495 | |
926 | 496 ******************************************************************** |
497 * skip white space | |
498 ******************************************************************** | |
1907 | 499 |
500 DoComa | |
501 DoRParen | |
502 DoLParen | |
503 DoSpace rts | |
504 | |
926 | 505 ******************************************************************** |
506 * set ready flag - skip warn messages | |
507 ******************************************************************** | |
1907 | 508 |
509 DoReady stb <ready set and save ready | |
510 rts return | |
511 | |
926 | 512 ******************************************************************** |
513 * 1/2 - number of sides | |
514 ******************************************************************** | |
1907 | 515 |
516 Do2 | |
517 Do1 cmpb <numsides | |
518 bgt OptAbort | |
519 stb <numsides | |
520 clrb | |
521 rts | |
522 | |
926 | 523 ******************************************************************** |
524 * only do a logical format on the rbf device | |
525 ******************************************************************** | |
1907 | 526 |
527 DoL stb <dolog do a logical format | |
528 clrb did option | |
529 rts return | |
530 | |
926 | 531 ******************************************************************** |
532 * not a option - show abort message and exit | |
533 ******************************************************************** | |
1907 | 534 |
535 OptAbort leax >AbortOp,pcr Option not allowed message | |
536 lbra PExit print message and exit | |
537 | |
926 | 538 ******************************************************************** |
539 * double quoted option "disk name" save name in dskname | |
540 ******************************************************************** | |
1907 | 541 |
542 DoQuote leay <dskname,u delimited buffer | |
543 ldb #C$SPAC delimited size | |
544 koQuote lda ,x+ delimited character | |
545 cmpa #'" is end quote? | |
546 beq L0221 must be done | |
547 sta ,y+ no, save character | |
548 decb decrement name size | |
549 bne KoQuote get all 32 of them or quote | |
550 L0215 ldb ,x+ next delimited character | |
551 cmpb #'" find end quote? | |
552 beq L0227 yes, back up and mark it | |
553 cmpb #C$SPAC skip space character? | |
554 bcc L0215 yes, get next one | |
555 bra L0227 no, mark it's end | |
556 L0221 lda #C$SPAC get space character | |
557 cmpb #C$SPAC any delimited characters? | |
558 beq L022B no, mark it's end | |
559 L0227 leay -$01,y yes, back up | |
560 lda ,y get saved character | |
561 L022B adda #$80 make it negative | |
562 sta ,y mark it's end | |
563 clrb did option | |
564 rts return | |
565 | |
926 | 566 ******************************************************************** |
567 * single quoted option 'number of cylinders' save number in ncyls | |
568 ******************************************************************** | |
1907 | 569 |
570 DoSQuote lbsr Decimal procces number of cylinders | |
571 ldd <dresult get it | |
572 std <ncyls save it | |
573 rts return | |
574 | |
926 | 575 ******************************************************************** |
576 * colon quoted option :interleave value: save value in interlv | |
577 ******************************************************************** | |
1907 | 578 |
579 DoColon lbsr Decimal proccess interleave value | |
580 ldd <dresult get it | |
581 tsta answer out of bounds? | |
582 beq L0243 no, save it | |
583 ldb #$01 yes, default size | |
584 L0243 stb <interlv save it | |
585 rts return | |
586 | |
926 | 587 ******************************************************************** |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
588 * Format option : formatting a CoCo or a Dragon disk ? |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
589 ******************************************************************** |
1907 | 590 |
591 DoFormat | |
592 lda ,x+ Get next char | |
2108 | 593 cmpa #'D Do a dragon disk ? |
1907 | 594 beq DoFmtDragon |
2108 | 595 cmpa #'d |
1907 | 596 bne DoFmtDragon |
597 clr IsDragon,u Mark it as a normal CoCo (or other) disk | |
598 clrb | |
599 rts | |
600 | |
601 DoFmtDragon | |
602 lda #DragonFlag Mark as Dragon disk | |
603 sta IsDragon,u | |
604 | |
605 ldd #DragonBootSize Setup additional system sectors | |
606 std AddedSysSecs,u | |
607 | |
608 clrb | |
609 rts | |
610 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
611 ******************************************************************** |
926 | 612 * quoted option /cluster size/ save size in clustsiz |
952 | 613 * cluster size is in decimal. The number of sectors |
614 * in a cluster must be a power of 2 and the number | |
615 * should max out at 32 for coco os9 | |
926 | 616 ******************************************************************** |
1907 | 617 |
618 DoClust lbsr Decimal proccess cluster size | |
619 ldd <dresult get it | |
620 tsta answer out of bounds? | |
621 beq L0250 no, save it | |
622 ldb #$01 yes, default size | |
623 L0250 stb <clustsiz save it | |
624 stb <clustspecified save fact that cluster was specified | |
625 negb get two's complement | |
626 decb power of 2 | |
627 andb <clustsiz in range? | |
628 beq L025C yes, skip ahead | |
629 ldb #$01 no, default size | |
630 stb <clustsiz save it | |
631 L025C clrb did option | |
632 L025D rts return | |
633 | |
926 | 634 ******************************************************************** |
1614 | 635 * print title, format (Y/N), and get response |
926 | 636 ******************************************************************** |
1907 | 637 |
638 Proceed | |
1664 | 639 * leax >Title,pcr coco formatter message |
640 * lbsr PrintLn print it | |
1907 | 641 tst <dtype disk type... |
642 bmi h@ | |
1664 | 643 lbsr FloppySummary |
1907 | 644 bra n@ |
645 h@ lbsr HDSummary | |
646 n@ leay >optbuf,u point to option buffer | |
647 ldx PD.T0S-PD.OPT,y default sectors/track tr00,s0 | |
648 tst <mfm double-density? | |
649 beq L0271 no, | |
650 ldx PD.SCT-PD.OPT,y default sectors/track | |
651 L0271 stx <sectors save it | |
652 lbsr LineFD | |
653 leax >FmtMsg,pcr formatting drive message | |
654 ldy #FmtMLen length of message | |
655 lbsr Print print it | |
656 leax <prmbuf,u input buffer | |
657 tfr x,y put it in y | |
658 L0283 lda ,y+ get input | |
659 cmpa #PENTIR proceed (y/n)? | |
660 bne L0283 no, wait for yes | |
661 pshs y save input pointer | |
662 lda #C$CR carriage return | |
663 sta -$01,y store it over input | |
664 lbsr PrintLn print line | |
665 puls y get pointer | |
666 lda #PENTIR | |
667 sta -$01,y | |
668 lda <ready ok to proceed? ready | |
669 bne L02BC yes, were ready skip ahead | |
1664 | 670 * tst <dtype is this a floppy or hard drive? |
671 * bpl L02AB it is a floppy | |
672 * leax >HDFmt,pcr it is a hard drive | |
673 * ldy #$002A length of message | |
674 * lbsr Print print message | |
1907 | 675 L02AB leax >Query,pcr query message |
676 ldy #QueryLen length of message | |
677 lbsr Input show it and get response (Y/N) | |
678 anda #$DF make it upper case | |
679 cmpa #'Y answered yes? | |
680 bne L02D5 no, check for no? | |
681 L02BC tst <dtype formatting hard drive? | |
682 bpl L025D no, return skip hard disk warn message | |
683 leax >HDFmt,pcr show hard disk warn message | |
684 ldy #HDFmtLen size of the message | |
685 lbsr Input show it and get response (Y/N) | |
686 anda #$DF make it upper case | |
687 cmpa #'Y answered yes? | |
688 beq L025D yes, return | |
689 clrb clear error | |
690 lbra Exit exit | |
691 L02D5 clrb clear error | |
692 cmpa #'N answered no? | |
693 lbeq Exit yes, exit | |
694 bra L02AB no, get a (Y/N) answer | |
695 | |
926 | 696 ******************************************************************** |
697 * print usage message and return | |
698 ******************************************************************** | |
1907 | 699 |
700 LineFD leax >CrRtn,pcr point to line feed | |
701 PrintLn ldy #80 size of message | |
702 Print lda #$01 standard output path | |
703 os9 I$WritLn print line | |
704 rts return | |
705 | |
926 | 706 ******************************************************************** |
1614 | 707 * print message and get response |
926 | 708 * entry: x holds data address y holds data size |
1614 | 709 * exit: a holds response (ascii character) |
926 | 710 ******************************************************************** |
1907 | 711 |
712 Input pshs u,y,x,b,a save registers | |
713 bsr Print print line | |
714 leax ,s get data address | |
715 ldy #$0001 data size | |
716 clra standard input | |
717 os9 I$Read read it | |
718 lbcs Exit exit on error | |
719 bsr LineFD print line feed | |
720 puls u,y,x,b,a restore stack | |
721 anda #$7F make it ascii | |
722 rts return | |
723 | |
926 | 724 ******************************************************************** |
725 * get capability of the rbf device | |
726 ******************************************************************** | |
1907 | 727 |
728 GetDTyp leax >hdsdat,pcr assume hard drive data for now | |
729 stx <trk0data sector data pointer | |
730 ldb <dtype get disk drive type | |
1614 | 731 bitb #TYP.HARD+TYP.NSF hard disk or non-standard type? |
1907 | 732 bne L0323 yes, branch |
733 tst <cocofmt is this a COCO formatted disk? | |
734 beq L031B branch if not | |
735 leax >dctdat,pcr point to COCO track data | |
736 bra L032D | |
737 L031B leax >sgtdat,pcr point to single density track data | |
738 tst <mfm double-density? | |
739 beq L032D no, save off X | |
740 L0323 stx <trk0data | |
926 | 741 leax >dbtdat,pcr |
1907 | 742 tst <t0sngdns track 0 is single density? |
743 beq L032F branch if so | |
744 L032D stx <trk0data save as track 0 data | |
745 L032F stx <trkdata and !0 track data | |
746 tst <sectmode LBA values already in place? | |
747 beq ack@ | |
1614 | 748 * Compute total sectors from C/H/S |
1907 | 749 clra |
750 ldb <numsides get number of sides | |
751 tfr d,y | |
752 clrb D = 0 | |
753 ldx <ncyls | |
754 bsr Mulbxty multiply B,X*Y | |
1614 | 755 * B,X now is numsides * numcyls |
756 * Subtract one from B,X because t0s will be added later | |
1907 | 757 exg d,x |
758 subd #$0001 | |
759 bcc L0344 | |
760 leax -$01,x | |
761 L0344 exg d,x | |
762 ldy <sectors | |
763 bsr Mulbxty multiply B,X*Y | |
1614 | 764 * B,X now is numsides * numcyls * sectors |
1907 | 765 exg d,x |
1614 | 766 * Add in sectors/track0 |
1907 | 767 addd <sectors0 |
1614 | 768 std <totsects+1 |
1907 | 769 exg d,x |
770 adcb #$00 | |
771 stb <totsects | |
772 ack@ | |
773 lda <dtype get type byte | |
774 bita #TYPH.DSQ drive size query bit set? | |
775 beq mlex branch if so (we don't take bps into account here) | |
1614 | 776 **** We now multiply totsects * the bytes per sector |
1907 | 777 dec <bps decrement bytes per sector (8=7,4=3,2=1,1=0) |
778 beq mlex exit out ofloop if zero | |
779 ml@ lsl <totsects+2 else multiply by 2 | |
1614 | 780 rol <totsects+1 |
1907 | 781 rol <totsects |
782 lsr <bps shift out bits | |
783 tst <bps | |
784 bne ml@ | |
785 | |
1614 | 786 ************************************************ |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
787 * Calculates the correct cluster size & size of bitmap in bytes |
1907 | 788 |
789 mlex lda #$08 | |
790 pshs a | |
791 ldx <totsects+1 | |
792 ldb <totsects | |
793 bsr Div24by8 divide totsects by 8 | |
794 lda <clustsiz get current cluster size | |
795 pshs a save it as divisor | |
796 bsr Div24by8 | |
797 tstb B = 0? (more than $FFFF bytes required ?) | |
798 beq L0374 branch if so | |
799 | |
1614 | 800 * Too small a cluster size comes here |
1907 | 801 tst <clustspecified did user specify cluster on command line? |
802 bne u@ branch if so (show error message) | |
803 lsl <clustsiz multiply by 2 | |
804 bcs u@ if carry set to stop | |
805 leas 2,s else eat stack | |
806 bra mlex and continue trying | |
807 u@ leax >ClustMsg,pcr cluster size mismatch message | |
808 lbsr PrintLn print mismatch message | |
809 lbra L05B1 abort message and exit | |
810 L0374 leas $02,s | |
811 stx <NumBitmapBytes Save Size of bitmap in bytes | |
812 rts return | |
813 | |
926 | 814 ******************************************************************** |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
815 * multiply (mlbxty B:X * Y) |
926 | 816 ******************************************************************** |
1907 | 817 |
818 Mulbxty lda #$08 make stack space | |
819 MulClr clr ,-s clear the space | |
820 deca cleared? | |
821 bne MulClr no, | |
822 sty ,s | |
823 stb $02,s | |
824 stx $03,s | |
825 MulLoop ldd ,s we done? | |
826 beq MulZer yes, clean up | |
827 lsra | |
828 rorb | |
829 std ,s | |
830 bcc MulNoC | |
831 ldd $03,s | |
832 addd $06,s | |
833 std $06,s | |
834 lda $02,s | |
835 adca $05,s | |
836 sta $05,s | |
837 MulNoC ldd $03,s | |
838 lslb | |
839 rola | |
840 std $03,s | |
841 lda $02,s | |
842 rola | |
843 sta $02,s | |
844 bra MulLoop continue rest | |
845 MulZer leas $05,s clean up space | |
846 puls pc,x,b pop results, return | |
847 | |
926 | 848 ******************************************************************** |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
849 * 24 bit divide (2,s = divisor, B:X = dividend, result in B:X) |
926 | 850 ******************************************************************** |
1907 | 851 |
852 L03AE pshs x,b save X,B on stack | |
853 lsr ,s divide B:X by 2 | |
854 ror $01,s | |
855 ror $02,s | |
856 puls x,b retrieve B:X | |
857 exg d,x exchange bits 15-0 in D,X | |
858 adcb #$00 | |
859 adca #$00 | |
860 exg d,x | |
861 adcb #$00 | |
862 Div24by8 lsr $02,s | |
863 bne L03AE | |
864 rts | |
865 | |
926 | 866 ******************************************************************** |
867 * format rbf device | |
868 ******************************************************************** | |
1907 | 869 |
870 Format tst <dolog doing a logical format? | |
871 bne L03E4 yes, don't do this then | |
872 tst <dtype test for hard drive from PD.TYP | |
873 bpl L03E5 branch if floppy | |
874 leax >Both,pcr PHYSICAL and LOGICAL? message | |
875 ldy #BothLen length of message | |
876 lbsr Input print and get input | |
877 anda #$DF make it upper case | |
878 cmpa #'Y is it yes? | |
879 beq L03E5 yes, | |
880 cmpa #'N is it no? | |
881 bne Format no, | |
882 L03E4 rts return | |
883 L03E5 lda <diskpath device path number | |
884 ldb #SS.Reset reset device | |
885 os9 I$SetStt at track zero | |
886 lbcs Exit exit if error | |
887 ldd #$0000 get current track | |
888 std <currtrak save it | |
889 inca get current sector | |
890 sta <currsect save it | |
891 L03F8 clr <currside clear current side | |
892 L03FA bsr L045C | |
893 leax >LSN0,u point to our LSN0 buffer | |
894 ldd <currtrak | |
895 addd <u0048 | |
896 tfr d,u | |
897 clrb | |
898 tst <cocofmt do we format this as a COCO disk? | |
899 bne L041B branch if so | |
900 tst <mfm single density? | |
901 beq L041D branch if so | |
902 tst <t0sngdns track 0 single density? | |
903 bne L041B branch if not | |
904 tst <currtrak+1 is current track 0? | |
905 bne L041B branch if not | |
906 tst <currside side is zero? | |
907 beq L041D branch if 0 | |
908 L041B orb #$02 else set side 1 | |
909 L041D tst <tpi 48 tpi? | |
910 beq L0423 branch if so | |
911 orb #$04 else set 96 tpi bit | |
912 L0423 lda <currside get current side | |
913 beq L0429 branch if 0 | |
914 orb #$01 | |
915 L0429 tfr d,y get side/density bits | |
916 lda <diskpath rbf device path number | |
917 ldb #SS.WTrk format (write) track | |
918 os9 I$SetStt do format it | |
919 lbcs Exit exit if error | |
920 ldu <savedu get u pointer | |
921 ldb <currside get current side | |
922 incb increment | |
923 stb <currside and store | |
924 cmpb <numsides compare against number of sides | |
925 bcs L03FA branch if greater than | |
926 ldd <currtrak get current track | |
927 addd #$0001 increment it | |
928 std <currtrak save it | |
929 cmpd <ncyls did all tracks? | |
930 bcs L03F8 no, | |
931 rts yes, return | |
932 | |
926 | 933 ******************************************************************** |
1683
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
934 * Writes AA bytes of BB to X (byte pairs are in tables above) |
926 | 935 ******************************************************************** |
1907 | 936 |
937 L044E ldy <u000E | |
938 L0451 ldd ,y++ get two bytes at Y | |
939 beq L046B branch if zero (end) | |
940 L0455 stb ,x+ store B at X and post increment | |
941 deca decrement count | |
942 bne L0455 continue if not done | |
943 bra L0451 else get next byte pair | |
944 L045C lda <dtype get drive's PD.TYP | |
945 bita #TYP.HARD+TYP.NSF hard disk or non-standard format? | |
946 beq L046C branch if neither | |
947 ldy <trkdata point Y to track data | |
948 leax >LSN0,u point to the LSN0 buffer | |
949 bsr L0451 build LSN0 sector | |
950 L046B rts | |
951 | |
926 | 952 ******************************************************************** |
953 * | |
954 ******************************************************************** | |
1907 | 955 |
956 L046C ldy <trkdata grab normal track data | |
957 ldb <sectors+1 get sector | |
958 tst <currtrak+1 track 0? | |
959 bne L047E branch if not | |
960 tst <currside side 0? | |
961 bne L047E branch if not | |
962 ldy <trk0data | |
1614 | 963 * ldb <u001C |
1907 | 964 ldb <sectors0+1 get sectors in track 0 |
965 L047E sty <u000E | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
966 stb <sectcount+1 |
1907 | 967 stb <u0018 |
968 bsr L04EC | |
969 leax >LSN0,u | |
970 bsr L0451 | |
971 sty <u000E | |
972 L0490 bsr L044E | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
973 dec <sectcount+1 |
1907 | 974 bne L0490 |
975 lda ,y+ | |
976 sty <u000E | |
977 stx <u003D | |
978 leay >u297E,u | |
979 sty <dresult | |
980 tfr a,b | |
981 L04A6 std ,x++ | |
982 cmpx <dresult | |
983 bcs L04A6 | |
984 ldy <u000E | |
985 ldd ,y++ | |
986 std <u003F | |
987 ldd ,y | |
988 std <u0041 | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
989 clr <sectcount+1 |
1907 | 990 leax >LSN0,u |
991 ldd <u003F | |
992 leay >u008F,u | |
993 L04C3 leax d,x | |
924 | 994 ldd <currtrak+1 |
1907 | 995 adda <toffs add in track offset |
996 std ,x | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
997 ldb <sectcount+1 |
1907 | 998 lda b,y |
999 incb | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
1000 stb <sectcount+1 |
1907 | 1001 ldb <currsect |
1002 adda <soffs add in sector offset | |
1003 bcs L04E5 | |
1004 std $02,x | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
1005 lda <sectcount+1 |
1907 | 1006 cmpa <u0018 |
1007 bcc L04E4 | |
1008 ldd <u0041 | |
1009 bra L04C3 | |
1010 L04E4 rts | |
1011 | |
926 | 1012 ******************************************************************** |
1013 * | |
1014 ******************************************************************** | |
1907 | 1015 |
1016 L04E5 leax >AbortSct,pcr sector number out of range message | |
1017 lbra PExit print message and exit | |
1018 | |
926 | 1019 ******************************************************************** |
1020 * | |
1021 ******************************************************************** | |
1907 | 1022 |
1023 L04EC pshs y,b | |
1024 tfr b,a | |
924 | 1025 ldb <currtrak+1 |
1907 | 1026 cmpb #$01 |
1027 bhi L0518 | |
1028 leax >u008F,u | |
1029 leay a,x | |
1030 ldb <interlv | |
1031 bne L0507 | |
1032 L0500 leax >AbortIlv,pcr Interleave out of range message | |
1033 lbra PExit print message and exit | |
1034 L0507 cmpb <u0018 | |
1035 bhi L0500 | |
1036 nega | |
1037 pshs y,x,b,a | |
1038 clra | |
1039 L050F sta ,x | |
1040 inca | |
1041 cmpa <u0018 | |
1042 bne L051A | |
1043 leas $06,s | |
1044 L0518 puls pc,y,b | |
1045 L051A ldb <interlv | |
1046 abx | |
1047 cmpx $04,s | |
1048 bcs L0525 | |
1049 ldb ,s | |
1050 leax b,x | |
1051 L0525 cmpx $02,s | |
1052 bne L050F | |
1053 leax $01,x | |
1054 stx $02,s | |
1055 bra L050F | |
1056 | |
926 | 1057 ******************************************************************** |
1614 | 1058 * initialize sector 0 |
926 | 1059 ******************************************************************** |
1907 | 1060 |
1061 InitLSN0 lbsr ClrBuf clear the sector buffer | |
1062 ldd <totsects+1 get total sectors bits 15-0 | |
1063 std DD.TOT+1,x save | |
1064 ldb <totsects get bits 23-16 | |
1065 stb DD.TOT,x save | |
1066 ldd <sectors get sectors/track | |
1067 std <DD.SPT,x save | |
1068 stb DD.TKS,x save | |
1069 lda <clustsiz get cluster size | |
1070 sta DD.BIT+1,x save | |
1071 | |
1072 clra | |
1073 ldb <NumBitmapBytes Calculate number of bitmap sectors needed | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1074 tst <NumBitmapBytes+1 Exact multiple of sector size ? |
1907 | 1075 beq L054F Yes no extra sectors needed |
1076 addd #$0001 Add extra sector for bytes at end | |
1077 L054F addd #$0001 | |
1078 addd AddedSysSecs,u Add additional system sectors (usually 0) | |
1079 std DD.DIR+1,x save directory sector | |
1080 | |
1081 clra | |
1082 tst <mfm single density? | |
1083 beq L0561 branch if so | |
1084 ora #FMT.DNS else set double density bit | |
1085 tst <t0sngdns track 0 is single density? | |
1086 beq L0561 branch if so | |
1707
3911533043d3
Some additional changes to address formatting 80 track drives.
boisy
parents:
1697
diff
changeset
|
1087 * ora #FMT.T0DN |
1907 | 1088 ora #$08 |
1089 L0561 ldb <numsides get number of sides | |
1090 cmpb #$01 just 1? | |
1091 beq L0569 branch if so | |
1092 ora #FMT.SIDE else set double-sided bit | |
1093 L0569 tst <tpi 48tpi? | |
1094 beq L056F branch if so | |
1095 ora #FMT.TDNS else set 96 tpi | |
1096 L056F sta <DD.FMT,x save | |
1097 ldd <NumBitmapBytes get size of bitmap in bytes | |
1098 std DD.MAP,x save number of bytes in allocation bit map | |
1099 lda #$FF attributes | |
1100 sta DD.ATT,x save | |
1101 leax >LSN0+DD.DAT,u point to time buffer | |
1102 os9 F$Time get current time | |
1614 | 1103 leax >LSN0+DD.NAM,u |
1907 | 1104 leay <dskname,u quote delimited disk name buffer |
1105 tst ,y name in buffer? | |
1106 beq L0594 branch if not | |
1107 L058C lda ,y+ get character of name | |
1108 sta ,x+ and save in name area of LSN0 | |
1109 bpl L058C | |
1110 bra L05C7 | |
1614 | 1111 * Here we prompt for a disk name |
312 | 1112 L0594 leax >DName,pcr |
1907 | 1113 ldy #DNameLen |
1114 lbsr Print print disk name prompt | |
1115 leax >LSN0+DD.NAM,u point to new name | |
1116 ldy #33 read up to 33 characters | |
1117 clra | |
1118 os9 I$ReadLn from standard input | |
1119 bcc L05B8 branch if ok | |
1120 cmpa #E$EOF end of file? | |
1121 bne L0594 branch if not | |
1122 L05B1 leax >Aborted,pcr format aborted message | |
1123 lbra PExit print message and exit | |
1124 L05B8 tfr y,d copy number of chars entered into D | |
1125 leax d,x point to last char + 1 | |
1126 clr ,-x | |
1127 decb decrement chars typed | |
1128 beq L0594 branch if zero (go ask again) | |
1129 lda ,-x get last character | |
1130 ora #$80 set hi bit | |
1131 sta ,x and save | |
1132 L05C7 leax >LSN0+DD.DAT,u point to time | |
1133 leay <$40,x | |
1134 pshs y | |
1135 ldd #$0000 | |
1136 L05D3 addd ,x++ | |
1137 cmpx ,s | |
1138 bcs L05D3 | |
1139 leas $02,s | |
1140 std >LSN0+DD.DSK,u save disk ID | |
1141 | |
1142 lda IsDragon,u Do we need to fixup for dragon ? | |
1143 cmpa #DragonFlag | |
1144 bne Nofixup | |
1145 bsr FixForDragon Adjust for Dragon disk format | |
1146 | |
1147 NoFixup | |
1614 | 1148 * Not sure what this code is for... |
1149 * ldd >val1,pcr | |
1150 * std >u01A7,u | |
1151 * ldd >val2,pcr | |
1152 * std >u01A9,u | |
1153 * ldd >val3,pcr | |
1154 * std >u01AB,u | |
1907 | 1155 lda <diskpath |
1156 ldb #SS.Opt | |
1157 leax >LSN0+DD.OPT,u point to disk options | |
1158 os9 I$GetStt get options | |
1159 ldb #SS.Reset reset head to track 0 | |
1160 os9 I$SetStt do it! | |
1161 lbcs Exit branch if error | |
1162 leax >LSN0,u point to LSN0 | |
1163 lbra WritSec and write it! | |
1164 | |
1165 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1166 ******************************************************************** |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1167 * Adjust LSN0 values so we make a Dragon OS-9 compatible disk |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1168 ******************************************************************** |
1907 | 1169 |
1170 FixForDragon | |
1171 pshs x | |
1172 leax LSN0,u Point at LSN0 | |
1173 | |
1174 lda dtype,u Get disk type | |
1175 bita #TYP.CCF CoCo/Dragon format disk ? | |
1176 beq DgnNoFix Nope, don't adjust | |
1177 | |
1178 ldd DD.MAP,x Fixup map | |
1179 cmpd #$ff Dragon disks have only one bitmap sector | |
1180 bls DgnMapOK only using 1, don't adjust | |
1181 lsra Divide map count by 2 | |
1182 rorb | |
1183 std DD.MAP,x | |
1184 inc DD.BIT+1,x Increment cluster size to 2 | |
1185 | |
1186 stb <clustsiz Update local cluster size var | |
1187 | |
1188 DgnMapOK | |
1189 DgnNoFix | |
1190 puls x,pc | |
1191 | |
1192 | |
926 | 1193 ******************************************************************** |
1614 | 1194 * read in sector 0 of device |
926 | 1195 ******************************************************************** |
1907 | 1196 |
1197 ReadLSN0 lda <diskpath get disk path | |
1198 os9 I$Close close it | |
1199 leax <prmbuf,u point to device name | |
1200 lda #READ. | |
1201 os9 I$Open open for read | |
1202 lbcs BadSect branch if problem | |
1203 sta <diskpath save new disk path | |
1204 leax >LSN0,u | |
1205 ldy #256 | |
1206 os9 I$Read read first sector | |
1207 lbcs BadSect branch if problem | |
1208 lda <diskpath get disk path | |
1209 os9 I$Close close path to device | |
1210 leax <prmbuf,u re-point to device name | |
1211 lda #UPDAT. | |
1212 os9 I$Open open in read/write mode | |
1213 lbcs BadSect branch if error | |
1214 sta <diskpath else save new disk path | |
1215 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1216 * Save location of start of root directory, for later use |
1907 | 1217 leax LSN0,u point to LSN0 |
1218 lda DD.DIR,x Get location of root | |
1219 ldx DD.DIR+1,x | |
1220 sta SaveRootLSN,u Save a copy for later use | |
1221 stx SaveRootLSN+1,u | |
1222 rts and return | |
1223 | |
926 | 1224 ******************************************************************** |
1907 | 1225 * Make Bitmap Sectors |
926 | 1226 ******************************************************************** |
1907 | 1227 |
1228 MkBMap lda <dtype get device type in A | |
1229 clr <dovfy clear verify flag | |
1230 bita #TYP.HARD hard drive? | |
1231 beq nothd branch if not | |
1614 | 1232 * Hard drives are asked for physical verification here |
1233 askphys leax >Verify,pcr | |
1907 | 1234 ldy #VerifyL |
1235 lbsr Input prompt for physical verify of hard drive | |
1236 anda #$DF | |
1237 cmpa #'Y yes? | |
1238 beq nothd branch if so | |
1239 cmpa #'N no? | |
1240 bne askphys not not, ask again | |
1241 sta <dovfy else flag that we don't want physical verify | |
1242 nothd ldd <sectors0 get sectors/track at track 0 | |
1243 std <u0017 save | |
1244 clra D = 0 | |
1245 clrb | |
1246 sta <oksects clear OK sectors | |
926 | 1247 std <oksects+1 |
1907 | 1248 std <currtrak clear current track |
1249 std <sectcount clear counted sectors | |
1250 std <u0032 | |
1251 stb <u0031 | |
1252 sta <u003C | |
1253 leax >optbuf,u | |
1254 stx <u0038 | |
1255 lbsr ClrSec | |
1256 leax 256,x | |
1257 stx <u003A | |
1258 clra | |
1259 ldb #$01 D = 1 | |
1260 std <u0034 | |
1261 lda <clustsiz get cluster size | |
1262 sta <clustcnt store in cluster counter | |
1263 clr <u002A | |
1264 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1265 * Calculate the number of reserved clusters at begining of disk, from |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1266 * number of reserved sectors |
1907 | 1267 clra |
1268 ldb <NumBitmapBytes Get no of sectors used by bitmap | |
1269 tst <NumBitmapBytes+1 Exact number of sectors in bitmap ? | |
1270 beq L069D Yes : skip | |
1271 addd #$0001 No : round up sector count | |
1272 L069D addd #$0009 Add 8 sectors for root FD (IT.SAS) + 1 sector for LSN0 | |
1273 addd AddedSysSecs,u Add additional system sectors (if any) | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1274 std <NoSysSectors |
1907 | 1275 std <NoSysClusters |
1276 lda <clustsiz get cluster size | |
1277 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1278 * Since cluster sizes can only be a power of 2 (1,2,4,8,16 etc) we divide block count |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1279 * by 2 until we get a carry, this gives us the cluster count |
1907 | 1280 |
1281 L06A4 lsra | |
1282 bcs L06B5 First calculate number of system clusters | |
1283 lsr <NoSysClusters | |
1284 ror <NoSysClusters+1 | |
1285 bcc L06A4 | |
1286 inc <NoSysClusters+1 | |
1287 bne L06A4 | |
1288 inc <NoSysClusters | |
1289 bra L06A4 | |
1290 | |
1291 L06B5 | |
1292 ldd <NoSysSectors | |
1293 * ldd <NoSysSectors | |
1294 * std <NoSysClusters Save No of clusters | |
1295 * lda <clustsiz get cluster size | |
1296 * mul Now work out number of system sectors | |
1297 * std <NoSysSectors Save it | |
1298 | |
1299 subd #$0001 Calculate number of sectors in root FD ? | |
1300 subd AddedSysSecs,u Remove additional system sectors (if any) | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1301 subb <NumBitmapBytes |
1907 | 1302 sbca #$00 |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1303 tst <NumBitmapBytes+1 |
1907 | 1304 beq L06CC |
1305 subd #$0001 | |
1306 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1307 L06CC stb <NoRootFDSecs |
1907 | 1308 |
1309 L06CE tst <dovfy do we verify? | |
1310 bne OutScrn no, output screen display | |
1311 lda <diskpath yes, get rbf device path | |
1312 leax >LSN0,u get sector buffer | |
1313 ldy #256 sector size | |
1314 os9 I$Read read of sector successful? | |
1315 bcc OutScrn yes, output screen display | |
1316 os9 F$PErr no, print error message | |
1317 lbsr NextSec get next sector | |
1318 lda #$FF | |
1319 sta <u002A | |
1320 tst <u0031 | |
1321 bne OutScrn output screen display | |
1322 ldx <u0032 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1323 cmpx <NoSysSectors |
1907 | 1324 bhi OutScrn output screen display |
1325 BadSect leax >BadSectM,pcr bad system sector message | |
1326 PExit lbsr PrintLn print message | |
1327 clrb clear error | |
1328 lbra Exit exit no error | |
1329 | |
926 | 1330 ******************************************************************** |
1614 | 1331 * output screen display scrolling track counter |
926 | 1332 ******************************************************************** |
1907 | 1333 |
1334 OutScrn ldd <sectcount get counted sectors | |
1335 addd #$0001 increment it | |
1336 std <sectcount save counted sectors | |
1337 cmpd <u0017 good sector count? | |
1338 bcs L0745 next segment | |
1339 clr <sectcount clear counted sectors | |
1340 clr <sectcount+1 | |
1341 tst <dovfy are we verifying? | |
1342 bne L073A no, | |
1343 lda #C$SPAC yes, get space | |
1344 pshs a save it | |
1345 lda <currtrak+1 track high byte | |
1346 lbsr HexDigit make it ascii | |
1347 L0724 pshs b,a save two ascii digits | |
1348 lda <currtrak track low byte | |
1349 lbsr HexDigit make it ascii | |
1350 pshs b,a save two ascii digits | |
1351 lda #C$CR get CR | |
1352 pshs a | |
1353 tfr s,x get output from stack | |
1354 ldy #$0006 length of output | |
1697 | 1355 * lbsr Print print it |
1907 | 1356 lda #$01 |
1357 os9 I$Write | |
1697 | 1358 * lda $02,s |
1359 * cmpa #$46 end of line? | |
1360 * bne L0738 skip line feed | |
1361 * lbsr LineFD print linefeed | |
1907 | 1362 L0738 leas $06,s pop output off stack |
1363 L073A ldd <currtrak get current track | |
1364 addd #$0001 increment it | |
1365 std <currtrak save it back | |
1366 ldd <sectors get number of sectors | |
1367 std <u0017 save it | |
1368 L0745 dec <clustcnt decrement cluster counter | |
1369 bne L075B | |
1370 bsr L0784 | |
1371 tst <u002A | |
1372 bne L0755 | |
1373 ldd <oksects+1 increment good sectors | |
1374 addd #$0001 | |
926 | 1375 std <oksects+1 |
1907 | 1376 bcc L0755 |
1377 inc <oksects | |
1378 L0755 clr <u002A | |
1379 lda <clustsiz get cluster size | |
1380 sta <clustcnt save in cluster counter | |
1381 L075B ldb <u0031 | |
1382 ldx <u0032 | |
1383 leax $01,x | |
1384 bne L0764 | |
1385 incb | |
1386 L0764 cmpb <totsects | |
1387 bcs L076C | |
1614 | 1388 cmpx <totsects+1 |
1907 | 1389 bcc L0773 |
1390 L076C stb <u0031 | |
1391 stx <u0032 | |
1392 lbra L06CE | |
1393 L0773 lda #$FF | |
1394 sta <u002A | |
1395 leay >optbuf,u | |
1396 L077B cmpy <u0038 | |
1397 beq GoodSect number of good sectors summary | |
1398 bsr L0784 | |
1399 bra L077B | |
1400 L0784 ldx <u0038 | |
1401 lda <u002A | |
1402 rora | |
1403 rol ,x+ | |
1404 inc <u003C | |
1405 lda <u003C | |
1406 cmpa #$08 | |
1407 bcs L07A6 | |
1408 clr <u003C | |
1409 stx <u0038 | |
1410 cmpx <u003A | |
1411 bne L07A6 | |
1412 bsr WrtSecs | |
1413 leax >optbuf,u | |
1414 stx <u0038 | |
1415 lbsr ClrSec | |
1416 L07A6 rts return | |
1417 | |
926 | 1418 ******************************************************************** |
1419 * convert byte to ascii hexadecimal and return it in d register | |
1420 ******************************************************************** | |
1907 | 1421 |
1422 HexDigit tfr a,b get byte again | |
1423 lsra shift upper digit | |
1424 lsra | |
1425 lsra | |
1426 lsra | |
1427 andb #$0F mask lower digit | |
1428 addd #$3030 make it ascii | |
1429 cmpa #$39 upper digit > 9 | |
1430 bls L07B8 no, | |
1431 adda #$07 yes, make hexadecimal | |
1432 L07B8 cmpb #$39 lower digit > 9 | |
1433 bls L07BE no, | |
1434 addb #$07 yes, make hexadecimal | |
1435 L07BE rts return | |
1436 | |
926 | 1437 ******************************************************************** |
1438 * number of good sectors message | |
1439 ******************************************************************** | |
1907 | 1440 |
1441 GoodSect lbsr LineFD print line feed | |
1442 leax >NumGood,pcr number of good sectors | |
1443 ldy #NGoodLen length of message | |
1444 lbsr Print print it | |
1445 ldb <clustsiz get cluster size | |
1446 lda <oksects get 24 bit counter | |
926 | 1447 ldx <oksects+1 |
1907 | 1448 pshs x,a save 24 bit counter |
1449 L07D4 lsrb carry set 0xxx xxxx -> X ? | |
1450 bcs L07DF yes, | |
1451 lsl $02,s <u0036 1 X <- nnnn nnnn X <- xxxx xxx0 | |
1452 rol $01,s <u0036 2 N <- nnnn nnnX N <- xxxx xxx0 | |
1453 rol ,s <u0036 3 N <- nnnn nnnN | |
1454 bra L07D4 did all sectors? | |
1455 L07DF puls x,a get counted sectors | |
1456 ldb #C$CR | |
1457 pshs b save enter | |
1458 tfr d,y get size | |
1459 tfr x,d get | |
1460 tfr b,a get convert byte | |
1461 bsr HexDigit convert it BYTE 1 | |
1462 pshs b,a save in buffer | |
1463 tfr x,d get convert byte | |
1464 bsr HexDigit convert it BYTE 2 | |
1465 pshs b,a save in buffer | |
1466 tfr y,d get convert byte | |
1467 bsr HexDigit convert it BYTE 3 | |
1468 pshs b,a save it buffer | |
1469 tfr s,x get output buffer | |
1470 lbsr PrintLn print it | |
1471 leas $07,s fix stack | |
1472 rts return | |
1473 | |
926 | 1474 ******************************************************************** |
1475 * get allocation bit map and write sectors | |
1476 ******************************************************************** | |
1907 | 1477 |
1478 WrtSecs | |
1479 pshs y save register | |
1480 clra set number | |
1481 ldb #$01 bits to set | |
1482 cmpd <u0034 map sector? | |
1483 bne L081E yes, write sector | |
1484 leax >optbuf,u allocation bit map | |
1485 clra get number | |
1486 ldy <NoSysClusters system sectors | |
1487 * tfr d,y into register | |
1488 clrb first bit to set | |
1489 os9 F$AllBit set allocation bit map | |
1490 lbcs BadSect if there a error | |
1491 L081E lbsr GetSec get sector | |
1492 leax >optbuf,u allocation bit map | |
1493 lbsr WritSec write sector | |
1494 ldd <totsects get total sectors | |
1495 cmpd <u0031 lsn sector count? | |
1496 bcs AdvSec advance to mapped sectors | |
1497 bhi NxtSec get next sector | |
1498 ldb <totsects+2 get LSB total sectors | |
1499 cmpb <u0033 good sector count? | |
1500 bcc AdvSec advance to mapped sectors | |
1501 NxtSec lbsr NextSec skip to next sector | |
1502 AdvSec ldd <u0034 get mapped sectors | |
1503 addd #$0001 count from one | |
1504 std <u0034 save mapped sectors count | |
1505 puls pc,y restore and return | |
1506 | |
926 | 1507 ******************************************************************** |
1614 | 1508 * create root directory file descriptor |
926 | 1509 ******************************************************************** |
1907 | 1510 |
1511 MkRootFD lbsr GetSec get sector | |
1512 leax >fdtbuf1,u sector buff | |
1513 lbsr ClrSec clear sector | |
1514 leax >fdtbuf2,u get date last modified | |
1515 os9 F$Time get system time | |
1516 leax >fdtbuf1,u get file descriptor | |
926 | 1517 lda #DIR.+PEXEC.+PWRIT.+PREAD.+EXEC.+UPDAT. |
1907 | 1518 sta FD.ATT,x save in FD.ATT |
1519 lda #$02 get link count | |
1520 sta FD.LNK,x save in FD.LNK | |
1521 clra directory size | |
1522 ldb #DIR.SZ*2 directory entries (DIR.SZ*2) | |
1523 std FD.SIZ+2,x save it (FD.SIZ+2) | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1524 ldb <NoRootFDSecs |
1907 | 1525 decb |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1526 stb <FD.SEG+FDSL.B+1,x save it (c+FDSL.B+1) |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1527 * ldd <u0034 |
1907 | 1528 |
1529 ldd SaveRootLSN+1,u Get saved root dir LSN | |
1530 | |
1531 addd #$0001 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1532 std <FD.SEG+FDSL.A+1,x save it (FD.SEG+FDSL.A+1) |
1907 | 1533 bsr SeekRootLSN |
1534 bsr WritSec | |
1535 bsr ClrBuf | |
1536 ldd #$2EAE (#'.*256+'.+128) | |
1537 std DIR.NM,x (DIR.NM) | |
926 | 1538 stb <DIR.SZ+DIR.NM,x (DIR.NM+DIR.SZ) |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1539 * ldd <u0034 |
1907 | 1540 |
1541 ldd SaveRootLSN+1,u Get saved root dir LSN | |
1542 | |
926 | 1543 std <DIR.FD+1,x |
1544 std <DIR.SZ+DIR.FD+1,x | |
1907 | 1545 bsr WritSec |
1546 bsr ClrBuf | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1547 ldb <NoRootFDSecs |
1907 | 1548 decb make zero offset (0 - 255) |
1549 NextCnt decb decrement sector count | |
1550 bne NextWrt if more to do | |
1551 rts else return | |
1552 NextWrt pshs b save sector count | |
1553 bsr WritSec write the sector | |
1554 puls b get count back | |
1555 bra NextCnt do until done | |
1556 | |
926 | 1557 ******************************************************************** |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1558 * Get root dir first LSN |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1559 ******************************************************************** |
1907 | 1560 |
1561 *GetRootLSN | |
1562 * pshs x Retrieve start of Dir from LSN0 | |
1563 * leax LSN0,u | |
1564 * ldd DD.DIR+1,x | |
1565 * puls x | |
1566 * | |
1567 * rts | |
1568 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1569 ******************************************************************** |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1570 * Seek to Root LSN |
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1571 ******************************************************************** |
1907 | 1572 |
1573 SeekRootLSN | |
1574 pshs d,x,u | |
1575 | |
1576 ldx SaveRootLSN,u msw of pos | |
1577 lda SaveRootLSN+2,u lsw | |
1578 clrb | |
1579 tfr d,u | |
1580 lbsr SeekSec | |
1581 | |
1582 puls d,x,u,pc | |
1583 | |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1584 ******************************************************************** |
926 | 1585 * clear the 256 byte sector buffer |
1586 ******************************************************************** | |
1907 | 1587 |
1588 ClrBuf leax >LSN0,u sector buffer | |
1589 ClrSec clra store mask | |
1590 clrb sector count | |
1591 ClrLop sta d,x clear the buffer | |
1592 decb decrement sector count | |
1593 bne ClrLop clear sector buffer | |
1594 rts return when done | |
1595 | |
926 | 1596 ******************************************************************** |
1597 * write physical 256 byte sector to the diskette | |
1598 ******************************************************************** | |
1907 | 1599 |
1600 WritSec lda <diskpath get path number | |
1601 ldy #256 get sector size | |
1602 os9 I$Write write the sector | |
1603 lbcs Exit exit on error | |
1604 rts return | |
1605 | |
926 | 1606 ******************************************************************** |
1607 * get sector file position | |
1608 ******************************************************************** | |
1907 | 1609 |
1610 GetSec clra | |
1611 ldb <u0034 get map sectors high word | |
1612 tfr d,x save it | |
1613 lda <u0035 | |
1614 clrb get map sectors low word | |
1615 tfr d,u save it | |
1616 | |
926 | 1617 ******************************************************************** |
1618 * seek to physical sector | |
1619 ******************************************************************** | |
1907 | 1620 |
1621 SeekSec lda <diskpath get path number | |
1622 os9 I$Seek seek to sector | |
1623 ldu <savedu get data pointer | |
1624 lbcs Exit exit if error | |
1625 rts return | |
1626 | |
926 | 1627 ******************************************************************** |
1628 * skip to the next sector | |
1629 ******************************************************************** | |
1907 | 1630 |
1631 NextSec ldx <u0031 lsn count | |
1632 lda <u0033 good sector count | |
1633 clrb add this | |
1634 addd #$0100 sector | |
1635 tfr d,u lsn count | |
1636 bcc SeekSec seek it? | |
1637 leax $01,x next sector | |
1638 bra SeekSec seek it | |
1639 | |
926 | 1640 ******************************************************************** |
1641 * the format module never gets to this code? | |
1642 ******************************************************************** | |
1907 | 1643 |
1644 ldd ,y | |
1645 leau >LSN0,u | |
1646 leax >dcnums,pcr decimal number conversion table | |
1647 ldy #$2F20 | |
1648 | |
926 | 1649 ******************************************************************** |
1650 * | |
1651 ******************************************************************** | |
1907 | 1652 |
1653 L08E6 leay >$0100,y | |
1654 subd ,x | |
1655 bcc L08E6 | |
1656 addd ,x++ | |
1657 pshs b,a | |
1658 ldd ,x | |
1659 tfr y,d | |
1660 beq L090E | |
1661 ldy #$2F30 | |
1662 cmpd #$3020 | |
1663 bne L0908 | |
1664 ldy #$2F20 | |
1665 tfr b,a | |
1666 L0908 sta ,u+ | |
1667 puls b,a | |
1668 bra L08E6 | |
1669 L090E sta ,u+ | |
1670 lda #C$CR | |
1671 sta ,u | |
1672 ldu <savedu | |
1673 leas $02,s | |
1674 leax >LSN0,u | |
1675 lbsr PrintLn | |
1676 rts | |
1677 | |
926 | 1678 dcnums fdb 10000,1000,100,10,1,0 |
1907 | 1679 |
926 | 1680 ******************************************************************** |
1681 * process decimal number input (65535) | |
1682 ******************************************************************** | |
1907 | 1683 |
1684 Decimal ldd #$0000 start at zero | |
1685 L092F bsr DecBin get first digit | |
1686 bcs L0939 if overflow | |
1687 bne L092F get next digit | |
1688 std <dresult save decimal as binary | |
1689 bne L093E if no error return | |
1690 L0939 ldd #$0001 flag error | |
1691 std <dresult save it | |
1692 L093E rts return | |
1693 | |
926 | 1694 ******************************************************************** |
1695 * process decimal number into it's binary representation | |
1696 * return with binary in the d register | |
1697 ******************************************************************** | |
1907 | 1698 |
1699 DecBin pshs y,b,a save registers | |
1700 ldb ,x+ get digit | |
1701 subb #$30 make it binary | |
1702 cmpb #$0A bla bla bla! | |
1703 bcc L095D | |
1704 lda #$00 | |
1705 ldy #$000A | |
1706 L094F addd ,s | |
1707 bcs L095B | |
1708 leay -$01,y | |
1709 bne L094F | |
1710 std ,s | |
1711 andcc #^Zero | |
1712 L095B puls pc,y,b,a | |
1713 L095D orcc #Zero | |
1714 puls pc,y,b,a | |
1715 | |
926 | 1716 ******************************************************************** |
1717 * print error, usage message, and exit | |
1718 ******************************************************************** | |
1907 | 1719 |
1720 PrtError lda #$02 standard error | |
1721 os9 F$PErr print error | |
1722 ifne DOHELP | |
1723 leax <HelpMsg,pcr point to usage | |
1724 ldy #HelpLen usage size | |
1725 lda #$02 standard error | |
1726 os9 I$WritLn print usage | |
1727 endc | |
1728 clrb no error | |
1729 os9 F$Exit exit module | |
1730 | |
926 | 1731 ******************************************************************** |
1732 * messages | |
1733 ******************************************************************** | |
1907 | 1734 |
1664 | 1735 *Title fcb C$LF |
1736 * fcc "COLOR COMPUTER FORMATTER" | |
1737 *HelpCR fcb C$CR | |
1907 | 1738 ifne DOHELP |
119 | 1739 HelpMsg fcc "Use: FORMAT /devname <opts>" |
1907 | 1740 fcb C$LF |
312 | 1741 fcc " opts: R - Ready" |
1907 | 1742 fcb C$LF |
926 | 1743 fcc " S/D - density; single or double" |
1907 | 1744 fcb C$LF |
312 | 1745 fcc " L - Logical format only" |
1907 | 1746 fcb C$LF |
119 | 1747 fcc / "disk name"/ |
1907 | 1748 fcb C$LF |
312 | 1749 fcc " 1/2 - number of sides" |
1907 | 1750 fcb C$LF |
312 | 1751 fcc " 'No. of cylinders' (in decimal)" |
1907 | 1752 fcb C$LF |
312 | 1753 fcc " :Interleave value: (in decimal)" |
1907 | 1754 fcb C$LF |
926 | 1755 fcc " /Cluster size/ (in decimal)" |
1907 | 1756 fcb C$LF |
1899
010adb3de936
Updates to allow formatting of Dragon OS-9 compatible disks
afra
parents:
1721
diff
changeset
|
1757 fcc " FD - Dragon format disk" |
1907 | 1758 fcb C$CR |
1759 HelpLen equ *-HelpMsg | |
1760 endc | |
1664 | 1761 FmtMsg fcc "Formatting device: " |
1907 | 1762 FmtMLen equ *-FmtMsg |
1763 Query | |
1664 | 1764 * fcc "y (yes) or n (no)" |
1765 * fcb C$LF | |
1682
e2ac12787e55
Sticking with clock2_smart for now. Also moved Robert's swread and swset to 3rdparty/utils
boisy
parents:
1677
diff
changeset
|
1766 fcc "Ready? " |
1907 | 1767 QueryLen equ *-Query |
1664 | 1768 CapErr fcc "ABORT can't get media capacity" |
1907 | 1769 fcb C$CR |
312 | 1770 AbortIlv fcc "ABORT Interleave value out of range" |
1907 | 1771 fcb C$CR |
312 | 1772 AbortSct fcc "ABORT Sector number out of range" |
1907 | 1773 fcb C$CR |
312 | 1774 AbortOp fcc "ABORT Option not allowed on Device" |
1907 | 1775 fcb C$CR |
119 | 1776 DName fcc "Disk name: " |
1907 | 1777 DNameLen equ *-DName |
119 | 1778 fcc "How many Cylinders (Tracks?) : " |
926 | 1779 BadSectM fcc "Bad system sector, " |
1780 Aborted fcc "FORMAT ABORTED" | |
1907 | 1781 fcb C$CR |
119 | 1782 ClustMsg fcc "Cluster size mismatch" |
1907 | 1783 CrRtn fcb C$CR |
1664 | 1784 * fcc "Double density? " |
1785 * fcc "Track 0 Double density? " | |
1786 *TPIChg fcc "Change from 96tpi to 48tpi? " | |
1787 *DSided fcc "Double sided? " | |
119 | 1788 NumGood fcc "Number of good sectors: $" |
1907 | 1789 NGoodLen equ *-NumGood |
1683
786453492c1e
Format doesn't multiply total sectors * bps if TYP.DSQ bit is clear
boisy
parents:
1682
diff
changeset
|
1790 HDFmt fcc "This is a HARD disk - are you sure? " |
1664 | 1791 *HDFmt fcc "WARNING: You are formatting a HARD Disk.." |
1792 * fcb C$LF | |
1793 * fcc "Are you sure? " | |
1907 | 1794 HDFmtLen equ *-HDFmt |
119 | 1795 Both fcc "Both PHYSICAL and LOGICAL format? " |
1907 | 1796 BothLen equ *-Both |
119 | 1797 Verify fcc "Physical Verify desired? " |
1907 | 1798 VerifyL equ *-Verify |
1799 SUMH | |
1800 fcb C$CR,C$LF | |
1664 | 1801 fcc " NitrOS-9 RBF Disk Formatter" |
1907 | 1802 fcb C$CR,C$LF |
1664 | 1803 fcc "------------ Format Data ------------" |
1907 | 1804 fcb C$CR,C$LF |
1664 | 1805 * fcb C$CR,C$LF |
1806 * fcc "Fixed values:" | |
1907 | 1807 fcb C$CR,C$LF |
1808 SUMHL equ *-SUMH | |
1721 | 1809 FMT fcc " Floppy Disk Format: " |
1907 | 1810 FMTL equ *-FMT |
1721 | 1811 TOF fcc " Track Offset: " |
1907 | 1812 TOFL equ *-TOF |
1721 | 1813 SOF fcc " Sector Offset: " |
1907 | 1814 SOFL equ *-SOF |
1664 | 1815 PFS fcc " Physical floppy size: " |
1907 | 1816 PFSL equ *-PFS |
1664 | 1817 DC fcc " Disk capacity: " |
1907 | 1818 DCL equ *-DC |
1664 | 1819 CSZ fcc " Cluster size: " |
1907 | 1820 CSZL equ *-CSZ |
1664 | 1821 *SSZ fcc " Sector size: " |
1822 *SSZL equ *-SSZ | |
1823 SST fcc " Sectors/track: " | |
1907 | 1824 SSTL equ *-SST |
1664 | 1825 TZST fcc " Track zero sect/trk: " |
1907 | 1826 TZSTL equ *-TZST |
1664 | 1827 *LSNOF fcc " LSN offset: $" |
1828 *LSNOFL equ *-LSNOF | |
1829 TPC fcc "Total physical cylinders: " | |
1907 | 1830 TPCL equ *-TPC |
1664 | 1831 MSA fcc " Minimum sect allocation: " |
1907 | 1832 MSAL equ *-MSA |
1664 | 1833 RF fcc " Recording format: " |
1907 | 1834 RFL equ *-RF |
1664 | 1835 TD fcc " Track density in TPI: " |
1907 | 1836 TDL equ *-TD |
1664 | 1837 NLC fcc "Number of log. cylinders: " |
1907 | 1838 NLCL equ *-NLC |
1664 | 1839 NS fcc " Number of surfaces: " |
1907 | 1840 NSL equ *-NS |
1664 | 1841 SI fcc "Sector interleave offset: " |
1907 | 1842 SIL equ *-SI |
1664 | 1843 SCTS fcc " sectors" |
1907 | 1844 fcb C$CR |
1664 | 1845 SPPR fcc " (" |
1907 | 1846 SPPRL equ *-SPPR |
1847 PRSP fcc " bytes)" | |
1848 fcb C$CR | |
1849 PRSPL equ *-PRSP | |
2040 | 1850 _CoCo fcc !CoCo! |
1907 | 1851 fcb C$CR |
2040 | 1852 _Dragon fcc !Dragon! |
1907 | 1853 fcb C$CR |
1721 | 1854 Standard fcc !Standard OS-9! |
1907 | 1855 fcb C$CR |
1856 Three5 fcc !3 1/2"! | |
1857 fcb C$CR | |
1858 FiveQ fcc !5 1/4"! | |
1859 fcb C$CR | |
1860 _MFM fcc /M/ | |
1861 FM fcc /FM/ | |
1862 fcb C$CR | |
1863 TPI48 fcc /48/ | |
1864 fcb C$CR | |
1865 TPI96 fcc !96! | |
1866 fcb C$CR | |
1867 TPI135 fcc !135! | |
1868 fcb C$CR | |
1869 | |
1870 | |
1871 HDSummary | |
1664 | 1872 bsr ShowHeader |
1721 | 1873 lbsr ShowDiskCapacity |
1907 | 1874 ldb <dtype |
1875 andb #TYPH.DSQ | |
1876 bne o@ | |
1664 | 1877 lbsr ShowSectorsTrack |
1878 lbsr ShowSectorsTrackZero | |
1879 lbsr ShowNumberSurfaces | |
1880 lbsr ShowTotalPhysCylinders | |
1881 o@ lbsr ShowClusterSize | |
1907 | 1882 lbsr ShowSAS |
1883 rts | |
1884 | |
1885 FloppySummary | |
1664 | 1886 bsr ShowHeader |
1721 | 1887 bsr ShowDiskType |
1664 | 1888 bsr ShowPhysFloppy |
1889 lbsr ShowSectorsTrack | |
1890 lbsr ShowSectorsTrackZero | |
1891 lbsr ShowTotalPhysCylinders | |
1721 | 1892 lbsr ShowTrackOffset |
1893 lbsr ShowSectorOffset | |
1907 | 1894 lbsr ShowSAS |
1664 | 1895 lbsr ShowRecordingFormat |
1896 lbsr ShowTrackDensity | |
1897 lbsr ShowNumberLogCylinders | |
1898 lbsr ShowNumberSurfaces | |
1899 lbsr ShowSectorInterleaveOffset | |
1907 | 1900 rts |
1901 | |
1902 ShowHeader | |
1903 lda #$01 | |
1904 leax SUMH,pcr | |
1905 ldy #SUMHL | |
1906 os9 I$Write | |
1907 rts | |
1908 | |
1909 ShowDiskType | |
1910 leax FMT,pcr | |
1911 ldy #FMTL | |
1912 os9 I$Write | |
1913 ldb <dtype | |
2040 | 1914 leax _CoCo,pcr |
1907 | 1915 bitb #TYP.CCF |
1916 bne n@ | |
1721 | 1917 t@ leax Standard,pcr |
1907 | 1918 bra s@ |
1919 n@ ldb IsDragon,u Get dragon flag | |
1920 cmpb #DragonFlag Dragon disk ? | |
1921 bne s@ | |
2040 | 1922 leax _Dragon,pcr |
1907 | 1923 s@ ldy #80 |
1924 os9 I$WritLn | |
1925 rts | |
1926 | |
1927 ShowPhysFloppy | |
1928 leax PFS,pcr | |
1929 ldy #PFSL | |
1930 os9 I$Write | |
1931 ldb <dtype | |
1932 leax FiveQ,pcr | |
1933 bitb #TYP.3 | |
1934 beq n@ | |
1664 | 1935 t@ leax Three5,pcr |
1907 | 1936 n@ ldy #80 |
1937 os9 I$WritLn | |
1938 rts | |
1939 | |
1940 ShowDiskCapacity | |
1941 leax DC,pcr | |
1942 ldy #DCL | |
1943 os9 I$Write | |
1944 clra | |
1945 ldb <totsects | |
1946 std <tmpnum | |
1664 | 1947 ldd <totsects+1 |
1907 | 1948 std <tmpnum+2 |
1949 leax <tmpnum,u | |
1950 leay numbuf,u | |
1951 lbsr itoa | |
1664 | 1952 * X points to buffer, Y holds size |
1907 | 1953 pshs x |
1954 tfr y,d | |
1955 leax d,x | |
1664 | 1956 * X points at character after last member |
1907 | 1957 leay SCTS,pcr |
1958 go@ lda ,y+ | |
1959 sta ,x+ | |
1960 cmpa #C$CR | |
1961 bne go@ | |
1962 puls x | |
1963 ldy #80 | |
1964 lda #$01 | |
1965 os9 I$WritLn | |
1664 | 1966 * Put out leading spaces and ( |
1907 | 1967 leax SPPR,pcr |
1968 ldy #SPPRL | |
1969 os9 I$Write | |
1664 | 1970 * Copy number from totsects |
1907 | 1971 clra |
1664 | 1972 ldd totsects,u |
1907 | 1973 std tmpnum,u |
1664 | 1974 lda totsects+2,u |
1907 | 1975 clrb |
1664 | 1976 std tmpnum+2,u |
1907 | 1977 leax <tmpnum,u |
1978 leay numbuf,u | |
1979 lbsr itoa | |
1664 | 1980 * X points to the ASCII number |
1981 * Y holds length | |
1907 | 1982 lda #$01 |
1983 os9 I$Write | |
1984 leax PRSP,pcr | |
1985 ldy #PRSPL | |
1986 os9 I$WritLn | |
1987 rts | |
1988 | |
1989 ShowSectorsTrack | |
1990 leax SST,pcr | |
1991 ldy #SSTL | |
1992 os9 I$Write | |
1993 ldd <sectors | |
1994 lbra PrintNum | |
1995 | |
1996 ShowTrackOffset | |
1997 leax TOF,pcr | |
1998 ldy #TOFL | |
1999 os9 I$Write | |
2000 clra | |
2001 ldb <toffs | |
2002 lbra PrintNum | |
2003 | |
2004 ShowSectorOffset | |
2005 leax sOF,pcr | |
2006 ldy #SOFL | |
2007 os9 I$Write | |
2008 clra | |
2009 ldb <soffs | |
2010 lbra PrintNum | |
2011 | |
2012 ShowSectorsTrackZero | |
2013 leax TZST,pcr | |
2014 ldy #TZSTL | |
2015 os9 I$Write | |
2016 ldd <sectors0 | |
2017 lbra PrintNum | |
2018 | |
2019 ShowTotalPhysCylinders | |
2020 leax TPC,pcr | |
2021 ldy #TPCL | |
2022 os9 I$Write | |
2023 ldd <ncyls | |
2024 lbra PrintNum | |
2025 | |
2026 ShowClusterSize | |
2027 leax CSZ,pcr | |
2028 ldy #CSZL | |
2029 os9 I$Write | |
2030 clra | |
2031 ldb <clustsiz | |
2032 lbra PrintNum | |
2033 | |
2034 ShowSAS | |
2035 leax MSA,pcr | |
2036 ldy #MSAL | |
2037 os9 I$Write | |
2038 clra | |
2039 ldb <sas | |
2040 lbra PrintNum | |
2041 | |
2042 ShowRecordingFormat | |
2043 leax RF,pcr | |
2044 ldy #RFL | |
2045 os9 I$Write | |
2046 leax _MFM,pcr | |
2047 tst <mfm | |
2048 bne n@ | |
2049 leax FM,pcr | |
2050 n@ ldy #80 | |
2051 os9 I$WritLn | |
2052 rts | |
2053 | |
2054 ShowTrackDensity | |
2055 leax TD,pcr | |
2056 ldy #TDL | |
2057 os9 I$Write | |
1721 | 2058 leax TPI135,pcr |
1907 | 2059 ldb <dtype |
2060 lsrb | |
2061 bcs n@ | |
2062 x@ leax TPI48,pcr | |
2063 ldb <dns | |
2064 bitb #DNS.DTD | |
2065 beq n@ | |
2066 leax TPI96,pcr | |
2067 n@ ldy #80 | |
2068 os9 I$WritLn | |
2069 rts | |
2070 | |
2071 ShowNumberLogCylinders | |
2072 leax NLC,pcr | |
2073 ldy #NLCL | |
2074 os9 I$Write | |
2075 ldd <ncyls | |
2076 lbra PrintNum | |
2077 | |
2078 ShowNumberSurfaces | |
2079 leax NS,pcr | |
2080 ldy #NSL | |
2081 os9 I$Write | |
2082 clra | |
2083 ldb <numsides | |
2084 bra PrintNum | |
2085 | |
2086 ShowSectorInterleaveOffset | |
2087 leax SI,pcr | |
2088 ldy #SIL | |
2089 os9 I$Write | |
2090 clra | |
2091 ldb <interlv | |
2092 bra PrintNum | |
2093 | |
1664 | 2094 * Output decimal number to stdout with CR tacked at end |
2095 * Entry: B = number | |
2096 * Leading zeros are NOT printed | |
1907 | 2097 PrintNum |
2098 pshs d | |
2099 clr ,-s | |
2100 clr ,-s | |
2101 leax ,s | |
2102 leay numbuf,u | |
2103 bsr itoa | |
2104 lda #$01 | |
2105 os9 I$Write | |
2106 leas 4,s | |
2107 lbra LineFd | |
2108 | |
2109 Base fcb $3B,$9A,$CA,$00 1,000,000,000 | |
2110 fcb $05,$F5,$E1,$00 100,000,000 | |
2111 fcb $00,$98,$96,$80 10,000,000 | |
2112 fcb $00,$0f,$42,$40 1,000,000 | |
2113 fcb $00,$01,$86,$a0 100,000 | |
2114 fcb $00,$00,$27,$10 10,000 | |
2115 fcb $00,$00,$03,$e8 1,000 | |
2116 fcb $00,$00,$00,$64 100 | |
2117 fcb $00,$00,$00,$0a 10 | |
2118 fcb $00,$00,$00,$01 1 | |
2119 | |
1664 | 2120 * Entry: |
2121 * X = address of 24 bit value | |
2122 * Y = address of buffer to hold hexadecimal number | |
2123 * Exit: | |
2124 * X = address of buffer holding hexadecimal number | |
2125 * Y = length of number string in bytes (always 6) | |
2126 *i24toha pshs y | |
2127 * ldb #3 | |
2128 * pshs b | |
2129 *a@ lda ,x | |
2130 * anda #$F0 | |
2131 * lsra | |
2132 * lsra | |
2133 * lsra | |
2134 * lsra | |
2135 * cmpa #10 | |
2136 * blt o@ | |
2137 * adda #$41 | |
2138 *o@ sta ,y+ | |
2139 * lda ,x+ | |
2140 * anda #$0F | |
2141 * cmpa #10 | |
2142 * blt p@ | |
2143 * adda #$41 | |
2144 *p@ sta ,y+ | |
2145 * dec ,s | |
2146 * bne a@ | |
2147 * leas 1,s | |
2148 * ldy #0006 | |
2149 * puls x,pc | |
1907 | 2150 |
1664 | 2151 * Entry: |
2152 * X = address of 32 bit value | |
2153 * Y = address of buffer to hold number | |
2154 * Exit: | |
2155 * X = address of buffer holding number | |
2156 * Y = length of number string in bytes | |
1907 | 2157 itoa pshs u,y |
2158 tfr y,u | |
2159 ldb #10 max number of numbers (10^9) | |
2160 pshs b save count on stack | |
2161 leay Base,pcr point to base of numbers | |
2162 s@ lda #$30 put #'0 | |
2163 sta ,u at U | |
2164 s1@ bsr Sub32 ,X=,X-,Y | |
2165 inc ,u | |
2166 bcc s1@ if X>0, continue | |
2167 bsr Add32 add back in | |
2168 dec ,u+ | |
2169 dec ,s decrement counter | |
2170 beq done@ | |
2171 lda ,s | |
2172 cmpa #$09 | |
2173 beq comma@ | |
2174 cmpa #$06 | |
2175 beq comma@ | |
2176 cmpa #$03 | |
2177 bne s2@ | |
2178 comma@ ldb #', | |
2179 stb ,u+ | |
2180 s2@ leay 4,y point to next | |
2181 bra s@ | |
2182 done@ leas 1,s | |
1664 | 2183 * 1,234,567,890 |
1907 | 2184 ldb #14 length of string with commas + 1 |
2185 ldx ,s++ get pointer to buffer | |
2186 a@ decb | |
2187 beq ex@ | |
2188 lda ,x+ get byte | |
2189 cmpa #'0 | |
2190 beq a@ | |
2191 cmpa #', | |
2192 beq a@ | |
2193 clra | |
2194 tfr d,y transfer count into Y | |
2195 v@ leax -1,x | |
2196 puls u,pc | |
2197 ex@ ldy #0001 | |
2198 bra v@ | |
2199 | |
1664 | 2200 * Entry: |
2201 * X = address of 32 bit minuend | |
2202 * Y = address of 32 bit subtrahend | |
2203 * Exit: | |
2204 * X = address of 32 bit difference | |
1907 | 2205 Sub32 ldd 2,x |
2206 subd 2,y | |
2207 std 2,x | |
2208 ldd ,x | |
2209 sbcb 1,y | |
2210 sbca ,y | |
2211 std ,x | |
2212 rts | |
2213 | |
2214 | |
1664 | 2215 * Entry: |
2216 * X = address of 32 bit number | |
2217 * Y = address of 32 bit number | |
2218 * Exit: | |
2219 * X = address of 32 bit sum | |
1907 | 2220 Add32 ldd 2,x |
2221 addd 2,y | |
2222 std 2,x | |
2223 ldd ,x | |
2224 adcb 1,y | |
2225 adca ,y | |
2226 std ,x | |
2227 rts | |
2228 | |
2229 | |
2230 ifne DOROLL | |
952 | 2231 RollMsg fcc " Recording Format: FM/MFM" |
1907 | 2232 fcb C$LF |
952 | 2233 fcc " Track density in TPI: 48/96" |
1907 | 2234 fcb C$LF |
952 | 2235 fcc " Number of Cylinders: 0000" |
1907 | 2236 fcb C$LF |
952 | 2237 fcc " Number of Surfaces: 0000" |
1907 | 2238 fcb C$LF |
952 | 2239 fcc "Sector Interleave Offset: 0000" |
1907 | 2240 fcb C$LF |
952 | 2241 fcc " Disk type: 0000" |
1907 | 2242 fcb C$LF |
961
53b612a9ef45
Added a conditional check to the roll message, so you can build format
johncollyer
parents:
960
diff
changeset
|
2243 fcc " Sectors/Cluster: 0000" |
1907 | 2244 fcb C$LF |
952 | 2245 fcc " Sectors/Track: 0000" |
1907 | 2246 fdb $0A0A |
952 | 2247 fcc "Sector: 00 Track: 00 Side: 00" |
1907 | 2248 RollLen equ *-RollMsg |
2249 endc | |
2250 | |
2251 emod | |
2252 eom equ * | |
2253 end |