-
Notifications
You must be signed in to change notification settings - Fork 5
/
main.asm
executable file
·4423 lines (3860 loc) · 68.7 KB
/
main.asm
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
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
INCLUDE "constants.asm"
SECTION "Code 1", ROMX
LoadPushOAM:: ; 4031
lb bc, (PushOAMEnd - PushOAM), (hPushOAM - $ff00)
ld hl, PushOAM
.loop
ld a, [hli]
ld [$ff00+c], a
inc c
dec b
jr nz, .loop
ret
PushOAM: ; 403f
ld a, Sprites / $100
ld [rDMA], a
ld a, 40
.loop
dec a
jr nz, .loop
ret
PushOAMEnd:
ReanchorBGMap_NoOAMUpdate:: ; 6454
call DelayFrame
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld [hLCDCPointer], a
ld a, $90
ld [hWY], a
call OverworldTextModeSwitch
ld a, VBGMap1 / $100
ld [hBGMapAddress + 1], a
xor a
ld [hBGMapAddress], a
farcall OpenAndCloseMenu_HDMATransferTileMapAndAttrMap
farcall LoadBlindingFlashPalette
farcall ApplyPals
xor a
ld [hBGMapMode], a
ld [hWY], a
inc a
ld [hCGBPalUpdate], a
call HDMATransfer_FillBGMap0WithBlackTile
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
ld [wBGMapAnchor + 1], a
xor a
ld [hBGMapAddress], a
ld [wBGMapAnchor], a
ld [hSCX], a
ld [hSCY], a
call ApplyBGMapAnchorToObjects
pop af
ld [hBGMapMode], a
pop af
ld [hOAMUpdate], a
ld hl, VramState
set 6, [hl]
ret
LoadFonts_NoOAMUpdate:: ; 64bf
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
call LoadFontsExtra
ld a, $90
ld [hWY], a
call SafeUpdateSprites
call LoadStandardFont
pop af
ld [hOAMUpdate], a
ret
HDMATransfer_FillBGMap0WithBlackTile: ; 64db
ld a, [rSVBK]
push af
ld a, $6
ld [rSVBK], a
ld a, "<BLACK>"
ld hl, wScratchTileMap
ld bc, BG_MAP_WIDTH * BG_MAP_HEIGHT
call ByteFill
ld a, wScratchTileMap / $100
ld [rHDMA1], a
ld a, wScratchTileMap % $100
ld [rHDMA2], a
ld a, (VBGMap0 % $8000) / $100
ld [rHDMA3], a
ld a, (VBGMap0 % $8000) % $100
ld [rHDMA4], a
ld a, $3f
ld [hDMATransfer], a
call DelayFrame
pop af
ld [rSVBK], a
ret
ReanchorBGMap_NoOAMUpdate_NoDelay::
ld a, [hOAMUpdate]
push af
ld a, $1
ld [hOAMUpdate], a
ld a, [hBGMapMode]
push af
xor a
ld [hBGMapMode], a
ld [hLCDCPointer], a
ld a, $90
ld [hWY], a
call OverworldTextModeSwitch
ld a, VBGMap1 / $100
ld [hBGMapAddress + 1], a
xor a
ld [hBGMapAddress], a
farcall BridgeTransition_HDMATransferTileMapAndAttrMap
ld a, VBGMap0 / $100
ld [hBGMapAddress + 1], a
ld [wBGMapAnchor + 1], a
xor a
ld [hBGMapAddress], a
ld [wBGMapAnchor], a
ld [hSCX], a
ld [hSCY], a
ld [hWY], a
inc a
ld [hCGBPalUpdate], a
farcall BridgeTransition_HDMATransferTileMapAndAttrMap
pop af
ld [hBGMapMode], a
pop af
ld [hOAMUpdate], a
ret
INCLUDE "engine/map_objects.asm"
INCLUDE "engine/intro_menu.asm"
INCLUDE "engine/init_options.asm"
INCLUDE "engine/learn.asm"
INCLUDE "engine/math.asm"
INCLUDE "engine/npc_movement.asm"
INCLUDE "engine/events/happiness_egg.asm"
INCLUDE "engine/events/specials_2.asm"
INCLUDE "data/items/attributes.asm"
SECTION "Code 2", ROMX
INCLUDE "engine/player_object.asm"
INCLUDE "engine/sine.asm"
INCLUDE "data/predef_pointers.asm"
INCLUDE "engine/color.asm"
INCLUDE "engine/trainer_scripts.asm"
SECTION "Code 3", ROMX
INCLUDE "engine/events/specials.asm"
INCLUDE "engine/printnum.asm"
INCLUDE "engine/health.asm"
INCLUDE "engine/events/overworld.asm"
INCLUDE "engine/items.asm"
INCLUDE "engine/player_step.asm"
INCLUDE "engine/anim_hp_bar.asm"
INCLUDE "engine/move_mon.asm"
INCLUDE "engine/billspctop.asm"
INCLUDE "engine/item_effects.asm"
CheckTime:: ; c000
ld a, [TimeOfDay]
ld hl, TimeOfDayTable
ld de, 2
call IsInArray
inc hl
ld c, [hl]
ret c
xor a
ld c, a
ret
TimeOfDayTable: ; c012
db MORN, 1 << MORN
db DAY, 1 << DAY
db NITE, 1 << NITE
db NITE, 1 << NITE
db -1
GetBreedMon1LevelGrowth: ; e698
ld hl, wBreedMon1Stats
ld de, TempMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
farcall CalcLevel
ld a, [wBreedMon1Level]
ld b, a
ld a, d
ld e, a
sub b
ld d, a
ret
GetBreedMon2LevelGrowth: ; e6b3
ld hl, wBreedMon2Stats
ld de, TempMon
ld bc, BOXMON_STRUCT_LENGTH
call CopyBytes
farcall CalcLevel
ld a, [wBreedMon2Level]
ld b, a
ld a, d
ld e, a
sub b
ld d, a
ret
BugContest_SetCaughtContestMon: ; e6ce
ld a, [wContestMon]
and a
jr z, .firstcatch
ld [wd265], a
call DisplayAlreadyCaughtText
call DisplayCaughtContestMonStats
call YesNoBox
ret c
.firstcatch
call .generatestats
ld a, [TempEnemyMonSpecies]
ld [wd265], a
call GetPokemonName
ld hl, .caughttext
jp PrintText
.generatestats ; e6fd
ld a, [TempEnemyMonSpecies]
ld [CurSpecies], a
ld [CurPartySpecies], a
call GetBaseData
xor a
ld bc, PARTYMON_STRUCT_LENGTH
ld hl, wContestMon
call ByteFill
xor a
ld [MonType], a
ld hl, wContestMon
jp GeneratePartyMonStats
.caughttext ; 0xe71d
; Caught @ !
text_jump UnknownText_0x1c10c0
db "@"
DisplayAlreadyCaughtText: ; cc0c7
call GetPokemonName
ld hl, .AlreadyCaughtText
jp PrintText
.AlreadyCaughtText: ; 0xcc0d0
; You already caught a @ .
text_jump UnknownText_0x1c10dd
db "@"
DisplayCaughtContestMonStats: ; cc000
call ClearBGPalettes
call ClearTileMap
call ClearSprites
call LoadFontsBattleExtra
ld hl, Options1
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
hlcoord 0, 0
lb bc, 4, 13
call TextBox
hlcoord 0, 6
lb bc, 4, 13
call TextBox
hlcoord 2, 0
ld de, .Stock
call PlaceString
hlcoord 2, 6
ld de, .This
call PlaceString
hlcoord 5, 4
ld de, .Health
call PlaceString
hlcoord 5, 10
ld de, .Health
call PlaceString
ld a, [wContestMon]
ld [wd265], a
call GetPokemonName
ld de, StringBuffer1
hlcoord 1, 2
call PlaceString
ld h, b
ld l, c
ld a, [wContestMonLevel]
ld [TempMonLevel], a
call PrintLevel
ld de, EnemyMonNick
hlcoord 1, 8
call PlaceString
ld h, b
ld l, c
ld a, [EnemyMonLevel]
ld [TempMonLevel], a
call PrintLevel
hlcoord 11, 4
ld de, wContestMonMaxHP
lb bc, 2, 3
call PrintNum
hlcoord 11, 10
ld de, EnemyMonMaxHP
call PrintNum
ld hl, SwitchMonText
call PrintText
pop af
ld [Options1], a
call WaitBGMap
ld b, CGB_DIPLOMA
call GetCGBLayout
jp SetPalettes
.Health:
db "Health@"
.Stock:
db " Stock <PK><MN> @"
.This:
db " This <PK><MN> @"
SwitchMonText: ; cc0c2
; Switch #MON?
text_jump UnknownText_0x1c10cf
db "@"
SECTION "Code 4", ROMX
INCLUDE "engine/pack.asm"
INCLUDE "engine/time.asm"
INCLUDE "engine/tmhm.asm"
INCLUDE "engine/naming_screen.asm"
INCLUDE "engine/events/itemball.asm"
INCLUDE "engine/events/heal_machine_anim.asm"
INCLUDE "engine/events/whiteout.asm"
INCLUDE "engine/events/forced_movement.asm"
INCLUDE "engine/events/itemfinder.asm"
INCLUDE "engine/startmenu.asm"
INCLUDE "engine/selectmenu.asm"
INCLUDE "engine/events/elevator.asm"
INCLUDE "engine/events/bug_contest.asm"
INCLUDE "engine/events/safari_game.asm"
INCLUDE "engine/events/std_tiles.asm"
SECTION "Code 5", ROMX
INCLUDE "engine/rtc.asm"
INCLUDE "engine/overworld.asm"
INCLUDE "engine/tile_events.asm"
INCLUDE "engine/save.asm"
INCLUDE "engine/spawn_points.asm"
INCLUDE "engine/map_setup.asm"
INCLUDE "engine/pokecenter_pc.asm"
INCLUDE "engine/mart.asm"
INCLUDE "engine/money.asm"
INCLUDE "data/items/marts.asm"
INCLUDE "engine/events/mom.asm"
INCLUDE "engine/events/daycare.asm"
INCLUDE "engine/breeding.asm"
SECTION "Code 6", ROMX
INCLUDE "engine/clock_reset.asm"
INCLUDE "engine/events/move_reminder.asm"
SECTION "Code 7", ROMX
INCLUDE "engine/events/pokepic.asm"
INCLUDE "engine/scrolling_menu.asm"
INCLUDE "engine/switch_items.asm"
INCLUDE "engine/menu.asm"
INCLUDE "engine/mon_menu.asm"
INCLUDE "engine/battle/menu.asm"
INCLUDE "engine/buy_sell_toss.asm"
INCLUDE "engine/trainer_card.asm"
INCLUDE "engine/events/prof_oaks_pc.asm"
INCLUDE "engine/decorations.asm"
INCLUDE "data/trainers/dvs.asm"
UpdateItemDescriptionAndBagQuantity:
hlcoord 1, 1
lb bc, 1, 8
call ClearBox
ld a, [MenuSelection]
cp -1
jr z, UpdateItemDescription
hlcoord 1, 1
ld de, BagXString
call PlaceString
ld a, [MenuSelection]
call GetQuantityInBag
hlcoord 6, 1
ld de, Buffer1
lb bc, 2, 3
call PrintNum
UpdateItemDescription: ; 0x244c3
ld a, [MenuSelection]
ld [CurSpecies], a
hlcoord 0, 12
lb bc, 4, SCREEN_WIDTH - 2
call TextBox
ld a, [MenuSelection]
cp -1
ret z
decoord 1, 14
farjp PrintItemDescription
BagXString:
db "Bag ×@"
UpdateTMHMDescriptionAndOwnership:
hlcoord 1, 1
lb bc, 1, 8
call ClearBox
ld a, [MenuSelection]
cp -1
jr z, UpdateTMHMDescription
ld a, [CurTMHM]
call CheckTMHM
ld de, OwnedTMString
jr c, .GotString
ld de, UnownedTMString
.GotString
hlcoord 1, 1
call PlaceString
UpdateTMHMDescription:
ld a, [MenuSelection]
ld [CurSpecies], a
hlcoord 0, 12
lb bc, 4, SCREEN_WIDTH - 2
call TextBox
ld a, [MenuSelection]
cp -1
ret z
decoord 1, 14
farjp PrintTMHMDescription
OwnedTMString:
db "Owned@"
UnownedTMString:
db "Unowned@"
GetQuantityInBag:
ld a, [CurItem]
push af
ld a, [MenuSelection]
ld [CurItem], a
call CountItem
pop af
ret
PlaceMenuItemName: ; 0x24ab4
push de
ld a, [MenuSelection]
ld [wNamedObjectIndexBuffer], a
call GetItemName
pop hl
jp PlaceString
PlaceMenuTMHMName:
push de
ld a, [MenuSelection]
ld [wNamedObjectIndexBuffer], a
call GetTMHMName
pop hl
jp PlaceString
PlaceMenuApricornQuantity:
ld a, [MenuSelection]
ld [CurItem], a
and a
ret nz
ld l, e
ld h, d
jr _PlaceMenuQuantity
PlaceMenuItemQuantity: ; 0x24ac3
push de
ld a, [MenuSelection]
ld [CurItem], a
farcall _CheckTossableItem
ld a, [wItemAttributeParamBuffer]
pop hl
and a
ret nz
_PlaceMenuQuantity:
ld de, $15
add hl, de
ld [hl], "×"
inc hl
ld de, MenuSelectionQuantity
lb bc, 1, 2
jp PrintNum
PlaceMoneyTopRight: ; 24ae8
ld hl, MenuDataHeader_0x24b15
call CopyMenuDataHeader
jr PlaceMoneyDataHeader
PlaceMoneyBottomLeft: ; 24af0
ld hl, MenuDataHeader_0x24b1d
call CopyMenuDataHeader
jr PlaceMoneyDataHeader
PlaceMoneyAtTopLeftOfTextbox: ; 24af8
ld hl, MenuDataHeader_0x24b15
lb de, 0, 11
call OffsetMenuDataHeader
PlaceMoneyDataHeader: ; 24b01
call MenuBox
call MenuBoxCoord2Tile
ld de, SCREEN_WIDTH + 1
add hl, de
ld de, Money
lb bc, PRINTNUM_MONEY | 3, 7
jp PrintNum
MenuDataHeader_0x24b15: ; 0x24b15
db $40 ; flags
db 00, 10 ; start coords
db 02, 19 ; end coords
dw NULL
db 1 ; default option
MenuDataHeader_0x24b1d: ; 0x24b1d
db $40 ; flags
db 11, 00 ; start coords
db 13, 09 ; end coords
dw NULL
db 1 ; default option
PlaceBlueCardPointsTopRight:
hlcoord 11, 0
lb bc, 1, 7
call TextBox
hlcoord 12, 1
ld de, wBlueCardBalance
lb bc, 1, 3
call PrintNum
ld de, .PointsString
jp PlaceString
.PointsString:
db " Pts@"
PlaceBattlePointsTopRight:
hlcoord 12, 0
lb bc, 1, 6
call TextBox
hlcoord 13, 1
ld de, BattlePoints
lb bc, 1, 3
call PrintNum
ld de, .BPString
jp PlaceString
.BPString:
db " BP@"
Special_DisplayCoinCaseBalance: ; 24b25
; Place a text box of size 1x7 at 11, 0.
hlcoord 11, 0
lb bc, 1, 7
call TextBox
hlcoord 12, 0
ld de, CoinString
call PlaceString
ld de, Coins
lb bc, 2, 5
hlcoord 13, 1
jp PrintNum
Special_DisplayMoneyAndCoinBalance: ; 24b4e
hlcoord 5, 0
lb bc, 3, 13
call TextBox
hlcoord 6, 1
ld de, MoneyString
call PlaceString
hlcoord 11, 1
ld de, Money
lb bc, PRINTNUM_MONEY | 3, 7
call PrintNum
hlcoord 6, 3
ld de, CoinString
call PlaceString
hlcoord 14, 3
ld de, Coins
lb bc, 2, 5
jp PrintNum
MoneyString: ; 24b83
db "Money@"
CoinString: ; 24b89
db "Coin@"
StartMenu_DrawBugContestStatusBox: ; 24bdc
hlcoord 0, 0
lb bc, 5, 17
jp TextBox
StartMenu_PrintBugContestStatus: ; 24be7
ld hl, Options1
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call StartMenu_DrawBugContestStatusBox
hlcoord 1, 5
ld de, .Balls
call PlaceString
hlcoord 8, 5
ld de, wParkBallsRemaining
lb bc, PRINTNUM_RIGHTALIGN | 1, 2
call PrintNum
hlcoord 1, 1
ld de, .Caught
call PlaceString
ld a, [wContestMon]
and a
ld de, .None
jr z, .no_contest_mon
ld [wd265], a
call GetPokemonName
.no_contest_mon
hlcoord 8, 1
call PlaceString
ld a, [wContestMon]
and a
jr z, .skip_level
hlcoord 1, 3
ld de, .Level
call PlaceString
ld a, [wContestMonLevel]
ld h, b
ld l, c
inc hl
ld c, 3
call Print8BitNumRightAlign
.skip_level
pop af
ld [Options1], a
ret
.Caught: ; 24c4b
db "Caught@"
.Balls: ; 24c52
db "Balls:@"
.None: ; 24c59
db "None@"
.Level: ; 24c5e
db "Level@"
PadCoords_de: ; 27092
ld a, d
add 4
ld d, a
ld a, e
add 4
ld e, a
jp GetBlockLocation
LevelUpHappinessMod: ; 2709e
ld a, [CurPartyMon]
ld hl, PartyMon1CaughtLocation
call GetPartyLocation
ld a, [hl]
and $7f
ld d, a
ld a, [MapGroup]
ld b, a
ld a, [MapNumber]
ld c, a
call GetWorldMapLocation
cp d
ld c, HAPPINESS_GAINLEVEL
jr nz, .ok
ld c, HAPPINESS_GAINLEVELATHOME
.ok
farjp ChangeHappiness
_ReturnToBattle_UseBall: ; 2715c
call ClearBGPalettes
call ClearTileMap
ld a, [BattleType]
cp BATTLETYPE_TUTORIAL
jr z, .gettutorialbackpic
farcall GetMonBackpic
jr .continue
.gettutorialbackpic
farcall GetTrainerBackpic
.continue
farcall GetMonFrontpic
farcall _LoadBattleFontsHPBar
call GetMemCGBLayout
call CloseWindow
call LoadStandardMenuDataHeader
call WaitBGMap
call SetPalettes
farcall LoadPlayerStatusIcon
farcall LoadEnemyStatusIcon
farjp InstantReloadPaletteHack
INCLUDE "data/moves/effects_pointers.asm"
INCLUDE "data/moves/effects.asm"
SECTION "Code 8", ROMX
INCLUDE "engine/link.asm"
SECTION "Code 9", ROMX
INCLUDE "data/battle/music.asm"
INCLUDE "engine/battle/trainer_huds.asm"
INCLUDE "engine/battle/ai/redundant.asm"
INCLUDE "engine/events/move_deleter.asm"
INCLUDE "engine/tmhm2.asm"
INCLUDE "engine/events/pokerus.asm"
INCLUDE "data/trainers/class_names.asm"
INCLUDE "data/moves/descriptions.asm"
ShowLinkBattleParticipants: ; 2ee18
; If we're not in a communications room,
; we don't need to be here.
ld a, [wLinkMode]
and a
ret z
farcall _ShowLinkBattleParticipants
ld c, 150
call DelayFrames
call ClearTileMap
jp ClearSprites
FindFirstAliveMonAndStartBattle: ; 2ee2f
xor a
ld [hMapAnims], a
call DelayFrame
ld b, 6
ld hl, PartyMon1HP
ld de, PARTYMON_STRUCT_LENGTH - 1
.loop
ld a, [hli]
or [hl]
jr nz, .okay
add hl, de
dec b
jr nz, .loop
.okay
ld de, MON_LEVEL - MON_HP
add hl, de
ld a, [hl]
ld [BattleMonLevel], a
predef Predef_StartBattle
farcall _LoadBattleFontsHPBar
ld a, 1
ld [hBGMapMode], a
call ClearSprites
call ClearTileMap
xor a
ld [hBGMapMode], a
ld [hWY], a
ld [rWY], a
ld [hMapAnims], a
ret
ClearBattleRAM: ; 2ef18
xor a
ld [wPlayerAction], a
ld [wBattleResult], a
ld hl, wPartyMenuCursor
ld [hli], a
ld [hli], a
ld [hli], a
ld [hl], a
ld [wMenuScrollPosition], a
ld [CriticalHit], a
ld [BattleMonSpecies], a
ld [wBattleParticipantsNotFainted], a
ld [CurBattleMon], a
ld [wForcedSwitch], a
ld [TimeOfDayPal], a
ld [PlayerTurnsTaken], a
ld [EnemyTurnsTaken], a
ld [EvolvableFlags], a
ld hl, PlayerHPPal
ld [hli], a
ld [hl], a
ld hl, BattleMonDVs
ld [hli], a
ld [hli], a
ld [hl], a
ld hl, BattleMonPersonality
ld [hli], a
ld [hl], a
ld hl, EnemyMonDVs
ld [hli], a
ld [hli], a
ld [hl], a
ld hl, EnemyMonPersonality
ld [hli], a
ld [hl], a
; Clear the entire BattleMons area
ld hl, wBattle
ld bc, wBattleEnd - wBattle
xor a
call ByteFill
; Clear UsedItems
ld hl, PartyUsedItems
ld bc, 6
xor a
call ByteFill
ld hl, OTPartyUsedItems
ld bc, 6
xor a
call ByteFill
farcall ResetEnemyStatLevels
call ClearWindowData
ld hl, hBGMapAddress
xor a
ld [hli], a
ld [hl], VBGMap0 / $100
ret
PlaceGraphic: ; 2ef6e
; Fill wBoxAlignment-aligned box width b height c
; with iterating tile starting from hGraphicStartTile at hl.
; Predef $13
ld de, SCREEN_WIDTH
ld a, [wBoxAlignment]
and a
jr nz, .right
ld a, [hGraphicStartTile]
.x1
push bc
push hl
.y1
ld [hl], a
add hl, de
inc a
dec c
jr nz, .y1
pop hl
inc hl
pop bc
dec b
jr nz, .x1
ret
.right
; Right-aligned.
push bc
ld b, 0
dec c
add hl, bc
pop bc
ld a, [hGraphicStartTile]
.x2
push bc
push hl
.y2
ld [hl], a
add hl, de
inc a
dec c
jr nz, .y2
pop hl
dec hl
pop bc
dec b
jr nz, .x2
ret
SECTION "Code 10", ROMX
INCLUDE "engine/mail.asm"
INCLUDE "engine/events/fruit_trees.asm"
INCLUDE "engine/events/hidden_grottoes.asm"
INCLUDE "engine/battle/ai/move.asm"
AnimateDexSearchSlowpoke: ; 441cf
ld hl, .FrameIDs
ld b, 25
.loop
ld a, [hli]
; Wrap around
cp $fe
jr nz, .ok
ld hl, .FrameIDs
ld a, [hli]
.ok
ld [wDexSearchSlowpokeFrame], a
ld a, [hli]
ld c, a
push bc
push hl
call DoDexSearchSlowpokeFrame
pop hl
pop bc
call DelayFrames
dec b
jr nz, .loop
xor a
ld [wDexSearchSlowpokeFrame], a
call DoDexSearchSlowpokeFrame
ld c, 32
jp DelayFrames
.FrameIDs: ; 441fc
; frame ID, duration