• 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.

Inserting Battle Backgrounds

Lance32497

LanceKoijer of Pokemon_Addicts
792
Posts
9
Years
The Data Behind Battle Backgrounds


Now that DrFuji has taught you how to edit Battle Backgrounds, I am going to take you into the data aspect. For right now, this lesson will just be for FireRed. If you do want it for another game and you are actually going to use it, I will attempt to do my best to help you.

To start off with, apply the patch at the bottom of this post to your rom. What it does is move the battle BG table to 0xF10000 where we can work with and expand it, and it also hacks the BG loading routine with branches placed 0xF00000 (I will completely explain this later).

The Table

To be honest, the table is quite simple. To start off, it has 20 backgrounds already in it designated by Game Freak. They are as follows:

1. Grass
2. Grass2
3. Sand
4. Field
5. Pond Sea
6. Sea Pond
7. Craggy
8. Cave
9. Multi/Indoor- White & Grey & some Yellow in the Palette (Normal Trainer Battle)
10. Multi/Indoor- Green & a little Yellow (Rival Trainer Battle)
11. Multi/Indoor- White & Grey ()
12. Multi/Indoor- White & Grey & some Tan in the Palette ("Gym" Trainer Battles (that option in A-Map))
13. Multi/Indoor- White & Grey & some Tan in the Palette (2) ("Gym" Gym Leader battle (yes the Leaders have different BG))
14. Multi2/Indoor2- White & Grey
15. Multi2/Indoor2- White & Grey & some Purple in the Palette
16. Multi2/Indoor2- Blue & some Tan in the Palette
17. Multi2/Indoor2- Yellow & Tan
18. Multi2/Indoor2- Purple & some Tan in the Palette
19. Multi2/Indoor2- Turquoise & some Tan in the Palette
20. Multi2/Indoor2- White & Grey & some Purple in the Palette

For each background, there are 5 pointers in order with this format:


Code:
[CENTER]VV VV VV 08  WW WW WW 08  XX XX XX 08  YY YY YY 08  ZZ ZZ ZZ 08
 
VV = Image Offset
WW = TileMap Offset
XX = Entry Image 
(Ex. The Grass that moves in front of the screen at the beginning of a grass battle.)
YY = Entry Image Tilemap
ZZ = Palette[/CENTER]
Here is the documentation of each background and their pointers in the original table:

Spoiler:


So, expanding this is really quite simple. Just follow the setup of the table and add on to the end. Don't delete any of them if you are not going to replace them. This may sound obvious, but you never know what people will do:p.


So, I expanded it... Now what?

This is probably what you are thinking after completing the above. This is where the hack of the loading routine that comes in. What it does is allows you to very easily change the battle background to whatever you wish.

If you remember, all of the backgrounds are in order. If the first grass is 0, then numbering from there will give you the number of background, which means that background slots from 0 to 19 are already filled. So, let's say we add 4 more backgrounds to the end of the table: Fire, Snow, Storm, and Metal, respectively.

The games coding does not directly allow access to these backgrounds, which is what the hacked routine does. Basically, it branches to a section of ASM that checks var 0x40F7. If this var is set to 0, it will automatically return to the regular routine and continue as normal. However, if it is set to any other number, the routine will operate from there and load the battle background of that number instead.

So, if you set var 0x40F7 to 20, then the Fire background will be loaded. If you set it to 22, then the Storm bg will be loaded, and so on. This will stay until you change it to something else. In order to return to the normal background for that map, then you simply set the var to 0.

Please note that this routine overrides every type of battle. This means you can change trainer battles, sea battles, grass battles, cave battles, etc, all by setting that one var. Also, the routine loads a half-word, not a byte, which means that you can have up to 0xFFFF backgrounds in the table, which is a little over 65,000. Granted, there isn't enough space in the rom to have unique backgrounds in each slot, but don't worry about over expanding the table. You won't have a problem there.:)

Well, that about wraps this up. Originally I had planned to give you the ASM routines and explain how to use them, but that got overly complicated with the branches, so I made it really simple with the patch.






