home *** CD-ROM | disk | FTP | other *** search
AMOS Source Code | 1993-06-16 | 21.4 KB | 801 lines |
- ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- '
- ' BOOT DISK MAKER V2.0
- '
- ' by Jean-Baptiste Bolcato
- '
- ' Trackdisk procedures
- ' by Francois Lionet
- '
- ' (c) 1993 Europress Software Ltd.
- '
- ' ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- ' --- Inits ---
-
- Break Off
-
- Dim F$(32)
- Global DB$
- Global XSLI,YSLI,SXSLI,SYSLI,MSLI
- Global COMP$,SRCE$,DEST$
- Global F$(),NF,NF_DONE,NF_MAX
-
- ' max buffered files/directory
- NF_MAX=32
-
- Resource Screen Open 1,64,16,0 : Screen Hide 1
- Resource Screen Open 0,640,144,0 : Screen Hide 0
- Screen Display 0,,88+28*(Ntsc=True),,
- Palette 0,0,0,0,0,0,0,0
- Paper 6 : Pen 7
-
- _INIT_DIALOG
- Dialog Open 1,DB$
- Screen Show 0
-
- ' --- Main Loop ---
-
- Do
-
- X=Free
-
- D=Dialog Run(1,1)
- Fade 2 To 1 : Wait 30
-
- ' --- choose compiled program ---
-
- Do
- COMP$=Fsel$("**","",Resource$(10),Resource$(11))
- Trap Open In 1,COMP$
- If Errtrap=0
- L=Lof(1)
- Close 1
- Trap Reserve As Work 10,L
- If Errtrap=0
- Trap Bload COMP$,Start(10)
- If Errtrap=0
- COMP$=Right$(COMP$,Len(COMP$)-Len(Dir$))
- Exit
- End If
- End If
- End If
- _WARN[2,Resource$(21)]
- If Param=1
- Exit 2
- End If
- Loop
-
- ' --- disk copy ---
-
- _WARN[2,Resource$(17)]
- _VERIFY=(Param=2)
- _DISK_COPY["AMOSPro_System (v2.0 or over)",_VERIFY]
- If Param=0
-
- ' --- remove unecessary files ---
-
- Print At(5,7);Space$(70);
- Centre Resource$(34)
- Set Dir 32,""
- _REMOVE[DEST$+"APSystem/",1]
- _REMOVE[DEST$+"Install_Data/",1]
- _REMOVE[DEST$+"Extra_Configs/",1]
- _REMOVE[DEST$,0]
-
- ' --- write back compiled program ---
-
- Print At(5,7);Space$(70);
- Centre Resource$(35)
- Trap Bsave DEST$+COMP$,Start(10) To Start(10)+Length(10)
- If Errtrap
- _WARN[3,Resource$(23)]
- Else
-
- ' --- write turbo-startup-sequence ---
-
- Print At(5,7);Space$(70);
- Centre Resource$(36)
- Trap Open Out 1,DEST$+"s/startup-sequence"
- If Errtrap=0
- Print #1,"Run >Nil: "+COMP$;Chr$(10);
- Print #1,"EndCli >Nil: ";Chr$(10);
- Close 1
- _WARN[1,Resource$(38)]
- _WARN[2,Resource$(37)]
- Exit If Param<>2
- Else
- _WARN[3,Resource$(23)]
- End If
- End If
- End If
-
- Loop
-
- Fade 1 : Wait 15
- Screen Close 0
- Screen Close 1
- Erase 10
- End
-
- ' --- Procedures ---
-
- Procedure _INIT_DIALOG
-
- Resource Bank 16
-
- Restore DBL
- Repeat
- Read A$ : DB$=DB$+A$
- Until A$=""
-
- ' Definition of quick-run dialog boxes
- DBL:
- Data "SIze 1VA TW 48+ SW MIn,72;"
- Data "BAse SWidth SX- 2/,SHeight SY- 2/;"
- Data "SAve 1;"
- Data "RB 0,0,SX,SY,0;"
- Data "RB 16,8,SX16-,24,0;"
- Data "POut 20MECX,12,20ME,0,7;"
- Data "PR 1VACX,32,1VA,3;"
- ' One button OK
- Data "IF 0VA 1=;"
- Data "["
- Data "BJ 1,SX 96- 2/,SY24-,96,3ME; KY 13,0;"
- Data "]"
- ' Two buttons OK CANCEL
- Data "IF 0VA 2=;"
- Data "["
- Data "BJ 1,16,SY24-,96,4ME; KY 27,0;"
- Data "BJ 2,SX112-,SY24-,96,3ME; KY 13,0;"
- Data "]"
- ' One Button CANCEL
- Data "IF 0VA 3=;"
- Data "["
- Data "BJ 1,SX 96- 2/,SY24-,96,4ME; KY 27,0;"
- Data "]"
- ' Two buttons RETRY CANCEL
- Data "IF 0VA 4=;"
- Data "["
- Data "BJ 1,16,SY24-,96,4ME; KY 27,0;"
- Data "BJ 2,SX112-,SY24-,96,5ME; KY 13,0;"
- Data "]"
- Data "RUn 0,3; EXit;"
-
-
- ' Definition of Welcome Screen
- Data "LA 1:"
- Data "BAse 0,0; SIze SW,SH;"
- Data "RB 0,0,SX,SY,0;"
- Data "RB 16,8,SX16-,SY8-,0;"
- Data "RB 160,16,SX160-,40,0;"
- Data "PO 1MECX,24,1ME,7,0;"
- Data "RB 32,48,SX32-,SY16-,0;"
- Data "EXit;"
-
-
- ' Installing... Slider screen
- Data "LAbel 2:"
- Data "BAse 32,48; SIze SW64-,SH64-;"
- Data "BOx 0,0,1,SX,SY;"
- Data "SV 4,16; "
- Data "SV 0,16; SV1,24; SV2,SX32-; SV3,36;"
- Data "BOx 0VA,1VA,67,0VA2VA+,1VA3VA+;"
- Data "PR XB40-,1VA3VA+4+,'100 %',7; PR 0VA,1VA3VA+4+,'0 %',7;"
- Data "KY 27,0;"
- Data "EXit;"
-
-
- ' User instructions
- '---------------------------------------
-
- Data "UI PP,2;["
- Data "PR P1MECX,P2,P1ME,7;]"
-
- ' *** temporaire!!! - a changer en PP si 'text' en ME resource$
-
- Data "UI PQ,2;["
- Data "PR P1CX,P2,P1,7;]"
-
- '----------------------------------------
- ' Text in a RBox, on the left
- ' RC x,y,sx,sy,act,txt
- Data "UI RC,6;["
- Data "RB P1,P2,P1P3+,P2P4+,P5;SW0;"
- Data "PR 6P1+,P4TH-2/ P2+,P6,3;"
- Data "]"
-
- ' --------------------------------
- ' List Slider: draw a list + a slider, linked together
- ' LS zone,x1,y1,x2,y2,flags
- Data "UI LS,6; ["
- Data "VLine P2,P3,76,P5;"
- Data "BOx XB,YA,67,P4,P5;"
- Data "SZone P1;"
- Data "VSlide P1,P2 8+,P3 4+,8,P5 P3- 8-,P1VA,P5 P3- 8- 8/,1P1+VA AS,1;[ZChange ZNum 1+,ZPos;]"
- Data "AList P1 1+,P2 48+,P3 6+,P4 P2- 64- 8/,P5 P3- 8- 8/,1P1+VA,P1VA,P6,2,3;[]"
- Data "XY P2,P3,P4,P5;]"
-
- '----------------------------------------
- ' One button, with text, click only
- ' BT zone,x,y,sx,text
- Data "UI BT,5; ["
- Data "SZone P5;"
- Data "BU P1,P2,P3,P4,16,0,0,1;"
- Data " [LIne 0,0,88 3BP*+,SX;SW0;"
- Data " PR ZV CX BP+,16 TH- 2/ BP+,ZV,3;]"
- Data " [BR 0;]"
- Data "]"
-
- '----------------------------------------
- ' ??? � effacer si pas label25 ?
- Data "UI BI,4;["
- Data "PR P2 32+,P3 2+,P4ME,3; SV 0,P2 272+; PR 0VA,YA,P1VA#,3; PR XA72+,YA,76ME,3;"
- Data "BU P1,P2,P3,24,12,6P1+VA,0,1;[UN 0,0,15BP+;][SV ZN 6+,BP;]"
- Data "XY P2,P3,P2,P3 12+;]"
-
- '----------------------------------------
- ' One button, with text, click only, QUIT!
- ' BJ zone,x,y,sx,text
- Data "UI BJ,5; ["
- Data "SZone P5;"
- Data "BU P1,P2,P3,P4,16,0,0,1;"
- Data " [LIne 0,0,88 3BP*+,SX;SW0;"
- Data " PR ZV CX BP+,16 TH- 2/ BP+,ZV,3;]"
- Data " [BR 0;BQuit;]"
- Data "]"
-
- '----------------------------------------
- ' Box definition
- ' RB x1,y1,x2,y2,activated
- Data "UI RB,5; ["
- Data "BOx P1,P2,1P5 78*+,P3,P4;]"
- Data "]"
- Data ""
-
- End Proc
- Procedure _WARN[REQ,W$]
- Trap D=Dialog Box(DB$,REQ,W$)
- If Errtrap : XSLI=Errtrap : End : End If
- End Proc[D]
- Procedure _INIT_SLIDER[M,A,B]
- Set Slider A,A,A,0,B,B,B,0
- XSLI=Vdialog(1,0)+10+32 : YSLI=Vdialog(1,1)+5+48
- SXSLI=Vdialog(1,2)-20 : SYSLI=Vdialog(1,3)-11
- MSLI=M : _SLIDER[0]
- End Proc
- Procedure _SLIDER[P]
- P=Min(P,MSLI)
- Hslider XSLI,YSLI To XSLI+SXSLI,YSLI+SYSLI,MSLI,0,P
- End Proc
- Procedure _DISK_COPY[S$,_VERIFY]
-
- Global _TDTRACKS,_TDB
-
- D=Dialog Run(1,2)
-
- SWP=False
- SRCE=0 : SRCE$="df0:"
- DEST=0
- Repeat
- Inc DEST
- Until Drive("df"+Right$(Str$(DEST),1)+":") or DEST=4
- If DEST=4
- DEST=0
- SWP=True
- End If
- DEST$="df"+Right$(Str$(DEST),1)+":"
-
- ' One drive copy
-
- If SWP=True
-
- E=1
- _TRACK_OPEN[0,SRCE]
- _INIT_SLIDER[_TDTRACKS-1,2,4]
- _TD=0
- Repeat
- _DISK_BUSY[SRCE,False]
- While Not Exist(SRCE$+"APsystem/")
- _WARN[2,Resource$(12)+Resource$(16)+S$+Resource$(13)+SRCE$]
- If Param=1 : E=2 : Exit 2 : End If
- Wend
- _DISK_BUSY[SRCE,True]
- For T=_TD To _TDTRACKS-1
- _SLIDER[T]
- Print At(32,7);Resource$(30);T;" "
- _TRACK_READ[0,T]
- If Param : _WARN[3,Resource$(22)] : Exit 2 : End If
- _TRACK_STORE[0,T]
- Exit If Param or(Chip Free+Fast Free<100000)
- Next T
- _TD2=T
-
- _WARN[2,Resource$(12)+Resource$(14)+Resource$(13)+DEST$]
- If Param=1 : E=2 : Exit : End If
-
- For T=_TD To _TD2-1
- _SLIDER[T]
- Print At(32,7);Resource$(31);T;" "
- _TRACK_USTORE[0,T]
- _TRACK_FORMAT[0,T]
- If Param : _WARN[3,Resource$(23)] : Exit 2 : End If
- If _VERIFY
- Print At(32,7);Resource$(32);T;" "
- _TRACK_VERIFY[0,T]
- If Param
- _WARN[4,Resource$(25)]
- If Param=2
- Exit 2
- Else
- T=T-1
- End If
- End If
- End If
- Next T
- E=0
- _TD=_TD2-1
- _TRACK_FREE
-
- Until _TD2=_TDTRACKS
-
- _TRACK_FREE
- _TRACK_CLOSE[0]
- _DISK_BUSY[0,False]
-
- Else
-
- ' Two drives copy
-
- While Not Exist(SRCE$+"APsystem/")
- _WARN[2,Resource$(12)+Resource$(16)+S$+Resource$(13)+SRCE$]
- If Param=1 : E=2 : Goto FINISH_DISKCOPY : End If
- Wend
-
- _WARN[2,Resource$(12)+Resource$(15)+Resource$(13)+DEST$]
- If Param=1 : E=2 : Goto FINISH_DISKCOPY : End If
-
- _TRACK_OPEN[0,SRCE]
- _DISK_BUSY[SRCE,True]
- _TRACK_OPEN[1,DEST]
- _DISK_BUSY[DEST,True]
- _INIT_SLIDER[_TDTRACKS-1,2,4]
-
-
- E=1
- For T=0 To _TDTRACKS-1
- _SLIDER[T]
- Print At(32,7);Resource$(30);T;" "
- _TRACK_READ[0,T]
- If Param : _WARN[3,Resource$(22)] : Exit : End If
- Print At(32,7);Resource$(31);T;" "
- Copy Start(_TDB),Start(_TDB)+Length(_TDB) To Start(_TDB+1)
- _TRACK_FORMAT[1,T]
- If Param : _WARN[3,Resource$(23)] : Exit : End If
- If _VERIFY
- Print At(32,7);Resource$(32);T;" "
- _TRACK_VERIFY[0,T]
- If Param
- _WARN[4,Resource$(25)]
- If Param=2
- Exit
- Else
- T=T-1
- End If
- End If
- End If
- Next T
- E=0
-
- _TRACK_FREE
- _TRACK_CLOSE[0]
- _DISK_BUSY[SRCE,False]
- _TRACK_CLOSE[1]
- _DISK_BUSY[DEST,False]
-
- End If
-
- FINISH_DISKCOPY:
-
- If E
- If E=2
- A$=Resource$(25)
- Else
- A$=Resource$(26)
- End If
- _WARN[1,A$]
- Else
- Print At(32,7); : Centre " "+Resource$(33)+" "
- End If
-
- End Proc[E]
- Procedure _REMOVE[DR$,RECUR]
-
- If Exist(DR$)
- A$=Dir First$(DR$+"**")
- While A$<>""
- B$=DR$+(Mid$(A$,2,31)-" ")
- If Left$(A$,1)="*"
- If RECUR
- _REMOVE[B$+"/**",RECUR]
- Trap Kill B$
- End If
- Else
- Trap Kill B$
- End If
- A$=Dir Next$
- Wend
- If Right$(DR$,1)="/"
- Trap Kill Left$(DR$,Len(DR$)-1)
- End If
- End If
-
- End Proc
-
- Procedure _DISK_BUSY[S,D]
- '--------------------------------------------------------------- DISK_BUSY
- ' This procedure calls the disk validator, and tell it not to
- ' check the floppy any more.
- ' _DISK_BUSY[drive,flag]
- ' Where: drive= the number of the drive, 0=DF0:, 1=DF1: 2=DF2
- ' flag= True: turns the drive into busy
- ' False: turns the drive back to normal
- ' You should ALWAYS call DISC_BUSY before modifying anything on the floppy.
-
- D$="Df"+Chr$(48+S)+":"+Chr$(0)
-
- Dreg(1)=Varptr(D$) : DEV=Doscall(Lvo("DeviceProc"))
-
- If DEV
-
- Areg(1)=0 : TSK=Execall(Lvo("FindTask"))
- PRT=TSK+Equ("pr_MsgPort")
-
- _RESFREEBANK[Equ("dp_SIZEOF")] : B=Param : S=Start(B)
- PKT=S+Equ("sp_Pkt") : MSG=S+Equ("sp_Msg")
- Struc(MSG,"LN_NAME")=PKT
- Struc(PKT,"dp_Link")=MSG
- Struc(PKT,"dp_Port")=PRT
- Struc(PKT,"dp_Type")=Equ("ACTION_INHIBIT")
- Struc(PKT,"dp_Arg1")=D
-
- Areg(0)=DEV : Areg(1)=MSG : A=Execall(Lvo("PutMsg"))
- Areg(0)=PRT : A=Execall(Lvo("WaitPort"))
- Areg(0)=PRT : A=Execall(Lvo("GetMsg"))
-
- Erase B
- Wait 50
-
- End If
-
- End Proc
- Procedure _TRACK_OPEN[S,D]
- '--------------------------------------------------------------- TRACK_OPEN
- ' This procedure opens the trackdisc device, for one of the drives.
- '_TRACK_OPEN[channel,drive]
- ' Where:
- ' channel= the number of an internal channel, from 0 to 3
- ' drive= the drive number (as above) associated to the channel
- '
- ' The procedure automatically reserves a memory bank for input/output,
- ' All reads will be done into this bank, all writes from this bank.
- ' The number of the bank is: _TDB+channel, where _TDB is a variable
- ' defined within the procedure (here, _TDB is 1000)
- '
- ' The size of the bank is the size of one floppy track, in chip ram.
- '
- ' The procedure ask informations about the device before returning, and
- ' store it into variables:
- ' _TDNUMSEC= number of sectors per track
- ' _TDSECTOR= size of a sector
- ' _TDTRACKS= number of tracks
- ' _TDSIZE= size of one track (and of the banks)
- '
- ' Return: Param=0 device opened
- ' Param<>0= number of the trackdisc.device error
- '
- ' Note: you can open more than one channel for a single disc, but this
- ' is not wise!
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- _TDB=1000 : E=1
-
- Trap Dev Open S,"trackdisk.device",Equ("IOTD_SIZE"),D,0
- If Errtrap=0
-
- _TDNUMSEC=Equ("NUMSECS")
- _TDSECTOR=Equ("TD_SECTOR")
-
- Trap Lib Open 3,"intuition.library",36
- If Errtrap=0
- Lib Close 3
- _RESFREEBANK[Equ("dg_SIZEOF")] : B=Param : A=Start(B)
- Struc(Dev Base(S),"IO_DATA")=A
- Dev Do S,Equ("TD_GETGEOMETRY")
- _TDSECTOR=Struc(A,"dg_SectorSize")
- _TDNUMSEC=Struc(A,"dg_TrackSectors")
- Erase B
- End If
-
- _TDSIZE=_TDNUMSEC*_TDSECTOR
-
- Dev Do S,Equ("TD_GETNUMTRACKS")
- _TDTRACKS=Struc(Dev Base(S),"IO_ACTUAL")
-
- Reserve As Chip Work _TDB+S,_TDSIZE
- Reserve As Work _TDB+4,_TDSIZE*2
- E=0
- End If
-
- End Proc[E]
- Procedure _TRACK_CLOSE[S]
- '--------------------------------------------------------------- TRACK_CLOSE
- ' This procedure closes a channel previously opened.
- ' _TRACK_CLOSE[channel]
- '
-
- Dev Close S
- Erase _TDB+S
- Erase _TDB+4
-
- End Proc
- Procedure _TRACK_PROTECTED[S]
-
- '----------------------------------------------------------- TRACK_PROTECTED
- ' This procedure asks the current state of a channel, and reports
- ' whether or not the disc in the drive handled by the channel is
- ' write-protected or not.
- '
- ' _TRACK_PROTECTED[channel]
- '
- ' On return:
- ' Param= 0 not protected
- ' Param<>0 protected
- '
-
- Trap Dev Do S,Equ("TD_PROTSTATUS")
- P=-1
- If Errtrap=0
- P=Sgn(Struc(Dev Base(S),"IO_ACTUAL"))
- End If
-
- End Proc[P]
- Procedure _TRACK_MOTOR[S,M]
- '----------------------------------------------------------- TRACK_MOTOR
- ' This procedure turns on or off the drive's motor of the channel.
- ' NOTE: it is not necessary to turn the motor ON, but the programmer
- ' must turn it OFF!
- '
- ' _TRACK_MOTOR[channel,flag]
- ' Where
- ' Flag=False OFF
- ' Flag=True ON
- '
-
- Struc(Dev Base(S),"IO_LENGTH")=M
- Trap Dev Do S,Equ("TD_MOTOR")
- P=-1
- If Errtrap=0
- P=Sgn(Struc(Dev Base(S),"IO_ACTUAL"))
- End If
-
- End Proc[P]
- Procedure _TRACK_READ[S,T]
- '------------------------------------------------------------ TRACK_READ
- ' This procedure reads a track into the channel's memory bank.
- '
- ' _TRACK_READ[channel,track]
- ' Where
- ' Track= the number of the track to read
- '
- ' Returns
- ' Param= 0 no errors
- ' Param<>0 the device's error
- '
- ' The bank used is the one associated with the channel: _TDB+channel
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- T=_TDSIZE*T
- Struc(Dev Base(S),"IO_DATA")=Start(_TDB+S)
- Struc(Dev Base(S),"IO_OFFSET")=T
- Struc(Dev Base(S),"IO_LENGTH")=_TDSIZE
- Trap Dev Do S,Equ("CMD_READ")
-
- End Proc[Errtrap]
- Procedure _TRACK_WRITE[S,T]
- '------------------------------------------------------------- TRACK_WRITE
- ' This procedure writes a track on a previously formatted disc.
- '
- ' _TRACK_WRITE[channel,track]
- ' Where
- ' Track= the number of the track to write
- '
- ' Returns
- ' Param= 0 no errors
- ' Param<>0 the device's error
- '
- ' Valid track data must be poked in the bank associated with the
- ' channel: _TDB+channel before calling this function.
- ' To write on a non-formated track, you should use _TRACK_FORMAT
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- T=_TDSIZE*T
- Struc(Dev Base(S),"IO_DATA")=Start(_TDB+S)
- Struc(Dev Base(S),"IO_OFFSET")=T
- Struc(Dev Base(S),"IO_LENGTH")=_TDSIZE
- Trap Dev Do S,Equ("CMD_WRITE")
-
- End Proc[Errtrap]
- Procedure _TRACK_FORMAT[S,T]
- '------------------------------------------------------------- TRACK_FORMAT
- ' This procedure writes a track on a non-formated disc.
- '
- ' _TRACK_FORMAT[channel,track]
- ' Where
- ' Track= the number of the track to write
- '
- ' Returns
- ' Param= 0 no errors
- ' Param<>0 the device's error
- '
- ' Valid track data must be poked in the bank associated with the
- ' channel: _TDB+channel before calling this function.
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- T=_TDSIZE*T
- Struc(Dev Base(S),"IO_DATA")=Start(_TDB+S)
- Struc(Dev Base(S),"IO_OFFSET")=T
- Struc(Dev Base(S),"IO_LENGTH")=_TDSIZE
- Trap Dev Do S,Equ("TD_FORMAT")
-
- End Proc[Errtrap]
- Procedure _TRACK_CHECKSUM[S]
- '------------------------------------------------------------- TRACK_CHECKSUM
- ' This procedure performs a checksum on every sectors of track stored
- ' in the channel's bank..
- '
- ' _TRACK_CHECKSUM[channel]
- '
- ' This procedure performs a checksum calculation within the
- ' channel's memory bank. You should call this procedure after modifying
- ' anything in any sector of the track.
- ' This procedure checks every sector of the track.
- '
- ' Warning: you'll get a disc corrupted error if you write a track with
- ' bad checksums!
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- For SEC=0 To _TDNUMSEC-1
- A=Start(_TDB+S)+_TDSECTOR*SEC
- Loke A+20,0
- C=0
- For B=A To A+_TDSECTOR-4 Step 4
- Add C,-Leek(B)
- Next
- Loke A+20,C
- Next
-
- End Proc
- Procedure _TRACK_VERIFY[S,T]
- '------------------------------------------------------------- TRACK_VERIFY
- ' This procedure performs a verify on the data stored into the channels
- ' bank. You should usually call it after a FORMAT or a WRITE
- ' It copy the datas onto another bank, call _TRACK_READ to re-load the
- ' data, and compare them byte by byte.
- '
- ' _TRACK_VERIFY[channel,track]
- ' Where
- ' track= number of the track to check
- '
- ' Returns:
- ' param=0 no errors
- ' param<>0 error found
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
- E=1
- A=Start(_TDB+S) : B=Start(_TDB+4) : Copy A,A+_TDSIZE To B
- _TRACK_READ[S,T]
- If Param=0
- Repeat
- For C=0 To _TDSIZE-4 Step 4
- Exit If Leek(A+C)<>Leek(B+C),2
- Next
- E=0
- Until True
- End If
-
- End Proc[E]
- Procedure _TRACK_STORE[S,T]
- '-------------------------------------------------------------- TRACK_STORE
- ' This procedure compress and copy the data hold in the channels bank
- ' into another memory bank automatically. Use this procedure when you
- ' want to perform a disc-copy.
- '
- ' _TRACK_STORE[channel,track]
- '
- ' Returns:
- ' Param=0 no errors
- ' Param<>0 out of memory
- '
- ' The number of the bank reserved is _TDB+5+track
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- _CRUNCHIT[0,_TDSIZE,Start(_TDB+S),Start(_TDB+4)] : L=Param
- Trap Reserve As Work _TDB+5+T,L
- If Errtrap=0
- Copy Start(_TDB+4),Start(_TDB+4)+L To Start(_TDB+5+T)
- End If
- End Proc[Errtrap]
- Procedure _TRACK_USTORE[S,T]
- '-------------------------------------------------------------- TRACK_USTORE
- ' This procedure unpack the data from a compressed bank create by STORE
- ' into the channels internal bank.
- '
- ' _TRACK_USTORE[channel,track]
- '
- ' If the bank is not defined, the channels bank is filled with 0
- '
- ' The number of the bank unpacked is _TDB+5+track
- ' If you call this procedure on other bank than the one created by
- ' TRACK_STORE, it will crash the system!
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- If Length(_TDB+4+T)
- _CRUNCHIT[1,0,Start(_TDB+5+T),Start(_TDB+S)]
- Else
- Fill Start(_TDB+S) To Start(_TDB+S)+Length(_TDB+S),0
- End If
- End Proc
- Procedure _TRACK_FREE
- '-------------------------------------------------------------- TRACK_FREE
- ' This procedure free all banks reserved by TRACK_STORE
- '
- ' _TRACK_FREE
- '
-
- Global _TDB,_TDNUMSEC,_TDSECTOR,_TDTRACKS,_TDSIZE
-
- For B=_TDB+5 To _TDB+5+_TDTRACKS
- Erase B
- Next
-
- End Proc
- Procedure _RESFREEBANK[S]
- '-------------------------------------------------------------- TRACK_STORE
- ' This small procedure is used by the others, it looks for a free
- ' free memory bank, and reserves it, as a "work" bank..
- '
- ' _RESFREEBANK[size]
- '
- ' Returns:
- ' Param=0 out of mem
- ' Param<>0 the number of the bank
- '
-
- E=0
- For B=65535 To 0 Step -1 : Exit If Length(B)=0 : Next
- Trap Reserve As Work B,S
- If Errtrap=0
- Fill Start(B) To Start(B)+Length(B),0
- E=B
- End If
-
- End Proc[E]
- Procedure _CRUNCHIT[A,B,C,D]
- ' COMPILED PROCEDURE -- can't convert this to AMOS code
- End Proc