summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--home/joypad.asm20
-rw-r--r--hram.asm23
2 files changed, 33 insertions, 10 deletions
diff --git a/home/joypad.asm b/home/joypad.asm
index 80371b7..35e8086 100644
--- a/home/joypad.asm
+++ b/home/joypad.asm
@@ -3,6 +3,16 @@ INCLUDE "constants.asm"
SECTION "Joypad functions", ROM0[$07FE]
Joypad:: ; 7fe (0:7fe)
+; Read the joypad register and translate it to something more
+; workable for use in-game. There are 8 buttons, so we can use
+; one byte to contain all player input.
+
+; Updates:
+
+; hJoypadUp: released this frame (delta)
+; hJoypadDown: pressed this frame (delta)
+; hJoypadState: currently pressed
+; hJoypadSum: pressed so far
ld a, [$d4ab]
and $d0
ret nz
@@ -28,22 +38,22 @@ Joypad:: ; 7fe (0:7fe)
ld b, a
ld a, (1 << 5 | 1 << 4) ; port reset
ldh [rJOYP], a
- ldh a, [hJoypadDown]
+ ldh a, [hJoypadState]
ld e, a
xor b
ld d, a
and e
- ldh [hJoypadReleased], a
+ ldh [hJoypadUp], a
ld a, d
and b
- ldh [hJoypadPressed], a
+ ldh [hJoypadDown], a
ld c, a
ldh a, [hJoypadSum]
or c
ldh [hJoypadSum], a
ld a, b
- ldh [hJoypadDown], a
- ldh [hJoypadDown2], a
+ ldh [hJoypadState], a
+ ldh [hJoypadState2], a
and $0f
cp $0f
jp z, Reset
diff --git a/hram.asm b/hram.asm
index 6932c10..d6df6a9 100644
--- a/hram.asm
+++ b/hram.asm
@@ -21,14 +21,27 @@ hVBlank:: ; ff99
ds 3 ; TODO
-hJoypadReleased:: db ; ff9d
-hJoypadPressed:: db ; ff9e
-hJoypadDown:: db ; ff9f
+hJoypadUp:: db ; ff9d
+; Raw Joypad Up Event
+; A pressed key was released
+hJoypadDown:: db ; ff9e
+; Raw Joypad Down Event
+; An unpressed key was pressed
+hJoypadState:: db ; ff9f
+; Raw Joypad State
+; State of all keys during current frame
hJoypadSum:: db ; ffa0
+; Raw Joypad State Sum
+; Sum of all keys that were pressed
+; since hJoypadSum was last cleared
- ds 5; TODO
+ ds 1; TODO
+hJoyDown:: db ; ffa2
+hJoyState:: db ; ffa3
+hJoySum:: db ; ffa4
+ ds 1; TODO
-hJoypadDown2:: db ; ffa6
+hJoypadState2:: db ; ffa6
ds 8 ; TODO