SHARE
TWEET

hello.z80

a guest Jan 13th, 2020 74 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #define     WRTPSG   $0093
  2. #define     RDPSG   $0096
  3. .org        $c000
  4.  
  5.  
  6. .db     $fe
  7. .dw     $c000
  8. .dw     (END)
  9. .dw     $c007
  10.  
  11. .db     $00
  12. .db     $00
  13.  
  14.     call    READJOYPORTLO
  15.     and $3F
  16.     ld  c,a     ; c=0,0,C,B,L,R,D,U
  17.  
  18.     call    READJOYPORTHI
  19.     and $3C     ; crop S,A,I,I
  20.     add a,a
  21.     add a,a
  22.     ld  b,a     ; b=S,A,I,I,0,0,0,0
  23.  
  24.     call    READJOYPORTLO
  25.     call    READJOYPORTHI
  26.     call    READJOYPORTLO
  27.     call    READJOYPORTHI
  28.     and 00001111b   ; 2nd ID = 0?
  29.     jr  nz,joy3btn  ; If this joypad isn't the 6-button model, skip
  30.  
  31.     ld  a,b     ; a=S,A,0,0,0,0,0,0
  32.     or  c       ; a=S,A,C,B,R,L,D,U
  33.     ld  c,a     ; c=S,A,C,B,R,L,D,U
  34.     call    READJOYPORTLO   ;   ?,?,C,B,M,X,Y,Z
  35.     and $0F     ; Crop      M,X,Y,Z
  36.     ld  b,a     ; b=0,0,0,0,M,X,Y,Z
  37.     ld  a,c     ; a=S,A,C,B,R,L,D,U
  38.     ret
  39. joy3btn:    ; This is a 3-button joypad
  40.     ; Now place the bits in the standard two-byte format used for all Sega
  41.     ; controllers & multi-tap
  42.     ld  a,b     ; a=ST,A,00,0000
  43.     or  c       ; a=ST,A,C,B,Rt,Lt,Dn,Up
  44.     ld  b,$1F   ; b=JOYID:001,11111 (L=MODE=X=Y=Z=1)
  45.     ret
  46.  
  47. READJOYPORTHI:
  48.     ld  e,$9F
  49.     ld  a,15
  50.     jp  WRTPSG
  51.     jp  READJOYPORT
  52. READJOYPORTLO:
  53.     ld  e,$8F
  54.     ld  a,15
  55.     jp  WRTPSG
  56.     jp  READJOYPORT
  57. READJOYPORT:
  58.     ld  a,14
  59.     di
  60.     call    RDPSG
  61.     ei
  62.     ret
  63.    
  64. END:
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top