-
Notifications
You must be signed in to change notification settings - Fork 823
/
main_menu.asm
384 lines (341 loc) · 6.37 KB
/
main_menu.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
; MainMenuItems indexes
const_def
const MAINMENU_NEW_GAME ; 0
const MAINMENU_CONTINUE ; 1
const MAINMENU_MOBILE_MYSTERY ; 2
const MAINMENU_MOBILE ; 3
const MAINMENU_MOBILE_STUDIUM ; 4
const MAINMENU_MYSTERY_MOBILE_STUDIUM ; 5
const MAINMENU_MYSTERY ; 6
const MAINMENU_MYSTERY_STUDIUM ; 7
const MAINMENU_STUDIUM ; 8
; MainMenu.Strings and MainMenu.Jumptable indexes
const_def
const MAINMENUITEM_CONTINUE ; 0
const MAINMENUITEM_NEW_GAME ; 1
const MAINMENUITEM_OPTION ; 2
const MAINMENUITEM_MYSTERY_GIFT ; 3
const MAINMENUITEM_MOBILE ; 4
const MAINMENUITEM_MOBILE_STUDIUM ; 5
const MAINMENUITEM_DEBUG_ROOM ; 6
MobileMenuGFX:
INCBIN "gfx/mobile/mobile_menu.2bpp"
MainMenu:
.loop
xor a
ld [wDisableTextAcceleration], a
call ClearTilemapEtc
ld b, SCGB_DIPLOMA
call GetSGBLayout
call SetDefaultBGPAndOBP
ld hl, wGameTimerPaused
res GAME_TIMER_COUNTING_F, [hl]
call MainMenu_GetWhichMenu
ld [wWhichIndexSet], a
call MainMenu_PrintCurrentTimeAndDay
ld hl, .MenuHeader
call LoadMenuHeader
call MainMenuJoypadLoop
call CloseWindow
jr c, .quit
call ClearTilemap
ld a, [wMenuSelection]
ld hl, .Jumptable
rst JumpTable
jr .loop
.quit
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, 16, 7
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR ; flags
db 0 ; items
dw MainMenuItems
dw PlaceMenuStrings
dw .Strings
.Strings:
; entries correspond to MAINMENUITEM_* constants
db "CONTINUE@"
db "NEW GAME@"
db "OPTION@"
db "MYSTERY GIFT@"
db "MOBILE@"
db "MOBILE STUDIUM@"
if DEF(_DEBUG)
db "DEBUG ROOM@"
endc
.Jumptable:
; entries correspond to MAINMENUITEM_* constants
dw MainMenu_Continue
dw MainMenu_NewGame
dw MainMenu_Option
dw MainMenu_MysteryGift
dw MainMenu_Mobile
dw MainMenu_MobileStudium
if DEF(_DEBUG)
dw MainMenu_DebugRoom
endc
MainMenuItems:
; entries correspond to MAINMENU_* constants
; MAINMENU_NEW_GAME
db 2
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db -1
; MAINMENU_CONTINUE
db 3 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_MOBILE_MYSTERY
db 5 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MYSTERY_GIFT
db MAINMENUITEM_MOBILE
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_MOBILE
db 4 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MOBILE
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_MOBILE_STUDIUM
db 5 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MOBILE
db MAINMENUITEM_MOBILE_STUDIUM
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_MYSTERY_MOBILE_STUDIUM
db 6 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MYSTERY_GIFT
db MAINMENUITEM_MOBILE
db MAINMENUITEM_MOBILE_STUDIUM
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_MYSTERY
db 4 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MYSTERY_GIFT
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_MYSTERY_STUDIUM
db 5 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MYSTERY_GIFT
db MAINMENUITEM_MOBILE_STUDIUM
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
; MAINMENU_STUDIUM
db 4 + DEF(_DEBUG)
db MAINMENUITEM_CONTINUE
db MAINMENUITEM_NEW_GAME
db MAINMENUITEM_OPTION
db MAINMENUITEM_MOBILE_STUDIUM
if DEF(_DEBUG)
db MAINMENUITEM_DEBUG_ROOM
endc
db -1
MainMenu_GetWhichMenu:
nop
nop
nop
ld a, [wSaveFileExists]
and a
jr nz, .next
ld a, MAINMENU_NEW_GAME
ret
.next
ldh a, [hCGB]
cp TRUE
ld a, MAINMENU_CONTINUE
ret nz
ld a, BANK(sNumDailyMysteryGiftPartnerIDs)
call OpenSRAM
ld a, [sNumDailyMysteryGiftPartnerIDs]
cp -1 ; locked?
call CloseSRAM
jr nz, .mystery_gift
; This check makes no difference.
ld a, [wStatusFlags]
bit STATUSFLAGS_MAIN_MENU_MOBILE_CHOICES_F, a
ld a, MAINMENU_CONTINUE
jr z, .ok
jr .ok
.ok
jr .ok2
.ok2
ld a, MAINMENU_CONTINUE
ret
.mystery_gift
; This check makes no difference.
ld a, [wStatusFlags]
bit STATUSFLAGS_MAIN_MENU_MOBILE_CHOICES_F, a
jr z, .ok3
jr .ok3
.ok3
jr .ok4
.ok4
ld a, MAINMENU_MYSTERY
ret
MainMenuJoypadLoop:
call SetUpMenu
.loop
call MainMenu_PrintCurrentTimeAndDay
ld a, [w2DMenuFlags1]
set _2DMENU_WRAP_UP_DOWN_F, a
ld [w2DMenuFlags1], a
call GetScrollingMenuJoypad
ld a, [wMenuJoypad]
cp B_BUTTON
jr z, .b_button
cp A_BUTTON
jr z, .a_button
jr .loop
.a_button
call PlayClickSFX
and a
ret
.b_button
scf
ret
MainMenu_PrintCurrentTimeAndDay:
ld a, [wSaveFileExists]
and a
ret z
xor a
ldh [hBGMapMode], a
call .PlaceBox
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call .PlaceTime
pop af
ld [wOptions], a
ld a, $1
ldh [hBGMapMode], a
ret
.PlaceBox:
call CheckRTCStatus
and RTC_RESET
jr nz, .TimeFail
hlcoord 0, 14
ld b, 2
ld c, 18
call Textbox
ret
.TimeFail:
call SpeechTextbox
ret
.PlaceTime:
ld a, [wSaveFileExists]
and a
ret z
call CheckRTCStatus
and RTC_RESET
jp nz, .PrintTimeNotSet
call UpdateTime
call GetWeekday
ld b, a
decoord 1, 15
call .PrintDayOfWeek
decoord 4, 16
ldh a, [hHours]
ld c, a
farcall PrintHour
ld [hl], ":"
inc hl
ld de, hMinutes
lb bc, PRINTNUM_LEADINGZEROS | 1, 2
call PrintNum
ret
.minString: ; unreferenced
db "min.@"
.PrintTimeNotSet:
hlcoord 1, 14
ld de, .TimeNotSetString
call PlaceString
ret
.TimeNotSetString:
db "TIME NOT SET@"
.MainMenuTimeUnknownText: ; unreferenced
text_far _MainMenuTimeUnknownText
text_end
.PrintDayOfWeek:
push de
ld hl, .Days
ld a, b
call GetNthString
ld d, h
ld e, l
pop hl
call PlaceString
ld h, b
ld l, c
ld de, .Day
call PlaceString
ret
.Days:
db "SUN@"
db "MON@"
db "TUES@"
db "WEDNES@"
db "THURS@"
db "FRI@"
db "SATUR@"
.Day:
db "DAY@"
ClearTilemapEtc:
xor a
ldh [hMapAnims], a
call ClearTilemap
call LoadFontsExtra
call LoadStandardFont
call ClearWindowData
ret
MainMenu_NewGame:
farcall NewGame
ret
MainMenu_Option:
farcall Option
ret
MainMenu_Continue:
farcall Continue
ret
MainMenu_MysteryGift:
farcall MysteryGift
ret