diff options
author | luckytyphlosion <alan.rj.huang@gmail.com> | 2015-05-10 15:40:56 -0400 |
---|---|---|
committer | luckytyphlosion <alan.rj.huang@gmail.com> | 2015-05-10 15:40:56 -0400 |
commit | cf00317e16cdcb9b589d31e90a8dbe6288af95b0 (patch) | |
tree | f7cfc6f245a47537e17422d6b70605451d5f2737 | |
parent | a01d306880402287a493e19fef2a8cc694cfcb78 (diff) |
Create readjoypad.asm
-rw-r--r-- | engine/readjoypad.asm | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/engine/readjoypad.asm b/engine/readjoypad.asm new file mode 100644 index 00000000..96897455 --- /dev/null +++ b/engine/readjoypad.asm @@ -0,0 +1,31 @@ +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 |