Also, I did my best to make this compatible with both JPAN's engine and Jambo51's 649 patch. I haven't tested it on either, but I asked Jambo if there would be any complications or things I should avoid and the only thing he gave me was which var to use since he had used a few. For JPAN's, I avoided using any RAM that he used (which didn't matter in the end because Jambo had me switch to a var) and I don't think he had any routines and such that would affect this.


In order to make this even better for people, on case you have already used the free space at 0xF00000, I have included the source code here:


You can do as you wish with this code.


If there are complications, please let me know!



~Credits!

Driver - Driver was an old-time German hacker whom originally accomplished this for his own hack. Instead of using a var, he freed up some RAM and used that. About two months ago, I received a rom and some notes of his from Narutoactor via Tajaros. It took me a while to make heads or tails of them, but once I did, I set out to port it over to English FireRed and this was the result! So, most of the credit goes to him!

Jambo51 - A HUGE help in making this. He taught me how to access vars and answered a lot of questions. I know he hates people bugging him with questions, so I really appreciate him not ignoring me!

Darthatron - For being a really good friend and giving me a lot of help. When I was stuck and didn't have access to the var_access routine due to being on the go, but I still wanted to write up the ASM for it, he Pastied it me and I got a lot done. As usual, he also answered a lot of questions and was really helpful.

Mat - While I didn't end up using it because I switched to a var, Mat spent over an hour helping me try to find some free save-able RAM for this project. I really appreciated the time he gave me as we explored the save blocks and got almost nowhere, but he stuck with me until he had to go, so I have to give him a huge thanks!

Tajaros (Not Shadowraze, this was before the switch:p) - For starting this whole project by sending me all of Drivers stuff and asking for my help in deciphering it. He also decoded a lot of the table and documented the first 9 backgrounds before I even started working, which was a huge help.

Narutoactor - For sharing all of Driver's research, and attempting to help me contact Driver which, unfortunately, never happened:(.

Lastly, Drfuji - For digging into the archives and redoing his old private bg editing tutorial and completely rewriting it to go along with this research to make this ultimate guide to hacking battle backgrounds.


Well, that is all for now! On to the next project.... !

~karatekid552

Does anyone have the file of bg hack uploaded by karatekid552 or just the source code of it?
 
4
Posts
8
Years
  • Age 30
  • Seen Nov 20, 2023
Hi everyone! I need help with something about battle backgrounds.

I'm editing Pokemon Ruby for the first time and I want to change the battle backgrounds in some places. I don't want to insert custom backgrounds but to switch the background is shown for another background from Gamefreak. For example, I want the Battle Tower to have this background from the Elite Four ( vizzed.com/vizzedboard/retro/user_screenshots/saves7/74397/GBA--Pokemon%20Ruby%20Destiny%20Reign%20of%20Legends_Jul11%2012_08_04.png ) instead the simple original one ( i.ytimg.com/vi/n7idSlLPxMA/hqdefault.jpg ).

I've been weeks looking for a way to do this and I always come to this post. After reading all the three pages over and over and trying to familiarize myself with HEX editors I'm still confused and I don't know what to do. I don't usually look for help in forums but I'm desperate.

In addition, Is there any tool like "Battle Frontier Editor" for the Pokemon Ruby Battle Tower? The background and the pokemon are the only things I have left.

Thanks
 
2
Posts
10
Years
  • Seen Jan 18, 2017
Good day Sir...
can someonehelp me because im trying to insert indoor battle BG on fire red then... when im in the process of editing the pallets on HXD i encounter this

Fire red.png
(On the left side is actual game on the right side is mock up one and also the result i want)

Its look like the the pallets are collaborating or combining...
i double check the image and the pallets...I also opened it on NTME to see if i get the same result but it showed me the right battle bg with right pallets i also tried to edit the field battle BG pallet and i successfully edited it just the indoor pallets...I think there is a pallet limiter or something that so can someone help me ? and point out the problem(s)?

haha sorry for my bad english...
Credit to skyHigh for his Dark Crystal indoor battle BG that i used...
 
16
Posts
9
Years
  • Age 41
  • Seen Jul 10, 2021
The Data Behind Battle Backgrounds


Now that DrFuji has taught you how to edit Battle Backgrounds, I am going to take you into the data aspect. For right now, this lesson will just be for FireRed. If you do want it for another game and you are actually going to use it, I will attempt to do my best to help you. ...

Please! You can reupload the Battle Background Hack.ips and theBattle BG Hack Source Code

Thanks
 

BluRose

blu rass
811
Posts
9
Years
Please! You can reupload the Battle Background Hack.ips and theBattle BG Hack Source Code

Thanks
i know that you ended up finding it on WaH but for future reference anyways/those that desire to get this in the future
http://wahackforo.com/361466-post11.html
Spoiler:

EDIT: oh and hey look at that the patch as well <3
 
Last edited:

Trev

[span="font-size: 8px; color: white;"][font="Monts
1,505
Posts
11
Years
  • Age 27
  • Seen Nov 15, 2023
Hi all! This thread is a little old, but as I've been working with battle backgrounds for the past day and half, I figured I should add this stuff to the thread.

  • The Gym battle background is linked to the field and three other backgrounds. Their palettes are incredibly garbled and you would be lucky to get more than 7-8 colours out of them.

I want to point out that this is total bullshit and that you can absolutely use more than 7 - 8 colors on a "Gym" background. First off, the field background is not connected to the "gym" background at all. The field background is actually never loaded. Look at this part of karatekid552's post.

9. Multi/Indoor- White & Grey & some Yellow in the Palette (Normal Trainer Battle)
10. Multi/Indoor- Green & a little Yellow (Rival Trainer Battle)
11. Multi/Indoor- White & Grey ()
12. Multi/Indoor- White & Grey & some Tan in the Palette ("Gym" Trainer Battles (that option in A-Map))
13. Multi/Indoor- White & Grey & some Tan in the Palette

This gets some things right but not all of them. The bolded part is the part that's wrong. For some weird, unexplained reason, GameFreak did a GameFreak and used the indoor tileset and tilemap for non-grass outdoor areas and simply slapped on a different palette for it. I have absolutely no idea whatsoever why they did this instead of, you know, using the background dedicated specifically for fields, which would encompass 90% of the routes, but that's irrelevant. What is relevant is that the field palette is something completely different from the "Gym palette."

The second part is the garbled palette and how we can/can't use it. DrFuji and karatekid mistakenly said that the palette was most unusable because it was "linked" to the field palette. This is pretty untrue. The palettes are compressed differently than the previous 8 backgrounds. While they are hard to edit directly in the hex editor, there is absolutely a way to change them and to use more than 7 - 8 colors. If you insert a palette into free space by using GBA Graphics Editor, and then use a hex editor to copy/paste-write all that palette data overtop the old palettes, you can have more than 7 - 8 colors and you won't have to go through the headache of trying to decode the palettes yourself in a hex editor. I've managed to use max 11 colors, but you might be able to use more. I'm pretty sure the compression omits some colors in the hex but loads them... separately somehow? I'm not entirely sure on the mechanics of the compression but I know for a fact that you aren't limited to 7 - 8.

Also, something interesting to note. If you look at entries 9-13 in the table, you'll notice that they all use the same pointers for everything but the palettes. You can repoint these individually to different images. For example, if you want to have a field background that doesn't depend on the indoor tileset/tilemap, you can insert the tileset and tilemap you want to use into free space and then change the tileset/tilemap pointers in entry 10 to those pointers. That way, you can have indoor backgrounds while also having a custom outdoor non-grass background that isn't just a palette-swapped indoor version (you can do the same for the entry images as well). Note, though, that unless you use the battle background hack, you can't load specific backgrounds and the backgrounds will load based on the pointers in the entry, as they did before. They'll just load different data if you change the pointers. :P
 
239
Posts
8
Years
  • Age 31
  • Seen Nov 12, 2023
This may be a silly question, but when using the Pallette viewer to replace the colors with the appropriate hex values in your new pallette, how does one know which colors to replace? Here's an image of what I get when I import the tileset and tilemap to slots 3 and 4 in unLZ:
Spoiler:

The magenta color obviously needs to be changed, but all the different shades of green have me a tad confused.

Thanks in advance for your help :)
 
23
Posts
7
Years
  • Age 29
  • Seen Nov 12, 2023
dose anyone know how to change the opening of background? just not like Emerald always do like left screen move to right screen, can we just set what ever background, opening screen start on meddle ?
 
3
Posts
6
Years
  • Age 26
  • Seen yesterday
Thanks you for this tutorial because i learn how to insert Grass, Cave, Sea and so on. I'm just having a problem with the field and indoor. Can someone help me separate the field with indoor Battle background image and also the pallet with indoor. Tried to read the Trev post about using the GBA graphics editor but It just seems 'can't find it out how to. I Read the whole post but seriously I still can't get it Can someone explain it more further.
 
27
Posts
7
Years
  • Age 36
  • Seen May 25, 2019
what did i do wrong? my whole screen is static but i can still attack...
 
3
Posts
5
Years
  • Age 34
  • Seen Jun 30, 2020
How do I insert additional backgrounds with unLZ? There are currently 10? tilesets for the backgrounds in FireRed and I have inserted over those, but I would like to add a few more. I will have the ASM code to access these extra background pointers but I have never done anything like this before.

Usually when I insert stuff in the ROM, it involves loading a relevant stock image to overwrite. But with these extra backgrounds, I don't have anything to overwrite. Hope this makes sense.

Edit: figured it out. Just need to uncheck "auto fix pointers"
 
Last edited:
3
Posts
6
Years
  • Age 28
  • Seen Apr 23, 2023
I think you skipped a few steps, or it was me that did not understand

with a video would be easier to understand


I would like to use an image similar to that of pokemon stone dragon
 
Last edited:
760
Posts
15
Years
  • Seen today
Two things I want to mention.

1: The battle background mentioned as the ''field'' background in the main (or second) post is actually the underwater background. The ''field'' background is the second one of the first Multi-type backgrounds/Indoor Backgrounds.

2: The link to the ASM routine is broken.
 

Flare7940

Oh, awful, my Klinklang became rusty!
6
Posts
6
Years
  • Age 30
  • Seen Jul 22, 2022
All photos are broken. Without them, everything is much less clear at times. I, like a noob, can't understand what is happening without them.
 
Back
Top