Last active
January 6, 2017 16:31
-
-
Save undergroundmonorail/d1c8621993f8be14f11e874144b1a258 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Get_Keys:: | |
ld a,$20 | |
ld [$ff00],a ; set bit 5 low to enable buttons | |
ld a,[$ff00] ; allow time for it to bounce | |
ld a,[$ff00] ; get result | |
cpl ; invert (because a low result means the button is pressed) | |
and $0f ; throw out high nybble | |
swap a | |
ld b,a ; save low nybble as high nybble of b | |
ld a,$10 | |
ld [$ff00],a ; set bit 4 low to enable dpad | |
ld a,[$ff00] ; allow time for it to bounce | |
ld a,[$ff00] ; (i don't know why i allow so much more time for this to | |
ld a,[$ff00] ; bounce than the buttons, but all the example code i've seen | |
ld a,[$ff00] ; does it) | |
ld a,[$ff00] | |
ld a,[$ff00] ; get result | |
cpl ; invert again | |
and $0f ; throw out high nybble | |
or b ; combine the two nybbles into one byte | |
ld b,a ; save it in b | |
ld a,$30 | |
ld [$ff00],a ; reset joypad register | |
ret |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment