summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoryenatch <yenatch@gmail.com>2014-05-31 01:31:08 -0700
committeryenatch <yenatch@gmail.com>2014-05-31 12:25:40 -0700
commitb32abf1f161d82c8cc2b3b84e64536124e17530f (patch)
treea384854b7cd89ca2cbbf6701f45df403e3805614
parent6d8c6055b5d5910d4da6997199f0984f8cd9149f (diff)
Split out joypad code from main.asm.
-rw-r--r--engine/joypad.asm51
-rwxr-xr-xmain.asm52
2 files changed, 52 insertions, 51 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
diff --git a/main.asm b/main.asm
index 4ba797f2..6a42c822 100755
--- a/main.asm
+++ b/main.asm
@@ -1940,57 +1940,7 @@ Func_7c18: ; 7c18 (1:7c18)
SECTION "bank3",ROMX,BANK[$3]
-_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
+INCLUDE "engine/joypad.asm"
INCLUDE "data/map_songs.asm"