summaryrefslogtreecommitdiff
path: root/engine/debug/debug_menu.asm
blob: 020e2272d52f5711a0c3d9a0d6983ee97bd9a7ea (plain)
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
INCLUDE "constants.asm"

SECTION "engine/menu/debug_menu.asm", ROMX

; DebugJumpTable indices
	const_def
	const DEBUGMENU_FIGHT
	const DEBUGMENU_FIELD
	const DEBUGMENU_SOUNDTEST
	const DEBUGMENU_SUBGAME
	const DEBUGMENU_POKEDEX
	const DEBUGMENU_TRAINERGEAR

DebugMenu::
	call ClearTileMap
	call ClearWindowData
	call LoadFont
	call LoadFontsBattleExtra
	call ClearSprites
	call GetMemSGBLayout
	xor a
	ld [wWhichIndexSet], a
	ld hl, DebugMenuHeader
	call LoadMenuHeader
	call OpenMenu
	call CloseWindow
	jp c, TitleSequenceStart
	ld a, $41
	ld [wce5f], a
	ld a, [wMenuSelection]
	ld hl, DebugJumpTable
	jp CallJumptable

DebugJumpTable::
	dw DebugMenuOptionFight
	dw DebugMenuOptionField
	dw DebugMenuSoundTest	; to home bank
	dw DebugMenuOptionSubGames
	dw DebugMenuOptionMonsterTest
	dw DebugMenuOptionName

DebugMenuHeader:
	db MENU_BACKUP_TILES ; flags
	menu_coords 5, 2, SCREEN_WIDTH - 7, SCREEN_HEIGHT - 1
	dw .MenuData
	db 1 ; default option

.MenuData:
	db STATICMENU_CURSOR | STATICMENU_WRAP
	db 0
	dw DebugMenuItems
	dw PlaceMenuStrings
	dw .Strings

.Strings
	db "ファイト@"
	db "フィールド@"
	db "サウンド@"
	db "サブゲーム@"
	db "モンスター@"
	db "なまえ@"

DebugMenuItems:
	db 6 ; items
	db DEBUGMENU_FIGHT
	db DEBUGMENU_FIELD
	db DEBUGMENU_SOUNDTEST
	db DEBUGMENU_SUBGAME
	db DEBUGMENU_POKEDEX
	db DEBUGMENU_TRAINERGEAR
	db -1

DebugMenuOptionField::
	ld hl, wDebugFlags
	set DEBUG_FIELD_F, [hl] ; set debug mode
	jp StartNewGame

DebugMenuOptionFight::
	ld hl, wDebugFlags
	set DEBUG_BATTLE_F, [hl]
	predef Functionfdb66
	ld hl, wDebugFlags
	res DEBUG_BATTLE_F, [hl]
	ret

DebugMenuOptionSubGames::
	callab CallSubGameMenu
	jp DebugMenu

DebugMenuOptionMonsterTest::
	ld hl, wPokedexOwned
	ld de, wPokedexSeen
	ld b, NUM_POKEMON / 8
	ld a, %11111111
.loop
	ld [hli], a
	ld [de], a
	inc de
	dec b
	jr nz, .loop
	ld a, (1 << ((NUM_POKEMON - 1) % 8)) - 1 ; discount #251
	ld [hl], a
	ld [de], a
	callab MonsterTest
	ld a, %11100100
	ldh [rBGP], a

Function40eb::
	jp DebugMenu

DebugMenuOptionName::
	callab OpenTrainerGear
	ld a, %11100100
	ldh [rBGP], a
	jp DebugMenu

SECTION "engine/menu/debug_menu.asm@Sound Test", ROMX

_DebugMenuSoundTest::
	call ClearTileMap
	call LoadFontExtra
	call ClearSprites
	call GetMemSGBLayout
	xor a
	ldh [hDebugMenuSoundMenuIndex], a
	call .DetermineDescriptionPointer

.RefreshScreenAndLoop:
	call WaitBGMap

.Loop:
	call ClearJoypad
	call GetJoypad
	ldh a, [hJoyDown]
	and a
	jr z, .Loop

	bit A_BUTTON_F, a
	jr nz, .a_pressed

	bit B_BUTTON_F, a
	jr nz, .b_pressed

	bit START_F, a
	jr nz, .start_pressed

	bit D_UP_F, a
	jr nz, .up_pressed

	bit D_DOWN_F, a
	jr nz, .down_pressed

	ret

