CpcAlive est un
environnement
de programmation
compatible
Amstrad CPC
pour création
d'animations
 graphiques.




Z80 opcodes et programmation

SmallAsm est un assembleur Z80
pour Dos


Les mots clés du basic Cpc

Les messages d'erreur du basic Cpc

La mémoire

La gestion des disquettes


Installateur CpcAlive pour
Windows & pour DosBox


Documentation CpcAlive






English

* Merge multiple files into one file *
(CpcAlive for Dosbox)


BAS: <- file header for the emulator CpcAlive
/* Merge multiple files into one file */
gosub Init

|OUTPUT,"Result",@er%:'name of file result
if er%<>0 then OFileEr

FilePointer=0:'start pointer first file
FileName$="FileName1":'name of first file to merge
gosub FileMerge
FilePointer=0:'start pointer second file
FileName$="FileName2":'name of second file to merge
gosub FileMerge
'...

|OUTPUT,":CLOSE":'close file result
|exit,"successful operation"

FileMerge:
DataSize=-1:'init while loop
while DataSize<>0
    '|INPUT,"FileName:D,BufSize,FilePointer,BufStart",@error_code
    |INPUT,FileName$+":D,&"+HEX$(BufSize)+","+DEC$(FilePointer,"########")+",&"+HEX$(BufStart),@er%
    if er%<>0 then IFileEr
    |INFO,@info$:DataSize=val("&"+mid$(info$,13,4)):'size of data block loaded
    poke SizeAdr1,DataSize:'new ChainSize
    poke SizeAdr2,DataSize:'new ChainSize
    PRINT#8,Buffer$;'output buffer in file result
    PRINT FileName$,FilePointer,DataSize
    FilePointer=FilePointer+DataSize
wend
return

Init:
mode 2:er%=0:info$=STRING$(16,"X"):'infos from |INPUT command
BufSize=255:Buffer$=STRING$(BufSize,"X"):'this string is used to be the I\O buffer
SizeAdr1=@Buffer$:'ChainSize pointer 1
BufStart=peek(SizeAdr1+1)+256*peek(SizeAdr1+2):'address of first character of Buffer$
SizeAdr2=BufStart-2:'ChainSize pointer 2
return

//I/O error messages
IFileEr:
        if er%=1 then |exit,"Input error: parameters error"
        if er%=2 then |exit,"Input error: file not found"
        if er%=3 then |exit,"Input error: directory or file not found"
        if er%=4 then |exit,"Input error: no more Dos handle"
        if er%=5 then |exit,"Input error: refused access"
        |exit,"Input file error"
OFileEr:
        if er%=2 or er%=5 then |exit,"Output error: refused access"
        if er%=3 then |exit,"Output error: directory not found"
        if er%=4 then |exit,"Output error: no more Dos handle"
        |exit,"Output file error"