Adding New Battle Transitions
This demonstration won't show you how to create a whole new custom fancy transition animation - I'm not smart enough for that - but it should hopefully be helpful to you in some way if you've never looked at this stuff before, even if just to show how they're set up and structured. Think of this post as an easy beginner's guide as opposed to a complete compendium.
We're simply going to add a new transition that has the same animation style as Team Aqua/Magma - basically creating another version of it as though it was a battle transition for another trainer class. Maybe you want five evil teams instead of two or want a special transition for a particular character, etc!
Please note that Pokéemerald labels are always subject to change; I'll do my best to keep this post up to date (I wrote this ages ago and forgot to post it until now, oops). I've colour coded some labels to help show how sections are related to one another, so try to pay attention to those. As well as trying to describe where to put things I've also mentioned which line number I'm adding code to, but remember that due to Pokéemerald being updated so often, it might be slightly different for you.
-----------------------------------------------------------------------------------------------------------------------------------------------------
Alright, first things first: you will need a tilemap (.bin), palette (.pal) and tileset (.png) for your new transition. I've named all of mine "
example_transition". These files go in the "
pokeemerald\graphics\battle_transitions" folder.
Once you've got your files in the correct location, open "
pokeemerald\include\battle_transition.h" and add an entry for your new transition
before "
B_TRANSITION_COUNT". (line 70)
Code:
...
#define B_TRANSITION_41 41
#define B_TRANSITION_EXAMPLE 42
#define B_TRANSITION_COUNT 43
#endif // GUARD_BATTLE_TRANSITION_H
The bottom of the file should then look something like the above. Remember to fix the numbers appropriately! Obviously since this is just a demonstration, I've named mine "
B_TRANSITION_EXAMPLE".
You're finished with "
battle_transition.h" now, so you can close it if you want.
-----------------------------------------------------------------------------------------------------------------------------------------------------
Next, open "
pokeemerald\src\battle_transition.c". It's a pretty big file, but don't worry, there are a lot of annotations - look for
//const rom data and add a few lines to the end of this section. (starting at line 317)
Code:
static const u32 [COLOR="Magenta"]sExampleTransition_Palette[/COLOR][] = INCBIN_U32("graphics/battle_transitions/example_transition.gbapal");
static const u32 [COLOR="Magenta"]sExampleTransition_Tileset[/COLOR][] = INCBIN_U32("graphics/battle_transitions/example_transition.4bpp.lz");
static const u32 [COLOR="Magenta"]sExampleTransition_Tilemap[/COLOR][] = INCBIN_U32("graphics/battle_transitions/example_transition.bin.lz");
On the left side of the "=" we have our label and on the right we have the file's location. Simple enough, right?
You'll want to follow the above example using your own labels and file names.
-----------------------------------------------------------------------------------------------------------------------------------------------------
Now that you're done with that, we're going to define our functions. Look for
//this file's functions (or just Ctrl+F if you get lost scrolling). You will want to add lines to the end of that list. (starting at line 262)
Code:
[COLOR="darkorange"]static void Phase2Task_ExampleTransition[/COLOR](u8 taskId);
static bool8 [COLOR="mediumturquoise"]Phase2_ExampleTransition_Func1[/COLOR](struct Task *task);
static bool8 [COLOR="mediumturquoise"]Phase2_ExampleTransition_Func2[/COLOR](struct Task *task);
The lines you add should look like this but with your own labels, of course. If you search for "TaskFunc sPhase2_Tasks" you should come across a list with commented corresponding numbers. Scroll to the bottom of this list and add an entry for the orange label shown above. (line 371)
Code:
...
Phase2Task_40, [COLOR="SeaGreen"]// 40[/COLOR]
Phase2Task_41, [COLOR="SeaGreen"]// 41[/COLOR]
[COLOR="DarkOrange"]Phase2Task_ExampleTransition[/COLOR], [COLOR="SeaGreen"]// 42[/COLOR]
};
This happens to have the same corresponding number as it does in "
battle_transition.h". Searching for "Phase2Task_BigPokeball" will bring you to a bunch of functions that look similar to what we've got below - simply copy it and replace the label with your own. (line 1268)
Code:
static void [COLOR="DarkOrange"]Phase2Task_ExampleTransition[/COLOR](u8 taskId)
{
while ([COLOR="Red"]sPhase2_ExampleTransition_Funcs[/COLOR][gTasks[taskId].tState](&gTasks[taskId]));
}
You'll notice that we have a new label here - "
sPhase2_ExampleTransition_Funcs".
-----------------------------------------------------------------------------------------------------------------------------------------------------
Search "TransitionStateFunc sPhase2_Magma_Funcs" to find this snippet here:
Code:
static const TransitionStateFunc sPhase2_Magma_Funcs[] =
{
Phase2_Magma_Func1,
Phase2_Magma_Func2,
Phase2_BigPokeball_Func3,
Phase2_BigPokeball_Func4,
Phase2_BigPokeball_Func5,
Phase2_FramesCountdown,
Phase2_BigPokeball_Func6
};
If you've looked at the code you'll notice that the battle transitions for Team Magma and Aqua use almost exactly the same functions as the big Pokéball transition aside from the first two. As this demo is for making a simple trainer class style transition, just copy & paste that and replace the first two labels with your own. (line 424) For instance, I now have:
Code:
static const TransitionStateFunc [COLOR="Red"]sPhase2_ExampleTransition_Funcs[/COLOR][] =
{
[COLOR="mediumturquoise"]Phase2_ExampleTransition_Func1[/COLOR],
[COLOR="MediumTurquoise"]Phase2_ExampleTransition_Func2[/COLOR],
Phase2_BigPokeball_Func3,
Phase2_BigPokeball_Func4,
Phase2_BigPokeball_Func5,
Phase2_FramesCountdown,
Phase2_BigPokeball_Func6
};
We're nearly done. Ctrl+F "Phase2_Magma_Func1" & "Phase2_Magma_Func2" and copypaste those as well, making the following changes:
Code:
static bool8 [COLOR="mediumturquoise"]Phase2_ExampleTransition_Func1[/COLOR](struct Task *task)
{
u16 *dst1, *dst2;
task->tFrames = 60;
sub_814669C(task);
sub_8149F58(&dst1, &dst2);
CpuFill16(0, dst1, 0x800);
LZ77UnCompVram([COLOR="Magenta"]sExampleTransition_Tileset[/COLOR], dst2);
LoadPalette([COLOR="Magenta"]sExampleTransition_Palette[/COLOR], 0xF0, 0x20);
task->tState++;
return FALSE;
}
The pink labels are for our tileset and tilemap - remember we added these back at the start?
Code:
static bool8 [COLOR="MediumTurquoise"]Phase2_ExampleTransition_Func2[/COLOR](struct Task *task)
{
u16 *dst1, *dst2;
sub_8149F58(&dst1, &dst2);
LZ77UnCompVram([COLOR="Magenta"]sExampleTransition_Tilemap[/COLOR], dst1);
sub_8149F98(gScanlineEffectRegBuffers[0], 0, task->tData4, 132, task->tData5, 160);
task->tState++;
return FALSE;
}
Again, the pink text is the tilemap's label. What's next? Save all that and now you are finished! You can assign your new battle transition to a trainer class in "
src\battle_setup.c". Just to demonstrate, I gave mine to the standard wild Pokémon battle. All that's left to do is test in-game and see how it looks.