Mercurial > hg > Members > kono > nitros9-code
annotate level1/cmds/copy.asm @ 2695:c321d41cd8d3 lwtools-port
Conditionalized VTIO to turn off caps-lock for coco2b port
author | Boisy Pitre <boisy.pitre@nuance.com> |
---|---|
date | Thu, 19 Jul 2012 14:36:52 -0500 |
parents | abdd67f458dd |
children |
rev | line source |
---|---|
0 | 1 ******************************************************************** |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
2 * Copy - File copy utility |
0 | 3 * |
4 * $Id$ | |
5 * | |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
6 * Edt/Rev YYYY/MM/DD Modified by |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
7 * Comment |
0 | 8 * ------------------------------------------------------------------ |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
9 * 9 ????/??/?? |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
10 * From Tandy OS-9 Level Two VR 02.00.01. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
11 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
12 * 10 ????/??/?? Ron Lamardo |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
13 * Reworked. |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
14 * |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
15 * 11 2003/01/11 Boisy G. Pitre |
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
16 * Added useful options, made more robust. |
0 | 17 |
18 nam Copy | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
19 ttl File copy utility |
0 | 20 |
802 | 21 ifp1 |
15 | 22 use defsfile |
802 | 23 endc |
15 | 24 |
921
617c1b90e623
Added DOHELP conditionals, set all to zero to eliminate help from commands
boisy
parents:
846
diff
changeset
|
25 DOHELP set 0 |
802 | 26 |
27 tylg set Prgrm+Objct | |
0 | 28 atrv set ReEnt+rev |
1325
84ea83668304
Redid comments, reset all rev nibbles that weren't explictly set to 0
boisy
parents:
929
diff
changeset
|
29 rev set $00 |
802 | 30 edition set 11 |
15 | 31 |
0 | 32 mod eom,name,tylg,atrv,start,size |
15 | 33 |
929
c04528763543
stack/parameter size increased to prevent collisions with memory
boisy
parents:
921
diff
changeset
|
34 STACKSZ equ 128 estimated stack size |
c04528763543
stack/parameter size increased to prevent collisions with memory
boisy
parents:
921
diff
changeset
|
35 PARMSZ equ 256 estimated parameter size |
802 | 36 DDIRBSIZ equ 64 destination directory buffer size |
37 | |
38 org 0 | |
39 rdbufptr rmb 2 | |
40 parmptr rmb 2 | |
41 srcpath rmb 1 | |
42 dstpath rmb 1 | |
43 devtyp rmb 1 | |
44 bufsiz rmb 2 | |
45 srcflsiz rmb 4 | |
46 abortflg rmb 1 | |
47 quiet rmb 1 | |
48 single rmb 1 | |
49 rewrite rmb 1 | |
50 filecnt rmb 1 | |
51 srccnt rmb 1 | |
52 srcmode rmb 1 | |
53 wopt rmb 1 | |
1590 | 54 vopt rmb 1 |
802 | 55 srcfname rmb 2 |
56 dstfptr rmb 2 | |
57 wfileptr rmb 2 | |
58 wfilelen rmb 2 | |
59 lstfopen rmb 2 pointer to name of last file attempted open | |
60 lstfopln rmb 2 length of last file atteppted open | |
61 srcattr rmb 1 | |
1590 | 62 writemsb rmb 2 |
63 writelsb rmb 2 | |
802 | 64 fdbufcpy rmb 16 |
65 optbuf rmb 32 | |
66 wdest rmb DDIRBSIZ portion after '-w=' | |
67 rmb DDIRBSIZ additional space | |
68 * Note: copy buffer must come just before the stack | |
1590 | 69 vfybuff rmb 256 verify buffer |
802 | 70 IFGT Level-1 |
71 copybuff rmb 8*1024 8K default buffer for Level 2 | |
72 ELSE | |
73 copybuff rmb 512 512 byte default buffer for Level 1 | |
74 ENDC | |
929
c04528763543
stack/parameter size increased to prevent collisions with memory
boisy
parents:
921
diff
changeset
|
75 rmb STACKSZ+PARMSZ |
0 | 76 size equ . |
200
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
188
diff
changeset
|
77 |
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
188
diff
changeset
|
78 name fcs /Copy/ |
e9ce43cc215e
Made major changes to headers for consistency and identification
boisy
parents:
188
diff
changeset
|
79 fcb edition |
15 | 80 |
802 | 81 SrcPmpt fcc /Ready SOURCE, hit C to continue: / |
82 SrcPmptL equ *-SrcPmpt | |
83 DstPmpt fcc /Ready DESTINATION, hit C to continue: / | |
84 DstPmptL equ *-DstPmpt | |
85 CrRtn fcb C$CR | |
86 IFNE DOHELP | |
87 HlpMsg fcb C$LF | |
88 fcc /Use: Copy [<opts>] <srcpath> [<dstpath>] [<opts>]/ | |
89 fcb C$LF | |
841 | 90 fcc / -a = abort on error/ |
802 | 91 fcb C$LF |
841 | 92 fcc / -p = don't print files copied (use with -w)/ |
802 | 93 fcb C$LF |
841 | 94 fcc / -r = rewrite destination/ |
802 | 95 fcb C$LF |
841 | 96 fcc / -s = single drive copy/ |
802 | 97 fcb C$LF |
1590 | 98 fcc / -v = verify the copy/ |
99 fcb C$LF | |
846 | 100 fcc / -w=<dir> = copy to <dir>/ |
802 | 101 fcb C$LF |
841 | 102 fcc / -x = copy from exec dir/ |
802 | 103 fcb C$CR |
104 HlpMsgL equ *-HlpMsg | |
105 ENDC | |
106 PLIncmp fcc /copy: destination must be complete pathlist/ | |
107 fcb C$CR | |
108 TooMany fcc /copy: must specify output directory if more than 2 files/ | |
109 fcb C$CR | |
110 Copying fcc /copying / | |
111 CopyingL equ *-Copying | |
112 CopyTo fcc / to / | |
113 CopyToL equ *-CopyTo | |
114 Cont fcc !Continue (y/n) ?! | |
115 ContL equ *-Cont | |
116 CantCpy fcc /copy: can't open / | |
117 CantCpyL equ *-CantCpy | |
118 SpcDsh fcc / - / | |
119 SpcDshL equ *-SpcDsh | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
120 |
802 | 121 * +-----------------+ <-- Y (highest address) |
122 * ! ! | |
123 * ! Parameter ! | |
124 * ! Area ! | |
125 * ! ! | |
126 * +-----------------+ <-- X, SP | |
127 * ! ! | |
128 * ! ! | |
129 * ! Data Area ! | |
130 * ! ! | |
131 * ! ! | |
132 * +-----------------+ | |
133 * ! Direct Page ! | |
134 * +-----------------+ <-- U, DP (lowest address) | |
135 * | |
136 * D = parameter area size | |
137 * PC = module entry point abs. address | |
138 * CC = F=0, I=0, others undefined | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
139 |
802 | 140 start pshs u,x |
141 leax <wdest,u | |
142 pshs x | |
143 clrnxt clr ,u+ | |
144 cmpu ,s | |
145 bne clrnxt | |
146 leas 2,s | |
147 puls x,u | |
148 leay copybuff,u point Y to copy buffer offset in U | |
149 stx <parmptr save parameter pointer | |
150 sty <rdbufptr save pointer to buffer | |
151 tfr s,d place top of stack in D | |
152 pshs y save Y on stack | |
153 subd ,s++ get size of space between copybuf and X | |
929
c04528763543
stack/parameter size increased to prevent collisions with memory
boisy
parents:
921
diff
changeset
|
154 subd #STACKSZ+PARMSZ subtract out our stack |
802 | 155 std <bufsiz size of our buffer |
156 lbsr SkipSpcs move past any spaces on command line | |
157 cmpa #C$CR CR? | |
158 lbeq ShowHelp if so, show help | |
159 GetNChr lda ,x+ | |
160 cmpa #C$CR CR? | |
161 lbeq CpyFiles branch if so | |
162 cmpa #'- option? | |
163 beq GetDash | |
164 inc <filecnt must be a file | |
165 lbsr SkipNSpc else go past non-spaces | |
166 ChkDash lbsr SkipSpcs and any following spaces | |
167 bra GetNChr and check for Cr | |
168 GetDash lda #C$SPAC | |
169 sta -1,x | |
170 GetDash2 ldd ,x+ load option char and char following | |
171 anda #$5F | |
172 cmpa #'S single drive copy? | |
173 bne IsItA branch if not | |
174 inc <single | |
175 lbra FixCmdLn | |
176 IsItA cmpa #'A abort option? | |
177 bne IsItP branch if not | |
178 inc <abortflg | |
1590 | 179 lbra FixCmdLn |
802 | 180 IsItP cmpa #'P supress output? |
1590 | 181 bne IsItV branch if not |
182 inc <quiet | |
183 bra FixCmdLn | |
184 IsItV cmpa #'V supress output? | |
802 | 185 bne IsItX branch if not |
1590 | 186 inc <vopt |
802 | 187 bra FixCmdLn |
188 IsItX cmpa #'X execution dir? | |
189 bne IsItW branch if not | |
190 lda #EXEC. else get EXEC. | |
191 sta <srcmode and save as source mode | |
192 bra FixCmdLn | |
193 IsItW cmpa #'W directory specification? | |
194 bne IsItR branch if not | |
195 tst <wopt already specified? | |
196 bne BadOpt show help if so | |
197 cmpb #'= 2nd char =? | |
198 bne BadOpt show help if not | |
199 inc <wopt else tag wopt as specified | |
200 ldb #C$SPAC get space | |
201 stb -$01,x write over w | |
202 stb ,x+ and = sign, inc X to dest dir | |
203 * check for valid char after -w= | |
204 lda ,x | |
205 cmpa #C$SPAC | |
206 lbeq ShowHelp | |
207 cmpa #C$COMA | |
208 lbeq ShowHelp | |
209 cmpa #C$CR | |
210 lbeq ShowHelp | |
211 leay <wdest,u point Y to parameber buffer | |
212 sty <dstfptr save pointer to destination file | |
213 tfr y,d transfer Y to D | |
214 addd #DDIRBSIZ add size | |
215 pshs b,a save updated ptr value | |
216 ldb #C$SPAC get space | |
217 L0339 lda ,x get byte at X | |
218 stb ,x+ store space at X and inc | |
219 sta ,y+ save loaded byte at Y and inc | |
220 cmpy ,s are we at end? | |
221 beq L035D branch if so (buffer too small) | |
222 cmpa #C$SPAC else is char in A a space? | |
223 beq L0350 branch if so | |
224 cmpa #C$COMA coma? | |
225 beq L0350 branch if so | |
226 cmpa #C$CR cr? | |
227 bne L0339 get next byte if not | |
228 L0350 leax -1,x | |
229 sta ,x restore previous A | |
230 lda #PDELIM get pathlist delimiter | |
231 sta -$01,y save slash at end (for building path later) | |
232 sty <wfileptr save pointer for -w pathlist file copying | |
233 leas $02,s kill stack | |
234 lbra ChkDash | |
235 L035D leas $02,s | |
236 ldb #$BF else buffer size too small | |
237 orcc #Carry | |
238 lbra Exit | |
239 IsItR cmpa #'R rewrite? | |
240 bne BadOpt branch if not | |
241 inc <rewrite | |
242 FixCmdLn lda #C$SPAC get space | |
243 sta -$01,x and wipe out option character | |
244 cmpb #'0 | |
245 lblt ChkDash start dash option processing again | |
246 lbra GetDash possibly another option following? | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
247 |
802 | 248 BadOpt puls x |
249 lbra ShowHelp | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
250 |
802 | 251 CopyToW ldx <srcfname get ptr to next file to process |
252 * In case the source file name has a / in it (i.e. /dd/x/y/fname), | |
253 * we go past the file and then back up to either the first / we | |
254 * encounter, or a space (be sure we don't go past parmptr) | |
255 lda ,x | |
256 cmpa #C$CR carriage return? | |
257 lbeq ExitOk yep, no more files | |
258 lbsr SkipNSpc skip over filename | |
259 * X points to first char after file name (space, comma or CR) | |
260 L038B cmpx <parmptr are we at start of command line? | |
261 beq PlugIt2 if so, we can't go further back | |
262 lda ,-x get byte | |
263 cmpa #PDELIM path delimiter? | |
264 beq PlugIt branch if so | |
265 cmpa #C$SPAC space? | |
266 beq PlugIt branch if so | |
267 cmpa #C$COMA comma? | |
268 beq PlugIt branch if so | |
269 bra L038B else get next char | |
270 PlugIt leax 1,x go forward 1 | |
271 PlugIt2 ldy <wfileptr get address past xxxx/ (specified by -w=) | |
823 | 272 lbsr StrCpy copy filename |
802 | 273 std <wfilelen save file length |
274 lda #C$CR get CR | |
275 sta ,y and terminate | |
276 * ldx <wopt | |
277 * stx <wfileptr | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
278 rts |
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
279 |
802 | 280 * At this point options are processed, so we need to start copying files |
281 CpyFiles tst <filecnt we should have at least one file on cmdline | |
282 lbeq ShowHelp if not, exit with error | |
283 ldx <parmptr get our parameter pointer off stack | |
284 lbsr SkipSpcs skip any leading spaces | |
285 tst <wopt -w specified? | |
286 beq L03C5 branch if not | |
287 stx <srcfname else save start of parameter pointer as next file | |
288 clr <single no single option with -w | |
289 L03BE bsr CopyToW copy file at <srcfname to -w buffer | |
290 bra OpenSrc | |
291 * This code handles single file copy (i.e. copy file1 file2) | |
292 * or a single disk copy (i.e. copy -s abc) | |
293 L03C5 lbsr GetSDFl else get source/destination files | |
294 bcc L03D4 branch if we got both ok | |
295 tst <single is this a single drive copy? | |
296 lbne PListErr if not, user didn't specify enough files | |
297 lbcs Exit if error, exit | |
298 * test for right number of files | |
299 L03D4 lda <filecnt get total file count | |
300 cmpa #2 should be no more than two files | |
301 ble OpenSrc | |
302 leax TooMany,pcr | |
303 lbsr WrLine | |
304 lbra ExitOk | |
1645
cc5f6fa1da23
Fixed bug in copy where -v was on by default (should be off) and writemsb/writelsb
boisy
parents:
1590
diff
changeset
|
305 OpenSrc |
cc5f6fa1da23
Fixed bug in copy where -v was on by default (should be off) and writemsb/writelsb
boisy
parents:
1590
diff
changeset
|
306 ldd #$0000 |
cc5f6fa1da23
Fixed bug in copy where -v was on by default (should be off) and writemsb/writelsb
boisy
parents:
1590
diff
changeset
|
307 std <writemsb clear writemsb/lsb |
cc5f6fa1da23
Fixed bug in copy where -v was on by default (should be off) and writemsb/writelsb
boisy
parents:
1590
diff
changeset
|
308 std <writelsb |
cc5f6fa1da23
Fixed bug in copy where -v was on by default (should be off) and writemsb/writelsb
boisy
parents:
1590
diff
changeset
|
309 ldx <srcfname get file to open |
802 | 310 pshs x |
311 lbsr StrLen get length | |
312 std <lstfopln save length | |
313 puls x | |
314 lda #READ. read mode | |
315 ora <srcmode or in any additional modes (i.e. EXEC.) | |
316 stx <lstfopen save pointer to last file open var | |
317 os9 I$Open open source file | |
318 bcc L03FA branch if open ok | |
319 cmpx <srcfname did open go past pathlist? | |
320 bne OpenFail branch if so | |
321 lbsr SkipNSpc else skip over failed filename | |
322 lbsr SkipSpcs and any trailing spaces | |
323 OpenFail stx <srcfname save updated pathlist pointer (points to next file on cmd line) | |
324 lbra ShutDown | |
325 L03FA sta <srcpath save source path | |
326 pshs a save path | |
327 lbsr SkipSpcs destroy any leading spaces | |
328 stx <srcfname and save pointer to next source filename | |
329 lbsr StrLen get length | |
330 std <lstfopln save length | |
331 puls a get path off stack | |
332 leax <fdbufcpy,u point to FD buffer | |
333 ldy #FD.SEG number of bytes | |
334 ldb #SS.FD | |
335 os9 I$GetStt get file's file descriptor | |
336 bcs L041B branch if error | |
337 tst <single single drive copy? | |
338 beq L041B branch if not | |
339 lda [<dstfptr,u] get first char of destination filename | |
340 ldb #E$BPNam prepare for possible error | |
341 cmpa #PDELIM path has leading slash? | |
342 lbne PListErr if not, show error | |
343 L041B lda <srcpath get source path | |
344 leax <optbuf,u point to options buffer | |
345 clrb was: ldb #SS.Opt | |
346 os9 I$GetStt get path options | |
347 lbcs ShutDown branch if error | |
348 lda ,x get device type | |
349 sta <devtyp save | |
2469 | 350 ldb #READ.+WRITE.+EXEC.+PREAD. |
802 | 351 cmpa #DT.RBF rbf device? |
352 bne L0449 branch if not | |
353 pshs u,x save regs | |
354 lda <srcpath get source path | |
355 ldb #SS.Size | |
356 os9 I$GetStt get size | |
357 lbcs ShutDown | |
358 stx <srcflsiz save file size | |
359 stu <srcflsiz+2 | |
360 puls u,x restore regs | |
361 ldb <PD.ATT-PD.OPT,x get source file's attributes | |
362 L0449 stb <srcattr save | |
363 lda #$01 | |
364 lbsr SwapDsk check for single disk copy and prompt if necessary | |
365 L0450 ldx <dstfptr point to destination file | |
366 pshs x | |
367 lbsr StrLen get length | |
368 std <lstfopln save length | |
369 puls x | |
1590 | 370 lda #UPDAT. update mode (in case we have to verify) |
802 | 371 ldb <srcattr get source attributes |
372 stx <lstfopen | |
373 os9 I$Create create file | |
374 bcc L048B branch if create ok | |
375 tst <rewrite rewrite flag set? | |
376 lbeq ShutDown branch if no | |
377 cmpb #E$CEF file already exists? | |
378 lbne ShutDown branch if any other error | |
379 L047A os9 I$Delete delete file first | |
380 lbcs ShutDown branch if error | |
381 bra L0450 else try opening again | |
382 L048B sta <dstpath save destination path | |
383 tst <wopt w option specified? | |
384 beq GetOpts branch iff not | |
385 tst <quiet p option specified? | |
386 bne GetOpts branch if so | |
387 pshs a else save dest path on stack | |
388 leax >Copying,pcr else print 'Copying...' | |
389 ldy #CopyingL | |
390 lbsr WritSOut write it to stdout | |
391 ldx <wfileptr get pointer to file being copied | |
392 ldy <wfilelen get file name length | |
393 lbsr WritSOut print file name | |
394 leax >CopyTo,pcr print ' to ' | |
395 ldy #CopyToL | |
396 lbsr WritSOut write it to stdout | |
397 ldx <dstfptr get pointer to file being copied | |
398 lbsr WrLine print file with CR | |
399 puls a restore dest path | |
400 GetOpts leax <optbuf,u point to option buffer | |
401 clrb was: ldb #SS.Opt | |
402 os9 I$GetStt get options | |
403 lbcs ShutDown branch if error | |
404 ldb ,x get device type | |
405 cmpb #DT.RBF rbf? | |
406 bne CopyLoop if not rbf device, don't get file size or fd seg | |
407 L04B4 lda <devtyp get device type | |
408 cmpa #DT.RBF rbf? | |
409 bne CopyLoop branch if not | |
410 pshs u save our statics ptr | |
411 lda <dstpath else get dest path | |
412 ldb #SS.Size and setstat option | |
413 ldx <srcflsiz get file size of source | |
414 ldu <srcflsiz+2 | |
415 os9 I$SetStt and set dest file to same size | |
416 lbcs ShutDown branch if error | |
417 puls u restore U | |
418 lda <dstpath get dest path | |
419 leax <fdbufcpy,u point to file desc. buffer | |
420 ldy #FD.SEG get size | |
421 ldb #SS.FD | |
422 os9 I$SetStt write src fd seg to dest file | |
423 * Copy loop is here | |
424 CopyLoop ldx <rdbufptr get ptr to read buffer | |
425 clra A = 0 = source prompt if needed | |
426 lbsr SwapDsk check for single disk copy and prompt if so | |
427 lda <srcpath get source path | |
428 ldy <bufsiz get buffer size | |
429 os9 I$Read read it! | |
430 bcs L0558 branch if error | |
431 lda #$01 A = 1 = dest prompt | |
432 lbsr SwapDsk check for single disk copy and prompt if so | |
433 lda <dstpath get dest path | |
434 os9 I$Write write it out! | |
435 lbcs ShutDown branch if error | |
1590 | 436 tst <vopt verify on? |
1645
cc5f6fa1da23
Fixed bug in copy where -v was on by default (should be off) and writemsb/writelsb
boisy
parents:
1590
diff
changeset
|
437 beq chkeof |
1590 | 438 lbsr DoVerify |
439 chkeof lda <srcpath get source path | |
802 | 440 ldb #SS.EOF |
441 os9 I$GetStt are we at end of file? | |
442 bcc CopyLoop branch if not | |
443 cmpb #E$EOF end of file error? | |
444 beq L0561 branch if so | |
445 L0558 cmpb #E$EOF end of file rror? | |
446 bne ShutDown branch if not | |
447 lda #$01 prompt destination flag | |
448 lbsr SwapDsk check for single drive copy and prompt if necessary | |
449 L0561 lda <dstpath get destination path | |
450 os9 I$Close close that file | |
451 bcs ShutDown branch if error | |
452 clr <dstpath else clear dest path | |
453 lda <srcpath get source path | |
454 os9 I$Close close it | |
455 bcs ShutDown branch if error | |
456 clr <srcpath clear src path | |
457 tst <wopt -w specified | |
458 lbeq ExitOk branch if not | |
459 lbra L03BE | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
460 |
802 | 461 * Entry: X = ptr to data to write, Y = length |
462 WritSOut lda #$01 standard out | |
463 os9 I$Write write it | |
0 | 464 rts |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
465 |
802 | 466 PListErr leax >PLIncmp,pcr |
467 bsr WrLine | |
468 bra ExitOk | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
469 |
802 | 470 ShutDown pshs b |
471 lda <srcpath get source path | |
472 beq L05AA branch if none | |
473 os9 I$Close close it | |
474 L05AA lda <dstpath get dest path | |
475 beq L05B1 branch if none | |
476 os9 I$Close close it | |
477 L05B1 clr <srcpath clear source path | |
478 clr <dstpath and destination | |
479 leax >CantCpy,pcr else show can't copy error | |
480 ldy #CantCpyL | |
481 bsr WritSOut write out | |
482 ldx <lstfopen show filename that failed | |
483 ldy <lstfopln get length | |
484 bsr WritSOut | |
485 leax >SpcDsh,pcr | |
486 ldy #SpcDshL | |
487 bsr WritSOut write out | |
488 puls b | |
489 PrintErr os9 F$PErr print error | |
490 tst <wopt -w used? | |
491 beq ExitOk branch if not | |
492 tst <abortflg abort flag set? | |
493 bne ExitOk branch if so | |
494 AskAgain leax >Cont,pcr point to continue prompt | |
495 ldy #ContL get length | |
496 bsr WritSOut write | |
497 clra ADDED +BGP+ | |
498 ldx <rdbufptr get pointer at readbuf | |
499 ldy #$0002 2 bytes | |
500 os9 I$ReadLn read form stdin | |
501 lda ,x get byte at X | |
502 anda #$5F | |
503 cmpa #'Y user wants to continue? | |
504 lbeq L03BE branch if so | |
505 cmpa #'N no? | |
506 beq ExitOk branch if so | |
507 bra AskAgain else ask again | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
508 |
802 | 509 ShowHelp equ * |
510 IFNE DOHELP | |
511 leax >HlpMsg,pcr point to help message | |
512 ldy #HlpMsgL get length | |
513 lda #$02 std error | |
514 os9 I$WritLn write it | |
515 ENDC | |
516 ExitOk clrb clear carry | |
517 Exit os9 F$Exit and exit | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
518 |
802 | 519 * Write line passed in X |
520 WrLine ldy #$00A0 | |
521 WrNBytes lda #$01 | |
522 os9 I$WritLn | |
523 rts | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
524 |
802 | 525 * Prompt User for Source or Destination Disk |
526 SwapDsk tst <single single disk copy? | |
527 beq NoSwap branch if not | |
528 pshs y,x | |
529 L0626 pshs a | |
530 tsta | |
531 bne L0635 | |
532 leax >SrcPmpt,pcr point to source prompt | |
533 ldy #SrcPmptL get size | |
534 bra L063D write it and get input | |
535 L0635 leax >DstPmpt,pcr point to dest prompt | |
536 ldy #DstPmptL get size | |
537 L063D bsr WrNBytes write it | |
538 leax ,-s point to stack for temp buffer | |
539 ldy #$0001 one byte | |
540 clra from std in | |
541 os9 I$Read read byte from user | |
542 lda ,s+ get char | |
543 eora #'C | |
544 anda #$DF | |
545 beq L0657 branch if C | |
546 bsr L065E | |
547 puls a | |
548 bne L0626 | |
549 L0657 bsr L065E | |
550 puls a | |
551 puls y,x | |
552 NoSwap rts | |
553 L065E pshs y,x,a | |
554 lda #$01 | |
555 leax >CrRtn,pcr | |
556 ldy #80 | |
557 os9 I$WritLn | |
558 puls pc,y,x,a | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
559 |
802 | 560 * StrLen |
561 * | |
562 * Entry: | |
563 * X = ptr to string (space, comma or CR terminated) | |
564 * Exit: | |
565 * D = length of string | |
566 * X = ptr to byte after string | |
567 StrLen pshs u | |
568 ldu #$0000 | |
569 StrLenLp lda ,x+ | |
570 cmpa #C$SPAC | |
571 beq StrLenEx | |
572 cmpa #C$COMA | |
573 beq StrLenEx | |
574 cmpa #C$CR | |
575 beq StrLenEx | |
576 leau 1,u | |
577 bra StrLenLp | |
578 StrLenEx tfr u,d | |
579 puls u,pc | |
580 | |
581 * StrCpy | |
582 * | |
583 * Entry: | |
584 * X = ptr to src string | |
585 * Y = ptr to dest string | |
586 * Exit: | |
587 * D = number of bytes copied | |
588 * X = ptr to byte after original string | |
589 * X = ptr to byte after copied string | |
590 StrCpy pshs u | |
591 ldu #$0000 | |
592 CopyFnLp lda ,x+ | |
593 cmpa #C$SPAC | |
594 beq CopyFnEx | |
595 cmpa #C$COMA | |
596 beq CopyFnEx | |
597 cmpa #C$CR | |
598 beq CopyFnEx | |
599 sta ,y+ | |
600 leau 1,u | |
601 bra CopyFnLp | |
602 CopyFnEx tfr u,d | |
603 puls u,pc | |
604 | |
605 * Skip over spaces and commas | |
606 * | |
607 * Entry: | |
608 * X = ptr to string | |
609 * Exit: | |
610 * X = ptr to first non-whitespace char | |
611 * A = non-whitespace char | |
612 SkipSpcs lda ,x+ | |
613 cmpa #C$SPAC | |
614 beq SkipSpcs | |
615 cmpa #C$COMA | |
616 beq SkipSpcs | |
617 leax -1,x | |
618 rts | |
15 | 619 |
802 | 620 * Skip over non-spaces and non-commas |
621 * | |
622 * Entry: | |
623 * X = ptr to string | |
624 * Exit: | |
625 * X = ptr to first non-whitespace char | |
626 * A = non-whitespace char | |
627 SkipNSpc lda ,x+ | |
628 cmpa #C$SPAC | |
629 beq EatOut | |
630 cmpa #C$COMA | |
631 beq EatOut | |
632 cmpa #C$CR | |
633 bne SkipNSpc | |
634 EatOut leax -1,x | |
635 rts | |
636 | |
637 * Get source file in <srcfname and destination file in <dstfptr | |
638 GetSDFl leay <srcfname,u point X to next file pointer | |
639 bsr SrchFile skip white spaces, look for name on cmd line | |
640 bcs L067D branch if end | |
641 inc <srccnt else increment souce count | |
642 leay <dstfptr,u point Y to destination file | |
643 bsr SkipSpcs destroy any leading spaces | |
644 bsr SrchFile skip white spaces, look for name on cmd line | |
645 L067D rts | |
662
1810b051d07e
copy, display and makdir are now improved versions with enhanced
boisy
parents:
200
diff
changeset
|
646 |
802 | 647 * Starting at X, parse for a filename, skipping leading white spaces |
648 SrchFile lda ,x | |
649 cmpa #C$CR CR? | |
650 beq L06A2 branch if so | |
651 stx ,y else store X at Y | |
652 SkipFile bsr SkipNSpc skip non-spaces | |
653 ParseOk clrb clear B | |
654 rts return | |
655 L06A2 tst <srccnt any file specified? | |
656 bne L06AA branch if so | |
657 BadPName ldb #E$BPNam else no source was specified | |
658 coma | |
659 rts | |
660 | |
661 L06AA ldx <srcfname get pointer | |
662 L06AC lda ,x+ get char | |
663 cmpa #C$SPAC space? | |
664 beq L06C4 branch if so | |
665 cmpa #C$COMA comma? | |
666 beq L06C4 branch if so | |
667 cmpa #C$CR carriage return? | |
668 beq L06C4 branch if so | |
669 cmpa #PDELIM pathlist delimiter? | |
670 bne L06AC branch if not | |
671 clr <srccnt else clear file count | |
672 stx ,y and store | |
673 bra L06AC continue parsing | |
674 L06C4 tst <srccnt file count 0? | |
675 beq L06D2 branch if so | |
676 tst <srcmode source mode? (exec or data dir) | |
677 beq BadPName branch if data | |
678 ldx <srcfname else get pointer | |
679 stx ,y save | |
680 bra ParseOk branch | |
681 L06D2 lda -$02,x | |
682 cmpa #PDELIM | |
683 beq BadPName | |
684 bra ParseOk | |
685 | |
1590 | 686 DoVerify |
687 pshs u,y save registers | |
688 ldx <writemsb get 2 msb's of last write | |
689 ldu <writelsb get 2 lsb's of last write | |
690 lda <dstpath get out path number | |
691 os9 I$Seek | |
692 lbcs Exit exit on error | |
693 ldu 2,s get original u back | |
694 leau copybuff,u point to buffer start | |
695 ldd ,s get bytes written | |
696 addd <writelsb add on to current 2 lsb positions | |
697 std <writelsb save them | |
698 ldd ,s get bytes written | |
699 bcc vfy000 skip if no carry | |
700 leax 1,x bump up 2 msb's | |
701 stx <writemsb and save them | |
702 | |
703 vfy000 ldy #$0100 chars to read for verify | |
704 std ,s save it | |
705 tsta did we write more than 255 bytes ? | |
706 bne vfy010 yes...only read 256 | |
707 tfr d,y else xfer amount we did write | |
708 | |
709 vfy010 ldx 2,s get u register | |
710 leax vfybuff,x point to start of verify buffer | |
711 lda <dstpath get output path number | |
712 os9 I$Read read a block in | |
713 lbcs Exit exit on error | |
714 | |
715 vfy020 lda ,u+ get char from in buffer | |
716 cmpa ,x+ get char from out buffer | |
717 bne snderr1 not equal...send write verfiy msg | |
718 leay -1,y decrement read count | |
719 bne vfy020 if more..loop back | |
720 ldd ,s get write count back | |
721 subd #$0100 subtract verify buffer size | |
722 bhi vfy000 if more left...loop back | |
723 puls u,y,pc else restore registers and return | |
724 | |
725 snderr1 leax errmsg1,pcr address of 'write verify failed' msg | |
726 lbsr WrLine send it | |
727 comb set carry | |
728 ldb #$01 set error | |
729 lbra Exit exit | |
730 | |
731 errmsg1 fcb C$BELL | |
732 fcc /Error - write verification failed./ | |
733 fcb C$CR | |
734 | |
802 | 735 emod |
0 | 736 eom equ * |
15 | 737 end |