home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
No Fragments Archive 10: Diskmags
/
nf_archive_10.iso
/
MAGS
/
STFORMAT
/
STF04.MSA
/
2ND_SIDE_GFADEMOS_FORMAT.LST
< prev
next >
Wrap
File List
|
1989-09-27
|
9KB
|
284 lines
' ******************************************************************
' * *
' * FORMAT.LST *
' * *
' * Written for ST FORMAT MAGAZINE *
' * *
' * This program will run in GFA Basic V2 or V3 *
' * *
' * *
' ******************************************************************
'
' This program formats a floppy disk, in drive A or B
' Single or double sided, standard tracks and sectors.
'
Dim Strip$(50) ! Set up space for the menu
While A$<>"**"
Read A$ ! Read data into the menu Strip$
Strip$(I%)=A$
Inc I%
Wend
Data " Desk "," About Me ",---------------,1,2,3,4,5,6,""
Data " File "," Format Disk "," Dive A "," Drive B "," Ssided "," Dsided "
Data ---------------," Quit ","",""
Data **
'
Menu Strip$() ! put the menu on the screen
On Menu Gosub Evaluate_menu ! turn on menu processing to go to the procedure
' ! evaluate_menu, when you choose a menu entry
Menu 12,1 ! set default to drive A
Sides%=1 ! Single sided
Menu 14,1 ! put a tick in front of menu items to indicate pre-selected
'
Do
On Menu ! this is our program, sit in a loop, allowing the menu
Loop ! to do all the work
'
Procedure Evaluate_menu ! this procedure handles the menu events
Menu Off ! turn menu back to white whilst processing command
Let Selected%=Menu(0) ! have to use LET here for V3 otherwise the editor splits it up into SELECT ed%
If Strip$(Selected%)=" About Me "
@Show_info ! you selected About Me - process command
Endif
If Strip$(Selected%)=" Format Disk "
@Format_routine(Sides%,Drive%) ! format disk. sides=1 or 2, drive=0 or 1
Endif ! pass these parameters to the procedure.
If Selected%=12 Or Selected%=13
@Change_disk ! change disk drive
Endif
If Selected%=14 Or Selected%=15
@Change_sides ! change number of sides
Endif
If Strip$(Selected%)=" Quit "
Menu Kill
End ! all done, kill menu and return to Basic
Endif
Return
'
Procedure Change_disk ! change default drive
If Drive%=0 !0=A
Drive%=1 !1=B
Menu 12,0 ! change ticks in menu from drive A to B
Menu 13,1
Else
Drive%=0
Menu 12,1
Menu 13,0
Endif
Return
'
Procedure Change_sides ! change default sides from 1 to 2
If Sides%=1
Sides%=2
Menu 14,0 ! menu 14 is Ssided (try Print Strip$(14) )
Menu 15,1
Else
Sides%=1
Menu 14,1 ! 1 places a tick in front of an entry
Menu 15,0 ! 0 removes the tick
Endif
Return
'
Procedure Show_info ! all about who wrote this wonderful program
Sget Temp$ ! get the screen into a temporary string
Rez%=Xbios(4) ! get screen resolution
If Rez%=0 ! low res
Screen_x_max%=300 ! get the maximum screen sizes for each resolution
Screen_y_max%=200
Endif
If Rez%=1 ! medium res
Screen_x_max%=600
Screen_y_max%=200
Endif
If Rez%=2 ! high res
Screen_x_max%=600
Screen_y_max%=400
Endif
Center_of_screen_x%=Screen_x_max%/2 !get center of the screen
Center_of_screen_y%=Screen_y_max%/2
'
' draw an expanding box, from the center of the screen
' start size is 0, end size is 80*50 pixels
Dpoke Gintin,Center_of_screen_x%
Dpoke Gintin+2,Center_of_screen_y%
Dpoke Gintin+4,0
Dpoke Gintin+6,0
Dpoke Gintin+8,Center_of_screen_x%-80
Dpoke Gintin+10,Center_of_screen_y%-50
Dpoke Gintin+12,160
Dpoke Gintin+14,100
Gemsys 73 ! AES call - GRAF_GROWBOX
'
' V3 Basic users could use the following call instead of all the DPOKE commands
' ~GRAF_GROWBOX(center_of_screen_x%,center_of_screen_y%,0,0,center_of_screen_x%-80,center_of_screen_y%-50,160,100)
'
' now draw a box, where the expanding box grew to.
Box Center_of_screen_x%-80,Center_of_screen_y%-50,Center_of_screen_x%+80,Center_of_screen_y%+50
'
' next put our message in the box
Text Center_of_screen_x%-70,Center_of_screen_y%-34," I wrote this"
Text Center_of_screen_x%-70,Center_of_screen_y%-18," Press any Mouse"
Text Center_of_screen_x%-70,Center_of_screen_y%-2," Button to"
Text Center_of_screen_x%-70,Center_of_screen_y%+14," Carry on"
'
Repeat
Until Mousek ! wait until a mouse button is pressed
'
Sput Temp$ ! restore the original screen
Return ! and return
'
Procedure Format_routine(Side%,Dev) ! the parameters were passed to this routine
'
Sub Side%,1 ! side needs to be 0 or 1 for the format routine
'
Dim V_buf%(8192/4) ! set aside 8K of buffer space
Buf=Varptr(V_buf%(0)) ! buf is the address of the start of this buffer area
'
Defmouse 0
' CHR$65 + drive% = either A or B
Al$="INSERT DISK TO FORMAT|INTO DISK DRIVE "+Chr$(65+Drive%)
Alert 1,Al$,2," DONE |CANCEL",V%
If V%=2
Goto Dend !if you pressed on Cancel, don't do the format
Endif
'
' if single sided format
If Side%=0
For I%=0 To 79 ! loop, formatting from track 0 to track 79
Print At(2,3);"Formatting Track ";I%;" "
'
' Xbios 10 does the format and returns an error code - 0 = no error
' buf= buffer address
' dev=device 0=A 1=B
' 9 sectors per track
' i%=track number
' 0=side
' 1=interleave
' &h87654321=a magic number
' &he5e5=what to format onto the disk
'
A=Xbios(10,L:Buf,L:0,Dev,9,I%,0,1,L:&H87654321,&HE5E5)
'
Gosub Errorcheck ! check for an error
'
Exit If Abort ! exit if a fatal error
'
Exit If Mousek And 2 ! also exit if right mouse button is pressed
'
Next I% ! next track
Endif
'
' if double sided format
If Side%=1
For I%=0 To 79
Print At(2,3);"Formatting Track ";I%;" Side ";Side%-1;" "
' format side 0
A=Xbios(10,L:Buf,L:0,Dev,9,I%,Side%-1,1,L:&H87654321,&HE5E5)
Gosub Errorcheck
Exit If Abort
Exit If Mousek And 2
Print At(2,3);"Formatting Track ";I%;" Side ";Side%;" "
' format side 1
A=Xbios(10,L:Buf,L:0,Dev,9,I%,Side%,1,L:&H87654321,&HE5E5)
Gosub Errorcheck
Exit If Abort
Next I%
Endif
'
If Mousek And 2
Goto Dend ! abort format, pressed right mouse button
Endif
'
If Abort ! error - abort
Goto Dend
Endif
'
For N%=Buf To Buf+(9*512) ! clear the buffer
Poke N%,0 ! enough space for 9 sectors (512 bytes per sector)
Next N%
'
' write 0's to the first 9 sectors of the disk
A=Xbios(9,L:Buf,L:0,Dev,1,0,0,9)
Gosub Errorcheck
'
If Side%=2
Type=3
Else
Type=2
Endif
' produce a boot sector
' this tells the disk what type it is
Void Xbios(18,L:Buf,L:&H1000000,Type,0)
'
' write boot sector to disk
Se=((Side%+1)*(79+1))*9
Poke Buf+19,Se-256*Int(Se/256)
Poke Buf+20,Int(Se/256)
Poke Buf+24,9
Poke Buf+26,Side%+1
Print At(2,3);"Writing Boot Sector to Disk "
A=Xbios(9,L:Buf,L:0,Dev,1,0,0,1)
'
If A=0 ! no error in writing boot sector
Df=Dfree(Dev+1)
Df$="| | DISK FORMATTED OK|BYTES FREE - "+Str$(Df)
Defmouse 0
Alert 1,Df$,1,"THANKS!",B
Endif
'
Dend: !come here directly if error, or mouse pressed
'
If Abort ! yes we had an error
Print At(2,3);"You had an error on Track ";I%
Out 2,7 ! ping
Pause 40
Endif
'
Erase V_buf%() !clear the buffer
Print At(2,3);Space$(37) ! clear our report messages
'
Return ! all done
'
Procedure Errorcheck ! check for errors, error message in variable a
Abort=False ! reset abort
'
If A=0 ! no error
Goto Errend
Endif
'
Er2$=" UNDETERMINED FAULT" ! default message
'
' TOS errors
If A=-2
Er2$=" DRIVE NOT READY"
Endif
'
If A=-6
Er2$=" NO DISK IN DRIVE"
Endif
'
If A=-10
Er2$=" WRITE ERROR"
Endif
'
If A=-11
Er2$=" READ ERROR"
Endif
'
If A=-13
Er2$=" WRITE PROTECTED"
Endif
'
If A=-16
Er2$=" WRONG DRIVE TYPE"
Endif
'
Er1$=Er2$+" | | DISK NOT FORMATTED|"
Defmouse 0
Alert 1,Er1$,1,"OK !",B
'
Abort=True !yes we had an error
'
Errend: !if you came directly here, then no error was detected
Return