Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
pret
GitHub Repository: pret/pokered
Path: blob/master/engine/movie/trade.asm
1271 views
1
InternalClockTradeAnim:
2
; Do the trading animation with the player's gameboy on the left.
3
; In-game trades and internally clocked link cable trades use this.
4
ld a, [wTradedPlayerMonSpecies]
5
ld [wLeftGBMonSpecies], a
6
ld a, [wTradedEnemyMonSpecies]
7
ld [wRightGBMonSpecies], a
8
ld de, InternalClockTradeFuncSequence
9
jr TradeAnimCommon
10
11
ExternalClockTradeAnim:
12
; Do the trading animation with the player's gameboy on the right.
13
; Externally clocked link cable trades use this.
14
ld a, [wTradedEnemyMonSpecies]
15
ld [wLeftGBMonSpecies], a
16
ld a, [wTradedPlayerMonSpecies]
17
ld [wRightGBMonSpecies], a
18
ld de, ExternalClockTradeFuncSequence
19
20
TradeAnimCommon:
21
ld a, [wOptions]
22
push af
23
ldh a, [hSCY]
24
push af
25
ldh a, [hSCX]
26
push af
27
xor a
28
ld [wOptions], a
29
ldh [hSCY], a
30
ldh [hSCX], a
31
push de
32
.loop
33
pop de
34
ld a, [de]
35
cp $ff
36
jr z, .done
37
inc de
38
push de
39
ld hl, TradeFuncPointerTable
40
add a
41
ld c, a
42
ld b, $0
43
add hl, bc
44
ld a, [hli]
45
ld h, [hl]
46
ld l, a
47
ld de, .loop
48
push de
49
jp hl ; call trade func, which will return to the top of the loop
50
.done
51
pop af
52
ldh [hSCX], a
53
pop af
54
ldh [hSCY], a
55
pop af
56
ld [wOptions], a
57
ret
58
59
MACRO addtradefunc
60
\1TradeFunc::
61
dw \1
62
ENDM
63
64
MACRO tradefunc
65
db (\1TradeFunc - TradeFuncPointerTable) / 2
66
ENDM
67
68
; The functions in the sequences below are executed in order by TradeFuncCommon.
69
; They are from opposite perspectives. The external clock one makes use of
70
; Trade_SwapNames to swap the player and enemy names for some functions.
71
72
InternalClockTradeFuncSequence:
73
tradefunc LoadTradingGFXAndMonNames
74
tradefunc Trade_ShowPlayerMon
75
tradefunc Trade_DrawOpenEndOfLinkCable
76
tradefunc Trade_AnimateBallEnteringLinkCable
77
tradefunc Trade_AnimLeftToRight
78
tradefunc Trade_Delay100
79
tradefunc Trade_ShowClearedWindow
80
tradefunc PrintTradeWentToText
81
tradefunc PrintTradeForSendsText
82
tradefunc PrintTradeFarewellText
83
tradefunc Trade_AnimRightToLeft
84
tradefunc Trade_ShowClearedWindow
85
tradefunc Trade_DrawOpenEndOfLinkCable
86
tradefunc Trade_ShowEnemyMon
87
tradefunc Trade_Delay100
88
tradefunc Trade_Cleanup
89
db -1 ; end
90
91
ExternalClockTradeFuncSequence:
92
tradefunc LoadTradingGFXAndMonNames
93
tradefunc Trade_ShowClearedWindow
94
tradefunc PrintTradeWillTradeText
95
tradefunc PrintTradeFarewellText
96
tradefunc Trade_SwapNames
97
tradefunc Trade_AnimLeftToRight
98
tradefunc Trade_SwapNames
99
tradefunc Trade_ShowClearedWindow
100
tradefunc Trade_DrawOpenEndOfLinkCable
101
tradefunc Trade_ShowEnemyMon
102
tradefunc Trade_SlideTextBoxOffScreen
103
tradefunc Trade_ShowPlayerMon
104
tradefunc Trade_DrawOpenEndOfLinkCable
105
tradefunc Trade_AnimateBallEnteringLinkCable
106
tradefunc Trade_SwapNames
107
tradefunc Trade_AnimRightToLeft
108
tradefunc Trade_SwapNames
109
tradefunc Trade_Delay100
110
tradefunc Trade_ShowClearedWindow
111
tradefunc PrintTradeWentToText
112
tradefunc Trade_Cleanup
113
db -1 ; end
114
115
TradeFuncPointerTable:
116
addtradefunc LoadTradingGFXAndMonNames
117
addtradefunc Trade_ShowPlayerMon
118
addtradefunc Trade_DrawOpenEndOfLinkCable
119
addtradefunc Trade_AnimateBallEnteringLinkCable
120
addtradefunc Trade_ShowEnemyMon
121
addtradefunc Trade_AnimLeftToRight
122
addtradefunc Trade_AnimRightToLeft
123
addtradefunc Trade_Delay100
124
addtradefunc Trade_ShowClearedWindow
125
addtradefunc PrintTradeWentToText
126
addtradefunc PrintTradeForSendsText
127
addtradefunc PrintTradeFarewellText
128
addtradefunc PrintTradeTakeCareText
129
addtradefunc PrintTradeWillTradeText
130
addtradefunc Trade_Cleanup
131
addtradefunc Trade_SlideTextBoxOffScreen
132
addtradefunc Trade_SwapNames
133
134
Trade_Delay100:
135
ld c, 100
136
jp DelayFrames
137
138
Trade_CopyTileMapToVRAM:
139
ld a, $1
140
ldh [hAutoBGTransferEnabled], a
141
call Delay3
142
xor a
143
ldh [hAutoBGTransferEnabled], a
144
ret
145
146
Trade_Delay80:
147
ld c, 80
148
jp DelayFrames
149
150
Trade_ClearTileMap:
151
hlcoord 0, 0
152
ld bc, SCREEN_AREA
153
ld a, " "
154
jp FillMemory
155
156
LoadTradingGFXAndMonNames:
157
call Trade_ClearTileMap
158
call DisableLCD
159
ld hl, TradingAnimationGraphics
160
ld de, vChars2 tile $31
161
ld bc, TradingAnimationGraphicsEnd - TradingAnimationGraphics
162
ld a, BANK(TradingAnimationGraphics)
163
call FarCopyData2
164
ld hl, TradingAnimationGraphics2
165
ld de, vSprites tile $7c
166
ld bc, TradingAnimationGraphics2End - TradingAnimationGraphics2
167
ld a, BANK(TradingAnimationGraphics2)
168
call FarCopyData2
169
ld hl, vBGMap0
170
ld bc, 2 * TILEMAP_AREA
171
ld a, " "
172
call FillMemory
173
call ClearSprites
174
ld a, $ff
175
ld [wUpdateSpritesEnabled], a
176
ld hl, wStatusFlags5
177
set BIT_NO_TEXT_DELAY, [hl]
178
ld a, [wOnSGB]
179
and a
180
ld a, $e4 ; non-SGB OBP0
181
jr z, .next
182
ld a, $f0 ; SGB OBP0
183
.next
184
ldh [rOBP0], a
185
call EnableLCD
186
xor a
187
ldh [hAutoBGTransferEnabled], a
188
ld a, [wTradedPlayerMonSpecies]
189
ld [wNamedObjectIndex], a
190
call GetMonName
191
ld hl, wNameBuffer
192
ld de, wStringBuffer
193
ld bc, NAME_LENGTH
194
call CopyData
195
ld a, [wTradedEnemyMonSpecies]
196
ld [wNamedObjectIndex], a
197
jp GetMonName
198
199
Trade_LoadMonPartySpriteGfx:
200
ld a, %11010000
201
ldh [rOBP1], a
202
farjp LoadMonPartySpriteGfx
203
204
Trade_SwapNames:
205
ld hl, wPlayerName
206
ld de, wBuffer
207
ld bc, NAME_LENGTH
208
call CopyData
209
ld hl, wLinkEnemyTrainerName
210
ld de, wPlayerName
211
ld bc, NAME_LENGTH
212
call CopyData
213
ld hl, wBuffer
214
ld de, wLinkEnemyTrainerName
215
ld bc, NAME_LENGTH
216
jp CopyData
217
218
Trade_Cleanup:
219
xor a
220
call LoadGBPal
221
ld hl, wStatusFlags5
222
res BIT_NO_TEXT_DELAY, [hl]
223
ret
224
225
Trade_ShowPlayerMon:
226
ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
227
ldh [rLCDC], a
228
ld a, $50
229
ldh [hWY], a
230
ld a, $86
231
ldh [rWX], a
232
ldh [hSCX], a
233
xor a
234
ldh [hAutoBGTransferEnabled], a
235
hlcoord 4, 0
236
ld b, 6
237
ld c, 10
238
call TextBoxBorder
239
call Trade_PrintPlayerMonInfoText
240
ld b, HIGH(vBGMap0)
241
call CopyScreenTileBufferToVRAM
242
call ClearScreen
243
ld a, [wTradedPlayerMonSpecies]
244
call Trade_LoadMonSprite
245
ld a, $7e
246
.slideScreenLoop
247
push af
248
call DelayFrame
249
pop af
250
ldh [rWX], a
251
ldh [hSCX], a
252
dec a
253
dec a
254
and a
255
jr nz, .slideScreenLoop
256
call Trade_Delay80
257
ld a, TRADE_BALL_POOF_ANIM
258
call Trade_ShowAnimation
259
ld a, TRADE_BALL_DROP_ANIM
260
call Trade_ShowAnimation ; clears mon pic
261
ld a, [wTradedPlayerMonSpecies]
262
call PlayCry
263
xor a
264
ldh [hAutoBGTransferEnabled], a
265
ret
266
267
Trade_DrawOpenEndOfLinkCable:
268
call Trade_ClearTileMap
269
ld b, HIGH(vBGMap0)
270
call CopyScreenTileBufferToVRAM
271
ld b, SET_PAL_GENERIC
272
call RunPaletteCommand
273
274
; This function call is pointless. It just copies blank tiles to VRAM that was
275
; already filled with blank tiles.
276
ld hl, vBGMap1 + $8c
277
call Trade_CopyCableTilesOffScreen
278
279
ld a, $a0
280
ldh [hSCX], a
281
call DelayFrame
282
ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_OFF | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
283
ldh [rLCDC], a
284
hlcoord 6, 2
285
ld b, TILEMAP_LINK_CABLE
286
call CopyTileIDsFromList_ZeroBaseTileID
287
call Trade_CopyTileMapToVRAM
288
ld a, SFX_HEAL_HP
289
call PlaySound
290
ld c, 20
291
.loop
292
ldh a, [hSCX]
293
add 4
294
ldh [hSCX], a
295
dec c
296
jr nz, .loop
297
ret
298
299
Trade_AnimateBallEnteringLinkCable:
300
ld a, TRADE_BALL_SHAKE_ANIM
301
call Trade_ShowAnimation
302
ld c, 10
303
call DelayFrames
304
ld a, %11100100
305
ldh [rOBP0], a
306
xor a
307
ld [wLinkCableAnimBulgeToggle], a
308
lb bc, $20, $60
309
.moveBallInsideLinkCableLoop
310
push bc
311
xor a
312
ld de, Trade_BallInsideLinkCableOAMBlock
313
call WriteOAMBlock
314
ld a, [wLinkCableAnimBulgeToggle]
315
xor $1
316
ld [wLinkCableAnimBulgeToggle], a
317
add $7e
318
ld hl, wShadowOAMSprite00TileID
319
ld de, 4
320
ld c, e
321
.cycleLinkCableBulgeTile
322
ld [hl], a
323
add hl, de
324
dec c
325
jr nz, .cycleLinkCableBulgeTile
326
call Delay3
327
pop bc
328
ld a, c
329
add $4
330
ld c, a
331
cp $a0
332
jr nc, .ballSpriteReachedEdgeOfScreen
333
ld a, SFX_TINK
334
call PlaySound
335
jr .moveBallInsideLinkCableLoop
336
.ballSpriteReachedEdgeOfScreen
337
call ClearSprites
338
ld a, $1
339
ldh [hAutoBGTransferEnabled], a
340
call ClearScreen
341
ld b, HIGH(vBGMap0)
342
call CopyScreenTileBufferToVRAM
343
call Delay3
344
xor a
345
ldh [hAutoBGTransferEnabled], a
346
ret
347
348
Trade_BallInsideLinkCableOAMBlock:
349
db $7e, 0
350
db $7e, OAM_XFLIP
351
db $7e, OAM_YFLIP
352
db $7e, OAM_XFLIP | OAM_YFLIP
353
354
Trade_ShowEnemyMon:
355
ld a, TRADE_BALL_TILT_ANIM
356
call Trade_ShowAnimation
357
call Trade_ShowClearedWindow
358
hlcoord 4, 10
359
ld b, 6
360
ld c, 10
361
call TextBoxBorder
362
call Trade_PrintEnemyMonInfoText
363
call Trade_CopyTileMapToVRAM
364
ld a, $1
365
ldh [hAutoBGTransferEnabled], a
366
ld a, [wTradedEnemyMonSpecies]
367
call Trade_LoadMonSprite
368
ld a, TRADE_BALL_POOF_ANIM
369
call Trade_ShowAnimation
370
ld a, $1
371
ldh [hAutoBGTransferEnabled], a
372
ld a, [wTradedEnemyMonSpecies]
373
call PlayCry
374
call Trade_Delay100
375
hlcoord 4, 10
376
lb bc, 8, 12
377
call ClearScreenArea
378
jp PrintTradeTakeCareText
379
380
Trade_AnimLeftToRight:
381
; Animates the mon moving from the left GB to the right one.
382
call Trade_InitGameboyTransferGfx
383
ld a, $1
384
ld [wTradedMonMovingRight], a
385
ld a, %11100100
386
ldh [rOBP0], a
387
ld a, $54
388
ld [wBaseCoordX], a
389
ld a, $1c
390
ld [wBaseCoordY], a
391
ld a, [wLeftGBMonSpecies]
392
ld [wMonPartySpriteSpecies], a
393
call Trade_WriteCircledMonOAM
394
call Trade_DrawLeftGameboy
395
call Trade_CopyTileMapToVRAM
396
call Trade_DrawCableAcrossScreen
397
ld hl, vBGMap1 + $8c
398
call Trade_CopyCableTilesOffScreen
399
ld b, $6
400
call Trade_AnimMonMoveHorizontal
401
ld a, $1
402
ldh [hAutoBGTransferEnabled], a
403
call Trade_DrawCableAcrossScreen
404
ld b, $4
405
call Trade_AnimMonMoveHorizontal
406
call Trade_DrawRightGameboy
407
ld b, $6
408
call Trade_AnimMonMoveHorizontal
409
xor a
410
ldh [hAutoBGTransferEnabled], a
411
call Trade_AnimMonMoveVertical
412
jp ClearSprites
413
414
Trade_AnimRightToLeft:
415
; Animates the mon moving from the right GB to the left one.
416
call Trade_InitGameboyTransferGfx
417
xor a
418
ld [wTradedMonMovingRight], a
419
ld a, $64
420
ld [wBaseCoordX], a
421
ld a, $44
422
ld [wBaseCoordY], a
423
ld a, [wRightGBMonSpecies]
424
ld [wMonPartySpriteSpecies], a
425
call Trade_WriteCircledMonOAM
426
call Trade_DrawRightGameboy
427
call Trade_CopyTileMapToVRAM
428
call Trade_DrawCableAcrossScreen
429
ld hl, vBGMap1 + $94
430
call Trade_CopyCableTilesOffScreen
431
call Trade_AnimMonMoveVertical
432
ld b, $6
433
call Trade_AnimMonMoveHorizontal
434
ld a, $1
435
ldh [hAutoBGTransferEnabled], a
436
call Trade_DrawCableAcrossScreen
437
ld b, $4
438
call Trade_AnimMonMoveHorizontal
439
call Trade_DrawLeftGameboy
440
ld b, $6
441
call Trade_AnimMonMoveHorizontal
442
xor a
443
ldh [hAutoBGTransferEnabled], a
444
jp ClearSprites
445
446
Trade_InitGameboyTransferGfx:
447
; Initialises the graphics for showing a mon moving between gameboys.
448
ld a, $1
449
ldh [hAutoBGTransferEnabled], a
450
call ClearScreen
451
xor a
452
ldh [hAutoBGTransferEnabled], a
453
call Trade_LoadMonPartySpriteGfx
454
call DelayFrame
455
ld a, LCDC_ON | LCDC_WIN_9800 | LCDC_WIN_ON | LCDC_BLOCK21 | LCDC_BG_9C00 | LCDC_OBJ_8 | LCDC_OBJ_ON | LCDC_BG_ON
456
ldh [rLCDC], a
457
xor a
458
ldh [hSCX], a
459
ld a, $90
460
ldh [hWY], a
461
ret
462
463
Trade_DrawLeftGameboy:
464
call Trade_ClearTileMap
465
466
; draw link cable
467
hlcoord 11, 4
468
ld a, $5d
469
ld [hli], a
470
ld a, $5e
471
ld c, 8
472
.loop
473
ld [hli], a
474
dec c
475
jr nz, .loop
476
477
; draw gameboy pic
478
hlcoord 5, 3
479
ld b, TILEMAP_GAME_BOY
480
call CopyTileIDsFromList_ZeroBaseTileID
481
482
; draw text box with player name below gameboy pic
483
hlcoord 4, 12
484
ld b, 2
485
ld c, 7
486
call TextBoxBorder
487
hlcoord 5, 14
488
ld de, wPlayerName
489
call PlaceString
490
491
jp DelayFrame
492
493
Trade_DrawRightGameboy:
494
call Trade_ClearTileMap
495
496
; draw horizontal segment of link cable
497
hlcoord 0, 4
498
ld a, $5e
499
ld c, $e
500
.loop
501
ld [hli], a
502
dec c
503
jr nz, .loop
504
505
; draw vertical segment of link cable
506
ld a, $5f
507
ld [hl], a
508
ld de, SCREEN_WIDTH
509
add hl, de
510
ld a, $61
511
ld [hl], a
512
add hl, de
513
ld [hl], a
514
add hl, de
515
ld [hl], a
516
add hl, de
517
ld [hl], a
518
add hl, de
519
ld a, $60
520
ld [hld], a
521
ld a, $5d
522
ld [hl], a
523
524
; draw gameboy pic
525
hlcoord 7, 8
526
ld b, TILEMAP_GAME_BOY
527
call CopyTileIDsFromList_ZeroBaseTileID
528
529
; draw text box with enemy name above link cable
530
hlcoord 6, 0
531
ld b, 2
532
ld c, 7
533
call TextBoxBorder
534
hlcoord 7, 2
535
ld de, wLinkEnemyTrainerName
536
call PlaceString
537
538
jp DelayFrame
539
540
Trade_DrawCableAcrossScreen:
541
; Draws the link cable across the screen.
542
call Trade_ClearTileMap
543
hlcoord 0, 4
544
ld a, $5e
545
ld c, SCREEN_WIDTH
546
.loop
547
ld [hli], a
548
dec c
549
jr nz, .loop
550
ret
551
552
Trade_CopyCableTilesOffScreen:
553
; This is used to copy the link cable tiles off screen so that the cable
554
; continues when the screen is scrolled.
555
push hl
556
hlcoord 0, 4
557
call CopyToRedrawRowOrColumnSrcTiles
558
pop hl
559
ld a, h
560
ldh [hRedrawRowOrColumnDest + 1], a
561
ld a, l
562
ldh [hRedrawRowOrColumnDest], a
563
ld a, REDRAW_ROW
564
ldh [hRedrawRowOrColumnMode], a
565
ld c, 10
566
jp DelayFrames
567
568
Trade_AnimMonMoveHorizontal:
569
; Animates the mon going through the link cable horizontally over a distance of
570
; b 16-pixel units.
571
ld a, [wTradedMonMovingRight]
572
ld e, a
573
ld d, $8
574
.scrollLoop
575
ld a, e
576
dec a
577
jr z, .movingRight
578
; moving left
579
ldh a, [hSCX]
580
sub $2
581
jr .next
582
.movingRight
583
ldh a, [hSCX]
584
add $2
585
.next
586
ldh [hSCX], a
587
call DelayFrame
588
dec d
589
jr nz, .scrollLoop
590
call Trade_AnimCircledMon
591
dec b
592
jr nz, Trade_AnimMonMoveHorizontal
593
ret
594
595
Trade_AnimCircledMon:
596
; Cycles between the two animation frames of the mon party sprite, cycles
597
; between a circle and an oval around the mon sprite, and makes the cable flash.
598
push de
599
push bc
600
push hl
601
ldh a, [rBGP]
602
xor $3c ; make link cable flash
603
ldh [rBGP], a
604
ld hl, wShadowOAMSprite00TileID
605
ld de, $4
606
ld c, $14
607
.loop
608
ld a, [hl]
609
xor ICONOFFSET
610
ld [hl], a
611
add hl, de
612
dec c
613
jr nz, .loop
614
pop hl
615
pop bc
616
pop de
617
ret
618
619
Trade_WriteCircledMonOAM:
620
farcall WriteMonPartySpriteOAMBySpecies
621
call Trade_WriteCircleOAMBlock
622
623
Trade_AddOffsetsToOAMCoords:
624
ld hl, wShadowOAM
625
ld c, $14
626
.loop
627
ld a, [wBaseCoordY]
628
add [hl]
629
ld [hli], a
630
ld a, [wBaseCoordX]
631
add [hl]
632
ld [hli], a
633
inc hl
634
inc hl
635
dec c
636
jr nz, .loop
637
ret
638
639
Trade_AnimMonMoveVertical:
640
; Animates the mon going through the link cable vertically as well as
641
; horizontally for a bit. The last bit of horizontal movement (when moving
642
; right) or the first bit of horizontal movement (when moving left) are done
643
; here instead of Trade_AnimMonMoveHorizontal because this function moves the
644
; sprite itself rather than scrolling the screen around the sprite. Moving the
645
; sprite itself is necessary because the vertical segment of the link cable is
646
; to the right of the screen position that the mon sprite has when
647
; Trade_AnimMonMoveHorizontal is executing.
648
ld a, [wTradedMonMovingRight]
649
and a
650
jr z, .movingLeft
651
; moving right
652
lb bc, 4, 0 ; move right
653
call .doAnim
654
lb bc, 0, 10 ; move down
655
jr .doAnim
656
.movingLeft
657
lb bc, 0, -10 ; move up
658
call .doAnim
659
lb bc, -4, 0 ; move left
660
.doAnim
661
ld a, b
662
ld [wBaseCoordX], a
663
ld a, c
664
ld [wBaseCoordY], a
665
ld d, $4
666
.loop
667
call Trade_AddOffsetsToOAMCoords
668
call Trade_AnimCircledMon
669
ld c, 8
670
call DelayFrames
671
dec d
672
jr nz, .loop
673
ret
674
675
Trade_WriteCircleOAMBlock:
676
; Writes the OAM blocks for the circle around the traded mon as it passes
677
; the link cable.
678
ld hl, Trade_CircleOAMBlocks
679
ld c, 4
680
xor a
681
.loop
682
push bc
683
ld e, [hl]
684
inc hl
685
ld d, [hl]
686
inc hl
687
ld c, [hl]
688
inc hl
689
ld b, [hl]
690
inc hl
691
push hl
692
inc a
693
push af
694
call WriteOAMBlock
695
pop af
696
pop hl
697
pop bc
698
dec c
699
jr nz, .loop
700
ret
701
702
MACRO trade_circle_oam_block
703
; oam block pointer, upper-left x coord, upper-left y coord
704
dw \1
705
db \2, \3
706
ENDM
707
708
Trade_CircleOAMBlocks:
709
trade_circle_oam_block .OAMBlock0, 8, 8
710
trade_circle_oam_block .OAMBlock1, 24, 8
711
trade_circle_oam_block .OAMBlock2, 8, 24
712
trade_circle_oam_block .OAMBlock3, 24, 24
713
714
.OAMBlock0:
715
db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1
716
db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1
717
db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1
718
db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1
719
720
.OAMBlock1:
721
db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 | OAM_XFLIP
722
db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 | OAM_XFLIP
723
db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 | OAM_XFLIP
724
db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 | OAM_XFLIP
725
726
.OAMBlock2:
727
db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 | OAM_YFLIP
728
db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 | OAM_YFLIP
729
db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 | OAM_YFLIP
730
db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 | OAM_YFLIP
731
732
.OAMBlock3:
733
db ICON_TRADEBUBBLE << 2 + 3, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP
734
db ICON_TRADEBUBBLE << 2 + 2, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP
735
db ICON_TRADEBUBBLE << 2 + 1, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP
736
db ICON_TRADEBUBBLE << 2 + 0, OAM_PAL1 | OAM_XFLIP | OAM_YFLIP
737
738
; a = species
739
Trade_LoadMonSprite:
740
ld [wCurPartySpecies], a
741
ld [wCurSpecies], a
742
ld [wWholeScreenPaletteMonSpecies], a
743
ld b, SET_PAL_POKEMON_WHOLE_SCREEN
744
ld c, 0
745
call RunPaletteCommand
746
ldh a, [hAutoBGTransferEnabled]
747
xor $1
748
ldh [hAutoBGTransferEnabled], a
749
call GetMonHeader
750
hlcoord 7, 2
751
call LoadFlippedFrontSpriteByMonIndex
752
ld c, 10
753
jp DelayFrames
754
755
Trade_ShowClearedWindow:
756
; clears the window and covers the BG entirely with the window
757
ld a, $1
758
ldh [hAutoBGTransferEnabled], a
759
call ClearScreen
760
ld a, LCDC_DEFAULT
761
ldh [rLCDC], a
762
ld a, $7
763
ldh [rWX], a
764
xor a
765
ldh [hWY], a
766
ld a, $90
767
ldh [hSCX], a
768
ret
769
770
Trade_SlideTextBoxOffScreen:
771
; Slides the window right until it's off screen. The window usually just has
772
; a text box at the bottom when this is called. However, when this is called
773
; after Trade_ShowEnemyMon in the external clock sequence, there is a mon pic
774
; above the text box and it is also scrolled off the screen.
775
ld c, 50
776
call DelayFrames
777
.loop
778
call DelayFrame
779
ldh a, [rWX]
780
inc a
781
inc a
782
ldh [rWX], a
783
cp $a1
784
jr nz, .loop
785
call Trade_ClearTileMap
786
ld c, 10
787
call DelayFrames
788
ld a, $7
789
ldh [rWX], a
790
ret
791
792
PrintTradeWentToText:
793
ld hl, TradeWentToText
794
call PrintText
795
ld c, 200
796
call DelayFrames
797
jp Trade_SlideTextBoxOffScreen
798
799
TradeWentToText:
800
text_far _TradeWentToText
801
text_end
802
803
PrintTradeForSendsText:
804
ld hl, TradeForText
805
call PrintText
806
call Trade_Delay80
807
ld hl, TradeSendsText
808
call PrintText
809
jp Trade_Delay80
810
811
TradeForText:
812
text_far _TradeForText
813
text_end
814
815
TradeSendsText:
816
text_far _TradeSendsText
817
text_end
818
819
PrintTradeFarewellText:
820
ld hl, TradeWavesFarewellText
821
call PrintText
822
call Trade_Delay80
823
ld hl, TradeTransferredText
824
call PrintText
825
call Trade_Delay80
826
jp Trade_SlideTextBoxOffScreen
827
828
TradeWavesFarewellText:
829
text_far _TradeWavesFarewellText
830
text_end
831
832
TradeTransferredText:
833
text_far _TradeTransferredText
834
text_end
835
836
PrintTradeTakeCareText:
837
ld hl, TradeTakeCareText
838
call PrintText
839
jp Trade_Delay80
840
841
TradeTakeCareText:
842
text_far _TradeTakeCareText
843
text_end
844
845
PrintTradeWillTradeText:
846
ld hl, TradeWillTradeText
847
call PrintText
848
call Trade_Delay80
849
ld hl, TradeforText
850
call PrintText
851
jp Trade_Delay80
852
853
TradeWillTradeText:
854
text_far _TradeWillTradeText
855
text_end
856
857
TradeforText:
858
text_far _TradeforText
859
text_end
860
861
Trade_ShowAnimation:
862
ld [wAnimationID], a
863
xor a
864
ld [wAnimationType], a
865
predef_jump MoveAnimation
866
867