home *** CD-ROM | disk | FTP | other *** search
- **************************************
- * *
- * ButtonAsk v1.0 *
- * *
- * (c) 1990 Chris Simpson *
- * *
- * USAGE: ButtonAsk <prompt> *
- * *
- * This program is a replacement for *
- * the AmigaDOS ASK command except *
- * that the mouse buttons are used *
- * rather than entering 'y' or 'n' *
- * For this program to work, some *
- * text for the prompt must be given *
- * in the command line. This text is *
- * echoed to stdout and then a mouse *
- * button is waited for. Pressing the *
- * left button returns a return code *
- * of 5(WARN) and pressing the right *
- * button returns a return code of 0. *
- * *
- **************************************
-
- SECTION ButtonAsk,code_c ; Put into chip ram
-
- INCDIR include: ; Read include files
- INCLUDE exec/exec_lib.i
- INCLUDE libraries/dos_lib.i
-
- LeftReg equ $bfe001 ; Set up button registers
- RightReg equ $dff016
-
- move.l d0,Length ; Store length of CLI line
- move.l a0,Address ; Store address of CLI line
-
- move.l #100,ReturnCode ; Default return code
-
- lea DOSName,a1 ; Try to open dos library
- clr.l d0
- CALLEXEC OpenLibrary
- tst.l d0 ; Quit if not opened
- beq Error
- move.l d0,_DOSBase ; Else store dos base
-
- CALLDOS Output ; Find standard output
- move.l d0,OutHandle ; Store handle address
-
- move.l Length,d0 ; Get back length
- move.l Address,a0 ; Get back address
-
- cmp.l #1,Length ; Make sure not just linefeed
- bgt GotPrompt
-
- move.l OutHandle,d1 ; Write USAGE text
- move.l #Usage,d2
- move.l #UsageEnd-Usage,d3
- CALLDOS Write
- bra CloseDOS
-
-
- GotPrompt move.l OutHandle,d1 ; Write the prompt out
- move.l a0,d2
- move.l d0,d3
- CALLDOS Write
-
- WaitForButton btst #6,$bfe001
- beq LeftPressed
-
- btst #10,$dff016
- beq RightPressed
-
- bra WaitForButton
-
- LeftPressed move.l #5,ReturnCode
- bra CloseDOS
-
- RightPressed move.l #0,ReturnCode
-
- CloseDOS move.l _DOSBase,a1 ; Close dos library
- CALLEXEC CloseLibrary
-
- move.l ReturnCode,d0 ; Exit with return code
- Error rts
-
- *** Data ***
-
- DOSName dc.b "dos.library",0
- even
- _DOSBase dc.l 0
-
- OutHandle dc.l 0
-
- Usage dc.b "ButtonAsk v1.0 (c) 1990 Chris Simpson",13,10,13,10
- dc.b "USAGE: ButtonAsk <prompt>",13,10,13,10
- dc.b "Return code will be ... 5 if left button pressed",13,10
- dc.b " 0 if right button pressed",13,10,0
- UsageEnd even
-
- Address dc.l 0
- Length dc.l 0
-
- ReturnCode dc.l 0
-
-