Post Reply 
41-MCODE: Copying X-Mem Files
03-14-2014, 06:37 AM (This post was last modified: 03-14-2014 06:39 AM by Ángel Martin.)
Post: #2
RE: 41-MCODE: Copying X-Mem Files
Because ASCII files are structured in Records, it's possible that the previous code messes up the destination file when both file sizes are not the same: it will copy registers until reaching the minimum of both sizes, which may leave out an EOR character for the last register.

Here's a safer version that requires both files having the same size - you can choose which one suits you better. Use it safely for all file types, like-to-like and same sizes.

Code:

08C    "L"    
006    "F"    
00D    "M"    Copy X-Mem File
019    "Y"    " Source,Destination"  in ALPHA
010    "P"    Both Files must exist
003    "C"    Ángel Martin
03E    B=0 MS    wildcard type!
0A5    ?NC XQ    Does [GTFLNA] and [RFLSCH]
0E8    ->3A29    [FLSHAC]
046    C=0 S&X    
270    RAMSLCT    select chip0
0B0    C=N  ALL    Source File Header
268    WRIT 9(Q)    saved in rg.9(Q)
3E9    ?NC XQ    Get Text after comma (!)
0D0    ->34FA    [ALNAM2]
008    SETF 3    tweak the settings
281    ?NC XQ    General File Search
0F0    ->3CA0    [EFLSCH]
38C    ?FSET 0    not found?
0B5    ?NC GO    nope, say so!
0F6    ->3D2D    [FLNOFN]
046    C=0 S&X    
270    RAMSLCT    select chip0
0B0    C=N ALL    Dest File Header
0AE    A<>C ALL    move to A
278    READ 9(Q)    Source File Header
37E    ?A#C MS    different types?
089    ?C XQ    File Type Error
0F5    ->3D22    [FTPER]
244    CLRF 9    equal sizes
366    ?A#C S&X    different?
063    JNC +12d    no, skip error
20D    ?NC XQ    yes, show error
0FC    ->3F83    [APERMSG]
006    "F"    
00C    "L"    
020    " "    MSG: : FL SIZE"
013    "S"    
009    "I"    
01A    "Z"    
205    "E"    
1D9    ?NC GO    
0FE    ->3F76    [DISERR]
158    M=C ALL    Source Header
0AE    A<>C ALL    
070    N=C ALL    DestInation header
198    C=M ALL    source file counters
0FC    RCR 10    rotate file addr to C[S&X]
10E    A=C ALL    prepare it as input
00D    ?NC XQ    Get next register adr
0D0    ->3403    [NXREG]
0A6    A<>C S&X    reg to C[S&X]
270    RAMSLCT    select it
0A6    A<>C S&X    rebuild A
038    READATA    get reg value
0EE    B<>C ALL    save in B
0AE    A<>C ALL    
07C    RCR 4    
158    M=C ALL    Update source counter
0B0    C=N ALL    Dest file register
0FC    RCR 10    rotate file addr to C[S&X]
10E    A=C ALL    prepare it as input
00D    ?NC XQ    Get next register adr
0D0    ->3403    [NXREG]
0A6    A<>C S&X    reg to C[S&X]
270    RAMSLCT    select it
0A6    A<>C S&X    rebuild A
0EE    B<>C ALL    reg value!
2F0    WRITDATA    copy to destination
0AE    A<>C ALL    
07C    RCR 4    
266    C=C-1 S&X    decrease size count
070    N=C ALL    update destination counter
266    C=C-1 S&X    last one?
323    JNC -28d    no, do next
3E0    RTN

Cheers,
'AM

PS. I tried to attach the RAMPAGE ROM image but it appears that file type isn't allowed any longer, ditto with MOD files - is that intended?

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: 41-MCODE: Copying X-Mem Files - Ángel Martin - 03-14-2014 06:37 AM



User(s) browsing this thread: 2 Guest(s)