Mercurial > hg > Members > kono > nitros9-code
comparison level1/cmds/dmode.asm @ 963:7cecd837bcab
Added new commands as part of standard CMDS distribution
author | boisy |
---|---|
date | Fri, 31 Jan 2003 17:37:19 +0000 |
parents | |
children | 84ea83668304 |
comparison
equal
deleted
inserted
replaced
962:8a0993b04c8a | 963:7cecd837bcab |
---|---|
1 nam dmode | |
2 | |
3 * DMode by Kevin K. Darling | |
4 * Disk descriptor utility. | |
5 * | |
6 * This version will do desc file on disk also. | |
7 * 23 Sept 86, 1 Oct 86, 2 Oct 86 | |
8 | |
9 * Modified by Roger A. Krupski (HARDWAREHACK) | |
10 * Fixes "lower case bug", allows "$" prefix for hex | |
11 * Last updated: 08-24-89 RAK | |
12 | |
13 * Oversized and kludgy, but works. | |
14 * Apologies for lack of comments. | |
15 ************************************************ | |
16 * RBF descriptor utility similar to xmode. | |
17 * Use: dmode </devicename> [options] | |
18 * dmode -<filename> [options] | |
19 * (allows dmode use on a saved desc) | |
20 * (-filename will use data dir for default) | |
21 * dmode -? will give bit definitions | |
22 * If no options given, just returns desc info. | |
23 * All numbers must be in HEX. | |
24 * dmode | |
25 * dmode /h0 cyl=0200 sas=8 ilv=4 | |
26 * dmode /d0 | |
27 * dmode -? | |
28 * dmode -/d1/modules/d2.dd cyl=0028 | |
29 | |
30 ifp1 | |
31 use defsfile use defsfile | |
32 use rbfdefs | |
33 endc | |
34 | |
35 mod size,name,$11,$81,entry,msiz | |
36 | |
37 org 0 | |
38 desc rmb $40 dev desc copy | |
39 dsize rmb 2 desc size | |
40 path rmb 1 file path | |
41 parmptr rmb 2 next name dataptr | |
42 module rmb 2 desc address | |
43 dataptr rmb 2 current option ptr | |
44 buffptr rmb 2 buffer address | |
45 txtptr rmb 2 option name ptr | |
46 hexin rmb 2 2 byte hex number | |
47 hexcnt rmb 1 number of option bytes | |
48 buffer rmb 10 output buffer | |
49 stack rmb 200 | |
50 params rmb 150 | |
51 msiz equ . | |
52 | |
53 ************************************************ | |
54 name fcs "Dmode" | |
55 fcb 8 version | |
56 | |
57 helpmsg | |
58 fcb C$CR,C$LF | |
59 fcc "drv Drive Number 0...n" | |
60 fcb C$CR,C$LF | |
61 fcc "stp Step Rate 0=30, 1=20, 2=12, 3=6ms" | |
62 fcb C$CR,C$LF | |
63 fcb C$CR,C$LF | |
64 fcc 'typ Device Type bit0- 0=5" 1=8"' | |
65 fcb C$CR,C$LF | |
66 fcc " $20 bit5- 0=non 1=coco" | |
67 fcb C$CR,C$LF | |
68 fcc " $40 bit6- 0=std 1=non" | |
69 fcb C$CR,C$LF | |
70 fcc " $80 bit7- 0=flop 1=hard" | |
71 fcb C$CR,C$LF | |
72 fcb C$CR,C$LF | |
73 fcc "dns Density bit0- 0=SD 1=DD" | |
74 fcb C$CR,C$LF | |
75 fcc " bit1- 0=48 1=96 tpi" | |
76 fcb C$CR,C$LF | |
77 fcb C$CR,C$LF | |
78 fcc "cyl Cylinders (tracks) (in hex)" | |
79 fcb C$CR,C$LF | |
80 fcc "sid Sides (heads) (in hex)" | |
81 fcb C$CR,C$LF | |
82 fcc "vfy Verify (0=yes)" | |
83 fcb C$CR,C$LF | |
84 fcc "sct Sectors/Track (in hex)" | |
85 fcb C$CR,C$LF | |
86 fcc "tos Sectors/Track on track 0 (in hex)" | |
87 fcb C$CR,C$LF | |
88 fcc "ilv Interleave (in hex)" | |
89 fcb C$CR,C$LF | |
90 fcc "sas Minimum segment allocation (in hex)" | |
91 fcb C$CR,C$LF | |
92 helplen equ *-helpmsg | |
93 | |
94 errmsg | |
95 fcb C$CR,C$LF | |
96 fcc "Use Dmode /<dev_name> [options...]" | |
97 fcb C$CR,C$LF | |
98 fcc " or Dmode -<filename> [options...]" | |
99 fcb C$CR,C$LF | |
100 fcc " or Dmode -? for options help" | |
101 fcb C$CR,C$LF | |
102 fcb C$CR,C$LF | |
103 fcc " NOTE: specify options in hex." | |
104 cr fcb C$CR,C$LF | |
105 msglen equ *-errmsg | |
106 | |
107 synmsg | |
108 fcb C$CR,C$LF | |
109 fcc "Syntax Error: " | |
110 synlen equ *-synmsg | |
111 | |
112 | |
113 muchhelp | |
114 leax helpmsg,pc | |
115 ldy #helplen | |
116 bra helpprnt | |
117 | |
118 rbfmsg | |
119 fcb C$CR,C$LF | |
120 fcc "NOT an RBF descriptor!" | |
121 fcb C$CR,C$LF | |
122 rbflen equ *-rbfmsg | |
123 | |
124 notrbf | |
125 leax rbfmsg,pc | |
126 ldy #rbflen | |
127 lda #2 | |
128 os9 I$Write | |
129 | |
130 help | |
131 leax errmsg,pc | |
132 ldy #msglen | |
133 | |
134 helpprnt | |
135 lda #2 | |
136 os9 I$Write | |
137 lbra okayend2 | |
138 | |
139 ************************************************ | |
140 entry | |
141 ldd #0 | |
142 std module zero mod flag | |
143 sta path zero file flag | |
144 ldd ,x+ check for device name | |
145 cmpa #'- file option? | |
146 bne link | |
147 cmpb #'? help option? | |
148 beq muchhelp | |
149 | |
150 * Use Filename to Get Desc: | |
151 lda #UPDAT. open path to desc file | |
152 os9 I$Open | |
153 bcs error | |
154 stx parmptr | |
155 sta path save path number | |
156 | |
157 ldy #$40 max size | |
158 leax desc,u desc buff | |
159 os9 I$Read get it | |
160 bcc use10 | |
161 cmpb #E$EOF | |
162 bne error | |
163 | |
164 use10 | |
165 sty dsize save desc size | |
166 bra gotit | |
167 | |
168 link | |
169 cmpa #PDELIM else must be /<devicename> | |
170 bne help | |
171 pshs u | |
172 lda #Devic | |
173 os9 F$Link link to descriptor | |
174 bcs error | |
175 stx parmptr update after name | |
176 tfr u,x | |
177 puls u | |
178 stx module | |
179 ldd M$Size,x get desc size | |
180 std dsize | |
181 leay desc,u | |
182 | |
183 mloop | |
184 lda ,x+ | |
185 sta ,y+ | |
186 decb | |
187 bne mloop | |
188 | |
189 gotit | |
190 leax desc,u | |
191 lda $12,x test device type | |
192 cmpa #1 RBF? | |
193 bne notrbf | |
194 | |
195 leax $13,x point to drive # | |
196 stx dataptr save mod option ptr | |
197 | |
198 ldx parmptr point to input parms | |
199 | |
200 skip | |
201 lda ,x+ | |
202 cmpa #$20 skip blanks | |
203 beq skip | |
204 | |
205 leax -1,x | |
206 cmpa #$0D no options? | |
207 lbeq info ..yes, give info | |
208 lbra findtxt else find options | |
209 | |
210 okayend | |
211 lbsr outcr | |
212 okayend2 | |
213 clrb okay | |
214 error | |
215 pshs b,cc | |
216 ldu module | |
217 beq bye | |
218 os9 F$UnLink | |
219 bye | |
220 puls b,cc | |
221 os9 F$Exit end dmode. | |
222 | |
223 table | |
224 fcc " drv" option name | |
225 fcb IT.DRV,1 option offset & byte count | |
226 fcc " stp" | |
227 fcb IT.STP,1 | |
228 fcc " typ" | |
229 fcb IT.TYP,1 | |
230 fcc " dns" | |
231 fcb IT.DNS,1 | |
232 fcc " cyl" | |
233 fcb IT.CYL,2 | |
234 fcc " sid" | |
235 fcb IT.SID,1 | |
236 fcc " vfy" | |
237 fcb IT.VFY,1 | |
238 fcc " sct" | |
239 fcb IT.SCT,2 | |
240 fcc " tos" | |
241 fcb IT.T0S,2 | |
242 fcc " ilv" | |
243 fcb IT.ILV,1 | |
244 fcc " sas" | |
245 fcb IT.SAS,1 | |
246 fcc " t0s" extra so it parses, but doesn't print! | |
247 fcb IT.T0S,2 | |
248 fcb $80 end of table | |
249 | |
250 info equ * Output Current Desc Info: | |
251 ldb #11 eleven entries (we won't print #12) | |
252 pshs b | |
253 leax table,pc point to text table | |
254 stx txtptr | |
255 ilup | |
256 bsr outtext print label and = | |
257 lbsr outnum print value | |
258 ldx txtptr | |
259 leax 6,x | |
260 stx txtptr | |
261 dec ,s | |
262 lbeq okayend ..end of info | |
263 ldb ,s | |
264 cmpb #5 <cr> after 6th option | |
265 bne ilup | |
266 bsr outcr <cr> | |
267 bra ilup ..loop | |
268 | |
269 outcr equ * Print a <CR/LF>: | |
270 leax cr,pc | |
271 ldy #2 byte count | |
272 | |
273 output equ * Print generic | |
274 lda #1 std out | |
275 os9 I$Write | |
276 bcc okay | |
277 leas 2,s purge return | |
278 lbra error error | |
279 okay rts | |
280 | |
281 | |
282 * ----------------------- | |
283 equal fcc "=$" | |
284 outtext equ * Print Option Name: | |
285 ldx txtptr | |
286 ldy #4 | |
287 bsr output print option name | |
288 leax equal,pc | |
289 ldy #2 | |
290 bsr output sorry, must be a bsr | |
291 rts return | |
292 | |
293 * ----------------------- | |
294 outnum equ * Print Hex Option Values: | |
295 ldx txtptr | |
296 ldb 5,x get # of digits | |
297 stb hexcnt | |
298 numlup | |
299 bsr outhex | |
300 dec hexcnt | |
301 bne numlup | |
302 rts | |
303 | |
304 outhex equ * Print One Byte: | |
305 ldx dataptr | |
306 lda ,x+ | |
307 stx dataptr | |
308 pshs a | |
309 lsra | |
310 lsra | |
311 lsra | |
312 lsra | |
313 bsr outone | |
314 puls a | |
315 anda #$0F | |
316 | |
317 outone equ * Print 1/2 Byte Hex Char: | |
318 cmpa #10 | |
319 bcs number | |
320 adda #$11-10 make alpha | |
321 number | |
322 adda #$30 make ASCII | |
323 sta buffer | |
324 leax buffer,u | |
325 ldy #1 | |
326 lbra output | |
327 | |
328 skipspc equ * Skip Spaces: | |
329 lda ,x+ | |
330 cmpa #C$SPAC | |
331 beq skipspc | |
332 rts | |
333 | |
334 ************************************************ | |
335 * X=parmptr | |
336 | |
337 findtxt equ * Find and Set Options: | |
338 | |
339 flup10 | |
340 bsr skipspc get next input param | |
341 stx parmptr save for syntax error use | |
342 cmpa #C$CR end? | |
343 lbeq verify ..yes, update desc CRC | |
344 | |
345 ora #$20 force lower case first char | |
346 leay table-6,pc ready option table ptr | |
347 pshs d,u | |
348 ldd ,x++ get next two chars | |
349 ora #$20 force lower case | |
350 orb #$20 -ditto- | |
351 tfr d,u place two chars in U | |
352 puls d restore A&B (u is still pushed) | |
353 | |
354 flup20 | |
355 leay 6,y next option entry | |
356 tst ,y last entry? | |
357 lbmi syntax ..yes, bad option | |
358 cmpa 1,y | |
359 bne flup20 same name? | |
360 cmpu 2,y | |
361 bne flup20 ..no, loop | |
362 | |
363 * Found Option | |
364 puls u | |
365 sty txtptr | |
366 lda ,x+ must be followed by "=" | |
367 cmpa #'= | |
368 lbne syntax | |
369 | |
370 bsr setnum set that option | |
371 bra flup10 | |
372 | |
373 * ------------- | |
374 setnum equ * Get Hex Input and Set Option: | |
375 ldb 5,y get # of bytes | |
376 stb hexcnt | |
377 clr hexin zero hex input bytes | |
378 clr hexin+1 | |
379 | |
380 setloop | |
381 lda ,x+ get next # | |
382 cmpa #'$ optional hex $? | |
383 beq setloop yes, ignore | |
384 cmpa #C$SPAC end of number? | |
385 beq setnum2 ..yes, set option, rts | |
386 cmpa #C$CR end of line? | |
387 beq setnum1 | |
388 bsr hexcnvt else, get next num | |
389 bra setloop ..loop | |
390 | |
391 setnum1 | |
392 leax -1,x reset so can find <cr> | |
393 setnum2 | |
394 ldb 4,y get option offset | |
395 leay desc,u point to desc | |
396 leay b,y point to option | |
397 ldd hexin pick up hex input | |
398 dec hexcnt | |
399 beq setone | |
400 std ,y set two byte option | |
401 rts | |
402 setone | |
403 tsta | |
404 lbne syntax | |
405 stb ,y set one byte option | |
406 rts | |
407 | |
408 hexcnvt equ * Convert ASCII Hex-->Byte: | |
409 suba #$30 make number from ASCII | |
410 lbmi syntax | |
411 cmpa #10 is it number? | |
412 bcs num | |
413 anda #$5F make uppercase | |
414 suba #$11-$0a make hex $A-$F | |
415 cmpa #$0A | |
416 lbcs syntax | |
417 cmpa #$10 not hex char? | |
418 lbcc syntax | |
419 num | |
420 ldb #16 fancy asl *4 | |
421 mul | |
422 pshs b save top 4 bits | |
423 ldd hexin | |
424 rol ,s | |
425 rolb | |
426 rola | |
427 rol ,s | |
428 rolb | |
429 rola | |
430 rol ,s | |
431 rolb | |
432 rola | |
433 rol ,s | |
434 rolb | |
435 rola | |
436 std hexin | |
437 puls b,pc drop temp, rts. | |
438 | |
439 verify equ * Update Descriptor CRC: | |
440 pshs u save data ptr | |
441 leau desc,u | |
442 tfr u,x X is mod address | |
443 | |
444 ldy M$Size,x Y is mod size | |
445 leay -3,y beginning of chksum | |
446 tfr y,d Y is byte count | |
447 leau d,u set U to chksum | |
448 | |
449 lda #$FF init chksum | |
450 sta ,u | |
451 sta 1,u | |
452 sta 2,u | |
453 pshs u | |
454 os9 F$CRC calc new crc | |
455 puls u | |
456 com ,u+ fix it up right | |
457 com ,u+ | |
458 com ,u | |
459 | |
460 lda path was it file? | |
461 beq memmod ..no, in memory | |
462 ldx #0 | |
463 tfr x,u | |
464 os9 I$Seek go back to file begin | |
465 lbcs error | |
466 puls u | |
467 leax desc,u | |
468 ldy dsize | |
469 os9 I$Write update desc file | |
470 lbra okayend | |
471 | |
472 memmod | |
473 puls u | |
474 leax desc,u | |
475 ldb dsize+1 | |
476 ldy module | |
477 | |
478 move | |
479 lda ,x+ | |
480 sta ,y+ | |
481 decb | |
482 bne move | |
483 | |
484 lbra okayend2 | |
485 | |
486 | |
487 syntax equ * | |
488 leax synmsg,pc | |
489 ldy #synlen | |
490 lda #2 | |
491 os9 I$Write | |
492 | |
493 ldx parmptr | |
494 leax -1,x | |
495 pshs x | |
496 ldy #0 | |
497 | |
498 slup | |
499 leay 1,y | |
500 lda ,x+ | |
501 cmpa #C$CR | |
502 beq synsay | |
503 cmpa #C$SPAC | |
504 bne slup | |
505 | |
506 synsay | |
507 puls x | |
508 lda #2 | |
509 os9 I$Write output err | |
510 lbra okayend | |
511 | |
512 emod | |
513 size equ * | |
514 end |