summaryrefslogtreecommitdiff
path: root/engine/debug/field/pokemart_menu.inc
blob: 4ebeb5b7c4d985cdbc98197da412d25a11ecaf75 (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
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
FieldDebug_PokemartMenu:
	ld hl, DebugMart_WelcomeText
	call MenuTextBox
	call ExitMenu
	call .DoPokemartMenu
	ld a, FIELDDEBUG_RETURN_REOPEN
	ret

.DoPokemartMenu:
	call LoadStandardMenuHeader
	callab asm_24860
	ld hl, DebugMart_PokemartMenuText
	call PrintText
	ld hl, .MenuHeader
	call CopyMenuHeader
	call VerticalMenu
	push af
	call ExitMenu
	pop af
	jr c, .exit_menu
	ld a, [wMenuCursorY]
	dec a
	ld hl, .MenuJumptable
	call CallJumptable
	jr nc, .DoPokemartMenu
	ret

.exit_menu
	ld hl, DebugMart_GoodbyeText
	call MenuTextBoxBackup
	scf
	ret

.MenuHeader:
	db MENU_BACKUP_TILES
	menu_coords 0, 0, 10, 8
	dw .MenuData
	db 1 ; default

.MenuData:
	db STATICMENU_CURSOR
	db 3 ; items
	db "どうぐを かう@"
	db "どうぐを うる@"
	db "さようなら@"

.MenuJumptable:
	dw DebugMart_Buy
	dw DebugMart_Sell
	dw .exit_menu

DebugMart_BuyMenuHeader:
	db MENU_BACKUP_TILES
	menu_coords 1, 3, 19, 11
	dw .BuyMenuParams
	db 1 ; default

.BuyMenuParams:
	db STATICMENU_WRAP
	db 4, 8 ; rows, columns
	db SCROLLINGMENU_ITEMS_NORMAL
	dbw 0, wcd60
	dba PlaceMenuItemName
	dba .PrintAmount
	dba UpdateItemDescription

.PrintAmount:
	ld a, [wScrollingMenuCursorPosition]
	ld c, a
	ld b, 0
	ld hl, wcc40
	add hl, bc
	add hl, bc
	add hl, bc
	push de
	ld d, h
	ld e, l
	pop hl
	ld c, $83
	call PrintBCDNumber
	ld [hl], "円"
	ret

DebugMart_WelcomeText:
	text "フレンドりーショップへ "
	line "ようこそ!"
	prompt

DebugMart_PokemartMenuText:
	text "なんになさいますか?"
	done

DebugMart_GoodbyeText:
	text "またのごりようを"
	line "おまちしています"
	prompt

DebugMart_Buy:
	ld de, DebugMart_ItemList
	call DebugMart_LoadItems
	call LoadStandardMenuHeader
	call ClearTileMap
.buy_loop
	call .BuyMenu
	jr nc, .buy_loop
	call ExitMenu
	and a
	ret

.BuyMenu:
	call UpdateSprites
	ld hl, DebugMart_BuyMenuHeader
	call CopyMenuHeader
	call ScrollingMenu
	ld a, [wMenuJoypad]
	cp B_BUTTON
	jr z, .cancel_buy
	cp A_BUTTON
	jr z, .buy_item
.buy_item
	ld a, 99
	ld [wItemQuantityBuffer], a
	ld hl, .HowManyText
	call PrintText
	callab asm_24c64
	call ExitMenu
	jr c, .done
	predef LoadItemData
	ld hl, .ConfirmPurchaseText
	call PrintText
	call YesNoBox
	jr c, .done
	ld hl, .UnderDevelopmentText
	call MenuTextBoxBackup
.done
	and a
	ret

.cancel_buy
	scf
	ret

.BuyPromptText: ; unreferenced?
	text "なにを おかいあげに"
	line "なりますか"
	done

.HowManyText:
	text "いくつ おかいあげになりますか"
	done

.ConfirmPurchaseText:
	text_from_ram wStringBuffer2
	text "を @"
	deciram wItemQuantity, 1, $2
	text "こで"
	line "@"
	deciram hFFCD, 3, $6
	text "円 おかいあげですか?"
	done

.UnderDevelopmentText:
	text "ごめんね"
	line "かいはつちゅうなんだ"
	prompt

INCLUDE "data/debug/field_debug_pokemart_items.inc"

DebugMart_Sell:
	call DebugMart_ShowPlaceholderText
	and a
	ret

; unused
	callab CheckItemsQuantity
	jp c, .no_items
	call LoadStandardMenuHeader
	xor a
	ld [wActiveBackpackPocket], a
.bag_loop
	callab DrawBackpack
	callab DebugBackpackLoop
	jr c, .close_bag
	call .DoBagFunctions
	jr nc, .bag_loop
.close_bag
	call ClearBGPalettes
	call CloseWindow
	call UpdateTimePals
	and a
	ret

.DoBagFunctions:
	callab CheckItemMenu
	ld a, [wItemAttributeParamBuffer]
	ld hl, .BagJumptable
	call CallJumptable
	ret

.BagJumptable:
	dw .CheckSellableItem
	dw .CannotSellItem
	dw .BallPocket
	dw .FlipPocket
	dw .CheckSellableItem
	dw .CheckSellableItem
	dw .CheckSellableItem

.FlipPocket:
	callab FlipPocket2Status
	xor a
	ld [wSelectedSwapPosition], a
	ret

.CannotSellItem:
	ld hl, .CannotSellText
	call MenuTextBoxBackup
	and a
	ret

.CannotSellText:
	text "つかえないのだ!"
	prompt

.BallPocket:
	callab BallPocket
	jr nc, .CheckSellableItem
	and a
	ret

.CheckSellableItem:
	callab _CheckTossableItem
	ld a, [wItemAttributeParamBuffer]
	and a
	jr nz, .not_sellable
	jp .ItemQuantityPrompt

.not_sellable
	ld hl, .ImportantItemText
	call MenuTextBoxBackup
	and a
	ret

.ImportantItemText:
	text "それは だいじなものです"
	line "うることは できません!"
	prompt

.no_items
	ld hl, .NoItemsText
	call MenuTextBoxBackup
	and a
	ret

.NoItemsText:
	text "どうぐを ひとつも"
	next "もっていません!"
	prompt

.ItemQuantityPrompt:
	ld hl, .HowManyItemsText
	call PrintText
	callab asm_24c64
	jr c, .got_quantity
	jr .CannotSellItem

.got_quantity
	and a
	ret

.HowManyItemsText:
	text "いくつ うりますか?"
	done

DebugMart_LoadItems:
	ld hl, wcd60
.load_loop
	ld a, [de]
	inc de
	ld [hli], a
	cp -1
	jr nz, .load_loop
	ld hl, wcc40
	ld de, wcd60 + 1
.load_loop2
	ld a, [de]
	inc de
	cp -1
	jr z, .done_load
	push de
	call .GetPrice
	pop de
	jr .load_loop2

.done_load
	ret

.GetPrice:
	push hl
	ld [wCurItem], a
	callab GetItemPrice
	ld a, d
	ld [wcdc3], a
	ld a, e
	ld [wcdc3 + 1], a
	ld hl, wStringBuffer1
	ld de, wcdc3
	ld bc, $8206
	call PrintNumber
	pop hl
	ld de, wStringBuffer1
	ld c, 3
.print_price
	call .PrintPaddedDigits
	swap a
	ld b, a
	call .PrintPaddedDigits
	or b
	ld [hli], a
	dec c
	jr nz, .print_price
	ret

.PrintPaddedDigits:
	ld a, [de]
	inc de
	cp " "
	jr nz, .to_digit
	ld a, "0"
.to_digit
	sub "0"
	ret

DebugMart_ShowPlaceholderText:
	ld hl, .PlaceholderText
	call MenuTextBox
	call ExitMenu
	ret

.PlaceholderText:
	text "かいはつちゅうです"
	next "<PROMPT>"