home *** CD-ROM | disk | FTP | other *** search
/ Amiga Elysian Archive / AmigaElysianArchive.iso / prog / arexx / alib.lha / joy.rexx < prev    next >
Encoding:
OS/2 REXX Batch file  |  1989-08-21  |  649 b   |  38 lines

  1. /* joy */
  2.  
  3. pos = "CenterUp    Up-Rt Right Dn-Rt Down  Dn-Lt Left  Up-Lt "
  4.  
  5. PIA = '00bfe001'X
  6. JOY = '00dff00c'X
  7.  
  8. do FOREVER
  9.  
  10. val = import(PIA,1)
  11.  
  12. if bittst(val,7) = 1 then do
  13.     match = -1
  14.     val = import(JOY,2)
  15.     if bittst(val,1) then match = 6
  16.     if bittst(val,9) then match = 2
  17.     rval = d2c(c2d(bitclr(val,0),2)/2,2)
  18.     rval = bitxor(val,rval)
  19.     if bittst(rval,8) = 1 then do
  20.         if match >= 0 then
  21.             if match = 2 then match = 1
  22.             else match = 7
  23.         else match = 0
  24.     end
  25.     if bittst(rval,0) = 1 then do
  26.         if match >= 0 then
  27.             if match = 2 then match = 3
  28.             else match = 5
  29.         else match = 4
  30.     end
  31.  
  32.     say substr(pos,1 + (match + 1) * 6,6)
  33. end
  34.  
  35. else say "FIRE!"
  36.  
  37. end
  38.