1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
_Joypad::
; hJoyReleased: (hJoyLast ^ hJoyInput) & hJoyLast
; hJoyPressed: (hJoyLast ^ hJoyInput) & hJoyInput
ld a, [hJoyInput]
cp A_BUTTON + B_BUTTON + SELECT + START ; soft reset
jp z, TrySoftReset
ld b, a
ld a, [hJoyLast]
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 [hJoyLast], a
ld a, [wd730]
bit 5, a
jr nz, DiscardButtonPresses
ld a, [hJoyLast]
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
; deselect (redundant)
ld a, $30
ld [rJOYP], a
ld hl, hSoftReset
dec [hl]
jp z, SoftReset
jp Joypad
|