# HG changeset patch # User boisy # Date 1042412890 0 # Node ID 3a308921e1351e41dd701863d4963d64ce0fa03a # Parent e3a18315da101b139719157159be14b7dc0e3383 New version of copy with OSK like features diff -r e3a18315da10 -r 3a308921e135 level1/cmds/copy.asm --- a/level1/cmds/copy.asm Sun Jan 12 17:25:32 2003 +0000 +++ b/level1/cmds/copy.asm Sun Jan 12 23:08:10 2003 +0000 @@ -5,315 +5,662 @@ * * Ed. Comments Who YY/MM/DD * ------------------------------------------------------------------ -* 10 Reworked RML +* 9 From Tandy OS-9 Level One VR 02.00.00 +* 10 Reworked RML +* 11 Added useful options, made more robust BGP 03/01/11 nam Copy ttl File copy utility -* Edition 10 rewrite 10/28/88 - RML - - ifp1 + ifp1 use defsfile use rbfdefs - endc + endc -tylg set Prgrm+Objct +* Tweakable options +DOHELP set 1 + +tylg set Prgrm+Objct atrv set ReEnt+rev rev set $01 -edition set 10 +edition set 11 mod eom,name,tylg,atrv,start,size -inpath rmb 1 input path number -outpath rmb 1 output path number -indevtyp rmb 1 input device type (1 = RBF) -verify rmb 1 verify on/off (1=on) -bufsize rmb 2 read/write buffer size -fsizemsb rmb 2 msb's of file size -fsizelsb rmb 2 lsb's of file size -writemsb rmb 2 msb's of bytes written to output -writelsb rmb 2 lsb's of bytes written to output -single rmb 1 single drive copy flag (1=yes) -attribs rmb 1 file attributes -fdbuff rmb 16 File Descriptor buffer -optbuff rmb 32 Path Descriptor Options Buffer -stack rmb 448 stack storage -vfybuff rmb 256 verify buffer -buffer rmb $2000-. read/write buffer (minimum..will expand with mem mod) +STCKSIZE equ 64 our stack size +DDIRBSIZ equ 64 destination directory buffer size + + org 0 +rdbufptr rmb 2 +parmptr rmb 2 +srcpath rmb 1 +dstpath rmb 1 +devtyp rmb 1 +bufsiz rmb 2 +srcflsiz rmb 4 +abortflg rmb 1 +quiet rmb 1 +single rmb 1 +rewrite rmb 1 +filecnt rmb 1 +srccnt rmb 1 +srcmode rmb 1 +wopt rmb 1 +srcfname rmb 2 +dstfptr rmb 2 +wfileptr rmb 2 +wfilelen rmb 2 +lstfopen rmb 2 pointer to name of last file attempted open +lstfopln rmb 2 length of last file atteppted open +srcattr rmb 1 +fdbufcpy rmb 16 +optbuf rmb 32 +wdest rmb DDIRBSIZ portion after '-w=' + rmb DDIRBSIZ additional space +* Note: copy buffer must come just before the stack + IFGT Level-1 +copybuff rmb 8*1024 8K default buffer for Level 2 + ELSE +copybuff rmb 512 512 byte default buffer for Level 1 + ENDC +stack rmb STCKSIZE size equ . name fcs /Copy/ fcb edition -start leas vfybuff,u set stack pointer to 512 - pshs u save u reg - leau ] [] []/ + fcb C$LF + fcc / -a abort on error/ + fcb C$LF + fcc / -p don't print file nammes copied (with -w option only)/ + fcb C$LF + fcc / -r rewrite destination/ + fcb C$LF + fcc / -s single drive copy/ + fcb C$LF + fcc / -w= copy files to / + fcb C$LF + fcc / -x look in execution directory for source/ + fcb C$CR +HlpMsgL equ *-HlpMsg + ENDC +PLIncmp fcc /copy: destination must be complete pathlist/ + fcb C$CR +TooMany fcc /copy: must specify output directory if more than 2 files/ + fcb C$CR +Copying fcc /copying / +CopyingL equ *-Copying +CopyTo fcc / to / +CopyToL equ *-CopyTo +Cont fcc !Continue (y/n) ?! +ContL equ *-Cont +CantCpy fcc /copy: can't open / +CantCpyL equ *-CantCpy +SpcDsh fcc / - / +SpcDshL equ *-SpcDsh -getopt lda ,x+ get a char - cmpa #'- was it a '-'?? - beq chkopt yes..go check opt - cmpa #C$CR was it a ?? - bne getopt no..check next char - bra openin else done..go finish processing - -chkopt ldd ,x+ get next 2 chars - eora #'S check if its an S - anda #$DF make upper case - lbne sndinstr not an s.. send instructions - cmpb #$30 else check if next char is number or letter - lbhs sndinstr yup...send instructions - inc Copying,pcr else print 'Copying...' + ldy #CopyingL + lbsr WritSOut write it to stdout + ldx CopyTo,pcr print ' to ' + ldy #CopyToL + lbsr WritSOut write it to stdout + ldx PLIncmp,pcr + bsr WrLine + bra ExitOk -chkdrive tst CantCpy,pcr else show can't copy error + ldy #CantCpyL + bsr WritSOut write out + ldx SpcDsh,pcr + ldy #SpcDshL + bsr WritSOut write out + puls b +PrintErr os9 F$PErr print error + tst Cont,pcr point to continue prompt + ldy #ContL get length + bsr WritSOut write + clra ADDED +BGP+ + ldx HlpMsg,pcr point to help message + ldy #HlpMsgL get length + lda #$02 std error + os9 I$WritLn write it + ENDC +ExitOk clrb clear carry +Exit os9 F$Exit and exit -srcmsg fcc /Ready SOURCE/ -srcmsgsz equ *-srcmsg +* Write line passed in X +WrLine ldy #$00A0 +WrNBytes lda #$01 + os9 I$WritLn + rts -dstmsg fcc /Ready DESTINATION/ -dstmsgsz equ *-dstmsg - -cntmsg fcc /, hit C to continue: / -cntmsgsz equ *-cntmsg - - -snddst leax dstmsg,pcr point to 'destination' msg - ldy #dstmsgsz chars to send +* Prompt User for Source or Destination Disk +SwapDsk tst SrcPmpt,pcr point to source prompt + ldy #SrcPmptL get size + bra L063D write it and get input +L0635 leax >DstPmpt,pcr point to dest prompt + ldy #DstPmptL get size +L063D bsr WrNBytes write it + leax ,-s point to stack for temp buffer + ldy #$0001 one byte + clra from std in + os9 I$Read read byte from user + lda ,s+ get char + eora #'C + anda #$DF + beq L0657 branch if C + bsr L065E + puls a + bne L0626 +L0657 bsr L065E + puls a + puls y,x +NoSwap rts +L065E pshs y,x,a + lda #$01 + leax >CrRtn,pcr + ldy #80 + os9 I$WritLn + puls pc,y,x,a -msgsnd lda #1 std out - os9 I$Write write it - leax cntmsg,pcr point to 'hit C ...' - ldy #cntmsgsz get size of message - os9 I$Write write it - leax ,-s back up for dummy buffer - ldy #1 chars to read - clra std in - os9 I$Read read one char - lda ,s+ - pshs y,x,a save registers - leax crmsg,pcr point to - bsr sndline write it - puls y,x,a restore registers - eora #'C check if its a C - anda #$DF make it upper case - puls a restore drive status - bne sndsrc loop back & send message - puls y,x restore registers -msgrts rts +* StrLen +* +* Entry: +* X = ptr to string (space, comma or CR terminated) +* Exit: +* D = length of string +* X = ptr to byte after string +StrLen pshs u + ldu #$0000 +StrLenLp lda ,x+ + cmpa #C$SPAC + beq StrLenEx + cmpa #C$COMA + beq StrLenEx + cmpa #C$CR + beq StrLenEx + leau 1,u + bra StrLenLp +StrLenEx tfr u,d + puls u,pc + +* StrCpy +* +* Entry: +* X = ptr to src string +* Y = ptr to dest string +* Exit: +* D = number of bytes copied +* X = ptr to byte after original string +* X = ptr to byte after copied string +StrCpy pshs u + ldu #$0000 +CopyFnLp lda ,x+ + cmpa #C$SPAC + beq CopyFnEx + cmpa #C$COMA + beq CopyFnEx + cmpa #C$CR + beq CopyFnEx + sta ,y+ + leau 1,u + bra CopyFnLp +CopyFnEx tfr u,d + puls u,pc + +* Skip over spaces and commas +* +* Entry: +* X = ptr to string +* Exit: +* X = ptr to first non-whitespace char +* A = non-whitespace char +SkipSpcs lda ,x+ + cmpa #C$SPAC + beq SkipSpcs + cmpa #C$COMA + beq SkipSpcs + leax -1,x + rts -Help fcc /Use: Copy [-s]/ - fcb C$LF - fcc / -s = single drive copy/ - fcc / (Path2 must be complete pathlist)/ - fcb C$CR -crmsg fcb C$CR +* Skip over non-spaces and non-commas +* +* Entry: +* X = ptr to string +* Exit: +* X = ptr to first non-whitespace char +* A = non-whitespace char +SkipNSpc lda ,x+ + cmpa #C$SPAC + beq EatOut + cmpa #C$COMA + beq EatOut + cmpa #C$CR + bne SkipNSpc +EatOut leax -1,x + rts + +* Get source file in