From 93b1361dffaff4fae83f4f283fa7a39ab414d73d Mon Sep 17 00:00:00 2001 From: yenatch Date: Fri, 30 May 2014 18:30:25 -0700 Subject: Split out joypad and overworld code from home.asm. --- home/joypad.asm | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 home/joypad.asm (limited to 'home/joypad.asm') 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 -- cgit v1.3.1-sl0p