Lance32497
LanceKoijer of Pokemon_Addicts
- 792
- Posts
- 10
- Years
- Criscanto town-Ginoa Region xD
- Seen Aug 14, 2017
Too bad, karatekid552's BattleBG Hack's link is broken
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.PondSea
6.SeaPond
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:
Here is the documentation of each background and their pointers in the original table: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]
Spoiler:Grass Background
VV = 24844C
WW = 2489A8
XX = 248C68
YY = 248F58
ZZ = 248400
Second Grass Background (There are two Grass Images in FR, I don't know the reason.)
VV = 2490C4
WW = 249620
XX = 2498DC
YY = 249E10
ZZ = 249074
Sand Background
VV = 249FE4
WW = 24A37C
XX = 24A618
YY = 24A844
ZZ = 249F98
Field Background
VV = 24A990
WW = 24ACD0
XX = 24AF70
YY = 24B0DC
ZZ = 24A940
PondSea Background
VV = 24B1EC
WW = 24B608
XX = 24B8A8
YY = 24BBE0
ZZ = 24B19C
SeaPond Background
VV = 24BD38
WW = 24C07C
XX = 24C314
YY = 24C520
ZZ = 24BCE0
Craggy Background (Don't know what this is supposed to be called)
VV = 24C624
WW = 24C9B8
XX = 24CBF8
YY = 24CEC8
ZZ = 24C5D8
Cave Background
VV = 24CFEC
WW = 24D418
XX = 24D6B8
YY = 24DC98
ZZ = 24CF98
Multi-type Backgrounds/Indoor Backgrounds (Usually appears in Trainer Battles)
-There are 5 different ones in a row. They use the same setup, but different palettes.
VV = 24DE34
WW = 24E16C
XX = 24E410
YY = 24E490
ZZ =
1. 24DDF0
2. 24E81C
3. 24E528
4. 24E56C
5. 24E5B8
Another set of Multi-type backgrounds/Indoor Backgrounds. This set has 7.
VV = 24E858
WW = 24EB90
XX = 24E410
YY = 24E490
ZZ =
1. 24E604
2. 24E650
3. 24E6A4
4. 24E6F0
5. 24E740
6. 24E78C
7. 24E7DC
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?
OH! Lucky you! I was just scrolling through my old files and saw this. Hope it helps! Happy hacking! ^_^
View attachment 76880
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. ...
i know that you ended up finding it on WaH but for future reference anyways/those that desire to get this in the futurePlease! You can reupload the Battle Background Hack.ips and theBattle BG Hack Source Code
Thanks
.align 2
.thumb
/*Well, this is the source code for the battle bg hack. Pretty simple stuff.
When the battle bg is loaded, the game stores the background number to be loaded in r0.
This hack branches the routine right after that to check the var and if there is something in it,
load that as the new background.
The branches to this routine (BPRE only) need to be done as follows:
0x0800F26C= change "ldr r5, #0x0824EE34" to "ldr r5, #0x08F00001" (or the location you choose to put this routine at.)
0x0800F26E= change "lsl r4,r0,#0x2" to "bx r5"
0x0800F270= change "add r4,r4,r0" to "pop {r5}"
0x0800F2B8= change "ldr r5, #0x0824EE34" to "ldr r5, 0x08F00041" (The location Main2 begins at, +1. It was 0x08F00031 in the patch)
0x0800F2BA= change "lsl r4,r0,#0x2" to "bx r5"
0x0800F2BC= change "add r4,r4,r0" to "pop {r5}"
Now, at 0x0800F320, 0x0800FD5C, and 0x0800FD88 change the pointer (which points to the original bg table [0x0824EE34])
to the new BG table location which is 0x08F10000 in here and the patch.
This source is based off what is in the patch. It is ment to modified so that hackers who have already used 0xF00000+ in their
hacks can have flexibility in the location of the routine.
I haven't tested this routine as it is, but it should work... "Should" being the key word...
The reason being, I was given the routine without the var_loader already in a German Rom and I branched it later
to include the var_loader, so this source code is the all in one.*/
.org 0xF00000
Main: ldr r5, new_bg_table
push {r5}
push {r1}
bl varloader
post_var_loader: cmp r1,#0x0
beq return
mov r0,r1
return: pop {r1}
ldr r5, return_offset
lsl r4,r0,#0x2
add r4,r4,r0
bx r5
varloader: push {r0, r2}
ldr r0, var_id
bl call_decrypt
ldrh r0, [r0]
mov r1, r0
pop {r0,r2}
bl post_var_loader
call_decrypt: ldr r2, vardecrypt
bx r2
.align 2
var_id: .word 0x000040F7
vardecrypt: .word 0x0806E455
new_bg_table: .word 0x08F10000
return_offset: .word 0x0800F271
.align 2
Main2: ldr r5, new_bg_table2
push {r5}
push {r1}
bl varloader2
post_var_loader2: cmp r1,#0x0
beq return2
mov r0,r1
return2: pop {r1}
ldr r5, return_offset2
lsl r4,r0,#0x2
add r4,r4,r0
bx r5
varloader2: push {r0, r2}
ldr r0, var_id2
bl call_decrypt2
ldrh r0, [r0]
mov r1, r0
pop {r0,r2}
bl post_var_loader2
call_decrypt2: ldr r2, vardecrypt2
bx r2
.align 2
var_id2: .word 0x000040F7
vardecrypt2: .word 0x0806E455
new_bg_table2: .word 0x08F10000
return_offset2: .word 0x0800F2BC
- 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.
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
Anyone have the battle bg asm for emerald?
Heh! i remember those days....Hack FR