home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 44 / af044.adf / Serious_Stuff / SEGA.S < prev    next >
Text File  |  1993-01-21  |  2KB  |  52 lines

  1. *  Amiga 4-button joystick code...
  2. *
  3. *  Stick discovery by Ed Bamber
  4. *  Code created by Anthony Ball
  5. *
  6. *  (C)1992 Anthony Ball & Edmund Bamber
  7. *
  8. *  We must be credited if this routine is to be used in any code
  9. *
  10. *  Requires a megadrive joystick with wires 5 & 7 swapped
  11. *
  12. *  Returns:   d0 register "Stick Bits"   76543210
  13. *                                        ABCDUDLR
  14. *  ABCD... Different buttons  U=Up  D=Down  L=Left  R=Right
  15. *
  16. *  Amiga Format Note: Thanks to Craig Proctor for his method
  17. *  But Pat McDonald regrets that he mislaid it. Sorry Craig - forgot my password to Cyberspace
  18. *  This one is just as good though.
  19. *
  20. chip        equ    $dff000            * chips
  21. joy1dat        equ    $00c            * joystick 1 data
  22. potinp        equ    $016            * pot port data read
  23. potgo        equ    $034            * pot port data write and start
  24. piaa        equ     $bfe001            * 8520 port A
  25. pra        equ    $000            * reg 0 peripheral data register a
  26.  
  27. Getstick    lea     chip,a6
  28.         moveq    #0,d2
  29.         btst.b    #7,piaa+pra        * button A pressed?
  30.         bne.s    .Not1            * No!
  31.         or    #$80,d2
  32. .Not1        btst.b    #6,potinp(a6)        * button B pressed?
  33.         bne.s    .Not2            * No!
  34.         or    #$40,d2
  35. .Not2        move    #$e000,potgo(a6)    * Set 5 volt port on
  36.         move    joy1dat(a6),d0        * Get stick for player
  37.         and    #$0303,d0        * Keep only the bits needed
  38.         move    d0,d1
  39.         lsr    #6,d0            * Make Table Smaller!
  40.         or.b    d1,d0
  41.         move.b    .Table(pc,d0),d0    * Get converted byte
  42.         or    d2,d0
  43.         btst.b    #7,piaa+pra        * button C pressed?
  44.         bne.s    .Not3            * No!
  45.         or    #$20,d0
  46. .Not3        btst.b    #6,potinp(a6)        * button D pressed?
  47.         bne.s    .Not4            * No!
  48.         or    #$10,d0
  49. .Not4        move    #$f000,potgo(a6)    * Ready for next read
  50.         rts
  51. .Table        dc.l    $00040501,$08000109,$0a020008,$02060400
  52.