Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/menus/start_sub_menus.asm
1271 views
1
StartMenu_Pokedex::
2
predef ShowPokedexMenu
3
call LoadScreenTilesFromBuffer2
4
call Delay3
5
call LoadGBPal
6
call UpdateSprites
7
jp RedisplayStartMenu
8
9
StartMenu_Pokemon::
10
ld a, [wPartyCount]
11
and a
12
jp z, RedisplayStartMenu
13
xor a
14
ld [wMenuItemToSwap], a
15
ld [wPartyMenuTypeOrMessageID], a
16
ld [wUpdateSpritesEnabled], a
17
call DisplayPartyMenu
18
jr .checkIfPokemonChosen
19
.loop
20
xor a
21
ld [wMenuItemToSwap], a
22
ld [wPartyMenuTypeOrMessageID], a
23
call GoBackToPartyMenu
24
.checkIfPokemonChosen
25
jr nc, .chosePokemon
26
.exitMenu
27
call GBPalWhiteOutWithDelay3
28
call RestoreScreenTilesAndReloadTilePatterns
29
call LoadGBPal
30
jp RedisplayStartMenu
31
.chosePokemon
32
call SaveScreenTilesToBuffer1
33
ld a, FIELD_MOVE_MON_MENU
34
ld [wTextBoxID], a
35
call DisplayTextBoxID ; display pokemon menu options
36
ld hl, wFieldMoves
37
lb bc, 2, 12 ; max menu item ID, top menu item Y
38
ld e, 5
39
.adjustMenuVariablesLoop
40
dec e
41
jr z, .storeMenuVariables
42
ld a, [hli]
43
and a ; end of field moves?
44
jr z, .storeMenuVariables
45
inc b
46
dec c
47
dec c
48
jr .adjustMenuVariablesLoop
49
.storeMenuVariables
50
ld hl, wTopMenuItemY
51
ld a, c
52
ld [hli], a ; top menu item Y
53
ldh a, [hFieldMoveMonMenuTopMenuItemX]
54
ld [hli], a ; top menu item X
55
xor a
56
ld [hli], a ; current menu item ID
57
inc hl
58
ld a, b
59
ld [hli], a ; max menu item ID
60
ld a, PAD_A | PAD_B
61
ld [hli], a ; menu watched keys
62
xor a
63
ld [hl], a
64
call HandleMenuInput
65
push af
66
call LoadScreenTilesFromBuffer1
67
pop af
68
bit B_PAD_B, a
69
jp nz, .loop
70
; if the B button wasn't pressed
71
ld a, [wMaxMenuItem]
72
ld b, a
73
ld a, [wCurrentMenuItem] ; menu selection
74
cp b
75
jp z, .exitMenu ; if the player chose Cancel
76
dec b
77
cp b
78
jr z, .choseSwitch
79
dec b
80
cp b
81
jp z, .choseStats
82
ld c, a
83
ld b, 0
84
ld hl, wFieldMoves
85
add hl, bc
86
jp .choseOutOfBattleMove
87
.choseSwitch
88
ld a, [wPartyCount]
89
cp 2 ; is there more than one pokemon in the party?
90
jp c, StartMenu_Pokemon ; if not, no switching
91
call SwitchPartyMon_InitVarOrSwapData ; init [wMenuItemToSwap]
92
ld a, SWAP_MONS_PARTY_MENU
93
ld [wPartyMenuTypeOrMessageID], a
94
call GoBackToPartyMenu
95
jp .checkIfPokemonChosen
96
.choseStats
97
call ClearSprites
98
xor a ; PLAYER_PARTY_DATA
99
ld [wMonDataLocation], a
100
predef StatusScreen
101
predef StatusScreen2
102
call ReloadMapData
103
jp StartMenu_Pokemon
104
.choseOutOfBattleMove
105
push hl
106
ld a, [wWhichPokemon]
107
ld hl, wPartyMonNicks
108
call GetPartyMonName
109
pop hl
110
ld a, [hl]
111
dec a
112
add a
113
ld b, 0
114
ld c, a
115
ld hl, .outOfBattleMovePointers
116
add hl, bc
117
ld a, [hli]
118
ld h, [hl]
119
ld l, a
120
ld a, [wObtainedBadges]
121
jp hl
122
.outOfBattleMovePointers
123
dw .cut
124
dw .fly
125
dw .surf
126
dw .surf
127
dw .strength
128
dw .flash
129
dw .dig
130
dw .teleport
131
dw .softboiled
132
.fly
133
bit BIT_THUNDERBADGE, a
134
jp z, .newBadgeRequired
135
call CheckIfInOutsideMap
136
jr z, .canFly
137
ld a, [wWhichPokemon]
138
ld hl, wPartyMonNicks
139
call GetPartyMonName
140
ld hl, .cannotFlyHereText
141
call PrintText
142
jp .loop
143
.canFly
144
call ChooseFlyDestination
145
ld a, [wStatusFlags6]
146
bit BIT_FLY_WARP, a
147
jp nz, .goBackToMap
148
call LoadFontTilePatterns
149
ld hl, wStatusFlags4
150
set BIT_UNKNOWN_4_1, [hl]
151
jp StartMenu_Pokemon
152
.cut
153
bit BIT_CASCADEBADGE, a
154
jp z, .newBadgeRequired
155
predef UsedCut
156
ld a, [wActionResultOrTookBattleTurn]
157
and a
158
jp z, .loop
159
jp CloseTextDisplay
160
.surf
161
bit BIT_SOULBADGE, a
162
jp z, .newBadgeRequired
163
farcall IsSurfingAllowed
164
ld hl, wStatusFlags1
165
bit BIT_SURF_ALLOWED, [hl]
166
res BIT_SURF_ALLOWED, [hl]
167
jp z, .loop
168
ld a, SURFBOARD
169
ld [wCurItem], a
170
ld [wPseudoItemID], a
171
call UseItem
172
ld a, [wActionResultOrTookBattleTurn]
173
and a
174
jp z, .loop
175
call GBPalWhiteOutWithDelay3
176
jp .goBackToMap
177
.strength
178
bit BIT_RAINBOWBADGE, a
179
jp z, .newBadgeRequired
180
predef PrintStrengthText
181
call GBPalWhiteOutWithDelay3
182
jp .goBackToMap
183
.flash
184
bit BIT_BOULDERBADGE, a
185
jp z, .newBadgeRequired
186
xor a
187
ld [wMapPalOffset], a
188
ld hl, .flashLightsAreaText
189
call PrintText
190
call GBPalWhiteOutWithDelay3
191
jp .goBackToMap
192
.flashLightsAreaText
193
text_far _FlashLightsAreaText
194
text_end
195
.dig
196
ld a, ESCAPE_ROPE
197
ld [wCurItem], a
198
ld [wPseudoItemID], a
199
call UseItem
200
ld a, [wActionResultOrTookBattleTurn]
201
and a
202
jp z, .loop
203
call GBPalWhiteOutWithDelay3
204
jp .goBackToMap
205
.teleport
206
call CheckIfInOutsideMap
207
jr z, .canTeleport
208
ld a, [wWhichPokemon]
209
ld hl, wPartyMonNicks
210
call GetPartyMonName
211
ld hl, .cannotUseTeleportNowText
212
call PrintText
213
jp .loop
214
.canTeleport
215
ld hl, .warpToLastPokemonCenterText
216
call PrintText
217
ld hl, wStatusFlags6
218
set BIT_FLY_WARP, [hl]
219
set BIT_ESCAPE_WARP, [hl]
220
ld hl, wStatusFlags4
221
set BIT_UNKNOWN_4_1, [hl]
222
res BIT_NO_BATTLES, [hl]
223
ld c, 60
224
call DelayFrames
225
call GBPalWhiteOutWithDelay3
226
jp .goBackToMap
227
.warpToLastPokemonCenterText
228
text_far _WarpToLastPokemonCenterText
229
text_end
230
.cannotUseTeleportNowText
231
text_far _CannotUseTeleportNowText
232
text_end
233
.cannotFlyHereText
234
text_far _CannotFlyHereText
235
text_end
236
.softboiled
237
ld hl, wPartyMon1MaxHP
238
ld a, [wWhichPokemon]
239
ld bc, wPartyMon2 - wPartyMon1
240
call AddNTimes
241
ld a, [hli]
242
ldh [hDividend], a
243
ld a, [hl]
244
ldh [hDividend + 1], a
245
ld a, 5
246
ldh [hDivisor], a
247
ld b, 2 ; number of bytes
248
call Divide
249
ld bc, wPartyMon1HP - wPartyMon1MaxHP
250
add hl, bc
251
ld a, [hld]
252
ld b, a
253
ldh a, [hQuotient + 3]
254
sub b
255
ld b, [hl]
256
ldh a, [hQuotient + 2]
257
sbc b
258
jp nc, .notHealthyEnough
259
ld a, [wPartyAndBillsPCSavedMenuItem]
260
push af
261
ld a, POTION
262
ld [wCurItem], a
263
ld [wPseudoItemID], a
264
call UseItem
265
pop af
266
ld [wPartyAndBillsPCSavedMenuItem], a
267
jp .loop
268
.notHealthyEnough ; if current HP is less than 1/5 of max HP
269
ld hl, .notHealthyEnoughText
270
call PrintText
271
jp .loop
272
.notHealthyEnoughText
273
text_far _NotHealthyEnoughText
274
text_end
275
.goBackToMap
276
call RestoreScreenTilesAndReloadTilePatterns
277
jp CloseTextDisplay
278
.newBadgeRequired
279
ld hl, .newBadgeRequiredText
280
call PrintText
281
jp .loop
282
.newBadgeRequiredText
283
text_far _NewBadgeRequiredText
284
text_end
285
286
; writes a blank tile to all possible menu cursor positions on the party menu
287
ErasePartyMenuCursors::
288
hlcoord 0, 1
289
ld bc, 2 * SCREEN_WIDTH ; menu cursor positions are 2 rows apart
290
ld a, 6 ; 6 menu cursor positions
291
.loop
292
ld [hl], " "
293
add hl, bc
294
dec a
295
jr nz, .loop
296
ret
297
298
ItemMenuLoop:
299
call LoadScreenTilesFromBuffer2DisableBGTransfer
300
call RunDefaultPaletteCommand
301
302
StartMenu_Item::
303
ld a, [wLinkState]
304
dec a ; is the player in the Colosseum or Trade Centre?
305
jr nz, .notInCableClubRoom
306
ld hl, CannotUseItemsHereText
307
call PrintText
308
jr .exitMenu
309
.notInCableClubRoom
310
ld bc, wNumBagItems
311
ld hl, wListPointer
312
ld a, c
313
ld [hli], a
314
ld [hl], b ; store item bag pointer in wListPointer (for DisplayListMenuID)
315
xor a
316
ld [wPrintItemPrices], a
317
ld a, ITEMLISTMENU
318
ld [wListMenuID], a
319
ld a, [wBagSavedMenuItem]
320
ld [wCurrentMenuItem], a
321
call DisplayListMenuID
322
ld a, [wCurrentMenuItem]
323
ld [wBagSavedMenuItem], a
324
jr nc, .choseItem
325
.exitMenu
326
call LoadScreenTilesFromBuffer2
327
call LoadTextBoxTilePatterns
328
call UpdateSprites
329
jp RedisplayStartMenu
330
.choseItem
331
; erase menu cursor (blank each tile in front of an item name)
332
ld a, " "
333
ldcoord_a 5, 4
334
ldcoord_a 5, 6
335
ldcoord_a 5, 8
336
ldcoord_a 5, 10
337
call PlaceUnfilledArrowMenuCursor
338
xor a
339
ld [wMenuItemToSwap], a
340
ld a, [wCurItem]
341
cp BICYCLE
342
jp z, .useOrTossItem
343
.notBicycle1
344
ld a, USE_TOSS_MENU_TEMPLATE
345
ld [wTextBoxID], a
346
call DisplayTextBoxID
347
ld hl, wTopMenuItemY
348
ld a, 11
349
ld [hli], a ; top menu item Y
350
ld a, 14
351
ld [hli], a ; top menu item X
352
xor a
353
ld [hli], a ; current menu item ID
354
inc hl
355
inc a ; a = 1
356
ld [hli], a ; max menu item ID
357
ld a, PAD_A | PAD_B
358
ld [hli], a ; menu watched keys
359
xor a
360
ld [hl], a ; old menu item id
361
call HandleMenuInput
362
call PlaceUnfilledArrowMenuCursor
363
bit B_PAD_B, a
364
jr z, .useOrTossItem
365
jp ItemMenuLoop
366
.useOrTossItem
367
ld a, [wCurItem]
368
ld [wNamedObjectIndex], a
369
call GetItemName
370
call CopyToStringBuffer
371
ld a, [wCurItem]
372
cp BICYCLE
373
jr nz, .notBicycle2
374
ld a, [wStatusFlags6]
375
bit BIT_ALWAYS_ON_BIKE, a
376
jr z, .useItem_closeMenu
377
ld hl, CannotGetOffHereText
378
call PrintText
379
jp ItemMenuLoop
380
.notBicycle2
381
ld a, [wCurrentMenuItem]
382
and a
383
jr nz, .tossItem
384
; use item
385
ld [wPseudoItemID], a ; a must be 0 due to above conditional jump
386
ld a, [wCurItem]
387
cp HM01
388
jr nc, .useItem_partyMenu
389
ld hl, UsableItems_CloseMenu
390
ld de, 1
391
call IsInArray
392
jr c, .useItem_closeMenu
393
ld a, [wCurItem]
394
ld hl, UsableItems_PartyMenu
395
ld de, 1
396
call IsInArray
397
jr c, .useItem_partyMenu
398
call UseItem
399
jp ItemMenuLoop
400
.useItem_closeMenu
401
xor a
402
ld [wPseudoItemID], a
403
call UseItem
404
ld a, [wActionResultOrTookBattleTurn]
405
and a
406
jp z, ItemMenuLoop
407
jp CloseStartMenu
408
.useItem_partyMenu
409
ld a, [wUpdateSpritesEnabled]
410
push af
411
call UseItem
412
ld a, [wActionResultOrTookBattleTurn]
413
cp $02
414
jp z, .partyMenuNotDisplayed
415
call GBPalWhiteOutWithDelay3
416
call RestoreScreenTilesAndReloadTilePatterns
417
pop af
418
ld [wUpdateSpritesEnabled], a
419
jp StartMenu_Item
420
.partyMenuNotDisplayed
421
pop af
422
ld [wUpdateSpritesEnabled], a
423
jp ItemMenuLoop
424
.tossItem
425
call IsKeyItem
426
ld a, [wIsKeyItem]
427
and a
428
jr nz, .skipAskingQuantity
429
ld a, [wCurItem]
430
call IsItemHM
431
jr c, .skipAskingQuantity
432
call DisplayChooseQuantityMenu
433
inc a
434
jr z, .tossZeroItems
435
.skipAskingQuantity
436
ld hl, wNumBagItems
437
call TossItem
438
.tossZeroItems
439
jp ItemMenuLoop
440
441
CannotUseItemsHereText:
442
text_far _CannotUseItemsHereText
443
text_end
444
445
CannotGetOffHereText:
446
text_far _CannotGetOffHereText
447
text_end
448
449
INCLUDE "data/items/use_party.asm"
450
451
INCLUDE "data/items/use_overworld.asm"
452
453
StartMenu_TrainerInfo::
454
call GBPalWhiteOut
455
call ClearScreen
456
call UpdateSprites
457
ldh a, [hTileAnimations]
458
push af
459
xor a
460
ldh [hTileAnimations], a
461
call DrawTrainerInfo
462
predef DrawBadges
463
ld b, SET_PAL_TRAINER_CARD
464
call RunPaletteCommand
465
call GBPalNormal
466
call WaitForTextScrollButtonPress
467
call GBPalWhiteOut
468
call LoadFontTilePatterns
469
call LoadScreenTilesFromBuffer2
470
call RunDefaultPaletteCommand
471
call ReloadMapData
472
call LoadGBPal
473
pop af
474
ldh [hTileAnimations], a
475
jp RedisplayStartMenu
476
477
; loads tile patterns and draws everything except for gym leader faces / badges
478
DrawTrainerInfo:
479
ld de, RedPicFront
480
lb bc, BANK(RedPicFront), $01
481
predef DisplayPicCenteredOrUpperRight
482
call DisableLCD
483
hlcoord 0, 2
484
ld a, " "
485
call TrainerInfo_DrawVerticalLine
486
hlcoord 1, 2
487
call TrainerInfo_DrawVerticalLine
488
ld hl, vChars2 tile $07
489
ld de, vChars2 tile $00
490
ld bc, $1c tiles
491
call CopyData
492
ld hl, TrainerInfoTextBoxTileGraphics
493
ld de, vChars2 tile $77
494
ld bc, 8 tiles
495
push bc
496
call TrainerInfo_FarCopyData
497
ld hl, BlankLeaderNames
498
ld de, vChars2 tile $60
499
ld bc, $17 tiles
500
call TrainerInfo_FarCopyData
501
pop bc
502
ld hl, BadgeNumbersTileGraphics
503
ld de, vChars1 tile $58
504
call TrainerInfo_FarCopyData
505
ld hl, GymLeaderFaceAndBadgeTileGraphics
506
ld de, vChars2 tile $20
507
ld bc, 8 * 8 tiles
508
ld a, BANK(GymLeaderFaceAndBadgeTileGraphics)
509
call FarCopyData2
510
ld hl, TextBoxGraphics
511
ld de, 13 tiles
512
add hl, de ; hl = colon tile pattern
513
ld de, vChars1 tile $56
514
ld bc, 1 tiles
515
ld a, BANK(TextBoxGraphics)
516
push bc
517
call FarCopyData2
518
pop bc
519
ld hl, TrainerInfoTextBoxTileGraphics tile 8 ; background tile pattern
520
ld de, vChars1 tile $57
521
call TrainerInfo_FarCopyData
522
call EnableLCD
523
ld hl, wTrainerInfoTextBoxWidthPlus1
524
ld a, 18 + 1
525
ld [hli], a
526
dec a
527
ld [hli], a
528
ld [hl], 1
529
hlcoord 0, 0
530
call TrainerInfo_DrawTextBox
531
ld hl, wTrainerInfoTextBoxWidthPlus1
532
ld a, 16 + 1
533
ld [hli], a
534
dec a
535
ld [hli], a
536
ld [hl], 3
537
hlcoord 1, 10
538
call TrainerInfo_DrawTextBox
539
hlcoord 0, 10
540
ld a, $d7
541
call TrainerInfo_DrawVerticalLine
542
hlcoord 19, 10
543
call TrainerInfo_DrawVerticalLine
544
hlcoord 6, 9
545
ld de, TrainerInfo_BadgesText
546
call PlaceString
547
hlcoord 2, 2
548
ld de, TrainerInfo_NameMoneyTimeText
549
call PlaceString
550
hlcoord 7, 2
551
ld de, wPlayerName
552
call PlaceString
553
hlcoord 8, 4
554
ld de, wPlayerMoney
555
ld c, 3 | LEADING_ZEROES | LEFT_ALIGN | MONEY_SIGN
556
call PrintBCDNumber
557
hlcoord 9, 6
558
ld de, wPlayTimeHours
559
lb bc, LEFT_ALIGN | 1, 3
560
call PrintNumber
561
ld [hl], $d6 ; colon tile ID
562
inc hl
563
ld de, wPlayTimeMinutes
564
lb bc, LEADING_ZEROES | 1, 2
565
jp PrintNumber
566
567
TrainerInfo_FarCopyData:
568
ld a, BANK(TrainerInfoTextBoxTileGraphics)
569
jp FarCopyData2
570
571
TrainerInfo_NameMoneyTimeText:
572
db "NAME/"
573
next "MONEY/"
574
next "TIME/@"
575
576
; $76 is a circle tile
577
TrainerInfo_BadgesText:
578
db $76,"BADGES",$76,"@"
579
580
; draws a text box on the trainer info screen
581
; height is always 6
582
; INPUT:
583
; hl = destination address
584
; [wTrainerInfoTextBoxWidthPlus1] = width
585
; [wTrainerInfoTextBoxWidth] = width - 1
586
; [wTrainerInfoTextBoxNextRowOffset] = distance from the end of a text box row to the start of the next
587
TrainerInfo_DrawTextBox:
588
ld a, $79 ; upper left corner tile ID
589
lb de, $7a, $7b ; top edge and upper right corner tile ID's
590
call TrainerInfo_DrawHorizontalEdge ; draw top edge
591
call TrainerInfo_NextTextBoxRow
592
ld a, [wTrainerInfoTextBoxWidthPlus1]
593
ld e, a
594
ld d, 0
595
ld c, 6 ; height of the text box
596
.loop
597
ld [hl], $7c ; left edge tile ID
598
add hl, de
599
ld [hl], $78 ; right edge tile ID
600
call TrainerInfo_NextTextBoxRow
601
dec c
602
jr nz, .loop
603
ld a, $7d ; lower left corner tile ID
604
lb de, $77, $7e ; bottom edge and lower right corner tile ID's
605
606
TrainerInfo_DrawHorizontalEdge:
607
ld [hli], a ; place left corner tile
608
ld a, [wTrainerInfoTextBoxWidth]
609
ld c, a
610
ld a, d
611
.loop
612
ld [hli], a ; place edge tile
613
dec c
614
jr nz, .loop
615
ld a, e
616
ld [hl], a ; place right corner tile
617
ret
618
619
TrainerInfo_NextTextBoxRow:
620
ld a, [wTrainerInfoTextBoxNextRowOffset] ; distance to the start of the next row
621
.loop
622
inc hl
623
dec a
624
jr nz, .loop
625
ret
626
627
; draws a vertical line
628
; INPUT:
629
; hl = address of top tile in the line
630
; a = tile ID
631
TrainerInfo_DrawVerticalLine:
632
ld de, SCREEN_WIDTH
633
ld c, 8
634
.loop
635
ld [hl], a
636
add hl, de
637
dec c
638
jr nz, .loop
639
ret
640
641
StartMenu_SaveReset::
642
ld a, [wStatusFlags4]
643
bit BIT_LINK_CONNECTED, a
644
jp nz, Init
645
predef SaveMenu
646
call LoadScreenTilesFromBuffer2
647
jp HoldTextDisplayOpen
648
649
StartMenu_Option::
650
xor a
651
ldh [hAutoBGTransferEnabled], a
652
call ClearScreen
653
call UpdateSprites
654
callfar DisplayOptionMenu
655
call LoadScreenTilesFromBuffer2
656
call LoadTextBoxTilePatterns
657
call UpdateSprites
658
jp RedisplayStartMenu
659
660
SwitchPartyMon::
661
call SwitchPartyMon_InitVarOrSwapData ; swap data
662
ld a, [wSwappedMenuItem]
663
call SwitchPartyMon_ClearGfx
664
ld a, [wCurrentMenuItem]
665
call SwitchPartyMon_ClearGfx
666
jp RedrawPartyMenu_
667
668
SwitchPartyMon_ClearGfx:
669
push af
670
hlcoord 0, 0
671
ld bc, SCREEN_WIDTH * 2
672
call AddNTimes
673
ld c, SCREEN_WIDTH * 2
674
ld a, " "
675
.clearMonBGLoop ; clear the mon's row in the party menu
676
ld [hli], a
677
dec c
678
jr nz, .clearMonBGLoop
679
pop af
680
ld hl, wShadowOAM
681
ld bc, $10
682
call AddNTimes
683
ld de, $4
684
ld c, e
685
.clearMonOAMLoop
686
ld [hl], $a0
687
add hl, de
688
dec c
689
jr nz, .clearMonOAMLoop
690
call WaitForSoundToFinish
691
ld a, SFX_SWAP
692
jp PlaySound
693
694
SwitchPartyMon_InitVarOrSwapData:
695
; This is used to initialise [wMenuItemToSwap] and to actually swap the data.
696
ld a, [wMenuItemToSwap]
697
and a ; has [wMenuItemToSwap] been initialised yet?
698
jr nz, .pickedMonsToSwap
699
; If not, initialise [wMenuItemToSwap] so that it matches the current mon.
700
ld a, [wWhichPokemon]
701
inc a ; [wMenuItemToSwap] counts from 1
702
ld [wMenuItemToSwap], a
703
ret
704
.pickedMonsToSwap
705
xor a
706
ld [wPartyMenuTypeOrMessageID], a
707
ld a, [wMenuItemToSwap]
708
dec a
709
ld b, a
710
ld a, [wCurrentMenuItem]
711
ld [wSwappedMenuItem], a
712
cp b ; swapping a mon with itself?
713
jr nz, .swappingDifferentMons
714
; can't swap a mon with itself
715
xor a
716
ld [wMenuItemToSwap], a
717
ld [wPartyMenuTypeOrMessageID], a
718
ret
719
.swappingDifferentMons
720
ld a, b
721
ld [wMenuItemToSwap], a
722
push hl
723
push de
724
ld hl, wPartySpecies
725
ld d, h
726
ld e, l
727
ld a, [wCurrentMenuItem]
728
add l
729
ld l, a
730
jr nc, .noCarry
731
inc h
732
.noCarry
733
ld a, [wMenuItemToSwap]
734
add e
735
ld e, a
736
jr nc, .noCarry2
737
inc d
738
.noCarry2
739
ld a, [hl]
740
ldh [hSwapTemp], a
741
ld a, [de]
742
ld [hl], a
743
ldh a, [hSwapTemp]
744
ld [de], a
745
ld hl, wPartyMons
746
ld bc, wPartyMon2 - wPartyMon1
747
ld a, [wCurrentMenuItem]
748
call AddNTimes
749
push hl
750
ld de, wSwitchPartyMonTempBuffer
751
ld bc, wPartyMon2 - wPartyMon1
752
call CopyData
753
ld hl, wPartyMons
754
ld bc, wPartyMon2 - wPartyMon1
755
ld a, [wMenuItemToSwap]
756
call AddNTimes
757
pop de
758
push hl
759
ld bc, wPartyMon2 - wPartyMon1
760
call CopyData
761
pop de
762
ld hl, wSwitchPartyMonTempBuffer
763
ld bc, wPartyMon2 - wPartyMon1
764
call CopyData
765
ld hl, wPartyMonOT
766
ld a, [wCurrentMenuItem]
767
call SkipFixedLengthTextEntries
768
push hl
769
ld de, wSwitchPartyMonTempBuffer
770
ld bc, NAME_LENGTH
771
call CopyData
772
ld hl, wPartyMonOT
773
ld a, [wMenuItemToSwap]
774
call SkipFixedLengthTextEntries
775
pop de
776
push hl
777
ld bc, NAME_LENGTH
778
call CopyData
779
pop de
780
ld hl, wSwitchPartyMonTempBuffer
781
ld bc, NAME_LENGTH
782
call CopyData
783
ld hl, wPartyMonNicks
784
ld a, [wCurrentMenuItem]
785
call SkipFixedLengthTextEntries
786
push hl
787
ld de, wSwitchPartyMonTempBuffer
788
ld bc, NAME_LENGTH
789
call CopyData
790
ld hl, wPartyMonNicks
791
ld a, [wMenuItemToSwap]
792
call SkipFixedLengthTextEntries
793
pop de
794
push hl
795
ld bc, NAME_LENGTH
796
call CopyData
797
pop de
798
ld hl, wSwitchPartyMonTempBuffer
799
ld bc, NAME_LENGTH
800
call CopyData
801
ld a, [wMenuItemToSwap]
802
ld [wSwappedMenuItem], a
803
xor a
804
ld [wMenuItemToSwap], a
805
ld [wPartyMenuTypeOrMessageID], a
806
pop de
807
pop hl
808
ret
809
810