• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Forum moderator applications are now open! Click here for details.
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

Development: Creating New Battle Animations

1,323
Posts
16
Years
  • Seen Dec 9, 2023
So I've managed to figure out enough to make decent custom battle animations. So far, I've managed to splice multiple animations together, and to add backgrounds to an animation action.


From what I've figured out so far, there are at least two types of actions:
1) a background
2) a movement of a graphic (requires loading correct graphics)

Note: Everything in this document/tutorial is designed with FireRed in mind. There are pointers within the animation scripts, meaning that unfortunately, these have to be ROM-specific. These will work with FireRed, and only FireRed.

Here's what I've got of the scripting language so far: (credits at bottom of post for people who found these)
------------------------------------------------------------------
00 XX 27 = loads image data, XX is an argument
00 XX 28 = same thing as above, but loads from a different bank of graphics

02 = executes current animation segment
05 = waits for current animation segment to finish
06 = does absolutely nothing
07 = does absolutely nothing
08 = ends the animation script (DO NOT CONFUSE WITH POINTER!!!)

0E XX XX XX 08 = jumps to another animation, continues execution of original script when finished (can be used to combine multiple animations to play right after another)
11 XX XX XX 08 = same as above, haven't figured out the difference yet

19 XX XX = plays a sound

Display a non-scrolling, static background: (note: if you change 17 to 16, then transparency effects will be deactivated)
Code:
14 [B]WW[/B] 17

Display a scrolling background: (note: if you change 17 to 16, then transparency effects will be deactivated)
Code:
14 [B]WW[/B] 17 03 2D B8 0B 08 05 04 00 [B]XX[/B] 00 [B]YY ZZ[/B] 00 FF FF
-WW = selects which background graphics to display

Choose one of these for the WW byte:
Spoiler:

-XX = how fast background scrolls horizontally
-YY = how fast background scrolls vertically
-ZZ = not sure but its either 00 or 01

Here is what each background looks like:
Spoiler:


Judging by unLZ, these backgrounds are simply tilesets+tilemaps. If we could find the table(s), we could theoretically expand them and have custom backgrounds.

To display the Psychic-background correctly, do not use the scrolling background command, instead use the 0E command, using it like this:
Code:
0E BB 59 1D 08
This will display the Psychic-type BG, while also animating it correctly.

To end any scrolling background (also works with the Psychic-BG animation):
Code:
0E C7 59 1D 08
Usually this is placed at the end of the script. If you're going to place it at the end of the script, make sure you add an extra 08 byte to the end of it, otherwise the game will freeze.

The table for the battle backgrounds starts at 0x3ADE18, and ends at 0x3ADF5B. The format goes like:
[XX XX XX 08] [YY YY YY 08] [ZZ ZZ ZZ 08] XX = pointer to graphics, YY = pointer to palette, ZZ = pointer to tilemap
Repoint and extend it, and you can create custom backgrounds:
2zy8qwi.png


Some other info (remember, these are FireRed offsets):
0x247094 = Attack names
0x250C04 = Attack data
0x4886E8 = Attack description pointers
0x1D65A8 = Battle script pointers
0x1C68F4 = Attack Animation pointers

To find the offset of an animation, follow these instructions:
Spoiler:

Eventually I will post a list of all the animation offsets, I haven't finished typing them all out yet.

Step-by-step example at creating a custom animation:
Example 1: Adding a background to an existing animation
Spoiler:


Example 2: Merging two animations to play right after another
Spoiler:


Some info on the 02 command (thanks to DoesntKnowHowToPlay):
The first two bytes indicate what image data to use, while the next two bytes indicate the palette. The enumeration for this is the same as that of the 00 command- in order for an effect to work properly, the 00 command must have been called for both of these- otherwise the palette and/or image will not be loaded. While the existing animations appear to always have these be the same, they don't have to be- you can for instance give the Stun Spore seeds Fire Blast's palette this way. For some animations both of these are 00- I believe these are effects that don't use images, such as Earthquake's screen-shaking.

Doing colored backgrounds:
02 24 7B 3E 08 02 05 01 00 SS 00 00 00 YY 00 XX XX 05

Where XX XX is the color you want, YY is the intensity (0C for Giga Drain- 10 replaces the background entirely with the given color), and SS is the speed of the transition (01 for Giga Drain, but I imagine Hyper Beam and other attacks use the same logic with a higher value). To revert the background to normal, place the following:

02 24 7B 3E 08 02 05 01 00 SS 00 YY 00 00 00 XX XX 05 0B 03 0D

The values here do not have to be the same, but I'd advise making the color and intensity the same or it will abruptly change at the start of the transition back.

