2014-05-31 01:30:25 +00:00
|
|
|
ReadJoypad::
|
|
|
|
; Poll joypad input.
|
|
|
|
; Unlike the hardware register, button
|
|
|
|
; presses are indicated by a set bit.
|
|
|
|
|
|
|
|
ld a, 1 << 5 ; select direction keys
|
|
|
|
ld c, 0
|
|
|
|
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [rJOYP], a
|
2020-11-05 18:23:57 +00:00
|
|
|
REPT 6
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [rJOYP]
|
2020-11-05 18:23:57 +00:00
|
|
|
ENDR
|
2014-05-31 01:30:25 +00:00
|
|
|
cpl
|
|
|
|
and %1111
|
|
|
|
swap a
|
|
|
|
ld b, a
|
|
|
|
|
|
|
|
ld a, 1 << 4 ; select button keys
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [rJOYP], a
|
2020-11-05 18:23:57 +00:00
|
|
|
REPT 10
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh a, [rJOYP]
|
2020-11-05 18:23:57 +00:00
|
|
|
ENDR
|
2014-05-31 01:30:25 +00:00
|
|
|
cpl
|
|
|
|
and %1111
|
|
|
|
or b
|
|
|
|
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [hJoyInput], a
|
2014-05-31 01:30:25 +00:00
|
|
|
|
|
|
|
ld a, 1 << 4 + 1 << 5 ; deselect keys
|
2020-07-06 23:03:05 +00:00
|
|
|
ldh [rJOYP], a
|
2014-05-31 01:30:25 +00:00
|
|
|
ret
|
|
|
|
|
|
|
|
Joypad::
|
|
|
|
; Update the joypad state variables:
|
|
|
|
; [hJoyReleased] keys released since last time
|
|
|
|
; [hJoyPressed] keys pressed since last time
|
|
|
|
; [hJoyHeld] currently pressed keys
|
|
|
|
homecall _Joypad
|
|
|
|
ret
|