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
|
This tutorial is for how to add a new battle transition, like the Poké Ball that covers the screen for a trainer battle. As an example, we'll add an "R" for battles with Team Rocket.
## Contents
1. [Add a new transition](#1-add-a-new-transition)
2. [Create a custom palette for that transition](#2-create-a-custom-palette-for-that-transition)
## 1. Add a new transition
First, edit [engine/battle/battle_transition.asm](../blob/master/engine/battle/battle_transition.asm):
```diff
StartTrainerBattle_LoadPokeBallGraphics:
...
call .loadpokeballgfx
...
.loadpokeballgfx
+ ld de, TeamRocketTransition
ld a, [wOtherTrainerClass]
+ cp GRUNTM
+ ret z
+ cp GRUNTF
+ ret z
+ cp EXECUTIVEM
+ ret z
+ cp EXECUTIVEF
+ ret z
+ cp SCIENTIST
+ ret z
ld de, PokeBallTransition
ret
PokeBallTransition:
; 16x16 overlay of a Poke Ball
pusho
opt b.X ; . = 0, X = 1
bigdw %......XXXX......
bigdw %....XXXXXXXX....
bigdw %..XXXX....XXXX..
bigdw %..XX........XX..
bigdw %.XX..........XX.
bigdw %.XX...XXXX...XX.
bigdw %XX...XX..XX...XX
bigdw %XXXXXX....XXXXXX
bigdw %XXXXXX....XXXXXX
bigdw %XX...XX..XX...XX
bigdw %.XX...XXXX...XX.
bigdw %.XX..........XX.
bigdw %..XX........XX..
bigdw %..XXXX....XXXX..
bigdw %....XXXXXXXX....
bigdw %......XXXX......
popo
+TeamRocketTransition:
+pusho
+opt b.X ; . = 0, X = 1
+ bigdw %XXXXXXXXXXXX....
+ bigdw %XXXXXXXXXXXXXX..
+ bigdw %XXXXXXXXXXXXXXX.
+ bigdw %XXXXXXXXXXXXXXX.
+ bigdw %XXXXX.....XXXXXX
+ bigdw %XXXXX......XXXXX
+ bigdw %XXXXX.....XXXXXX
+ bigdw %XXXXXXXXXXXXXXX.
+ bigdw %XXXXXXXXXXXXXXX.
+ bigdw %XXXXXXXXXXXXXX..
+ bigdw %XXXXXXXXXXXXX...
+ bigdw %XXXXX....XXXXX..
+ bigdw %XXXXX....XXXXX..
+ bigdw %XXXXX.....XXXXX.
+ bigdw %XXXXX......XXXXX
+ bigdw %XXXXX......XXXXX
+popo
```
Older versions of pokecrystal define the `PokeBallTransition` pattern with literal binary numbers:
```
PokeBallTransition:
db %00000011, %11000000
db %00001111, %11110000
db %00111100, %00111100
db %00110000, %00001100
db %01100000, %00000110
db %01100011, %11000110
db %11000110, %01100011
db %11111100, %00111111
db %11111100, %00111111
db %11000110, %01100011
db %01100011, %11000110
db %01100000, %00000110
db %00110000, %00001100
db %00111100, %00111100
db %00001111, %11110000
db %00000011, %11000000
```
Either way works, but the new method shows the 16x16 tile pattern more clearly.
Notice that `StartTrainerBattle_LoadPokeBallGraphics.loadpokeballgfx` already has the line `ld a, [wOtherTrainerClass]` but doesn't do anything with it. Maybe trainer-based patterns like this were a scrapped feature.
Anyway, that's all it takes to change the overlay pattern:

## 2. Create a custom palette for that transition
We can create a custom palette for any transition. Let's try creating a file called `rocket_battle.pal` in [gfx/overworld](../blob/master/gfx/overworld).
```
RGB 31, 08, 08
RGB 31, 07, 06
RGB 31, 02, 03
RGB 07, 07, 07
```
Next, edit [engine/battle/battle_transition.asm](../blob/master/engine/battle/battle_transition.asm) again:
```diff
.cgb
+ ld hl, .rocketpals
+ ld a, [wOtherTrainerClass]
+ cp GRUNTM
+ jr z, .load_rocket_pals
+ cp GRUNTF
+ jr z, .load_rocket_pals
+ cp EXECUTIVEM
+ jr z, .load_rocket_pals
+ cp EXECUTIVEF
+ jr z, .load_rocket_pals
+ cp SCIENTIST
+ jr z, .load_rocket_pals
ld hl, .pals
+.load_rocket_pals
ld a, [wTimeOfDayPal]
maskbits NUM_DAYTIMES
cp DARKNESS_F
jr nz, .not_dark
ld hl, .darkpals
.not_dark
...
.pals:
INCLUDE "gfx/overworld/trainer_battle.pal"
.darkpals:
INCLUDE "gfx/overworld/trainer_battle_dark.pal"
+.rocketpals:
+INCLUDE "gfx/overworld/rocket_battle.pal"
```
And that's it! Now the overlay colors for the pattern have been changed!

You can create more palettes to handle different trainer classes.
Changing the transition animations (the ones that fade, wipe, distort, or otherwise erase the screen to begin a battle) is more complicated.
TODO: new transition animation
|