Getting the background to change depending on what side you're on:
21 07 XX 00 YY YY YY YY branches to YY YY YY YY if the side the attacker is on matches XX. Mega Punch's custom background operates by placing two of these in a row (with XX = 00 and 01) to branch to subroutines that set the background to the correct one and then return.

0F appears to return to where the initial script left off after a branch.

Credits:
-Jambo51 for explaining how to add new attacks, and the offset of several tables, which helped me test animations
-DoestKnowHowToPlay for already documenting some of the commands
-Darthatron for finding the table containing all the animation command routines, hopefully these can be used to find out what each command does


EDIT: Some useful information found by Doesn'tKnowHowToPlay and dreamengine:
http://www.pokecommunity.com/showpost.php?p=7481054&postcount=32
http://www.pokecommunity.com/showpost.php?p=7485231&postcount=37
http://www.pokecommunity.com/showpost.php?p=7485560&postcount=38
 
Last edited:

Gamer2020

Accept no Imitations!
1,062
Posts
15
Years
I added animation repointing to the attack editor in PGE weeks ago but just haven't released the update. There is no need for such complex instructions on repointing :P
 

Full Metal

C(++) Developer.
810
Posts
16
Years
Congrats on working things out! (:
Hopefully somebody with more talent than me will figure out the last two abilities. o:
 
1,323
Posts
16
Years
  • Seen Dec 9, 2023
I added animation repointing to the attack editor in PGE weeks ago but just haven't released the update. There is no need for such complex instructions on repointing :P
Haha, but because you haven't released it yet, I didn't exactly have a choice. It's the only way I can find the animation offsets, as I have no knowledge of tool making. But I'm glad you're still improving PGE.

Congrats on working things out! (:
Hopefully somebody with more talent than me will figure out the last two abilities. o:
From what I know, particle movement is controlled by the 0E XX XX XX 08 command, so its simply a matter of loading correct graphics and correct movement to match. But I don't even know where to start for custom particle movement :/


I also apologize for the poor quality of the second attack example, I will fix it soon. Also I realized that you can use either the 11 command or the 0E command, and place a pointer right after it to any existing attack animation, allowing you to sequentially do attacks. For instance, if you take the animation data of Tackle, remove the 08 byte at the end of it, then place 0E XX XX XX 08, and say we place the pointer to Earthquake's animation in the XX spots, then Tackle's animation will play the Earthquake animation right after it. This saves a lot of space, since it means you don't have to manually place Earthquake's animation data, it just means you can use the 0E or 11 command and point directly to it.
 
1,323
Posts
16
Years
  • Seen Dec 9, 2023
I'm pretty sure I just found the table containing the Battle BG's at: 0x3ADE18.

The format goes like:
[XX XX XX 08] [YY YY YY 08] [ZZ ZZ ZZ 08]
XX = pointer to graphics
YY = pointer to palette
ZZ = pointer to tilemap

I haven't tried expanding it, but I will tomorrow (or whenever). This means we can use custom backgrounds, that's actually pretty big.
 

Darthatron

巨大なトロール。
1,152
Posts
18
Years
The routines for each of the "commands" for these animations are located in a table at 0x083ADF5C in the ROM. From this, I can say for sure that there are 0x30 commands (0x00-0x2F) and that commands 0x6 and 0x7 do nothing.

With this we can at least see how many parameters each command has.

EDIT1: I here-by name command 0x6 "nop" and command 0x7 "darthnop".

EDIT2:

Code:
00:
01:
02:
03: something <word> <byte> <byte2> (<hword> * byte2) 
04:
05: waitstate
06: nop
07: nop2
08:
09: playsound <hword ID>
0A:
0B:
0C:
0D:
0F:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
1A:
1B:
1C:
1D:
1E:
1F:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
2A:
2B:
2C:
2D:
2E:
2F:

Edit3: I think when Gamefreak coded this, they set the compiler to "annoy hackers" mode.
 
Last edited:
94
Posts
13
Years
  • Seen Nov 2, 2016
There's probably couple of tables for these image data. Most likely one for backgrounds, and one for "particles". If we can find these we'll be able to expand them and put our own tilemaps and images in...

As far as manipulating them, that'd take some assembly work, unless we could find values like how far data moves across the screen, how many times, etc. That way we could reuse the animation, but with slight alterations.

Edit:
I've found the table of the "particles" / image data. Darth helped me find with researching a bit.
It's at 0x083ACC08, and is arranged in 8 byte entries, like so:
4: word - pointer to image data
2: hword - something to do with size?
2: hword - index number

For example, the first entry...
0x080D02520 - pointer to the bone image, used in bone rush
0x0002 - hword that may have something to do with size? not sure needs more research
0x2710 - hword thats the index number, when calculating, 0x2710 is subtracted from it, no idea why, but 0x2710 is the first one

083AD510 - seems to have the palette entries that each image uses:
4: [pointer to palette]
2: [index number in same format as above]
2: [unknown]
 
Last edited:
1,323
Posts
16
Years
  • Seen Dec 9, 2023
I can now confirm that it is possible to create custom battle backgrounds by expanding the battle background table:
4trcow.png


2zy8qwi.png

This custom battle background takes up slot 0x1B (which does not exist in the original FireRed rom)

The table starts at 0x3ADE18, and ends at 0x3ADF5B. There's another table right after it, which I mistook as part of the same table, so just remember that it ends at 0x3ADF5B, even though it looks like it doesn't.

I inserted my tileset, palette, and tilemap all with unLZ (I made the tilemap with NTME). Simply insert into free space, then manually point to the offsets you used in your new table with a hex editor.


For anyone that wants to experiment, here is my tileset and tilemap (the palette is included within the tileset because it's indexed). To test it, insert these with unLZ, keep track of the offsets you inserted the tileset, palette, and tilemap, then repoint and expand the table (make sure you don't mistake the table right after it as part of the original table!!! just look at the start and end offsets I gave earlier in this post), then have the new entries in the table point to your tileset, palette, and tilemap, then make a custom battle animation (or edit an existing one) and use the background slot 0x1B. And yes, I designed the graphics so that it can scroll horizontally.
 
Last edited:

Jambo51

Glory To Arstotzka
736
Posts
14
Years
  • Seen Jan 28, 2018
Ruby Version Please. I make Hack with Ruby Not Fire Red

He's not making it specifically for you. Besides, do you know how much work it would take for him to redo all of it for Ruby?

Actually, because it's a scripting language, it may well work for Ruby (and Emerald) without any modifications, apart from ROM pointers.
 

ShadowTails

I'm working on a better Avatar
638
Posts
18
Years
  • Age 32
  • Seen Mar 7, 2015
Am I on to something here?
http://www.youtube.com/watch?v=bRguM5EI09o
I basically just copied and pasted Super Fang over Slash without changing any pointers to see if I had actually found the animation data.

Yeah, embed isn't working...

I'll see if I can play around more with this later and repoint the data. Slash is at 2CD3DB. (or atleast, the data I was playing around with, attempting to copy Substitute over Slash made the game crash, so I just tried the one before it and it worked other than not loading the correct graphics, which obviously it wouldn't since I didn't change any pointers)
 

timson733333

Woah.
135
Posts
16
Years
I compared Slash's code from FireRed with Slash's code from Emerald, and this is what I got:

FireRed:

Code:
00 C7 27 02 A4 35 3E 08 82 03 01 00 F8 FF 00 00 19 81 00 3F 04 04 02 A4 35 3E 08 82 03 01 00 08 00 00 00 03 1D 8B 09 08 02 05 01 00 04 00 00 00 12 00 01 00 19 81 00 3F 05 08

Emerald:

Code:
00 C7 27 02 2C 2D 59 08 82 03 01 00 F8 FF 00 00 19 88 00 3F 04 04 02 2C 2D 59 08 82 03 01 00 08 00 00 00 03 D1 52 0D 08 02 05 01 00 04 00 00 00 12 00 01 00 19 88 00 3F 05 08

Since the codes are different, would using the scrolling animation code not work? Or would it have to be tweaked? Problem is, I don't know how to tweak it.
 
1,323
Posts
16
Years
  • Seen Dec 9, 2023
I compared Slash's code from FireRed with Slash's code from Emerald, and this is what I got:

FireRed:

Code:
00 C7 27 02 A4 35 3E 08 82 03 01 00 F8 FF 00 00 19 81 00 3F 04 04 02 A4 35 3E 08 82 03 01 00 08 00 00 00 03 1D 8B 09 08 02 05 01 00 04 00 00 00 12 00 01 00 19 81 00 3F 05 08

Emerald:

Code:
00 C7 27 02 2C 2D 59 08 82 03 01 00 F8 FF 00 00 19 88 00 3F 04 04 02 2C 2D 59 08 82 03 01 00 08 00 00 00 03 D1 52 0D 08 02 05 01 00 04 00 00 00 12 00 01 00 19 88 00 3F 05 08

Since the codes are different, would using the scrolling animation code not work? Or would it have to be tweaked? Problem is, I don't know how to tweak it.
The codes are exactly the same, except for the pointers. The scrolling animation code I had in the first post is for FireRed, so you would need to find the corresponding Emerald pointers and then replace it, then it should work.
 
Back
Top