8-Bit Software Online Conversion
Backup Update - Listing
10REM >BACKUP
20REM Backup program
30REM V1.15 28-12-97: More display, t
idier program
40REM V1.16 11-01-98: Countdown count
s down (not up!)
50REM V1.18 20-03-98: Command line pa
rameters
55REM V1.19 01-06-98: Num%OR&20 set
60MODE&87:A$=FNOS`GetEnv:quit$=FNcl("
-q",1):ONERRORREPORT:PRINT:PROCend
70IFFNcl("-?",0):PRINT"Syntax: "run$"
(<src> <dst> (<trks> <sides>) (-s <spt>
) (-t <tries>)":PROCend
80PROCinit:PRINT"BACKUP PROGRAM 1.18.
Buffer size: &";÷maxlen%'
90PROCparams:PROCbackup:PROCend
100END
110:
120DEFPROCinit:*K.10O.|MCLOSE#0:RUN|M
130OSWORD=&FFF1:maxlen%=(HIMEM-LOMEM-3
000)AND&FFFF00
140DIM ctrl%30,data%maxlen%:X%=ctrl%:Y
%=X%DIV256
150ENDPROC
160:
170DEFFNh(A%,N%)=RIGHT$("0000000"+STR$
÷A%,N%)
180DEFPROCDrd(Ad%,Dv%,Sc%,Nm%):PROCdsk
(&53):ENDPROC
190DEFPROCDwr(Ad%,Dv%,Sc%,Nm%):PROCdsk
(&4B):ENDPROC
200:
210DEFPROCdsk(Cmd%):Nm0%=Nm%:A%=&7F:RE
PEAT
220Num%=Nm%DIV256:IFNum%+(Sc%MOD10)>10
:Num%=10-(Sc%MOD10)
230try%=tries%:REPEAT
240?X%=Dv%:X%!1=Ad%:X%?5=3:X%?6=Cmd%:X
%?7=Sc%DIV10:X%?8=Sc%MOD10
250X%!9=Num%OR&20:IFX%?7>79:X%?7=X%?7-
80:?X%=?X% OR 2:REM Side 2
260VDU13:IFCmd%=&53:PRINT"Read "; ELSE
PRINT"Write";
270PRINT" "FNh(Dv%,1)":"FNh(Sc%,6)"+"F
Nh(Nm%DIV256,2)" "FNh(tries%-try%,1)" ";
280CALL OSWORD:Derr%=X%?10:try%=try%-1
:UNTILDerr%=0 OR try%=0
290IFDerr%:PRINTFNerr(Derr%);SPC(39-PO
S);:IFNm%=&100:PRINT
300IFCmd%=&53 ANDDerr%=0:PRINT;read%+N
m0%-Nm%;" bytes read"; ELSE IFCmd%=&4B A
NDDerr%=0 PRINT;write%-Nm0%+Nm%;" bytes
left";
310PRINTSPC(39-POS);:Ad%=Ad%+Num%*256:
Sc%=Sc%+Num%:Nm%=Nm%-Num%*256
320UNTILNm%<1 OR Derr%:ENDPROC
330:
340DEFFNerr(A%):IFA%<&08 ORA%>&18:="Er
ror "+FNh(A%,2)
350=MID$("Clock errorID CRC errorData
CRC errorNot readyWrite protectedTrack 0
not foundSector not found",VALMID$("010
012243847620079",A%-7,2),VALMID$("110012
140915170016",A%-7,2))
360:
370DEFPROCseek
380?X%=Dv%:X%?5=1:X%?6=&69:X%?7=(Sc%DI
V10)AND(Sc%>10)
390CALL OSWORD:ENDPROC
400:
410DEFPROCparams:spt%=VALFNcl("-s",1):
tries%=VALFNcl("-t",1)
420IFLENA$<3:A$="":INPUT"Source drive:
"sdrv%:INPUT"Dest. drive: "ddrv% ELSE s
drv%=VALA$:ddrv%=VALMID$(A$,3):A$=MID$(A
$,5)+" "
430same%=sdrv%=ddrv%:IFsame%:PRINT"Usi
ng same drive."
440IFA$="":INPUT"Number of tracks (80)
"trk%:INPUT"Number of sides (2) "sides%
ELSE trk%=VALA$:sides%=VALMID$(A$,1+LEN
STR$trk%)
450trk%=trk%OR(80AND(trk%=0)):IFsides%
<>1:sides%=2
460IFA$="":INPUT"Sectors/track (10) "s
pt%:INPUT"Number of tries (10) "tries%
470spt%=spt%OR(10AND(spt%=0)):tries%=t
ries%OR(10AND(tries%<2))
480ENDPROC
490:
500DEFPROCbackup
510IF NOTsame% PRINT"Press a key to ba
ckup from :";sdrv%;" to :";ddrv%;:IFGETO
R1 PRINT'
520read%=0:write%=2560*trk%*sides%:FOR
s%=0TO(sides%-1)*2 STEP2
530sect%=0:length%=trk%*2560:REPEAT:nu
m%=maxlen%:IFnum%>length%:num%=length%
540:
550IFsame%:PRINTCHR$13"Insert source d
isk and press a key";:IFGETOR1:PRINTCHR$
13;SPC(39);CHR$13;
560REPEATPROCDrd(data%,sdrv%+s%,sect%,
num%)
570IFDerr%:num%=(num%AND&FFFE00)DIV2
580UNTILDerr%=0 ORnum%<&100:IFnum%<&10
0:num%=&100
590IFDerr%=0 ORnum%=&100:read%=read%+n
um%
600:
610IFsame%:PRINTCHR$13"Insert dest. di
sk and press a key";:IFGETOR1:PRINTCHR$1
3;SPC(39);CHR$13;
620REPEATPROCDwr(data%,ddrv%+s%,sect%,
num%)
630IFDerr%:num%=(num%AND&FFFE00)DIV2
640UNTILDerr%=0 ORDerr%=&12 ORnum%<&10
0:IFnum%<&100:num%=&100
650IFDerr%=0 ORnum%=&100:write%=write%
-num%
660IFDerr%=&12:PRINT'"Destination disk
write protected":length%=0:s%=99
670:
680sect%=sect%+num%DIV256:length%=leng
th%-num%
690UNTILlength%<1 ORDerr%=&12:NEXTs%:P
RINTCHR$13;SPC(39)
700ENDPROC
710:
720DEFFNOS`GetEnv:LOCALA$:A%=0:X%=1:os
%=((USR&FFF4)AND&FF00)DIV256
730IFos%=6ANDPAGE>&8000:LOADATN"OS`Get
Env"TOA$:A$=MID$(A$,1+INSTR(A$," "))
740IFos%=32:A$=$&100
750IFLENA$=0:IF?(TOP-3):A$=$&600 ELSE
IFLENA$=0:A$=$&3800
760A%=INSTR(A$+" "," "):run$=LEFT$(A$,
A%-1):=MID$(A$,A%+1)
770:
780DEFFNcl(l$,n%):IFASCl$=32 AND A$<>"
":A$=" "+A$
790I%=INSTR(A$,l$):l$="":IFI%>0ANDn%>0
:l$=MID$(A$,INSTR(A$," ",I%+1)+1):IFMID$
(A$,I%,1)<>" ":l$=LEFT$(l$,INSTR(l$," ")
-1)
800IFI%:IFMID$(A$,I%,1)=" ":A$=MID$(A$
,2+(ASCA$<>32),I%-1+(ASCA$=32)) ELSE IFI
%:A$=LEFT$(A$,I%-1)+MID$(A$,INSTR(A$," "
,INSTR(A$," ",I%)+LENl$)+1)
810IFn%:=l$ ELSE =I%<>0
820:
830DEFPROCos(A$):IFA$=""ORASCA$=42:OSC
LIA$:ENDPROC ELSE CHAINA$:ENDPROC
840:
850DEFPROCend
860IFquit$<>"":A$=quit$:quit$="":PROCo
s(A$):END
870END:ENDPROC