> COPYROM/src 0.01 " 0.01 05-Feb-2015 J.G.Harston : (#assem(0)::assem(2):sm_table 2FA$="*SAVE "+fname$+" "+~(mcode%+M%)+" "+~O%+" FFFF0000 FFFBBC00" <A$;:A$: F P: Zassem(pass%) d4fname$="COPYROM" : Saved filename n/title$="COPY" : ROM title x:vers$="0.01 (01 Jan 2015)" : ROM version and date 7copy$="(C)J.G.Harston" : Copyright message : ver%=vers$*10  mcode% &4800,L% -1 *OSASCI=&FFE3:OSNEWL=&FFE7:OSWRCH=&FFEE :  pass%=pass% pass%+1 opt%=sm_pass(pass%) [OPT opt% .RomStart BRK:EQUW RelocTable JMP Service $EQUB &82:EQUB Copyright-RomStart  .RomTitle EQUB ver%:EQUS title$ EQUB &00 :EQUS vers$ ".Copyright ,EQUB &00:EQUS copy$ 6 EQUB &00 @: J .Service T)CMP #4:BEQ Serv4 :\ *command ^*CMP #9:BNE NotServ9 :\ Not *Help hLDA (&F2),Y r/CMP #13:BNE Serv9Skip :\ Not *Help |JSR OSNEWL:LDX #0  .Serv9Lp 0LDA RomTitle+1,X :\ Print ROM title 3BNE P%+4:LDA #" " :\ Convert &00 to )CMP #"(":BEQ Serv9Done :\ End at '(' JSR OSWRCH:INX:BNE Serv9Lp .Serv9Done JSR OSNEWL .Serv9Skip  LDA #9  .NotServ9 RTS :  .Serv4 TYA:PHA:DEY:LDX #&FF  .Serv4Lp INX:INY:LDA (&F2),Y &CMP #".":BEQ Serv4Dot 0CMP #"!":BCC Serv4End :8CMP RomTitle+1,X:BEQ Serv4Lp :\ Match with ROM title D- #&20 :\ Change case N8CMP RomTitle+1,X:BEQ Serv4Lp :\ Match with ROM title X.Serv4Quit b-PLA:TAY :\ Restore Y l.Serv4Exit vBLDA #4:RTS :\ Restore A and return unclaimed  .Serv4End "LDA RomTitle+1,X:BNE Serv4Quit DEY  .Serv4Dot 1INY:LDA (&F2),Y :\ Step past '.' 1CMP #" ":BEQ Serv4Dot :\ Skip any spaces : \ (&F2),Y => any parameters :JSR CheckCopyCommand :\ Pre-parse command line : H: R9LDA #0:RTS :\ Claim call and return \: f: p<\ Check command parameters to check for DFS *COPY syntax z<\ ------------------------------------------------------ 3\ Returns A=0 DFS "*COPY d d name" syntax >\ A<>0 Generic "*COPY name name (options)" syntax \ .CheckCopyCommand 4TYA:PHA :\ Save line pointer 9JSR chkdigit:BCS newcopy :\ COPY x x<>digit PHA DJSR chkspc:BCS newcopy1 :\ COPY nxxxx 1st param not drive PLA 4CMP (&F2),Y:BEQ newcopy :\ COPY x y x=y 9JSR chkdigit:BCS newcopy :\ COPY x y y<>digit KJSR chkspc:BCS newcopy :\ COPY n nxxxx 2nd param not drive number BCMP #" ":BCC newcopy :\ COPY x y only two parameters /LDX #2 :\ option count  .loop LDA (&F2),Y $>CMP #"~":BEQ newcopy :\ COPY x y ...~... copy option .DCMP #"*":BEQ oldcopy :\ COPY x y ..*.... wildcard filename 8DCMP #"#":BEQ oldcopy :\ COPY x y ...#... wildcard filename BACMP #".":BEQ oldcopy :\ COPY x y xxx.xxx directory name LCMP #" ":BNE chknext VEDEX:BEQ newcopy :\ COPY x y zzz zzz multiple options `JSR skipspc j .chknext tINY:CMP #13:BNE loop ~ .oldcopy 6PLA:TAY:LDA #0:RTS :\ DFS COPY parameters  .newcopy1 PLA  .newcopy :PLA:TAY:LDA #1:RTS :\ Generic COPY parameters :  .chkspc INY:LDA (&F2),Y 7CMP #" ":BNE chkdigit1 :\ SEC=no following space  .skipspc INY:LDA (&F2),Y CMP #" ":BEQ skipspc @CLC:RTS :\ CLC=follow space, and skipped  :  .chkdigit LDA (&F2),Y (0CMP #"0":BCC chkdigit1 :\ SEC=not a digit 2/CMP #"9"+1:BCC chkdigit2 :\ CLC=is a digit <.chkdigit1 FSEC P.chkdigit2 ZRTS d: n]:RelocTable=P% x: : ݤsm_pass(pass%) pass%=0:M%=0 pass%=1:M%=O%-mcode% P%=&8100-128*(pass%2) O%=mcode%+M%*(pass%2)2 /pass%=1: O%+M%*2.125>L%:"Code overrun": ="4647",pass%+1,1) : sm_table >base80%=mcode%+M%:base81%=mcode%:byte%=0:count%=0:off%=0: Pbyte80%=base80%?off%:byte81%=base81%?off%: off%>=M%:byte80%=&80:byte81%=&80 ] ((byte81%-byte80%) &FE)<>0 "ERROR: Offset by more than one page at &";~&8000+off% M (byte80% &C0)=&80:byte%=byte%2+128*(byte81%-byte80%):count%=count%+1 1 count%=8:?O%=byte%:O%=O%+1:byte%=0:count%=0 $off%=off%+1:off%>=M% count%=0 "