home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
AMOS PD CD
/
amospdcd.iso
/
601-625
/
apd602
/
disk_formatter.amos
/
disk_formatter.amosSourceCode
< prev
Wrap
AMOS Source Code
|
1993-02-25
|
6KB
|
302 lines
Rem**WARNING THIS PROGRAM FORMATS A DISK**
Rem**DO NOT RUN UNTIL YOU HAVE A DISK YOU WANT FORMATTED IN DF0:**
'
'ripped from Amos_copy
'
Dim UPP(79),LOW(79)
If Length(7)=0 Then Reserve As Chip Data 7,1024
Global UPP(),LOW()
Global SOURCE,TARGET,VERIFY
Global ABORT,UPP,LOW,_DOIT
Global XUPP,YUPP,XLOW,YLOW,UPPSIDE,LOWSIDE
SOURCE=0 : TARGET=1 : VERIFY=1 : OPTION=1 : UPPSIDE=1 : LOWSIDE=1
For I=0 To 79
UPP(I)=1
LOW(I)=1
Next I
TARGET=0
'
'**** Format ****
O2:
_TRACK[1]
_TRACKBLOCK[0,-1]
Return
'
'
Procedure _TRACKBLOCK[BLOCK,COMMAND]
'
'**** Variablen & Adressen definieren ****
DISKREP$=Space$(40)+Chr$(0)
DEVNAME$="trackdisk.device"+Chr$(0)
IOREQ$=Space$(80)+Chr$(0)
DISKREP=Varptr(DISKREP$)
IOREQADR=Varptr(IOREQ$)
'
'**** BootBlock erstellen ****
If COMMAND=-1
COMMAND=3
For I=0 To 1023
Poke Start(7)+I,0
Next I
For I=0 To 12
Read N
Loke Start(7)+I*4,N
Next I
End If
'
'**** Eigene Taskadresse suchen ****
Areg(0)=0
Areg(1)=0
Dreg(0)=0
Dreg(1)=0
XFINDTASK=Execall(-294)
Loke DISKREP+$10,XFINDTASK
'
'**** Device �ffnen ****
Areg(0)=Varptr(DEVNAME$)
Areg(1)=IOREQADR
Dreg(0)=TARGET
Dreg(1)=0
XOPENDEVICE=Execall(-444)
'
'**** Devicekommando ausf�hren ****
Loke IOREQADR+14,DISKREP
Doke IOREQADR+28,COMMAND
Loke IOREQADR+40,Start(7)
Loke IOREQADR+36,1024
Loke IOREQADR+44,BLOCK*512
XDOIO=Execall(-456)
'
'**** UPDATE[4] falls COMMAND=WRITE[3] ****
If COMMAND=3
Doke IOREQADR+28,4
XDOIO=Execall(-456)
End If
'
'**** Motor ausschalten ****
Doke IOREQADR+28,9
Loke IOREQADR+36,0
XDOIO=Execall(-456)
'
'**** Device schlie�en ****
XCLOSEDEVICE=Execall(-450)
'
'**** BootBlockDaten ****
Data $444F5300,$C0200F19,$370,$43FA0018,$4EAEFFA0,$4A80670A
Data $20402068,$167000,$4E7570FF,$60FA646F,$732E6C69,$62726172,$79000000
End Proc
Procedure _RASTER[TRACK,XDOIO]
N=TRACK mod 2
If XDOIO
Ink 2
Add XDOIO,-19
If XDOIO>8
If XDOIO=9 : N$="Disk is write protected !" : End If
If XDOIO=10 : N$="No disk in drive !" : End If
_MESSAGE[N$]
ABORT=True
Pop Proc
End If
End If
If N=0
Text 84+XUPP*10,66+YUPP*11,Str$(XDOIO)-" "
Else
Text 202+XLOW*10,66+YLOW*11,Str$(XDOIO)-" "
End If
End Proc
Procedure _TRACK[N]
'
Reserve As Chip Data 2,5632
'
'**** Variablen & Adressen definieren ****
DISKREP$=Space$(40)+Chr$(0)
DEVNAME$="trackdisk.device"+Chr$(0)
IOREQ$=Space$(80)+Chr$(0)
DISKREP=Varptr(DISKREP$)
IOREQADR=Varptr(IOREQ$)
'
'**** Eigene Taskadresse suchen ****
Areg(0)=0
Areg(1)=0
Dreg(0)=0
Dreg(1)=0
XFINDTASK=Execall(-294)
Loke DISKREP+$10,XFINDTASK
'
'**** Device �ffnen ****
Areg(0)=Varptr(DEVNAME$)
Areg(1)=IOREQADR
Dreg(0)=TARGET
Dreg(1)=0
XOPENDEVICE=Execall(-444)
'
'**** Befehl aufrufen ****
Loke IOREQADR+14,DISKREP
Loke IOREQADR+40,Start(2)
Loke IOREQADR+36,5632
Ink 1,0
On N Gosub _FORMAT,_QFORMAT,_ERASE,_TEST
'
'**** Motor ausschalten ****
Doke IOREQADR+28,9
Loke IOREQADR+36,0
XDOIO=Execall(-456)
'
'**** Device schlie�en ****
XCLOSEDEVICE=Execall(-450)
'
Erase 2
'
Pop Proc
'
'**** Track formattieren ****
_FORMAT:
Doke IOREQADR+28,11
UL=-1
For TRACK=0 To 159
Add UL,1,0 To 1
_BAMCHECK[UL]
If _DOIT
Loke IOREQADR+44,TRACK*5632
XDOIO=Execall(-456)
_RASTER[TRACK,XDOIO]
'
'**** Verify ****
If VERIFY and ABORT=0
Doke IOREQADR+28,2
XDOIO=Execall(-456)
_VERIFY[TRACK,XDOIO]
Doke IOREQADR+28,11
Ink 1
End If
End If
'
'**** Abbruch ? ****
If Mouse Key<>0
_ABORT
End If
If ABORT : TRACK=159 : ABORT=0 : End If
'
Next TRACK
Gosub _QFORMAT
Return
'
_QFORMAT:
Doke IOREQADR+28,11
N=Start(2)
For I=$204 To $2DF
Poke N+I,$FF
Next I
Doke N+2,$2
Poke N+15,$48
Loke N+20,$A661AEF3
Doke N+$13A,$1
Doke N+$13E,$371
Poke N+$1B0,$5
Poke N+$1B1,$45
Poke N+$1B2,$4D
Poke N+$1B3,$50
Poke N+$1B4,$54
Poke N+$1B5,$59
Poke N+$1FF,$1
Loke N+$200,$C000C037
Poke N+$272,$3F
Poke N+$2DC,$3F
Loke IOREQADR+44,$6E000
XDOIO=Execall(-456)
Return
'
_ERASE:
Doke IOREQADR+28,17
UL=-1
For TRACK=0 To 159
Add UL,1,0 To 1
_BAMCHECK[UL]
If _DOIT
Loke IOREQADR+44,TRACK
XDOIO=Execall(-456)
_RASTER[TRACK,XDOIO]
End If
'
'**** Abbruch ? ****
If Mouse Key<>0
_ABORT
End If
If ABORT : TRACK=159 : ABORT=0 : End If
'
Next TRACK
Return
'
'**** Track testen ****
_TEST:
Doke IOREQADR+28,2
UL=-1
For TRACK=0 To 159
Add UL,1,0 To 1
_BAMCHECK[UL]
If _DOIT
Loke IOREQADR+44,TRACK*5632
XDOIO=Execall(-456)
Ink 1
_RASTER[TRACK,XDOIO]
End If
'
'**** Abbruch ? ****
If Mouse Key<>0
_ABORT
End If
If ABORT : TRACK=159 : ABORT=0 : End If
'
Next TRACK
Return
'
End Proc
Procedure _MESSAGE[N$]
Ink 0,0 : Bar 14,189 To 301,198
Ink 2 : Text 14,196,N$
End Proc
Procedure _BAMCHECK[UL]
If UL=0
Add XUPP,1
If XUPP=10
Add YUPP,1 : XUPP=0
End If
If UPP(UPP) and UPPSIDE : _DOIT=True Else _DOIT=False : End If
Inc UPP
Else
If LOW(LOW) and LOWSIDE : _DOIT=True Else _DOIT=False : End If
Inc LOW
Add XLOW,1
If XLOW=10
Add YLOW,1 : XLOW=0
End If
End If
End Proc
Procedure _VERIFY[TRACK,XDOIO]
If XDOIO=0 Then Pop Proc
N=TRACK mod 2
Add XDOIO,-19
_MESSAGE["Verify error ! � ESC=Abort process �"]
If N=0
Text 84+XUPP*10,66+YUPP*11,Str$(XDOIO)-" "
Else
Text 202+XLOW*10,66+YLOW*11,Str$(XDOIO)-" "
End If
Repeat : N2=Asc(Inkey$) : Until N2
_MESSAGE[""]
If N2=27 Then ABORT=True
End Proc
Procedure _ABORT
XM=X Screen(X Mouse)
YM=Y Screen(Y Mouse)
If XM>40 and XM<72 and YM>134 and YM<146
G[41,135,71,145,1]
ABORT=True
Wait 5
G[41,135,71,145,0]
End If
End Proc
Procedure G[X,Y,X2,Y2,S]
If S Then C1=2 : C2=1 Else C1=1 : C2=2
Ink C1 : Draw X,Y To X2-1,Y : Draw X,Y To X,Y2 : Ink C2 : Draw X+1,Y2 To X2,Y2 : Draw X2,Y To X2,Y2 : Ink 1,0
End Proc