Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/home/joypad2.asm
1270 views
1
; this function is used when lower button sensitivity is wanted (e.g. menus)
2
; OUTPUT: [hJoy5] = pressed buttons in usual format
3
; there are two flags that control its functionality, [hJoy6] and [hJoy7]
4
; there are essentially three modes of operation
5
; 1. Get newly pressed buttons only
6
; ([hJoy7] == 0, [hJoy6] == any)
7
; Just copies [hJoyPressed] to [hJoy5].
8
; 2. Get currently pressed buttons at low sample rate with delay
9
; ([hJoy7] == 1, [hJoy6] != 0)
10
; If the user holds down buttons for more than half a second,
11
; report buttons as being pressed up to 12 times per second thereafter.
12
; If the user holds down buttons for less than half a second,
13
; report only one button press.
14
; 3. Same as 2, but report no buttons as pressed if A or B is held down.
15
; ([hJoy7] == 1, [hJoy6] == 0)
16
JoypadLowSensitivity::
17
call Joypad
18
ldh a, [hJoy7] ; flag
19
and a ; get all currently pressed buttons or only newly pressed buttons?
20
ldh a, [hJoyPressed] ; newly pressed buttons
21
jr z, .storeButtonState
22
ldh a, [hJoyHeld] ; all currently pressed buttons
23
.storeButtonState
24
ldh [hJoy5], a
25
ldh a, [hJoyPressed] ; newly pressed buttons
26
and a ; have any buttons been newly pressed since last check?
27
jr z, .noNewlyPressedButtons
28
.newlyPressedButtons
29
ld a, 30 ; half a second delay
30
ldh [hFrameCounter], a
31
ret
32
.noNewlyPressedButtons
33
ldh a, [hFrameCounter]
34
and a ; is the delay over?
35
jr z, .delayOver
36
.delayNotOver
37
xor a
38
ldh [hJoy5], a ; report no buttons as pressed
39
ret
40
.delayOver
41
; if [hJoy6] = 0 and A or B is pressed, report no buttons as pressed
42
ldh a, [hJoyHeld]
43
and PAD_A | PAD_B
44
jr z, .setShortDelay
45
ldh a, [hJoy6] ; flag
46
and a
47
jr nz, .setShortDelay
48
xor a
49
ldh [hJoy5], a
50
.setShortDelay
51
ld a, 5 ; 1/12 of a second delay
52
ldh [hFrameCounter], a
53
ret
54
55
WaitForTextScrollButtonPress::
56
ldh a, [hDownArrowBlinkCount1]
57
push af
58
ldh a, [hDownArrowBlinkCount2]
59
push af
60
xor a
61
ldh [hDownArrowBlinkCount1], a
62
ld a, $6
63
ldh [hDownArrowBlinkCount2], a
64
.loop
65
push hl
66
ld a, [wTownMapSpriteBlinkingEnabled]
67
and a
68
jr z, .skipAnimation
69
call TownMapSpriteBlinkingAnimation
70
.skipAnimation
71
hlcoord 18, 16
72
call HandleDownArrowBlinkTiming
73
pop hl
74
call JoypadLowSensitivity
75
predef CableClub_Run
76
ldh a, [hJoy5]
77
and PAD_A | PAD_B
78
jr z, .loop
79
pop af
80
ldh [hDownArrowBlinkCount2], a
81
pop af
82
ldh [hDownArrowBlinkCount1], a
83
ret
84
85
; (unless in link battle) waits for A or B being pressed and outputs the scrolling sound effect
86
ManualTextScroll::
87
ld a, [wLinkState]
88
cp LINK_STATE_BATTLING
89
jr z, .inLinkBattle
90
call WaitForTextScrollButtonPress
91
ld a, SFX_PRESS_AB
92
jp PlaySound
93
.inLinkBattle
94
ld c, 65
95
jp DelayFrames
96
97