summaryrefslogtreecommitdiff
path: root/Trainer-Backsprite-Editing.md
blob: 42489876f8e4b563da5590425302b2d6e67d070c (plain)
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
The backsprite frames for Brendan, May, Steven, Wally, RS-Brendan, and RS-May use the same palette as their front trainer sprite.
Plus they uses 4 frames instead of 5. This tutorial will instruct you how to delink the palette sharing and make the backsprites use 5 frames.

Note :
* I personally opt to delink the palette sharing and edit all of the backsprites so they'll have 5 frames.
Should you specifically only want to edit player backsprites, then focus only on Brendan and May part of this tutorial.
* Albeit can be edited, for easy references. 4 frames animation uses 4th frame as the beginning of the animation. And goes from 4th > 1st > 2nd > 3rd.
* While 5 frames animation uses the 1st frame as the beginning of the animation and goes from 1st > 2nd > 3rd > 4th > 5th

### Allow Backsprite Frames to Use Different Palettes.
Prepare your backsprites frames, indexed in 16 colors in a preferable name format like `brendan_back_pic.png` for Male Player backsprite and `may_back_pic.png` for Female Player backsprite. `steven_back_pic.png`, so on and so forth. Then move all of them to **`graphics/trainers/back_pics`**.
While you're there, delete the `.4bpp` files as well.

Then export the palette of your indexed backsprites into a `.pal` format, preferable name it something like `brendan_back_pic.pal` for Male Player backsprite and `may_back_pic.pal` for Female Player backsprite. `steven_back_pic.pal`, so on and so forth. Then move all of them to **`graphics/trainers/palettes`**`.

Then go to **`include/graphics.h`**, Search for `extern const u32 gTrainerBackPicPalette_Leaf[];` add these code below it.
```c
extern const u32 gTrainerBackPicPalette_Brendan[];
extern const u32 gTrainerBackPicPalette_May[];
extern const u32 gTrainerBackPicPalette_Steven[];
extern const u32 gTrainerBackPicPalette_Wally[];
extern const u32 gTrainerBackPicPalette_RubySapphireBrendan[];
extern const u32 gTrainerBackPicPalette_RubySapphireMay[];
```

Then go to **`src/data/graphics/trainers.h`** Head to the bottom and you should see `gTrainerBackPicPalette_Leaf[]`, Add these code below it.
```c
const u32 gTrainerBackPicPalette_Brendan[] = INCBIN_U32("graphics/trainers/palettes/brendan_back_pic.gbapal.lz");
const u32 gTrainerBackPicPalette_May[] = INCBIN_U32("graphics/trainers/palettes/may_back_pic.gbapal.lz");
const u32 gTrainerBackPicPalette_Steven[] = INCBIN_U32("graphics/trainers/palettes/steven_back_pic.gbapal.lz");
const u32 gTrainerBackPicPalette_Wally[] = INCBIN_U32("graphics/trainers/palettes/wally_back_pic.gbapal.lz");
const u32 gTrainerBackPicPalette_RubySapphireBrendan[] = INCBIN_U32("graphics/trainers/palettes/ruby_sapphire_brendan_back_pic.gbapal.lz");
const u32 gTrainerBackPicPalette_RubySapphireMay[] = INCBIN_U32("graphics/trainers/palettes/ruby_sapphire_may_back_pic.gbapal.lz");
```

Then go to **`src/data/trainer_graphics/back_pic_tables.h`**, jump into the bottom and replace all of the code with :
```c
    TRAINER_BACK_PAL(BRENDAN, gTrainerBackPicPalette_Brendan),
    TRAINER_BACK_PAL(MAY, gTrainerBackPicPalette_May),
    TRAINER_BACK_PAL(RED, gTrainerBackPicPalette_Red),
    TRAINER_BACK_PAL(LEAF, gTrainerBackPicPalette_Leaf),
    TRAINER_BACK_PAL(RUBY_SAPPHIRE_BRENDAN, gTrainerBackPicPalette_RubySapphireBrendan),
    TRAINER_BACK_PAL(RUBY_SAPPHIRE_MAY, gTrainerBackPicPalette_RubySapphireMay),
    TRAINER_BACK_PAL(WALLY, gTrainerBackPicPalette_Wally),
    TRAINER_BACK_PAL(STEVEN, gTrainerBackPicPalette_Steven),
