diff options
author | U-Fish-PC\Daniel <corrnondacqb@yahoo.com> | 2014-06-09 15:10:49 -0400 |
---|---|---|
committer | U-Fish-PC\Daniel <corrnondacqb@yahoo.com> | 2014-06-09 15:10:49 -0400 |
commit | d266f788b4ba251c5a41f47745c941d81e5d7d88 (patch) | |
tree | 004892d1cc02111732dcb81ef9734ab13ab49ef5 /engine/joypad.asm | |
parent | 683a62cc1cb7d07b4c88eeec9333c415da8f0bdc (diff) | |
parent | fc123e360b147221b5b44d265cdf38feabe99bbe (diff) |
Merge branch 'master' of https://github.com/yenatch/pokered
Diffstat (limited to 'engine/joypad.asm')
-rw-r--r-- | engine/joypad.asm | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/engine/joypad.asm b/engine/joypad.asm new file mode 100644 index 00000000..d2ad1c31 --- /dev/null +++ b/engine/joypad.asm @@ -0,0 +1,51 @@ +_Joypad:: + ld a, [hJoyInput] + cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset + jp z, TrySoftReset + ld b, a + ld a, [hJoyHeldLast] + ld e, a + xor b + ld d, a + and e + ld [hJoyReleased], a + ld a, d + and b + ld [hJoyPressed], a + ld a, b + ld [hJoyHeldLast], a + ld a, [wd730] + bit 5, a + jr nz, DiscardButtonPresses + ld a, [hJoyHeldLast] + ld [hJoyHeld], a + ld a, [wJoyIgnore] + and a + ret z + cpl + ld b, a + ld a, [hJoyHeld] + and b + ld [hJoyHeld], a + ld a, [hJoyPressed] + and b + ld [hJoyPressed], a + ret + +DiscardButtonPresses: + xor a + ld [hJoyHeld], a + ld [hJoyPressed], a + ld [hJoyReleased], a + ret + +TrySoftReset: + call DelayFrame + ; reset joypad (to make sure the + ; player is really trying to reset) + ld a, $30 + ld [rJOYP], a + ld hl, hSoftReset + dec [hl] + jp z, SoftReset + jp Joypad |