![]() |
Pokéball hacking guide
Pokéball Hacking Guide http://cdn.bulbagarden.net/upload/9/93/Bag_Pok%C3%A9_Ball_Sprite.pngIntroductionhttp://cdn.bulbagarden.net/upload/9/93/Bag_Pok%C3%A9_Ball_Sprite.png All credits for the original thread go to danills. It's thanks to him any of this is even possible. The following introduction is from him. Some months ago, when I was still attempting my first hack, I was wondering whether it was possible to create a custom pokeball. The only thing I found was this post by JPAN. It wasn't complete, and I hadn't seen anyone using it, so I forgot about it. Now, I am working full-time on Platinum Red&Blue with GoGoJJTech, and had to implement gen IV pokeballs into the hack. I have altered JPAN's asm code a bit, and included documentation on the throwing graphics for everybody to use. Enjoy! http://cdn.bulbagarden.net/upload/c/ca/Bag_Great_Ball_Sprite.pngRequirementshttp://cdn.bulbagarden.net/upload/c/ca/Bag_Great_Ball_Sprite.png
http://cdn.bulbagarden.net/upload/0/03/Bag_Ultra_Ball_Sprite.pngStep 1: Dealing with the pokemon data limitershttp://cdn.bulbagarden.net/upload/0/03/Bag_Ultra_Ball_Sprite.png WARNING: This step will break any saves in progress! This is the easiest part. As you can see here, the balls only get four bits of data, and 0 is unused, meaning you can add up to three balls. Since I don't think there are many people who have transferred pokemon from Colosseum or XD to a hack, it's safe to sacrifice the most significant bit used to determine the game of origin, leaving us space for 19 extra balls. If you need more, you will need a different workaround.You've got to change six bytes:
And you're done! Move on to step 2. http://cdn.bulbagarden.net/upload/e/eb/Bag_Safari_Ball_Sprite.pngStep 2: Inserting the catch rate routinehttp://cdn.bulbagarden.net/upload/e/eb/Bag_Safari_Ball_Sprite.png JPAN has written a neat routine that replaces the regular check for pokeballs (see the link posted above). However, it requires you to perform a cmp for every ball index, and that's not very efficient and forces you to modify the routine every time you add a ball. Thus, I have modified it, so that it checks what pocket the selected item is in. Now, you only have to give the item the right pocket value and it becomes a ball. The routine: Spoiler:
Now, in the code you see "somevar". There you must place an address (or use this one I saw in JPAN's original routine) that will keep track of the current pokeball index. Other than in the routine, there are a few places you need to place a pointer to it:
(more information here) Now you've done all that, it's time to assemble the routine. Insert in anywhere, and place a pointer to it at 08016494. Then at 08016460, type 00 00 00 00 0B 4A 97 46. Done! Move on to the next step to make your ball actually do something. http://cdn.bulbagarden.net/upload/6/6d/Bag_Master_Ball_Sprite.pngStep 3: Making the balls do somethinghttp://cdn.bulbagarden.net/upload/6/6d/Bag_Master_Ball_Sprite.png The balls with a pokeball index (previously index number) higher than 5 each have their own catch rate calculation subroutine. We need to extend that. To do this, first change the byte at 0x802D52C to FF. Then, look at the table at 0x802D54C. It has a pointer to a routine for every pokeball starting from 6. At 0x802D548 you can see a pointer to the table; repoint it somewhere else (the table is 0x1C bytes long). Now, to give a ball a certain catch rate, you must write a routine to load it into r4, and exit to 0x802D7A2. Then place a pointer to that routine in the table. Some example routines: http://cdn.bulbagarden.net/upload/4/41/Bag_Quick_Ball_Sprite.pngQuick ball: Spoiler:
http://cdn.bulbagarden.net/upload/0/06/Bag_Dusk_Ball_Sprite.pngDusk ball: Spoiler:
http://cdn.bulbagarden.net/upload/b/b2/Bag_Park_Ball_Sprite.pngPark ball; this one uses a modified safari ball routine, and will get another piece of code later: Spoiler:
http://cdn.bulbagarden.net/upload/1/17/Bag_Heal_Ball_Sprite.pnghttp://cdn.bulbagarden.net/upload/f/ff/Bag_Cherish_Ball_Sprite.pngHeal ball/Cherish ball (the heal ball will get another piece of code later) These are special. They load the catch rate from the "Extra value" of the item (labeled as "Extra" in Gen3Tools). In the case of these balls it's 10, but you can easily change it without altering the code: Spoiler:
https://cdn.bulbagarden.net/upload/f/f9/Bag_Moon_Ball_Sprite.pngMoon Ball: Spoiler:
https://cdn.bulbagarden.net/upload/3/3e/Bag_Sport_Ball_Sprite.pngSport Ball: Spoiler:
https://cdn.bulbagarden.net/upload/4/4a/Bag_Dream_Ball_Sprite.pngDream Ball: This is a hook from the Master Ball routine. This code DOES NOT go at the end of the catch routine table. Where a routine in the table would have gone for the Dream Ball, place 00 00 00 00. Despite it not having its own routine, the Dream Ball still receives a unique index like every other ball. Spoiler:
https://cdn.bulbagarden.net/upload/f/f2/Bag_Beast_Ball_Sprite.pngBeast Ball: Spoiler:
Here comes the part JPAN didn't document: animations. And be prepared, it's a long part. Step four: Expanding the Throwing Graphics - Part 1 http://cdn.bulbagarden.net/upload/d/df/Bag_Level_Ball_Sprite.pngThe conversion tablehttp://cdn.bulbagarden.net/upload/d/df/Bag_Level_Ball_Sprite.png Now, if you've ever looked at the pokeballs in an item viewer and at the throwing graphics of them in an image viewer, you might have noticed they're in a different order. So, there is a routine somewhere that converts the index to the throwing graphics table (or tgt in short because I'm lazy) entry. That routine is located at 080EF52C. Due to the way it's written, there's enough space to replace it by a new routine and a table. First the routine: Spoiler:
Assemble this routine and insert it at 080ef52C. Now, the conversion from index to tgt entry will be done through throwtablepositionstable. By this, we freed up more than enough space at the specified offset, so I recommend you to put the table there. Now for the table, it will look like this: Code:
Code:
After inserting this, remove a limiter by typing 00 00 at 080EF972 and at 080F02D6, and continue to the next step. Step four: Expanding the Throwing Graphics - Part 2 http://cdn.bulbagarden.net/upload/2/25/Bag_Lure_Ball_Sprite.pngThe image and palette tableshttp://cdn.bulbagarden.net/upload/4/4e/Bag_Lure_Ball_IV_Sprite.png Prepare your ball images. Example with gen 4 balls: https://dl.dropboxusercontent.com/s/6nopc4oo4kx7ok4/DzLLV9G.png Made by Bela. Isn't he awesome? :D Anyways, you must repoint and extend two tables in this step. First, the one for the images, located at 0826056C. 12 entries, each eight bytes: one word and two halfwords. Repoint it somewhere. Then, append your own balls as follows: Code:
Code:
Step four: Expanding the Throwing Graphics - Part 3 http://cdn.bulbagarden.net/upload/f/f9/Bag_Moon_Ball_Sprite.pngRepointing generic tableshttp://cdn.bulbagarden.net/upload/f/f9/Bag_Moon_Ball_Sprite.png Here comes a list of the tables: Spoiler:
Step four: Expanding the Throwing Graphics - Part 4 http://cdn.bulbagarden.net/upload/1/17/Bag_Friend_Ball_Sprite.pngThe particle and animation tableshttp://cdn.bulbagarden.net/upload/1/17/Bag_Friend_Ball_Sprite.png As for now, I will only document the tables and their meanings, and how to assign existing animations/particles to new balls. Another part on custom animations may follow later. The first table you need to repoint and extend is located at 0840C068. For every ball it tells which particle to use. 0=sticks, 1=stars, 2=bubbles, 3=hearts, 4=big green crosses, 5=small green crosses (last two strongly affected by the second table). The second table is located at 0840C074. Each entry is a pointer to a routine+1 that describes how the particles should act. I can't really describe the effects, so just look at them. And that's it! Congratulations, you've succesfully expanded the pokeballs! The next parts will describe how to apply some special effects. Step Five: Expanding the Throwing Graphics - Part 5 https://cdn.bulbagarden.net/upload/8/87/Bag_Luxury_Ball_Sprite.png Ball Opening Colour Table https://cdn.bulbagarden.net/upload/8/87/Bag_Luxury_Ball_Sprite.png There is one last table at 0x40C1C4: Code:
Step Six: Additional effects part 1 http://cdn.bulbagarden.net/upload/4/42/Bag_Love_Ball_Sprite.pngHealing pokemon after capturehttp://cdn.bulbagarden.net/upload/4/42/Bag_Love_Ball_Sprite.png This effect was written by danills for the Heal Ball: Spoiler:
Step Six: Additional effects part 2 http://cdn.bulbagarden.net/upload/7/74/Bag_Heavy_Ball_Sprite.pngRetaining pokeballshttp://cdn.bulbagarden.net/upload/7/74/Bag_Heavy_Ball_Sprite.png This effect was written by me for the Park Ball, and will work if the caught poke already has a pokeball, like with the Pal Park: Spoiler:
Step Six: Additional effects part 3 http://cdn.bulbagarden.net/upload/7/70/Bag_Fast_Ball_Sprite.pngThe givepokemon hackhttp://cdn.bulbagarden.net/upload/7/70/Bag_Fast_Ball_Sprite.png One of the gen 4 balls is the Cherish Ball, which has no effects other than being the standard ball for event pokes. To copy this effect, I wrote a piece of code to change the givepokemon command. Know how it has three unused parameters? Well, the last one, a byte, is now the pokeball the received pokemon will be in. If it's 0, it will be in a regular pokeball. Anyways, the hack: Code:
http://cdn.bulbagarden.net/upload/3/3e/Bag_Sport_Ball_Sprite.pngTo-do listhttp://cdn.bulbagarden.net/upload/3/3e/Bag_Sport_Ball_Sprite.png
http://cdn.bulbagarden.net/upload/5/55/Bag_Premier_Ball_Sprite.pngCreditshttp://cdn.bulbagarden.net/upload/5/55/Bag_Premier_Ball_Sprite.png
|
For everyone use Ruby (me x'D)
0802B78E catch_rate_calc_function 0202E83F map_tipe (out,in,secret_base,caves) 030042F3 battle_turn_counter 083C5564 item_data 080C52CE heal_poke |
Great tutorial! Really, really thank you for sharing! This is amazing! (:
|
Really good tutorial..... Easy to understand ... :)
|
This is great!
You do a wonderful job of explaining such a complex task! :) EDIT: To use the givepokemon hack on LeafGreen 1.0, just do everything you would for FireRed 1.0. The offsets and ASM are unchanged. :) |
Quote:
Awesome tut btw |
Thanks for all the positive feedback guys!
Quote:
|
Hey,
Can you please guide me if this level ball works? Spoiler:
I sourced it from http://bulbapedia.bulbagarden.net/wiki/Pok%C3%A9_Ball#Level_Ball This is my very first branching asm, would like some feedback please :) ? It basically checks your level against theirs, if its lower x1 If its higher it branches and halves your level, then checks again. if lower x2 (less than double but higher than wild) If its higher again it will half, then check again. If lower x4 (more than double but less than quadruple) If its higher it branches and moves x8. How does that sound? |
Quote:
Also you forgot to add 84 to yourpokelevel, and I don't really get why you're using bne instead of simple b, and the last bne has no real use too, but good job apart from that! |
Cool so I'm definitely improving my asm skills.
I made a test code for heavy ball, I haven't applied your tut yet so I haven't tested it but it looks reasonable. The main problem with the heavy ball is this hack let's you set a value in r4 and then C*R4, so R4 is basically the ball bonus. Heavy ball doesn't multiply... it adds eg (C+40). So without modifying the routine we could be stuck. But I think what if we could always have (C+40) = (C*R4)? We simply have algebra to deal with. So our R4 will always mathematically be: (C+40)/C right? I think so. Luckily Knizz has found a division routine that's lets me code this to one decimal place. Any way here it is: Spoiler:
So this is still my 2nd asm script so I'm 100% sure there are inefficiencies and it's probably wrong, but maybe this could help with the heavy ball solution? |
Quote:
EDIT: daniilS explained what could happen to cause the bug. |
Very nice! I was looking for something like this!
|
Is there any way you could also give the routine for a Master Ball & a regular Pokeball??
|
Quote:
|
Quote:
|
The masterball is a special case because it skips catch rate calculation completely, but entering 255 as a value should give you no problems unless a poke has a catch rate below 3.
|
Alrighty thanks daniilS! I'll use test it out later today.
I wish I'd known how to work this tutorial when it had come out, I think this is flipping awesome, thanks for answer me too:D |
I've updated the offset of somevar. If anybody is actually using this, please change it, as the first offset may be unsafe to use in some hacks.
|
For some reason, my extended balls don't have particles assigned in game even when I assign them. I changed all balls to sticks, and it works until I get to new balls.
Any clue? |
Quote:
|
Coolio! Got it working, I had particle tags and ball tags using the same tag number which is a big NONO! Thanks Daniils.
Note using Bela's balls in the tutorial you will notice that the balls don't occupy 15 colours. But they all need to be non-black otherwise the particles will be black. EDIT: Spoiler:
EDIT 2: That is wrong, they are all tied to the Pal7 ut I have no idea why the extended balls don't work. |
Here is a list of Gen II pokeballs and their respective ASM routines:
NOTE: Please change the basestats and pokedex locations in your ROM, they will be different!! http://cdn.bulbagarden.net/upload/7/70/Bag_Fast_Ball_Sprite.pngFast Ball: Spoiler:
http://cdn.bulbagarden.net/upload/1/17/Bag_Friend_Ball_Sprite.pngFriendball: Spoiler:
http://cdn.bulbagarden.net/upload/7/74/Bag_Heavy_Ball_Sprite.pngHeavyball: Spoiler:
http://cdn.bulbagarden.net/upload/d/df/Bag_Level_Ball_Sprite.pngLevelball: Spoiler:
http://cdn.bulbagarden.net/upload/4/42/Bag_Love_Ball_Sprite.pngLoveball: Spoiler:
http://cdn.bulbagarden.net/upload/2/25/Bag_Lure_Ball_Sprite.pngLureball: Spoiler:
http://cdn.bulbagarden.net/upload/f/f9/Bag_Moon_Ball_Sprite.pngMoonball: Spoiler:
|
I don't understand how to take pokeball index part...
|
Quote:
|
Quote:
|
| All times are GMT -8. The time now is 8:47 AM. |
![]()
© 2002 - 2018 The PokéCommunity™, pokecommunity.com.
Pokémon characters and images belong to The Pokémon Company International and Nintendo. This website is in no way affiliated with or endorsed by Nintendo, Creatures, GAMEFREAK, The Pokémon Company or The Pokémon Company International. We just love Pokémon.
All forum styles, their images (unless noted otherwise) and site designs are © 2002 - 2016 The PokéCommunity / PokéCommunity.com.
PokéCommunity™ is a trademark of The PokéCommunity. All rights reserved. Sponsor advertisements do not imply our endorsement of that product or service. User generated content remains the property of its creator.
Acknowledgements
Use of PokéCommunity Assets
vB Optimise by DragonByte Technologies Ltd © 2023.