Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define WRTPSG $0093
- #define RDPSG $0096
- .org $c000
- .db $fe
- .dw $c000
- .dw (END)
- .dw $c007
- .db $00
- .db $00
- call READJOYPORTLO
- and $3F
- ld c,a ; c=0,0,C,B,L,R,D,U
- call READJOYPORTHI
- and $3C ; crop S,A,I,I
- add a,a
- add a,a
- ld b,a ; b=S,A,I,I,0,0,0,0
- call READJOYPORTLO
- call READJOYPORTHI
- call READJOYPORTLO
- call READJOYPORTHI
- and 00001111b ; 2nd ID = 0?
- jr nz,joy3btn ; If this joypad isn't the 6-button model, skip
- ld a,b ; a=S,A,0,0,0,0,0,0
- or c ; a=S,A,C,B,R,L,D,U
- ld c,a ; c=S,A,C,B,R,L,D,U
- call READJOYPORTLO ; ?,?,C,B,M,X,Y,Z
- and $0F ; Crop M,X,Y,Z
- ld b,a ; b=0,0,0,0,M,X,Y,Z
- ld a,c ; a=S,A,C,B,R,L,D,U
- ret
- joy3btn: ; This is a 3-button joypad
- ; Now place the bits in the standard two-byte format used for all Sega
- ; controllers & multi-tap
- ld a,b ; a=ST,A,00,0000
- or c ; a=ST,A,C,B,Rt,Lt,Dn,Up
- ld b,$1F ; b=JOYID:001,11111 (L=MODE=X=Y=Z=1)
- ret
- READJOYPORTHI:
- ld e,$9F
- ld a,15
- jp WRTPSG
- jp READJOYPORT
- READJOYPORTLO:
- ld e,$8F
- ld a,15
- jp WRTPSG
- jp READJOYPORT
- READJOYPORT:
- ld a,14
- di
- call RDPSG
- ei
- ret
- END:
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement