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 /home/joypad.asm | |
parent | 683a62cc1cb7d07b4c88eeec9333c415da8f0bdc (diff) | |
parent | fc123e360b147221b5b44d265cdf38feabe99bbe (diff) |
Merge branch 'master' of https://github.com/yenatch/pokered
Diffstat (limited to 'home/joypad.asm')
-rw-r--r-- | home/joypad.asm | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/home/joypad.asm b/home/joypad.asm new file mode 100644 index 00000000..2002bb29 --- /dev/null +++ b/home/joypad.asm @@ -0,0 +1,39 @@ +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 + + 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:: +; Update the joypad state variables: +; [hJoyReleased] keys released since last time +; [hJoyPressed] keys pressed since last time +; [hJoyHeld] currently pressed keys + homecall _Joypad + ret |