Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/menus/players_pc.asm
1271 views
1
PlayerPC::
2
ld hl, wStatusFlags5
3
set BIT_NO_TEXT_DELAY, [hl]
4
ld a, ITEM_NAME
5
ld [wNameListType], a
6
call SaveScreenTilesToBuffer1
7
xor a
8
ld [wBagSavedMenuItem], a
9
ld [wParentMenuItem], a
10
ld a, [wMiscFlags]
11
bit BIT_USING_GENERIC_PC, a
12
jr nz, PlayerPCMenu
13
; accessing it directly
14
ld a, SFX_TURN_ON_PC
15
call PlaySound
16
ld hl, TurnedOnPC2Text
17
call PrintText
18
19
PlayerPCMenu:
20
ld a, [wParentMenuItem]
21
ld [wCurrentMenuItem], a
22
ld hl, wMiscFlags
23
set BIT_NO_MENU_BUTTON_SOUND, [hl]
24
call LoadScreenTilesFromBuffer2
25
hlcoord 0, 0
26
ld b, $8
27
ld c, $e
28
call TextBoxBorder
29
call UpdateSprites
30
hlcoord 2, 2
31
ld de, PlayersPCMenuEntries
32
call PlaceString
33
ld hl, wTopMenuItemY
34
ld a, 2
35
ld [hli], a ; wTopMenuItemY
36
dec a
37
ld [hli], a ; wTopMenuItemX
38
inc hl
39
inc hl
40
ld a, 3
41
ld [hli], a ; wMaxMenuItem
42
ld a, PAD_A | PAD_B
43
ld [hli], a ; wMenuWatchedKeys
44
xor a
45
ld [hl], a
46
ld hl, wListScrollOffset
47
ld [hli], a ; wListScrollOffset
48
ld [hl], a ; wMenuWatchMovingOutOfBounds
49
ld [wPlayerMonNumber], a
50
ld hl, WhatDoYouWantText
51
call PrintText
52
call HandleMenuInput
53
bit B_PAD_B, a
54
jp nz, ExitPlayerPC
55
call PlaceUnfilledArrowMenuCursor
56
ld a, [wCurrentMenuItem]
57
ld [wParentMenuItem], a
58
and a
59
jp z, PlayerPCWithdraw
60
dec a
61
jp z, PlayerPCDeposit
62
dec a
63
jp z, PlayerPCToss
64
65
ExitPlayerPC:
66
ld a, [wMiscFlags]
67
bit BIT_USING_GENERIC_PC, a
68
jr nz, .next
69
; accessing it directly
70
ld a, SFX_TURN_OFF_PC
71
call PlaySound
72
call WaitForSoundToFinish
73
.next
74
ld hl, wMiscFlags
75
res BIT_NO_MENU_BUTTON_SOUND, [hl]
76
call LoadScreenTilesFromBuffer2
77
xor a
78
ld [wListScrollOffset], a
79
ld [wBagSavedMenuItem], a
80
ld hl, wStatusFlags5
81
res BIT_NO_TEXT_DELAY, [hl]
82
xor a
83
ld [wDoNotWaitForButtonPressAfterDisplayingText], a
84
ret
85
86
PlayerPCDeposit:
87
xor a
88
ld [wCurrentMenuItem], a
89
ld [wListScrollOffset], a
90
ld a, [wNumBagItems]
91
and a
92
jr nz, .loop
93
ld hl, NothingToDepositText
94
call PrintText
95
jp PlayerPCMenu
96
.loop
97
ld hl, WhatToDepositText
98
call PrintText
99
ld hl, wNumBagItems
100
ld a, l
101
ld [wListPointer], a
102
ld a, h
103
ld [wListPointer + 1], a
104
xor a
105
ld [wPrintItemPrices], a
106
ld a, ITEMLISTMENU
107
ld [wListMenuID], a
108
call DisplayListMenuID
109
jp c, PlayerPCMenu
110
call IsKeyItem
111
ld a, 1
112
ld [wItemQuantity], a
113
ld a, [wIsKeyItem]
114
and a
115
jr nz, .next
116
; if it's not a key item, there can be more than one of the item
117
ld hl, DepositHowManyText
118
call PrintText
119
call DisplayChooseQuantityMenu
120
cp $ff
121
jp z, .loop
122
.next
123
ld hl, wNumBoxItems
124
call AddItemToInventory
125
jr c, .roomAvailable
126
ld hl, NoRoomToStoreText
127
call PrintText
128
jp .loop
129
.roomAvailable
130
ld hl, wNumBagItems
131
call RemoveItemFromInventory
132
call WaitForSoundToFinish
133
ld a, SFX_WITHDRAW_DEPOSIT
134
call PlaySound
135
call WaitForSoundToFinish
136
ld hl, ItemWasStoredText
137
call PrintText
138
jp .loop
139
140
PlayerPCWithdraw:
141
xor a
142
ld [wCurrentMenuItem], a
143
ld [wListScrollOffset], a
144
ld a, [wNumBoxItems]
145
and a
146
jr nz, .loop
147
ld hl, NothingStoredText
148
call PrintText
149
jp PlayerPCMenu
150
.loop
151
ld hl, WhatToWithdrawText
152
call PrintText
153
ld hl, wNumBoxItems
154
ld a, l
155
ld [wListPointer], a
156
ld a, h
157
ld [wListPointer + 1], a
158
xor a
159
ld [wPrintItemPrices], a
160
ld a, ITEMLISTMENU
161
ld [wListMenuID], a
162
call DisplayListMenuID
163
jp c, PlayerPCMenu
164
call IsKeyItem
165
ld a, 1
166
ld [wItemQuantity], a
167
ld a, [wIsKeyItem]
168
and a
169
jr nz, .next
170
; if it's not a key item, there can be more than one of the item
171
ld hl, WithdrawHowManyText
172
call PrintText
173
call DisplayChooseQuantityMenu
174
cp $ff
175
jp z, .loop
176
.next
177
ld hl, wNumBagItems
178
call AddItemToInventory
179
jr c, .roomAvailable
180
ld hl, CantCarryMoreText
181
call PrintText
182
jp .loop
183
.roomAvailable
184
ld hl, wNumBoxItems
185
call RemoveItemFromInventory
186
call WaitForSoundToFinish
187
ld a, SFX_WITHDRAW_DEPOSIT
188
call PlaySound
189
call WaitForSoundToFinish
190
ld hl, WithdrewItemText
191
call PrintText
192
jp .loop
193
194
PlayerPCToss:
195
xor a
196
ld [wCurrentMenuItem], a
197
ld [wListScrollOffset], a
198
ld a, [wNumBoxItems]
199
and a
200
jr nz, .loop
201
ld hl, NothingStoredText
202
call PrintText
203
jp PlayerPCMenu
204
.loop
205
ld hl, WhatToTossText
206
call PrintText
207
ld hl, wNumBoxItems
208
ld a, l
209
ld [wListPointer], a
210
ld a, h
211
ld [wListPointer + 1], a
212
xor a
213
ld [wPrintItemPrices], a
214
ld a, ITEMLISTMENU
215
ld [wListMenuID], a
216
push hl
217
call DisplayListMenuID
218
pop hl
219
jp c, PlayerPCMenu
220
push hl
221
call IsKeyItem
222
pop hl
223
ld a, 1
224
ld [wItemQuantity], a
225
ld a, [wIsKeyItem]
226
and a
227
jr nz, .next
228
ld a, [wCurItem]
229
call IsItemHM
230
jr c, .next
231
; if it's not a key item, there can be more than one of the item
232
push hl
233
ld hl, TossHowManyText
234
call PrintText
235
call DisplayChooseQuantityMenu
236
pop hl
237
cp $ff
238
jp z, .loop
239
.next
240
call TossItem ; disallows tossing key items
241
jp .loop
242
243
PlayersPCMenuEntries:
244
db "WITHDRAW ITEM"
245
next "DEPOSIT ITEM"
246
next "TOSS ITEM"
247
next "LOG OFF@"
248
249
TurnedOnPC2Text:
250
text_far _TurnedOnPC2Text
251
text_end
252
253
WhatDoYouWantText:
254
text_far _WhatDoYouWantText
255
text_end
256
257
WhatToDepositText:
258
text_far _WhatToDepositText
259
text_end
260
261
DepositHowManyText:
262
text_far _DepositHowManyText
263
text_end
264
265
ItemWasStoredText:
266
text_far _ItemWasStoredText
267
text_end
268
269
NothingToDepositText:
270
text_far _NothingToDepositText
271
text_end
272
273
NoRoomToStoreText:
274
text_far _NoRoomToStoreText
275
text_end
276
277
WhatToWithdrawText:
278
text_far _WhatToWithdrawText
279
text_end
280
281
WithdrawHowManyText:
282
text_far _WithdrawHowManyText
283
text_end
284
285
WithdrewItemText:
286
text_far _WithdrewItemText
287
text_end
288
289
NothingStoredText:
290
text_far _NothingStoredText
291
text_end
292
293
CantCarryMoreText:
294
text_far _CantCarryMoreText
295
text_end
296
297
WhatToTossText:
298
text_far _WhatToTossText
299
text_end
300
301
TossHowManyText:
302
text_far _TossHowManyText
303
text_end
304
305