diff options
author | luckytyphlosion <alan.rj.huang@gmail.com> | 2015-05-10 15:46:37 -0400 |
---|---|---|
committer | luckytyphlosion <alan.rj.huang@gmail.com> | 2015-05-10 15:46:37 -0400 |
commit | a5cb0cbc3633f90bdf054f80cf9551809c90a5f1 (patch) | |
tree | 6d0ff2373fe6c4cb19568ca1c339a5f02eff4093 | |
parent | dae43e450716915c583f64da7a43ef8f501ba9a3 (diff) |
Update joypad.asm
-rw-r--r-- | engine/joypad.asm | 37 |
1 files changed, 36 insertions, 1 deletions
diff --git a/engine/joypad.asm b/engine/joypad.asm index 31e197e2..791056ca 100644 --- a/engine/joypad.asm +++ b/engine/joypad.asm @@ -1,8 +1,43 @@ -_Joypad:: +ReadJoypad_:: ; c000 (3:4000) +; 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 + + ld [rJOYP], a + rept 6 + ld a, [rJOYP] + endr + cpl + and %1111 + swap a + ld b, a + + ld a, 1 << 4 ; select button keys + ld [rJOYP], a + rept 10 + ld a, [rJOYP] + endr + cpl + and %1111 + or b + + ld [hJoyInput], a + + ld a, 1 << 4 + 1 << 5 ; deselect keys + ld [rJOYP], a + ret + + +_Joypad:: ; c02d (3:402d) ; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast ; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput ld a, [hJoyInput] + ld b,a + and $4F cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset jp z, TrySoftReset |