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
|
_BillsPC:
call .CheckCanUsePC
ret c
call .LogIn
call .UseBillsPC
jp .LogOut
.CheckCanUsePC:
ld a, [wPartyCount]
and a
ret nz
ld hl, .PCGottaHavePokemonText
call MenuTextboxBackup
scf
ret
.PCGottaHavePokemonText:
text_far _PCGottaHavePokemonText
text_end
.LogIn:
xor a
ldh [hBGMapMode], a
call LoadStandardMenuHeader
call ClearPCItemScreen
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
ld hl, .PCWhatText
call PrintText
pop af
ld [wOptions], a
call LoadFontsBattleExtra
ret
.PCWhatText:
text_far _PCWhatText
text_end
.LogOut:
call CloseSubmenu
ret
.UseBillsPC:
ld hl, .MenuHeader
call LoadMenuHeader
ld a, $1
.loop
ld [wMenuCursorPosition], a
call SetPalettes
xor a
ld [wWhichIndexSet], a
ldh [hBGMapMode], a
call DoNthMenu
jr c, .cancel
ld a, [wMenuCursorPosition]
push af
ld a, [wMenuSelection]
ld hl, .Jumptable
rst JumpTable
pop bc
ld a, b
jr nc, .loop
.cancel
call CloseWindow
ret
.MenuHeader:
db MENU_BACKUP_TILES ; flags
menu_coords 0, 0, SCREEN_WIDTH - 1, SCREEN_HEIGHT - 1
dw .MenuData
db 1 ; default option
.MenuData:
db STATICMENU_CURSOR ; flags
db 0 ; items
dw .items
dw PlaceMenuStrings
dw .strings
.strings
db "WITHDRAW <PK><MN>@"
db "DEPOSIT <PK><MN>@"
db "CHANGE BOX@"
db "MOVE <PK><MN> W/O MAIL@"
db "SEE YA!@"
.Jumptable:
dw BillsPC_WithdrawMenu
dw BillsPC_DepositMenu
dw BillsPC_ChangeBoxMenu
dw BillsPC_MovePKMNMenu
dw BillsPC_SeeYa
.items
db 5 ; # items
db 0 ; WITHDRAW
db 1 ; DEPOSIT
db 2 ; CHANGE BOX
db 3 ; MOVE PKMN
db 4 ; SEE YA!
db -1
BillsPC_SeeYa:
scf
ret
BillsPC_MovePKMNMenu:
call LoadStandardMenuHeader
farcall IsAnyMonHoldingMail
jr nc, .no_mail
ld hl, .PCMonHoldingMailText
call PrintText
jr .quit
.no_mail
farcall StartMoveMonWOMail_SaveGame
jr c, .quit
farcall _MovePKMNWithoutMail
call ReturnToMapFromSubmenu
call ClearPCItemScreen
.quit
call CloseWindow
and a
ret
.PCMonHoldingMailText:
text_far _PCMonHoldingMailText
text_end
BillsPC_DepositMenu:
call LoadStandardMenuHeader
farcall _DepositPKMN
call ReturnToMapFromSubmenu
call ClearPCItemScreen
call CloseWindow
and a
ret
BillsPC_Deposit_CheckPartySize: ; unreferenced
ld a, [wPartyCount]
and a
jr z, .no_mon
cp 2
jr c, .only_one_mon
and a
ret
.no_mon
ld hl, .PCNoSingleMonText
call MenuTextboxBackup
scf
ret
.only_one_mon
ld hl, .PCCantDepositLastMonText
call MenuTextboxBackup
scf
ret
.PCNoSingleMonText:
text_far _PCNoSingleMonText
text_end
.PCCantDepositLastMonText:
text_far _PCCantDepositLastMonText
text_end
CheckCurPartyMonFainted:
ld hl, wPartyMon1HP
ld de, PARTYMON_STRUCT_LENGTH
ld b, $0
.loop
ld a, [wCurPartyMon]
cp b
jr z, .skip
ld a, [hli]
or [hl]
jr nz, .notfainted
dec hl
.skip
inc b
ld a, [wPartyCount]
cp b
jr z, .done
add hl, de
jr .loop
.done
scf
ret
.notfainted
and a
ret
BillsPC_WithdrawMenu:
call LoadStandardMenuHeader
farcall _WithdrawPKMN
call ReturnToMapFromSubmenu
call ClearPCItemScreen
call CloseWindow
and a
ret
BillsPC_Withdraw_CheckPartySize: ; unreferenced
ld a, [wPartyCount]
cp PARTY_LENGTH
jr nc, .party_full
and a
ret
.party_full
ld hl, PCCantTakeText
call MenuTextboxBackup
scf
ret
PCCantTakeText:
text_far _PCCantTakeText
text_end
BillsPC_ChangeBoxMenu:
farcall _ChangeBox
and a
ret
ClearPCItemScreen:
call DisableSpriteUpdates
xor a
ldh [hBGMapMode], a
call ClearBGPalettes
call ClearSprites
hlcoord 0, 0
ld bc, SCREEN_HEIGHT * SCREEN_WIDTH
ld a, " "
call ByteFill
hlcoord 0, 0
lb bc, 10, 18
call Textbox
hlcoord 0, 12
lb bc, 4, 18
call Textbox
call WaitBGMap2
call SetPalettes ; load regular palettes?
ret
CopyBoxmonToTempMon:
ld a, [wCurPartyMon]
ld hl, sBoxMon1Species
ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld de, wTempMonSpecies
ld bc, BOXMON_STRUCT_LENGTH
ld a, BANK(sBoxMon1Species)
call OpenSRAM
call CopyBytes
call CloseSRAM
ret
LoadBoxMonListing: ; unreferenced
ld a, [wCurBox]
cp b
jr z, .same_box
ld a, b
ld hl, .BoxAddresses
ld bc, 3
call AddNTimes
ld a, [hli]
push af
ld a, [hli]
ld h, [hl]
ld l, a
pop af
jr .okay
.same_box
ld a, BANK(sBoxCount)
ld hl, sBoxCount
.okay
call OpenSRAM
ld a, [hl]
ld bc, sBoxMons - sBox
add hl, bc
ld b, a
ld c, $0
ld de, wBoxPartialData
ld a, b
and a
jr z, .empty_box
.loop
push hl
push bc
ld a, c
ld bc, sBoxMon1Species - sBoxMons
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [de], a
inc de
ld [wCurSpecies], a
call GetBaseData
pop bc
pop hl
push hl
push bc
ld a, c
ld bc, sBoxMonNicknames - sBoxMons
add hl, bc
call SkipNames
call CopyBytes
pop bc
pop hl
push hl
push bc
ld a, c
ld bc, MON_LEVEL
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hl]
ld [de], a
inc de
pop bc
pop hl
push hl
push bc
ld a, c
ld bc, MON_DVS
add hl, bc
ld bc, BOXMON_STRUCT_LENGTH
call AddNTimes
ld a, [hli]
and $f0
ld b, a
ld a, [hl]
and $f0
swap a
or b
ld b, a
ld a, [wBaseGender]
cp b
ld a, $1
jr c, .okay2
xor a
.okay2
ld [de], a
inc de
pop bc
pop hl
inc c
dec b
jr nz, .loop
.empty_box
call CloseSRAM
ret
.BoxAddresses:
table_width 3, LoadBoxMonListing.BoxAddresses
dba sBox1
dba sBox2
dba sBox3
dba sBox4
dba sBox5
dba sBox6
dba sBox7
dba sBox8
dba sBox9
dba sBox10
dba sBox11
dba sBox12
dba sBox13
dba sBox14
assert_table_length NUM_BOXES
|