Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/joypad.asm
1270 views
1
_Joypad::
2
; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast
3
; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput
4
5
ldh a, [hJoyInput]
6
cp PAD_BUTTONS ; soft reset
7
jp z, TrySoftReset
8
9
ld b, a
10
ldh a, [hJoyLast]
11
ld e, a
12
xor b
13
ld d, a
14
and e
15
ldh [hJoyReleased], a
16
ld a, d
17
and b
18
ldh [hJoyPressed], a
19
ld a, b
20
ldh [hJoyLast], a
21
22
ld a, [wStatusFlags5]
23
bit BIT_DISABLE_JOYPAD, a
24
jr nz, DiscardButtonPresses
25
26
ldh a, [hJoyLast]
27
ldh [hJoyHeld], a
28
29
ld a, [wJoyIgnore]
30
and a
31
ret z
32
33
cpl
34
ld b, a
35
ldh a, [hJoyHeld]
36
and b
37
ldh [hJoyHeld], a
38
ldh a, [hJoyPressed]
39
and b
40
ldh [hJoyPressed], a
41
ret
42
43
DiscardButtonPresses:
44
xor a
45
ldh [hJoyHeld], a
46
ldh [hJoyPressed], a
47
ldh [hJoyReleased], a
48
ret
49
50
TrySoftReset:
51
call DelayFrame
52
53
; deselect (redundant)
54
ld a, $30
55
ldh [rJOYP], a
56
57
ld hl, hSoftReset
58
dec [hl]
59
jp z, SoftReset
60
61
jp Joypad
62
63