-
Notifications
You must be signed in to change notification settings - Fork 826
/
trade_animation.asm
1450 lines (1303 loc) · 26.9 KB
/
trade_animation.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
DEF TRADEANIM_RIGHT_ARROW EQU "▶" ; $ed
DEF TRADEANIM_LEFT_ARROW EQU "▼" ; $ee
; TradeAnim_TubeAnimJumptable.Jumptable indexes
const_def
const TRADEANIMSTATE_0 ; 0
const TRADEANIMSTATE_1 ; 1
const TRADEANIMSTATE_2 ; 2
const TRADEANIMSTATE_3 ; 3
DEF TRADEANIMJUMPTABLE_LENGTH EQU const_value
MACRO add_tradeanim
\1_TradeCmd:
dw \1
ENDM
MACRO tradeanim
db (\1_TradeCmd - DoTradeAnimation.Jumptable) / 2
ENDM
TradeAnimation:
xor a
ld [wUnusedTradeAnimPlayEvolutionMusic], a
ld hl, wPlayerTrademonSenderName
ld de, wOTTrademonSenderName
call LinkTradeAnim_LoadTradePlayerNames
ld hl, wPlayerTrademonSpecies
ld de, wOTTrademonSpecies
call LinkTradeAnim_LoadTradeMonSpecies
ld de, .script
jr RunTradeAnimScript
.script
tradeanim TradeAnim_SetupGivemonScroll
tradeanim TradeAnim_ShowGivemonData
tradeanim TradeAnim_DoGivemonScroll
tradeanim TradeAnim_Wait80
tradeanim TradeAnim_Wait96
tradeanim TradeAnim_Poof
tradeanim TradeAnim_RockingBall
tradeanim TradeAnim_EnterLinkTube1
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_BulgeThroughTube
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_TextboxScrollStart
tradeanim TradeAnim_GiveTrademonSFX
tradeanim TradeAnim_TubeToOT1
tradeanim TradeAnim_SentToOTText
tradeanim TradeAnim_ScrollOutRight
tradeanim TradeAnim_OTSendsText1
tradeanim TradeAnim_OTBidsFarewell
tradeanim TradeAnim_Wait40
tradeanim TradeAnim_ScrollOutRight
tradeanim TradeAnim_GetTrademonSFX
tradeanim TradeAnim_TubeToPlayer1
tradeanim TradeAnim_EnterLinkTube1
tradeanim TradeAnim_DropBall
tradeanim TradeAnim_ExitLinkTube
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_ShowGetmonData
tradeanim TradeAnim_Poof
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_FrontpicScrollStart
tradeanim TradeAnim_AnimateFrontpic
tradeanim TradeAnim_Wait80IfOTEgg
tradeanim TradeAnim_TextboxScrollStart
tradeanim TradeAnim_TakeCareOfText
tradeanim TradeAnim_ScrollOutRight
tradeanim TradeAnim_End
TradeAnimationPlayer2:
xor a
ld [wUnusedTradeAnimPlayEvolutionMusic], a
ld hl, wOTTrademonSenderName
ld de, wPlayerTrademonSenderName
call LinkTradeAnim_LoadTradePlayerNames
ld hl, wOTTrademonSpecies
ld de, wPlayerTrademonSpecies
call LinkTradeAnim_LoadTradeMonSpecies
ld de, .script
jr RunTradeAnimScript
.script
tradeanim TradeAnim_OTSendsText2
tradeanim TradeAnim_OTBidsFarewell
tradeanim TradeAnim_Wait40
tradeanim TradeAnim_ScrollOutRight
tradeanim TradeAnim_GetTrademonSFX
tradeanim TradeAnim_TubeToOT1
tradeanim TradeAnim_EnterLinkTube1
tradeanim TradeAnim_DropBall
tradeanim TradeAnim_ExitLinkTube
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_ShowGetmonData
tradeanim TradeAnim_Poof
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_FrontpicScrollStart
tradeanim TradeAnim_AnimateFrontpic
tradeanim TradeAnim_Wait180IfOTEgg
tradeanim TradeAnim_TextboxScrollStart
tradeanim TradeAnim_TakeCareOfText
tradeanim TradeAnim_ScrollOutRight
tradeanim TradeAnim_SetupGivemonScroll
tradeanim TradeAnim_ShowGivemonData
tradeanim TradeAnim_DoGivemonScroll
tradeanim TradeAnim_Wait40
tradeanim TradeAnim_Poof
tradeanim TradeAnim_RockingBall
tradeanim TradeAnim_EnterLinkTube1
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_BulgeThroughTube
tradeanim TradeAnim_WaitAnim
tradeanim TradeAnim_TextboxScrollStart
tradeanim TradeAnim_GiveTrademonSFX
tradeanim TradeAnim_TubeToPlayer1
tradeanim TradeAnim_SentToOTText
tradeanim TradeAnim_ScrollOutRight
tradeanim TradeAnim_End
RunTradeAnimScript:
ld hl, wTradeAnimAddress
ld [hl], e
inc hl
ld [hl], d
ldh a, [hMapAnims]
push af
xor a
ldh [hMapAnims], a
ld hl, wStateFlags
ld a, [hl]
push af
res SPRITE_UPDATES_DISABLED_F, [hl]
ld hl, wOptions
ld a, [hl]
push af
set NO_TEXT_SCROLL, [hl]
call .TradeAnimLayout
ld a, [wUnusedTradeAnimPlayEvolutionMusic]
and a
jr nz, .anim_loop
ld de, MUSIC_EVOLUTION
call PlayMusic2
.anim_loop
call DoTradeAnimation
jr nc, .anim_loop
pop af
ld [wOptions], a
pop af
ld [wStateFlags], a
pop af
ldh [hMapAnims], a
ret
.TradeAnimLayout:
xor a
ld [wJumptableIndex], a
call ClearBGPalettes
call ClearSprites
call ClearTilemap
call DisableLCD
call LoadFontsBattleExtra
callfar ClearSpriteAnims
ldh a, [hCGB]
and a
jr z, .NotCGB
ld a, $1
ldh [rVBK], a
ld hl, STARTOF(VRAM)
ld bc, SIZEOF(VRAM)
xor a
call ByteFill
ld a, $0
ldh [rVBK], a
.NotCGB:
hlbgcoord 0, 0
ld bc, STARTOF(VRAM) + SIZEOF(VRAM) - vBGMap0
ld a, " "
call ByteFill
ld hl, TradeGameBoyLZ
ld de, vTiles2 tile $31
call Decompress
ld hl, TradeArrowRightGFX
ld de, vTiles0 tile TRADEANIM_RIGHT_ARROW
ld bc, 1 tiles
ld a, BANK(TradeArrowRightGFX)
call FarCopyBytes
ld hl, TradeArrowLeftGFX
ld de, vTiles0 tile TRADEANIM_LEFT_ARROW
ld bc, 1 tiles
ld a, BANK(TradeArrowLeftGFX)
call FarCopyBytes
xor a
ldh [hSCX], a
ldh [hSCY], a
ld a, $7
ldh [hWX], a
ld a, $90
ldh [hWY], a
farcall GetTrademonFrontpic
call EnableLCD
call LoadTradeBallAndCableGFX
ld a, [wPlayerTrademonSpecies]
ld hl, wPlayerTrademonDVs
ld de, vTiles0
call TradeAnim_GetFrontpic
ld a, [wOTTrademonSpecies]
ld hl, wOTTrademonDVs
ld de, vTiles0 tile $31
call TradeAnim_GetFrontpic
ld a, [wPlayerTrademonSpecies]
ld de, wPlayerTrademonSpeciesName
call TradeAnim_GetNicknamename
ld a, [wOTTrademonSpecies]
ld de, wOTTrademonSpeciesName
call TradeAnim_GetNicknamename
call TradeAnim_NormalPals
ret
DoTradeAnimation:
ld a, [wJumptableIndex]
bit JUMPTABLE_EXIT_F, a
jr nz, .finished
call .DoTradeAnimCommand
callfar PlaySpriteAnimations
ld hl, wFrameCounter2
inc [hl]
call DelayFrame
and a
ret
.finished
call LoadStandardFont
scf
ret
.DoTradeAnimCommand:
jumptable .Jumptable, wJumptableIndex
.Jumptable:
add_tradeanim TradeAnim_AdvanceScriptPointer ; 00
add_tradeanim TradeAnim_ShowGivemonData ; 01
add_tradeanim TradeAnim_ShowGetmonData ; 02
add_tradeanim TradeAnim_EnterLinkTube1 ; 03
add_tradeanim TradeAnim_EnterLinkTube2 ; 04
add_tradeanim TradeAnim_ExitLinkTube ; 05
add_tradeanim TradeAnim_TubeToOT1 ; 06
add_tradeanim TradeAnim_TubeToOT2 ; 07
add_tradeanim TradeAnim_TubeToOT3 ; 08
add_tradeanim TradeAnim_TubeToOT4 ; 09
add_tradeanim TradeAnim_TubeToOT5 ; 0a
add_tradeanim TradeAnim_TubeToOT6 ; 0b
add_tradeanim TradeAnim_TubeToOT7 ; 0c
add_tradeanim TradeAnim_TubeToOT8 ; 0d
add_tradeanim TradeAnim_TubeToPlayer1 ; 0e
add_tradeanim TradeAnim_TubeToPlayer2 ; 0f
add_tradeanim TradeAnim_TubeToPlayer3 ; 10
add_tradeanim TradeAnim_TubeToPlayer4 ; 11
add_tradeanim TradeAnim_TubeToPlayer5 ; 12
add_tradeanim TradeAnim_TubeToPlayer6 ; 13
add_tradeanim TradeAnim_TubeToPlayer7 ; 14
add_tradeanim TradeAnim_TubeToPlayer8 ; 15
add_tradeanim TradeAnim_SentToOTText ; 16
add_tradeanim TradeAnim_OTBidsFarewell ; 17
add_tradeanim TradeAnim_TakeCareOfText ; 18
add_tradeanim TradeAnim_OTSendsText1 ; 19
add_tradeanim TradeAnim_OTSendsText2 ; 1a
add_tradeanim TradeAnim_SetupGivemonScroll ; 1b
add_tradeanim TradeAnim_DoGivemonScroll ; 1c
add_tradeanim TradeAnim_FrontpicScrollStart ; 1d
add_tradeanim TradeAnim_TextboxScrollStart ; 1e
add_tradeanim TradeAnim_ScrollOutRight ; 1f
add_tradeanim TradeAnim_ScrollOutRight2 ; 20
add_tradeanim TradeAnim_Wait80 ; 21
add_tradeanim TradeAnim_Wait40 ; 22
add_tradeanim TradeAnim_RockingBall ; 23
add_tradeanim TradeAnim_DropBall ; 24
add_tradeanim TradeAnim_WaitAnim ; 25
add_tradeanim TradeAnim_WaitAnim2 ; 26
add_tradeanim TradeAnim_Poof ; 27
add_tradeanim TradeAnim_BulgeThroughTube ; 28
add_tradeanim TradeAnim_GiveTrademonSFX ; 29
add_tradeanim TradeAnim_GetTrademonSFX ; 2a
add_tradeanim TradeAnim_End ; 2b
add_tradeanim TradeAnim_AnimateFrontpic ; 2c
add_tradeanim TradeAnim_Wait96 ; 2d
add_tradeanim TradeAnim_Wait80IfOTEgg ; 2e
add_tradeanim TradeAnim_Wait180IfOTEgg ; 2f
TradeAnim_IncrementJumptableIndex:
ld hl, wJumptableIndex
inc [hl]
ret
TradeAnim_AdvanceScriptPointer:
ld hl, wTradeAnimAddress
ld e, [hl]
inc hl
ld d, [hl]
ld a, [de]
ld [wJumptableIndex], a
inc de
ld [hl], d
dec hl
ld [hl], e
ret
TradeAnim_End:
ld hl, wJumptableIndex
set JUMPTABLE_EXIT_F, [hl]
ret
TradeAnim_TubeToOT1:
ld a, TRADEANIM_RIGHT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeSendmonSpecies]
ld [wTempIconSpecies], a
xor a
depixel 5, 11, 4, 0
ld b, $0
jr TradeAnim_InitTubeAnim
TradeAnim_TubeToPlayer1:
ld a, TRADEANIM_LEFT_ARROW
call TradeAnim_PlaceTrademonStatsOnTubeAnim
ld a, [wLinkTradeGetmonSpecies]
ld [wTempIconSpecies], a
ld a, TRADEANIMSTATE_2
depixel 9, 18, 4, 4
ld b, $4
TradeAnim_InitTubeAnim:
push bc
push de
push bc
push de
push af
call DisableLCD
callfar ClearSpriteAnims
hlbgcoord 20, 3
ld bc, 12
ld a, $60
call ByteFill
pop af
call TradeAnim_TubeAnimJumptable
xor a
ldh [hSCX], a
ld a, $7
ldh [hWX], a
ld a, $70
ldh [hWY], a
call EnableLCD
call LoadTradeBubbleGFX
pop de
ld a, SPRITE_ANIM_OBJ_TRADEMON_ICON
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
add hl, bc
pop bc
ld [hl], b
pop de
ld a, SPRITE_ANIM_OBJ_TRADEMON_BUBBLE
call InitSpriteAnimStruct
ld hl, SPRITEANIMSTRUCT_JUMPTABLE_INDEX
add hl, bc
pop bc
ld [hl], b
call WaitBGMap
ld b, SCGB_TRADE_TUBE
call GetSGBLayout
ld a, %11100100 ; 3,2,1,0
call DmgToCgbBGPals
ld a, %11010000
call DmgToCgbObjPal0
call TradeAnim_IncrementJumptableIndex
ld a, 92
ld [wFrameCounter], a
ret
TradeAnim_TubeToOT2:
call TradeAnim_FlashBGPals
ldh a, [hSCX]
add $2
ldh [hSCX], a
cp $50
ret nz
ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToOT3:
call TradeAnim_FlashBGPals
ldh a, [hSCX]
add $2
ldh [hSCX], a
cp $a0
ret nz
ld a, TRADEANIMSTATE_2
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToOT4:
call TradeAnim_FlashBGPals
ldh a, [hSCX]
add $2
ldh [hSCX], a
and a
ret nz
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToPlayer3:
call TradeAnim_FlashBGPals
ldh a, [hSCX]
sub $2
ldh [hSCX], a
cp $b0
ret nz
ld a, TRADEANIMSTATE_1
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToPlayer4:
call TradeAnim_FlashBGPals
ldh a, [hSCX]
sub $2
ldh [hSCX], a
cp $60
ret nz
xor a ; TRADEANIMSTATE_0
call TradeAnim_TubeAnimJumptable
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToPlayer5:
call TradeAnim_FlashBGPals
ldh a, [hSCX]
sub $2
ldh [hSCX], a
and a
ret nz
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToOT6:
TradeAnim_TubeToPlayer6:
ld a, 128
ld [wFrameCounter], a
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_TubeToOT8:
TradeAnim_TubeToPlayer8:
call ClearBGPalettes
call ClearTilemap
call ClearSprites
call DisableLCD
callfar ClearSpriteAnims
hlbgcoord 0, 0
ld bc, STARTOF(VRAM) + SIZEOF(VRAM) - vBGMap0
ld a, " "
call ByteFill
xor a
ldh [hSCX], a
ld a, $90
ldh [hWY], a
call EnableLCD
call LoadTradeBallAndCableGFX
call WaitBGMap
call TradeAnim_NormalPals
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_TubeToOT5:
TradeAnim_TubeToOT7:
TradeAnim_TubeToPlayer2:
TradeAnim_TubeToPlayer7:
call TradeAnim_FlashBGPals
ld hl, wFrameCounter
ld a, [hl]
and a
jr z, .done
dec [hl]
ret
.done
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_GiveTrademonSFX:
call TradeAnim_AdvanceScriptPointer
ld de, SFX_GIVE_TRADEMON
call PlaySFX
ret
TradeAnim_GetTrademonSFX:
call TradeAnim_AdvanceScriptPointer
ld de, SFX_GET_TRADEMON
call PlaySFX
ret
TradeAnim_TubeAnimJumptable:
maskbits TRADEANIMJUMPTABLE_LENGTH
ld e, a
ld d, 0
ld hl, .Jumptable
add hl, de
add hl, de
ld a, [hli]
ld h, [hl]
ld l, a
jp hl
.Jumptable:
; entries correspond to TRADEANIMSTATE_* constants
dw .Zero
dw .One
dw .Two
dw .Three
.Zero:
.Three:
call TradeAnim_BlankTilemap
hlcoord 9, 3
ld [hl], $5b
inc hl
ld bc, 10
ld a, $60
call ByteFill
hlcoord 3, 2
call TradeAnim_CopyTradeGameBoyTilemap
ret
.One:
call TradeAnim_BlankTilemap
hlcoord 0, 3
ld bc, SCREEN_WIDTH
ld a, $60
call ByteFill
ret
.Two:
call TradeAnim_BlankTilemap
hlcoord 0, 3
ld bc, $11
ld a, $60
call ByteFill
hlcoord 17, 3
ld a, $5d
ld [hl], a
ld a, $61
ld de, SCREEN_WIDTH
ld c, $3
.loop
add hl, de
ld [hl], a
dec c
jr nz, .loop
add hl, de
ld a, $5f
ld [hld], a
ld a, $5b
ld [hl], a
hlcoord 10, 6
call TradeAnim_CopyTradeGameBoyTilemap
ret
TradeAnim_CopyTradeGameBoyTilemap:
ld de, TradeGameBoyTilemap
lb bc, 8, 6
call TradeAnim_CopyBoxFromDEtoHL
ret
TradeAnim_PlaceTrademonStatsOnTubeAnim:
push af
call ClearBGPalettes
call WaitTop
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
call ClearTilemap
hlcoord 0, 0
ld bc, SCREEN_WIDTH
ld a, "─"
call ByteFill
hlcoord 0, 1
ld de, wLinkPlayer1Name
call PlaceString
ld hl, wLinkPlayer2Name
ld de, 0
.find_name_end_loop
ld a, [hli]
cp "@"
jr z, .done
dec de
jr .find_name_end_loop
.done
hlcoord 0, 4
add hl, de
ld de, wLinkPlayer2Name
call PlaceString
hlcoord 7, 2
ld bc, 6
pop af
call ByteFill
call WaitBGMap
call WaitTop
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
call ClearTilemap
ret
TradeAnim_EnterLinkTube1:
call ClearTilemap
call WaitTop
ld a, $a0
ldh [hSCX], a
call DelayFrame
hlcoord 8, 2
ld de, TradeLinkTubeTilemap
lb bc, 3, 12
call TradeAnim_CopyBoxFromDEtoHL
call WaitBGMap
ld b, SCGB_TRADE_TUBE
call GetSGBLayout
ld a, %11100100 ; 3,2,1,0
call DmgToCgbBGPals
lb de, %11100100, %11100100 ; 3,2,1,0, 3,2,1,0
call DmgToCgbObjPals
ld de, SFX_POTION
call PlaySFX
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_EnterLinkTube2:
ldh a, [hSCX]
and a
jr z, .done
add $4
ldh [hSCX], a
ret
.done
ld c, 80
call DelayFrames
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_ExitLinkTube:
ldh a, [hSCX]
cp $a0
jr z, .done
sub $4
ldh [hSCX], a
ret
.done
call ClearTilemap
xor a
ldh [hSCX], a
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_SetupGivemonScroll:
ld a, $8f
ldh [hWX], a
ld a, $88
ldh [hSCX], a
ld a, $50
ldh [hWY], a
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_DoGivemonScroll:
ldh a, [hWX]
cp $7
jr z, .done
sub $4
ldh [hWX], a
ldh a, [hSCX]
sub $4
ldh [hSCX], a
ret
.done
ld a, $7
ldh [hWX], a
xor a
ldh [hSCX], a
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_FrontpicScrollStart:
ld a, $7
ldh [hWX], a
ld a, $50
ldh [hWY], a
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_TextboxScrollStart:
ld a, $7
ldh [hWX], a
ld a, $90
ldh [hWY], a
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_ScrollOutRight:
call WaitTop
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
call WaitBGMap
ld a, $7
ldh [hWX], a
xor a
ldh [hWY], a
call DelayFrame
call WaitTop
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
call ClearTilemap
call TradeAnim_IncrementJumptableIndex
ret
TradeAnim_ScrollOutRight2:
ldh a, [hWX]
cp $a1
jr nc, .done
add $4
ldh [hWX], a
ret
.done
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
call WaitBGMap
ld a, $7
ldh [hWX], a
ld a, $90
ldh [hWY], a
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_ShowGivemonData:
call ShowPlayerTrademonStats
ld a, [wPlayerTrademonSpecies]
ld [wCurPartySpecies], a
ld a, [wPlayerTrademonDVs]
ld [wTempMonDVs], a
ld a, [wPlayerTrademonDVs + 1]
ld [wTempMonDVs + 1], a
ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetSGBLayout
ld a, %11100100 ; 3,2,1,0
call DmgToCgbBGPals
call TradeAnim_ShowGivemonFrontpic
ld a, [wPlayerTrademonSpecies]
call GetCryIndex
jr c, .skip_cry
ld e, c
ld d, b
call PlayCry
.skip_cry
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_ShowGetmonData:
call ShowOTTrademonStats
ld a, [wOTTrademonSpecies]
ld [wCurPartySpecies], a
ld a, [wOTTrademonDVs]
ld [wTempMonDVs], a
ld a, [wOTTrademonDVs + 1]
ld [wTempMonDVs + 1], a
ld b, SCGB_PLAYER_OR_MON_FRONTPIC_PALS
call GetSGBLayout
ld a, %11100100 ; 3,2,1,0
call DmgToCgbBGPals
call TradeAnim_ShowGetmonFrontpic
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_AnimateFrontpic:
farcall AnimateTrademonFrontpic
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_GetFrontpic:
push de
push af
predef GetUnownLetter
pop af
ld [wCurPartySpecies], a
ld [wCurSpecies], a
call GetBaseData
pop de
predef GetMonFrontpic
ret
TradeAnim_GetNicknamename:
push de
ld [wNamedObjectIndex], a
call GetPokemonName
ld hl, wStringBuffer1
pop de
ld bc, NAME_LENGTH
call CopyBytes
ret
TradeAnim_ShowGivemonFrontpic:
ld de, vTiles0
jr TradeAnim_ShowFrontpic
TradeAnim_ShowGetmonFrontpic:
ld de, vTiles0 tile $31
TradeAnim_ShowFrontpic:
call DelayFrame
ld hl, vTiles2
lb bc, 10, $31
call Request2bpp
call WaitTop
call TradeAnim_BlankTilemap
hlcoord 7, 2
xor a
ldh [hGraphicStartTile], a
lb bc, 7, 7
predef PlaceGraphic
call WaitBGMap
ret
TradeAnim_Wait80:
ld c, 80
call DelayFrames
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_Wait40:
ld c, 40
call DelayFrames
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_Wait96:
ld c, 96
call DelayFrames
call TradeAnim_AdvanceScriptPointer
ret
TradeAnim_Wait80IfOTEgg:
call IsOTTrademonEgg
ret nz
ld c, 80
call DelayFrames
ret
TradeAnim_Wait180IfOTEgg:
call IsOTTrademonEgg
ret nz
ld c, 180
call DelayFrames
ret
IsOTTrademonEgg:
call TradeAnim_AdvanceScriptPointer
ld a, [wOTTrademonSpecies]
cp EGG
ret
ShowPlayerTrademonStats:
ld de, wPlayerTrademonSpecies
ld a, [de]
cp EGG
jr z, TrademonStats_Egg
call TrademonStats_MonTemplate
ld de, wPlayerTrademonSpecies
call TrademonStats_PrintSpeciesNumber
ld de, wPlayerTrademonSpeciesName
call TrademonStats_PrintSpeciesName
ld a, [wPlayerTrademonCaughtData]
ld de, wPlayerTrademonOTName
call TrademonStats_PrintOTName
ld de, wPlayerTrademonID
call TrademonStats_PrintTrademonID
call TrademonStats_WaitBGMap
ret
ShowOTTrademonStats:
ld de, wOTTrademonSpecies
ld a, [de]
cp EGG
jr z, TrademonStats_Egg
call TrademonStats_MonTemplate
ld de, wOTTrademonSpecies
call TrademonStats_PrintSpeciesNumber
ld de, wOTTrademonSpeciesName
call TrademonStats_PrintSpeciesName
ld a, [wOTTrademonCaughtData]
ld de, wOTTrademonOTName
call TrademonStats_PrintOTName
ld de, wOTTrademonID
call TrademonStats_PrintTrademonID
call TrademonStats_WaitBGMap
ret
TrademonStats_MonTemplate:
call WaitTop
call TradeAnim_BlankTilemap
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
hlcoord 3, 0
ld b, $6
ld c, $d
call Textbox
hlcoord 4, 0
ld de, .OTMonData
call PlaceString
ret
.OTMonData:
db "─── №."
next ""
next "OT/"
next "<ID>№.@"
TrademonStats_Egg:
call WaitTop
call TradeAnim_BlankTilemap
ld a, HIGH(vBGMap1)
ldh [hBGMapAddress + 1], a
hlcoord 3, 0
ld b, 6
ld c, 13
call Textbox
hlcoord 4, 2
ld de, .EggData
call PlaceString
call TrademonStats_WaitBGMap
ret
.EggData:
db "EGG"
next "OT/?????"
next "<ID>№.?????@"
TrademonStats_WaitBGMap:
call WaitBGMap
call WaitTop
ld a, HIGH(vBGMap0)
ldh [hBGMapAddress + 1], a
ret
TrademonStats_PrintSpeciesNumber:
hlcoord 10, 0
lb bc, PRINTNUM_LEADINGZEROS | 1, 3
call PrintNum
ld [hl], " "
ret
TrademonStats_PrintSpeciesName:
hlcoord 4, 2
call PlaceString
ret
TrademonStats_PrintOTName:
cp 3
jr c, .caught_gender_okay
xor a
.caught_gender_okay
push af
hlcoord 7, 4
call PlaceString
inc bc
pop af
ld hl, .Gender
ld d, 0
ld e, a
add hl, de
ld a, [hl]
ld [bc], a
ret