home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / aga_software / animdemo / joystick.asm < prev    next >
Assembly Source File  |  1993-01-22  |  1KB  |  66 lines

  1. *******************************************************************************
  2. *
  3. * (c) Copyright 1993 Commodore-Amiga, Inc.  All rights reserved.
  4. *
  5. * This software is provided as-is and is subject to change; no warranties
  6. * are made.  All use is at your own risk.  No liability or responsibility
  7. * is assumed.
  8. *
  9. * joystick.asm - reads the joystick port.
  10. *
  11. *******************************************************************************
  12.     incdir    'include:'
  13.     include    'hardware/custom.i'
  14.     include "stick.i"
  15.  
  16.     xdef    _ReadJoystick
  17.  
  18. custom    equ    $dff000
  19.  
  20. * ULONG __asm ReadJoystick(register __a0 struct JoyStick *stick);
  21.  
  22. _ReadJoystick:
  23. ; joystick - get current state of switches in variables
  24. ; uses d0,d1,a1
  25.     move.w    custom+joy1dat,d0
  26.     btst    #1,d0
  27.     sne    stick_right(a0)
  28.     btst    #9,d0
  29.     sne    stick_left(a0)
  30.     move    d0,d1
  31.     add    d0,d0
  32.     eor    d1,d0
  33.     btst    #1,d0
  34.     sne    stick_down(a0)
  35.     btst    #9,d0
  36.     sne    stick_up(a0)
  37.     tst.b    $bfe0ff        ; fire button
  38.     spl    stick_fire(a0)
  39.     move.b    stick_fire(a0),d0
  40.     bmi.s    j_1
  41.     tst.b    old_stick_fire(a0)
  42.     smi    stick_click(a0)
  43. j_1:    move.b    d0,old_stick_fire(a0)
  44.  
  45.     moveq    #0,d0
  46.     move.b    stick_left(a0),d0
  47.     and.b    #LEFT,d0
  48.     move.b    stick_right(a0),d1
  49.     and.b    #RIGHT,d1
  50.     or.b    d1,d0
  51.     move.b    stick_up(a0),d1
  52.     and.b    #UP,d1
  53.     or.b    d1,d0
  54.     move.b    stick_down(a0),d1
  55.     and.b    #DOWN,d1
  56.     or.b    d1,d0
  57.     move.b    stick_fire(a0),d1
  58.     and.b    #FIRE,d1
  59.     or.b    d1,d0
  60.     move.b    stick_click(a0),d1
  61.     and.b    #CLICK,d1
  62.     or.b    d1,d0
  63.  
  64.     rts
  65.  
  66.