forked from Rangi42/polishedcrystal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit_options.asm
384 lines (344 loc) · 6.09 KB
/
init_options.asm
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
NUM_INITIAL_OPTIONS EQU 6
SetInitialOptions:
ld a, $10
ld [wMusicFade], a
xor a ; MUSIC_NONE
ld [wMusicFadeIDLo], a
ld [wMusicFadeIDHi], a
ld c, 8
call DelayFrames
call ClearBGPalettes
call LoadFontsExtra
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
hlcoord 0, 0, wAttrMap
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
xor a
call ByteFill
ld hl, .BGPalette
ld de, wUnknBGPals
ld bc, 1 palettes
ld a, $5
call FarCopyWRAM
ld de, .BGTile
ld hl, VTiles2 tile $00
lb bc, BANK(.BGTile), 1
call Get2bpp
farcall ApplyPals
call ApplyAttrAndTilemapInVBlank
call SetPalettes
ld hl, .InitialOptionsText
call PrintText
ld hl, hInMenu
ld a, [hl]
push af
ld [hl], $1
; call ClearBGPalettes
hlcoord 0, 0
lb bc, SCREEN_HEIGHT - 2, SCREEN_WIDTH - 2
call TextBox
hlcoord 2, 2
ld de, .InitialOptionsString
call PlaceString
; ld b, CGB_DIPLOMA
; call GetCGBLayout
; call SetPalettes
xor a
ld [wJumptableIndex], a
ld [hJoyPressed], a
ld c, NUM_INITIAL_OPTIONS
.print_text_loop ; this next will display the settings of each option when the menu is opened
push bc
xor a
ld [hJoyLast], a
call GetInitialOptionPointer
pop bc
ld hl, wJumptableIndex
inc [hl]
dec c
jr nz, .print_text_loop
xor a
ld [wJumptableIndex], a
inc a
ld [hBGMapMode], a
call ApplyTilemapInVBlank
.joypad_loop
call JoyTextDelay
ld a, [hJoyPressed]
and START | B_BUTTON
jr nz, .ExitOptions
call InitialOptionsControl
jr c, .dpad
call GetInitialOptionPointer
jr c, .ExitOptions
.dpad
call InitialOptions_UpdateCursorPosition
ld c, 3
call DelayFrames
jr .joypad_loop
.ExitOptions:
ld de, SFX_TRANSACTION
call PlaySFX
call WaitSFX
pop af
ld [hInMenu], a
ret
; e4241
.InitialOptionsText:
text_jump _InitialOptionsText
db "@"
.BGPalette:
if !DEF(MONOCHROME)
RGB 31, 31, 31
RGB 09, 30, 31
RGB 01, 11, 31
RGB 00, 00, 00
else
MONOCHROME_RGB_FOUR
endc
.BGTile:
INCBIN "gfx/new_game/init_bg.2bpp"
.InitialOptionsString:
db "Natures<LNBRK>"
db " :<LNBRK>"
db "Abilities<LNBRK>"
db " :<LNBRK>"
db "Color variation<LNBRK>"
db " :<LNBRK>"
db "Perfect IVs<LNBRK>"
db " :<LNBRK>"
db "Traded #mon<LNBRK>"
db "treat you as OT<LNBRK>"
db " :<LNBRK>"
db "Nuzlocke mode<LNBRK>"
db " :<LNBRK>"
db "<LNBRK>"
db "Done@"
GetInitialOptionPointer: ; e42d6
ld a, [wJumptableIndex] ; load the cursor position to a
ld e, a ; copy it to de
ld d, 0
ld hl, .Pointers
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl ; jump to the code of the current highlighted item
; e42e5
.Pointers:
dw InitialOptions_Natures
dw InitialOptions_Abilities
dw InitialOptions_ColorVariation
dw InitialOptions_PerfectIVs
dw InitialOptions_TradedMon
dw InitialOptions_NuzlockeMode
dw InitialOptions_Done
InitialOptions_Natures:
ld hl, wInitialOptions
ld a, [hJoyPressed]
and D_LEFT | D_RIGHT | A_BUTTON
jr nz, .Toggle
bit NATURES_OPT, [hl]
jr z, .SetNo
jr .SetYes
.Toggle
bit NATURES_OPT, [hl]
jr z, .SetYes
.SetNo:
res NATURES_OPT, [hl]
ld de, NoString
jr .Display
.SetYes:
set NATURES_OPT, [hl]
ld de, YesString
.Display:
hlcoord 15, 3
call PlaceString
and a
ret
InitialOptions_Abilities:
ld hl, wInitialOptions
ld a, [hJoyPressed]
and D_LEFT | D_RIGHT | A_BUTTON
jr nz, .Toggle
bit ABILITIES_OPT, [hl]
jr z, .SetNo
jr .SetYes
.Toggle
bit ABILITIES_OPT, [hl]
jr z, .SetYes
.SetNo:
res ABILITIES_OPT, [hl]
ld de, NoString
jr .Display
.SetYes:
set ABILITIES_OPT, [hl]
ld de, YesString
.Display:
hlcoord 15, 5
call PlaceString
and a
ret
InitialOptions_ColorVariation:
ld hl, wInitialOptions
ld a, [hJoyPressed]
and D_LEFT | D_RIGHT | A_BUTTON
jr nz, .Toggle
bit COLOR_VARY_OPT, [hl]
jr z, .SetNo
jr .SetYes
.Toggle
bit COLOR_VARY_OPT, [hl]
jr z, .SetYes
.SetNo:
res COLOR_VARY_OPT, [hl]
ld de, NoString
jr .Display
.SetYes:
set COLOR_VARY_OPT, [hl]
ld de, YesString
.Display:
hlcoord 15, 7
call PlaceString
and a
ret
InitialOptions_PerfectIVs:
ld hl, wInitialOptions
ld a, [hJoyPressed]
and D_LEFT | D_RIGHT | A_BUTTON
jr nz, .Toggle
bit PERFECT_IVS_OPT, [hl]
jr z, .SetNo
jr .SetYes
.Toggle
bit PERFECT_IVS_OPT, [hl]
jr z, .SetYes
.SetNo:
res PERFECT_IVS_OPT, [hl]
ld de, NoString
jr .Display
.SetYes:
set PERFECT_IVS_OPT, [hl]
ld de, YesString
.Display:
hlcoord 15, 9
call PlaceString
and a
ret
InitialOptions_TradedMon:
ld hl, wInitialOptions
ld a, [hJoyPressed]
and D_LEFT | D_RIGHT | A_BUTTON
jr nz, .Toggle
bit TRADED_AS_OT_OPT, [hl]
jr z, .SetNo
jr .SetYes
.Toggle
bit TRADED_AS_OT_OPT, [hl]
jr z, .SetYes
.SetNo:
res TRADED_AS_OT_OPT, [hl]
ld de, NoString
jr .Display
.SetYes:
set TRADED_AS_OT_OPT, [hl]
ld de, YesString
.Display:
hlcoord 15, 12
call PlaceString
and a
ret
InitialOptions_NuzlockeMode:
ld hl, wInitialOptions
ld a, [hJoyPressed]
and D_LEFT | D_RIGHT | A_BUTTON
jr nz, .Toggle
bit NUZLOCKE_MODE, [hl]
jr z, .SetNo
jr .SetYes
.Toggle
bit NUZLOCKE_MODE, [hl]
jr z, .SetYes
.SetNo:
res NUZLOCKE_MODE, [hl]
ld de, NoString
jr .Display
.SetYes:
set NUZLOCKE_MODE, [hl]
ld de, YesString
.Display:
hlcoord 15, 14
call PlaceString
and a
ret
InitialOptions_Done:
ld hl, wInitialOptions
res RESET_INIT_OPTS, [hl]
ld a, [hJoyPressed]
and A_BUTTON
jr nz, .Exit
and a
ret
.Exit:
scf
ret
NoString:
db "No @"
YesString:
db "Yes@"
InitialOptionsControl: ; e452a
ld hl, wJumptableIndex
ld a, [hJoyLast]
cp D_DOWN
jr z, .DownPressed
cp D_UP
jr z, .UpPressed
and a
ret
.DownPressed:
ld a, [hl] ; load the cursor position to a
cp NUM_INITIAL_OPTIONS
jr nz, .Increase
ld [hl], -1
.Increase:
inc [hl]
scf
ret
.UpPressed:
ld a, [hl]
and a
jr nz, .Decrease
ld [hl], NUM_INITIAL_OPTIONS + 1
.Decrease:
dec [hl]
scf
ret
; e455c
InitialOptions_UpdateCursorPosition: ; e455c
hlcoord 1, 1
ld de, SCREEN_WIDTH
ld c, SCREEN_HEIGHT - 2
.loop
ld [hl], " "
add hl, de
dec c
jr nz, .loop
ld hl, .InitialOptions_CursorPositions
ld a, [wJumptableIndex]
ld c, a
ld b, 0
add hl, bc
ld a, [hl]
; hlcoord 1, a
ld hl, wTileMap
ld bc, SCREEN_WIDTH
rst AddNTimes
inc hl
ld [hl], "▶"
ret
; e4579
.InitialOptions_CursorPositions:
db 2, 4, 6, 8, 10, 13, 16