.a_pressed
	ldh a, [hDebugMenuSoundBank]
	ld c, a
	ldh a, [hDebugMenuSoundID]
	jr .RefreshScreenAndLoop

.up_pressed
	ldh a, [hDebugMenuSoundMenuIndex]
	inc a
	cp 55
	jr nz, .SetIndex

	xor a

.SetIndex:
	ldh [hDebugMenuSoundMenuIndex], a
	call .DetermineDescriptionPointer
	jr .RefreshScreenAndLoop

.down_pressed
	ldh a, [hDebugMenuSoundMenuIndex]
	dec a
	cp -1
	jr nz, .SetIndex2

	ld a, 54

.SetIndex2:
	ldh [hDebugMenuSoundMenuIndex], a
	call .DetermineDescriptionPointer
	jr .RefreshScreenAndLoop

.start_pressed
	ldh a, [hDebugMenuSoundBank]
	ld c, a
	ld a, -1
	jr .RefreshScreenAndLoop

.b_pressed
	ldh a, [hDebugMenuSoundBank]
	ld c, a
	ld a, 10
	ld [wcdb5], a
	ld [wcdb6], a
	ld a, $ff
	ld [wcdb4], a
	jr .RefreshScreenAndLoop

.DetermineDescriptionPointer:
	ld hl, SoundTestTextPointers
	ldh a, [hDebugMenuSoundMenuIndex]
	add a
	add a ; a * 4
	ld d, 0
	ld e, a
	add hl, de
	ld a, [hli]
	ldh [hDebugMenuSoundID], a
	ld a, [hli]
	ldh [hDebugMenuSoundBank], a
	ld a, [hli]
	ld e, a
	ld d, [hl]
	call CopyStringToStringBuffer2
	call .DisplayText
	ret

.DisplayText:
	ld hl, hDebugMenuSoundMenuIndex
	inc [hl]
	ld hl, .String
	call PrintText
	ld hl, hDebugMenuSoundMenuIndex
	dec [hl]
	ld c, 3
	call DelayFrames
	ret

.String:
	deciram hDebugMenuSoundMenuIndex, 1, 1
	text "<LINE>@"
	text_from_ram wStartDay
	text " "
	done

INCLUDE "data/sound_test_text_pointers.inc"

SECTION "engine/menu/debug_menu.asm@Subgame Menu", ROMX

CallSubGameMenu:
	call ClearTileMap
	call LoadFont
	call LoadFontsBattleExtra
	call ClearSprites
	call GetMemSGBLayout
	ld hl, .MenuHeader
	call CopyMenuHeader
	call VerticalMenu
	ret c

	ld a, [wMenuCursorY]
	dec a
	ld e, a
	ld d, 0
	ld hl, .Jumptable
	add hl, de
	add hl, de
	ld a, [hli]
	ld h, [hl]
	ld l, a
	ld de, .return
	push de
	jp hl

.return
	jr CallSubGameMenu

.Jumptable:
	dw SubGameMenu_PokerGame
	dw SubGameMenu_PuzzleGame
	dw SubGameMenu_CardFlipGame
	dw SubGameMenu_PicrossGame
	dw SubGameMenu_SlotMachineGame

.MenuHeader:
	db 0 ; flags
	menu_coords 5, 4, SCREEN_WIDTH - 7, SCREEN_HEIGHT - 3
	dw .MenuData
	db 1 ; default option

.MenuData:
	db STATICMENU_CURSOR | STATICMENU_WRAP
	db 5 ; items
	db "ポーカー@"
	db "15パズル@"
	db "しんけい@"
	db "ピクロス@"
	db "スロット@"

SubGameMenu_PokerGame:
	callab PokerMinigame
	ret

SubGameMenu_PuzzleGame:
	callab FifteenPuzzleMinigame
	ret

SubGameMenu_CardFlipGame:
	callab MemoryMinigame
	ret

SubGameMenu_PicrossGame:
	callab PicrossMinigame
	ret

SubGameMenu_SlotMachineGame:
	callab SlotMachineGame
	ret