**************************************************************************** * *** Clean V1.0 (c) 1989 By Dan Burris *** * * * * This is a program to clean your Floppy diskettes, it has protection from * * trying to write to anything other than DF something, and only 0 thru 3, * * and then only if that drive is connected to the Amiga that it is running * * on. * * * * I hereby declare this program to be in the Public domain. You may use * * in your programs including commercial or whatever, as long as you do not * * use it maliciously, or blame ME for any of it's failures, or misgivings! * **************************************************************************** **** Equates and Offsets **** OpenLibrary EQU -408 CloseLibrary EQU -414 ExecBase EQU 4 **** Amiga Dos Calls **** Open EQU -30 Close EQU -36 OpenDevice EQU -444 CloseDevice EQU -450 SendIO EQU -462 Delay EQU -198 Read EQU -42 Write EQU -48 WaitForCh EQU -204 mode_old EQU 1005 OutPut EQU -60 Exit EQU -144 Lock EQU -84 run: move.l d0,d4 ;save length of Parameter move.l a0,a1 ;save Parameter address move.l #whodisk,a5 ;address of drive name in a5 getit move.b (a1)+,(a5)+ ;save Parameter in whodisk dbra d0,getit ;until all in whodisk cmpi.b #4,d4 ;was Parameter - df#:? bne Template ;tell user how to use, & exit bsr init ;Initialization-Open stuff bra ScreenOut ;Print Msgs, and work init: ;System initialization and Open move.l ExecBase,a6 ;Pointer to EXEC-library move.l #dosname,a1 ;Dos Library name in a1 moveq #0,d0 ;Version # = don't care jsr OpenLibrary(a6) ;Open DOS-Library move.l d0,dosbase ;Save the Address of the Dos beq Clean1 ;Bad open - set flag, and exit OpenTrkDsk: lea diskio,a1 ;Pointer to I/0 structure in a1 move.l #diskrep,14(a1) ;Address of I/O Port in A1 + 14 move.l #whodisk,a5 ;Address of drive name in a5 clr.l d0 ;Clear d0 to do byte operation move.b 2(a5),d0 ;Put ascii drive number in d0 sub.b #$30,d0 ;Convert to Actual Drive Number cmpi.b #4,d0 ;Too Large of drive number? bge Template ;Tell user to start over clr.l d1 ;No Flags move.l #trddevice,a0 ;Put device name in a0 jsr OpenDevice(a6) ;Open trackdisk.device tst.l d0 ;Was it a good Open? bne BadDrive ;If so,Bad Drive Number-Exit RawOpen: lea RAWname(pc),a1 ;RAW-Definition move.l #mode_old,d0 ;The Mode you use bsr Openfile ;RAW Open beq CleanUp ;Error handling routine move.l d0,rawhandle ;Save the address of the Window rts Template: move.l ExecBase,a6 ;Pointer to EXEC-library move.l #dosname,a1 ;Dos Library name in a1 moveq #0,d0 ;Version # = don't care jsr OpenLibrary(a6) ;Open DOS-Library move.l d0,dosbase ;save DOS address move.l dosbase,a6 ;Address of the Dos->A6 jsr OutPut(a6) ;get CLI window handle move.l d0,d1 ;save CLI handle lea TempMsg(pc),a0 ;Start of the message move.l #TempMsg1,d3 ;End of message to print bsr print2 ;Routine to print message above jsr Exit(a6) ;Exit program! ScreenOut: lea message(pc),a0 ;Start of the message move.l #message1,d3 ;End of message to print bsr print ;Routine to print message above NoRemove: move.l ExecBase,a6 ;Start of Exec Library in a6 lea diskio,a1 ;Pointer to I/O Structure in A1 move.l #0,40(a1) ;To shut off disk remove spin move.l 32(a1),d7 ;IO_ACTUAL in d7 move #12,28(a1) ;Command = Toggle motor on/off move.l #1,36(a1) ;Turn DFO disk drive motor on! move.l #1,d0 ;Drive #1 jsr SendIO(a6) ;Send the command to the drive GetKey: move.l #inbuff,d2 ;Address of Input Buffer move.l #1,d3 ;Number of characters to read move.l dosbase,a6 ;Find Dos Library move.l rawhandle,d1 ;The Place to get keypress from jsr Read(a6) ;Get 1 character move.b inbuff,d0 ;Put it in d0 moveq #$1b,d4 ;ESC character in d4 cmp.b d4,d0 ;Was it ESC key? beq CleanUp ;If so close Libraries and Exit moveq #$0d,d4 ;Return character in d4 cmp d4,d0 ;Was it Return? bne GetKey ;Bad input, start over. MotorOn: lea MotorMsg(pc),a0 ;Address of MotorMsg in a0 move.l #MotorMsg1,d3 ;Address of end of MotorMsg bsr print ;Print it move.l ExecBase,a6 ;Start of Exec Library in a6 lea diskio,a1 ;Pointer to I/O Structure in A1 move.l 32(a1),d7 ;IO_ACTUAL in d7 move #9,28(a1) ;Command = Toggle motor on/off move.l #1,36(a1) ;Turn DFO disk drive motor on! move.l #1,d0 ;Drive #1 jsr SendIO(a6) ;Send the command to the drive move.l #750,d1 ;Delay() parameter - 15 seconds jsr Wait ;Wait 15 secs. while spinning MotorOff: move.l ExecBase,a6 ;Start of Exec Library in a6 lea diskio,a1 ;Pointer to I/O Structure in A1 move.l 32(a1),d7 ;IO_ACTUAL in d7 move #9,28(a1) ;Command = Toggle motor on/off move.l #0,36(a1) ;Turn DFO disk drive motor off! jsr SendIO(a6) ;Send the command to the drive bra CleanUp ;Close Libraries and exit CleanUp: move.l rawhandle,d1 ;Handle to RAW move.l dosbase,a6 ;Dos Library Close jsr Close(a6) ;Close Window Clean1: move.l dosbase,a1 ;DOS.Lib Close move.l ExecBase,a6 ;Address of Exec in a6 jsr CloseLibrary(a6) ;Close Dos Library Clean2: lea diskio,a1 ;Address of Trackdisk move.l 32(a1),d7 ;IO_ACTUAL in d7 jsr CloseDevice(a6) ;Close TrackDisk Device rts BadDrive: move.l ExecBase,a6 ;Pointer to EXEC-library move.l #dosname,a1 ;Dos Library name in a1 moveq #0,d0 ;Version # = don't care jsr OpenLibrary(a6) ;Open DOS-Library move.l d0,dosbase ;save DOS address move.l dosbase,a6 ;Address of the Dos->A6 jsr OutPut(a6) ;get CLI window handle move.l d0,d1 ;save CLI handle lea BadMsg(pc),a0 ;Start of the message move.l #BadMsg1,d3 ;End of message to print bsr print2 ;Routine to print message above jsr Exit(a6) ;Exit program! Openfile: ;Open File move.l a1,d1 ;I/O Pointer - Filename move.l d0,d2 ;Mode for the Open move.l dosbase,a6 ;Address of Dos in A6 jsr Open(a6) ;Open the file tst.l d0 ;Was it a good open? rts print: move.l rawhandle,d1 ;Output Window in D1 print2: move.l a0,d2 ;Address of Text in d2 move.l dosbase,a6 ;Address of Dos in A6 jsr Write(a6) ;Write Message to Window rts Wait: move.l dosbase,a6 ;Find the Dos Library jsr Delay(a6) ;Wait 30 seconds(drive spins) rts RAWname: dc.b 'RAW:65/35/490/120/' dc.b ' Dan',$27,'s Drive Cleaner V1.0 ',0 message: dc.b $0c,$0a,$0d,$9b,'7;32;43m' dc.b $9b,'15C' dc.b $20,$20,' The Drive Cleaner ',$20,$20 dc.b $0a,$0d,$9b,'0m' dc.b $9b,'15C' dc.b $9b,'7;32;43m' dc.b $20,$20,$20,'© 1988 By Dan Burris ',$20,$20,$20 dc.b $0a,$0a,$0a,$0d,$9b,'0;31;40m' dc.b ' Please Insert a Prepared Cleaning Disk in ' dc.b $9b,'4;31;40mDrive ' whodisk ds.b 4 dc.b $0a,$0d,$0a,$0d dc.b $9b,'0;31;40m' dc.b ' And Press Return (Or Press Esc to Exit). ' dc.b $9b,$30,$20,$70 message1 EQU *-message MotorMsg dc.b $0a,$0a,$0a,$0d dc.b $9b,'0;32;40m *** ' dc.b $9b,'0;4;33;40mWorking' dc.b $9b,'0;32;40m ***' MotorMsg1 EQU *-MotorMsg BadMsg dc.b 'That Drive is Not Connected to this Amiga!',$0d,$0a BadMsg1 EQU *-BadMsg TempMsg dc.b 'Please Type -> Clean [DF0,DF1,DF2, or DF3]',$0d,$0a TempMsg1 EQU *-TempMsg dosname: dc.b 'dos.library',0,0 cnop 0,2 trddevice: dc.b 'trackdisk.device',0 cnop 0,2 dosbase: dc.l 0 ;DOS base address rawhandle: dc.l 0 ;Window Handle inbuff: ds.b 8 ;Keyboard Buffer diskio: ds.l 20 ;I/O Structure diskrep: ds.l 8 ;I/O Port end