*******************************************************************
*                       G P W                                     *
*                       ~~~~~                                     *
*  GamePortWarn                                                   *
*     Test Amiga mousebutton or joystick firebutton.              *
*  Written by Michael Stapleton of Graphic Bits © 1993.           *
*  For all Amigas. Assembled using 68k by Charlie Gibb.           *
*                                                                 *
*  Contents                                                       *
*  ~~~~~~~~                                                       *
*  This file contains these items:                                *
*  1. This introduction.                                          *
*  2. The commented assembler source                              *
*  3. The executable, in uuencoded form.                          *
*  4. AmigaDOS command lines to assemble & link this file.        *
*                                                                 *
*  Distribution                                                   *
*  ~~~~~~~~~~~~                                                   *
*  This file may be distributed under these conditions:           *
*   1. Only nominal handling fees are charged.                    *
*   2. This original file is included unchanged in the            *
*      distributed package. Compression or archiving is allowed.  *
*                                                                 *
*  Instructions                                                   *
*  ~~~~~~~~~~~~                                                   *
*  Use this program in an AmigaDOS or ARexx script.               *
*    To read the left mousebutton:                                *
*  gpw                                                            *
*    To read the joystick firebutton:                             *
*  gpw joy                                                        *
*  Returns 0 if not pressed or 5 (WARN) if pressed.               *
*                                                                 *
*******************************************************************

        SECTION GPw,CODE
        moveq   #6,d1           ;setup for (potential) mouse bit
        cmp.b   #2,d0           ;do we have an argument?
        ble.s   \ok             ;no, mouse selected

        moveq   #7,d1           ;setup for joystick bit

\ok     moveq   #0,d0           ;set (potential) Ok return code
        btst.b  d1,$BFE001      ;test CIA register
        bne.s   \up

        moveq   #5,d0           ;return WARN
\up     rts

        END

******************************************************************
Here is the executable, uuencoded:
begin 777 gpw
M   #\P         !               &   #Z0    9R!@P   )O G('<  #X
/.0"_X %F G %3G4   /RX
 X
end

And in hex:
000003F3 00000000 00000001 00000000 00000000 00000006
000003E9 00000006 72060C00 00026F02 72077000 033900BF
E0016602 70054E75 000003F2

******************************************************************
;Assemble & link using:
;dos1
a68k gpw.a ; -lgpw.lst
blink gpw.o
;dos1
******************************************************************