```

At this point, you have delinked the palette sharing between the backsprite frames and front trainer sprite.

### Allow Backsprites to Animate in 5 Frames.
Still in the **`src/data/trainer_graphics/back_pic_tables.h`**, you should see `gTrainerBackPicCoords`. Replace all of them with :
```c
    [TRAINER_BACK_PIC_BRENDAN] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_MAY] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_RED] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_LEAF] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_WALLY] = {.size = 8, .y_offset = 5},
    [TRAINER_BACK_PIC_STEVEN] = {.size = 8, .y_offset = 5},
```

Then head to **`src/data/trainer_graphics/back_pic_anims.h`**, and you should see how the frames are animated.
For simple editing, delete all of the code of this file and replace everything with the code below :
```c
static const union AnimCmd gAnimCmd_Brendan_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd gAnimCmd_May_Steven_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd gAnimCmd_Wally_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd gAnimCmd_Red_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd gAnimCmd_Leaf_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd gAnimCmd_RubySapphireBrendan_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd gAnimCmd_RubySapphireMay_1[] =
{
    ANIMCMD_FRAME(1, 20),
    ANIMCMD_FRAME(2, 6),
    ANIMCMD_FRAME(3, 6),
    ANIMCMD_FRAME(4, 24),
    ANIMCMD_FRAME(0, 1),
    ANIMCMD_END,
};

static const union AnimCmd *const sBackAnims_Brendan[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_Brendan_1,
};

static const union AnimCmd *const sBackAnims_May[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_May_Steven_1,
};

static const union AnimCmd *const sBackAnims_Red[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_Red_1,
};

static const union AnimCmd *const sBackAnims_Leaf[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_Leaf_1,
};

static const union AnimCmd *const sBackAnims_RubySapphireBrendan[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_RubySapphireBrendan_1,
};

static const union AnimCmd *const sBackAnims_RubySapphireMay[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_RubySapphireMay_1,
};

static const union AnimCmd *const sBackAnims_Wally[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_Wally_1,
};

static const union AnimCmd *const sBackAnims_Steven[] =
{
    sAnim_GeneralFrame0,
    gAnimCmd_May_Steven_1,
};

const union AnimCmd *const *const gTrainerBackAnimsPtrTable[] =
{
    [TRAINER_BACK_PIC_BRENDAN] = sBackAnims_Brendan,
    [TRAINER_BACK_PIC_MAY] = sBackAnims_May,
    [TRAINER_BACK_PIC_RED] = sBackAnims_Red,
    [TRAINER_BACK_PIC_LEAF] = sBackAnims_Leaf,
    [TRAINER_BACK_PIC_RUBY_SAPPHIRE_BRENDAN] = sBackAnims_RubySapphireBrendan,
    [TRAINER_BACK_PIC_RUBY_SAPPHIRE_MAY] = sBackAnims_RubySapphireMay,
    [TRAINER_BACK_PIC_WALLY] = sBackAnims_Wally,
    [TRAINER_BACK_PIC_STEVEN] = sBackAnims_Steven,
};
```

Then head to **`src/data.c`**, search for `gTrainerBackPicTable_Brendan`. You should see the backsprite data for Brendan, May, Steven, etc.
Simply add `gTrainerBackPic_X + 0x2000, 0x0800,` in the 5th line, don't forget to replace the *X* to match the code above , for example : 
```c
const struct SpriteFrameImage gTrainerBackPicTable_Brendan[] =
{
    gTrainerBackPic_Brendan, 0x0800,
    gTrainerBackPic_Brendan + 0x0800, 0x0800,
    gTrainerBackPic_Brendan + 0x1000, 0x0800,
    gTrainerBackPic_Brendan + 0x1800, 0x0800,
    gTrainerBackPic_Brendan + 0x2000, 0x0800, //5th
};

const struct SpriteFrameImage gTrainerBackPicTable_May[] =
{
    gTrainerBackPic_May, 0x0800,
    gTrainerBackPic_May + 0x0800, 0x0800,
    gTrainerBackPic_May + 0x1000, 0x0800,
    gTrainerBackPic_May + 0x1800, 0x0800,
    gTrainerBackPic_May + 0x2000, 0x0800, //5th
};

So on and so forth
```

At this point, you have successfully animate your backsprites.