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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
_PauseMenu_Config:
ld a, [wd291]
push af
ld a, [wLineSeparation]
push af
xor a
ld [wConfigExitSettingsCursorPos], a
ld a, 1
ld [wLineSeparation], a
call InitMenuScreen
lb de, 0, 3
lb bc, 20, 5
call DrawRegularTextBox
lb de, 0, 9
lb bc, 20, 5
call DrawRegularTextBox
ld hl, ConfigScreenLabels
call PrintLabels
call GetConfigCursorPositions
ld a, 0
call ShowConfigMenuCursor
ld a, 1
call ShowConfigMenuCursor
xor a
ld [wCursorBlinkTimer], a
call FlashWhiteScreen
.asm_10588
call DoFrameIfLCDEnabled
ld a, [wConfigCursorYPos]
call UpdateConfigMenuCursor
ld hl, wCursorBlinkTimer
inc [hl]
call ConfigScreenHandleDPadInput
ldh a, [hKeysPressed]
and B_BUTTON | START
jr nz, .asm_105ab
ld a, [wConfigCursorYPos]
cp $02
jr nz, .asm_10588
ldh a, [hKeysPressed]
and A_BUTTON
jr z, .asm_10588
.asm_105ab
ld a, SFX_02
call PlaySFX
call SaveConfigSettings
pop af
ld [wLineSeparation], a
pop af
ld [wd291], a
ret
ConfigScreenLabels:
db 1, 1
tx ConfigMenuTitleText
db 1, 4
tx ConfigMenuMessageSpeedText
db 1, 10
tx ConfigMenuDuelAnimationText
db 1, 16
tx ConfigMenuExitText
db $ff
; checks the current saved configuration settings
; and sets wConfigMessageSpeedCursorPos and wConfigDuelAnimationCursorPos
; to the right positions for those values
GetConfigCursorPositions:
call EnableSRAM
ld c, 0
ld hl, TextDelaySettings
.loop
ld a, [sTextSpeed]
cp [hl]
jr nc, .match
inc hl
inc c
ld a, c
cp 4
jr c, .loop
.match
ld a, c
ld [wConfigMessageSpeedCursorPos], a
ld a, [sSkipDelayAllowed]
and $1
rlca
ld c, a
ld a, [wAnimationsDisabled]
and $1
or c
ld c, a
ld b, $00
ld hl, DuelAnimationSettingsIndices
add hl, bc
ld a, [hl]
ld [wConfigDuelAnimationCursorPos], a
call DisableSRAM
ret
; indexes into DuelAnimationSettings
; 0: show all
; 1: skip some
; 2: none
DuelAnimationSettingsIndices:
db 0 ; skip delay allowed = false, animations disabled = false
db 0 ; skip delay allowed = false, animations disabled = true (unused)
db 1 ; skip delay allowed = true, animations disabled = false
db 2 ; skip delay allowed = true, animations disabled = true
SaveConfigSettings:
call EnableSRAM
ld a, [wConfigDuelAnimationCursorPos]
and %11
rlca
ld c, a
ld b, $00
ld hl, DuelAnimationSettings
add hl, bc
ld a, [hli]
ld [wAnimationsDisabled], a
ld [sAnimationsDisabled], a
ld a, [hl]
ld [sSkipDelayAllowed], a
call DisableSRAM
ld a, [wConfigMessageSpeedCursorPos]
ld c, a
ld b, $00
ld hl, TextDelaySettings
add hl, bc
call EnableSRAM
ld a, [hl]
ld [sTextSpeed], a
ld [wTextSpeed], a
call DisableSRAM
ret
DuelAnimationSettings:
; animation disabled, skip delay allowed
db FALSE, FALSE ; show all
db FALSE, TRUE ; skip some
db TRUE, TRUE ; none
db FALSE, FALSE ; unused
; text printing delay
TextDelaySettings:
; slow to fast
db 6, 4, 2, 1, 0
UpdateConfigMenuCursor:
push af
ld a, [wCursorBlinkTimer]
and $10
jr z, .show
pop af
jr HideConfigMenuCursor
.show
pop af
jr ShowConfigMenuCursor ; can be fallthrough
ShowConfigMenuCursor:
push bc
ld c, a
ld a, SYM_CURSOR_R
call DrawConfigMenuCursor
pop bc
ret
HideConfigMenuCursor:
push bc
ld c, a
ld a, SYM_SPACE
call DrawConfigMenuCursor
pop bc
ret
DrawConfigMenuCursor:
push af
sla c
ld b, $00
ld hl, ConfigScreenCursorPositions
add hl, bc
ld a, [hli]
ld h, [hl]
ld l, a
ld a, [hli]
ld c, a
ld a, [hli]
ld b, a
ld a, [bc]
add a
ld c, a
ld b, $00
add hl, bc
ld a, [hli]
ld b, a
ld a, [hl]
ld c, a
pop af
call WriteByteToBGMap0
ret
ConfigScreenCursorPositions:
dw MessageSpeedCursorPositions
dw DuelAnimationsCursorPositions
dw ExitSettingsCursorPosition
MessageSpeedCursorPositions:
dw wConfigMessageSpeedCursorPos
db 5, 6
db 7, 6
db 9, 6
db 11, 6
db 13, 6
DuelAnimationsCursorPositions:
dw wConfigDuelAnimationCursorPos
db 1, 12
db 7, 12
db 15, 12
ExitSettingsCursorPosition:
dw wConfigExitSettingsCursorPos
db 1, 16
db 0
ConfigScreenHandleDPadInput:
ldh a, [hDPadHeld]
and D_PAD
ret z
farcall GetDirectionFromDPad
ld hl, ConfigScreenDPadHandlers
jp JumpToFunctionInTable
ConfigScreenDPadHandlers:
dw ConfigScreenDPadUp ; up
dw ConfigScreenDPadRight ; right
dw ConfigScreenDPadDown ; down
dw ConfigScreenDPadLeft ; left
ConfigScreenDPadUp:
ld a, -1
jr ConfigScreenDPadDown.up_or_down
ConfigScreenDPadDown:
ld a, 1
.up_or_down
push af
ld a, [wConfigCursorYPos]
cp 2
jr z, .hide_cursor
call ShowConfigMenuCursor
jr .skip
.hide_cursor
; hide "exit settings" cursor if leaving bottom row
call HideConfigMenuCursor
.skip
ld a, [wConfigCursorYPos]
ld b, a
pop af
add b
cp 3
jr c, .valid
jr z, .wrap_min
; wrap max
ld a, 2 ; max
jr .valid
.wrap_min
xor a ; min
.valid
ld [wConfigCursorYPos], a
ld c, a
ld b, 0
ld hl, Unknown_106ff
add hl, bc
ld a, [hl]
ld [wCursorBlinkTimer], a
ld a, [wConfigCursorYPos]
call UpdateConfigMenuCursor
ld a, SFX_01
call PlaySFX
ret
Unknown_106ff:
db $18 ; message speed, start hidden
db $18 ; duel animation, start hidden
db $8 ; exit settings, start visible
ConfigScreenDPadRight:
ld a, 1
jr ConfigScreenDPadLeft.left_or_right
ConfigScreenDPadLeft:
ld a, -1
.left_or_right
push af
ld a, [wConfigCursorYPos]
call HideConfigMenuCursor
pop af
call .ApplyPosChange
ld a, [wConfigCursorYPos]
call ShowConfigMenuCursor
xor a
ld [wCursorBlinkTimer], a
ret
; a = 1 for right, -1 for left
.ApplyPosChange
push af
ld a, [wConfigCursorYPos]
ld c, a
add a
add c ; *3
ld c, a
ld b, $00
ld hl, .MaxCursorPositions
add hl, bc
ld a, [hli]
ld e, a
ld a, [hli]
ld d, a
ld c, [hl] ; max value
ld a, [de]
ld b, a
pop af
add b ; apply pos change
cp c
jr c, .got_new_pos
jr z, .got_new_pos
cp $80
jr c, .wrap_around
; wrap to last
ld a, c
jr .got_new_pos
.wrap_around
; wrap to first
xor a
.got_new_pos
ld [de], a
ld a, c
or a
jr z, .skip_sfx
ld a, SFX_01
call PlaySFX
.skip_sfx
ret
.MaxCursorPositions:
; x pos variable, max x value
dwb wConfigMessageSpeedCursorPos, 4
dwb wConfigDuelAnimationCursorPos, 2
dwb wConfigExitSettingsCursorPos, 0
|