Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Poll joypad and update regs
- ld c, LOW(rP1)
- ld a, $20 ; Select D-pad
- ld [$ff00+c], a
- REPT 6
- ld a, [$ff00+c]
- ENDR
- or $F0 ; Set 4 upper bits (give them consistency)
- ld b, a
- ; Filter impossible D-pad combinations
- and $0C ; Filter only Down and Up
- ld a, b
- jr nz, .notUpAndDown
- or $0C ; If both are pressed, "unpress" them
- ld b, a
- .notUpAndDown
- and $03 ; Filter only Left and Right
- jr nz, .notLeftAndRight
- ld a, b
- or $03 ; If both are pressed, "unpress" them
- ld b, a
- .notLeftAndRight
- swap b ; Put D-pad buttons in upper nibble
- ld a, $10 ; Select buttons
- ld [$ff00+c], a
- REPT 6
- ld a, [$ff00+c]
- ENDR
- ; On SsAB held, soft-reset
- and $0F
- jp z, Reset
- or $F0 ; Set 4 upper bits
- xor b ; Mix with D-pad bits, and invert all bits (such that pressed=1) thanks to "or $F0"
- ld b, a
- ldh a, [hHeldButtons]
- cpl
- and b
- ldh [hPressedButtons], a
- ld a, b
- ldh [hHeldButtons], a
- ; Release joypad
- ld a, $30
- ld [$ff00+c], a
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement