10
20
30 trksz%=10*256
40 DIM ctrl% 31,mem% trksz%-1:X%=ctrl%:Y%=X%DIV256
50 INPUT "Side 1: "in1$
60 INPUT "Side 2: "in2$
70 INPUT "Output: "out$
80 ON ERROR REPORT:PROCClose_All:PRINT:PROCexit(ERR):END
90 in1%=OPENIN(in1$):IFin1%=0:PRINT"File '"in1$"' not found":PROCexit(214):END
100 in2%=OPENIN(in2$):IFin2%=0:PRINT"File '"in2$"' not found":CLOSE#in1%:PROCexit(214):END
110 out%=OPENOUT(out$):IFout%=0:PRINT"Can't open '"out$"'":CLOSE#in2%:CLOSE#in1%:PROCexit(192):END
120 REPEAT:PRINTCHR$13;~PTR#out%;
130 FOR A%=0 TO trksz%-1 STEP 4:mem%!A%=&E5E5E5E5:NEXT
140 IFNOTEOF#in1%:PROCgbpb(4,in1%,mem%,trksz%,0)
150 PROCgbpb(2,out%,mem%,trksz%,0)
160 FOR A%=0 TO trksz%-1 STEP 4:mem%!A%=&E5E5E5E5:NEXT
170 IFNOTEOF#in2%:PROCgbpb(4,in2%,mem%,trksz%,0)
180 PROCgbpb(2,out%,mem%,trksz%,0)
190 UNTILEOF#in1% AND EOF#in2%
200 CLOSE#out%:out%=0
210 CLOSE#in2%:in2%=0
220 CLOSE#in1%:in1%=0
230 PRINTCHR$13;"Done"SPC5:PROCexit(0):END
240 :
250 DEFPROCgbpb(A%,chn%,addr%,num%,ptr%):?X%=chn%:X%!1=addr%:X%!5=num%:X%!9=ptr%:CALL &FFD1:ENDPROC
260 :
270 DEFPROCClose_All
280 in1%=in1%:IFin1%:A%=in1%:in1%=0:CLOSE#A%
290 in2%=in2%:IFin2%:A%=in2%:in2%=0:CLOSE#A%
300 out%=out%:IFout%:A%=out%:out%=0:CLOSE#A%
310 ENDPROC
320 :
330 DEFPROCexit(A%):END