Pages: 1
Posted on 08-19-14, 08:13 pm (rev. 2 by  MeroMero on 09-17-14, 10:07 am)
Death by cuteness

Karma: 6284
Posts: 116/598
Since: 05-01-13
What the title says.
"Says the guy who said he wouldn't play Pokémon anymore, oh well *shrugs*"

Note : before someone asks me, if you see a number preceded by 0×, it means that number is expressed in hexadecimal format.

This is the type-chart :

Here is its format :
AA DD EE
_AA : attack type
_DD : defender type
_EE : effectiveness
those 3 bytes are repeated consecutively for basically each type, and the table will end at the first occurrence of AA DD equal to FF FF.

AA and DD can take one of the following values :
_0×00 : Normal
_0×01 : Fighting
_0×02 : Flying
_0×03 : Poison
_0×04 : Ground
_0×05 : Rock
_0×06 : Bug
_0×07 : Ghost
_0×08 : Steel
_0×09 : ???
_0×0A : Fire
_0×0B : Water
_0×0C : Grass
_0×0D : Electric
_0×0E : Psychic
_0×0F : Ice
_0×10 : Dragon
_0×11 : Dark

EE can take one of these 4 values :
_0×00 : ineffective
_0×05 : not very effective
_0×0A : normal damage
_0×14 : super effective

As you have guessed, EE is actually a multiplier, but before the effect is applied, EE is divided by 10, thus the origin of the coefficients ×0, ×0.5, ×1 and ×2 !

But there's a first problem, if you try to search for 00 05 05 00 08 05 0A 0A 05, etc. in the ROM, your hex editor of choice will return no results !
This is because the overlay that contains the table (overlay 12 here) is LZ-compressed, like in NSMB all overlays are LZ-compressed (there are 129 of them in HGSS).
Decompress it with Crystal Tile 2 for example.

Okay now you search through the decompressed overlay 12 with your hex editor, and now you have found the string, great; but there's a second problem !
Look at the table, there's no EE bytes whose value is equal to 0×0A !
That's because 0A is the default multiplier in Gen 4 Pokémon games (Gen 3 too, probably Gen 2 ?), which is why ???-typed moves/Pokémon deal/take neutral damage to/from everything. But unlike Gen 2 and Gen 3, thanks to the Physical-Special split, ???-typed moves are actually able to deal damage greater than 1HP (read real damage).
How is it going to affect us ?
Well you're going to have a hard time if you want to port the Fairy type effectiveness in HGSS (for the sake of an example).
If you try to add (DON'T !) even only one more relationship, once you get into a fight you will break the game since the arm9 code will read wrong instructions from everything in the overlay 12 that come after the type table…


How to trick the game then ?

First you have to understand how the game works :
Let's say you have 2 main states in Pokémon games, the overworld and the fights.
The game needs to load the following overlays for the overworld : 1, 2, 3 and 27 (Group 1)
And it needs to load these for the fights : 6, 7, 10, 12, and 18 (Group 2)
Actually the overlay 10 is loaded every time you get to choose your action, the overlay 7 when you have chosen said action (and initially at the beginning of the fight too).

Once you press continue on the menu screen, the game will load the group 1, and when you get in a fight, it will load the group 2, once you are finished with your fight the game will load again the group 1, etc.
You can see that with the RAM Viewer around address 0×021D0E00 for those who are curious
It's something like this :
Overworld : 01 00 00 00 01 00 00 00 02 00 00 00 01 00 00 00 03 00 00 00 01 00 00 00 1B 00 00 00 01 00 00 00 Fight : 0C 00 00 00 01 00 00 00 12 00 00 00 01 00 00 00 06 00 00 00 01 00 00 00 0A 00 00 00 01 00 00 00


If you parse through the RAM, you'll see that when the overlays from one group are loaded, the previous overlays who happened to be there will be overwritten.

The trick here is to find a place in the RAM that is not used during the fights and that could be used to fit in the new table.
And such an area exists !
It just so happen that overlay 18 and overlay 1 have the same offset in the RAM, but ovl_1 is much longer than ovl_18 ! That's exactly what we need.

What does it means ? It basically means that the ovl_1 leftovers is basically free space during the fights !


Modus Operandi

Step 1
Open your Pokémon HeartGold or Pokémon SoulSilver ROM in Crystal Tile 2.


Step 2
Click the NDS icon (or alternatively click Ctrl+N).

Expand the window if necessary.

Step 3
Right-click on overlay_0012.bin and click Extract (not Export !), this will actually decompress the overlay.

Step 4
Do the same for overlay_0018.bin.

Step 5
Open both decompressed files in a hex editor.

Step 6
Add your improved type-chart at the end of overlay_0018.bin


I advise you to make a full chart with all 324 relationships from the get-go, so that if you want to change something, you won't have to go through all the trouble again.
Or you can take mine, which is up to date with the relationships according to Gen 6 :


Step 7
In overlay_0012, look at address XXXXXXXX for value YYYYYYYY and change it to ZZZZZZZZ, of course these 3 values change according to the region, so here's a complete table :
game and language id overlay12 addr. original pointer updated pointer (XXXXXXXX) (YYYYYYYY) (ZZZZZZZZ) Japanese POKEMON HG IPKJ 0x0001A794 78C12602 E0B01F02 POKEMON SS IPGJ 0x0001A794 78C12602 E0B01F02 English POKEMON HG IPKE 0x0001A78C 7CCC2602 60BE1F02 POKEMON SS IPGE 0x0001A78C 7CCC2602 60BE1F02 French POKEMON HG IPKF 0x0001A78C 9CCC2602 A0BA1F02 POKEMON SS IPGF 0x0001A78C 9CCC2602 A0BA1F02 German POKEMON HG IPKD 0x0001A78C 5CCC2602 60BA1F02 POKEMON SS IPGD 0x0001A78C 5CCC2602 60BA1F02 Spanish POKEMON HG IPKS 0x0001A78C 9CCC2602 A0BA1F02 POKEMON SS IPGS 0x0001A78C BCCC2602 C0BA1F02 Italian POKEMON HG IPKI 0x0001A78C 1CCC2602 20BA1F02 POKEMON SS IPGI 0x0001A78C 1CCC2602 20BA1F02 South Korean POKEMON HG IPKK 0x0001A790 80D62602 A0C41F02 POKEMON SS IPGK 0x0001A790 80D62602 A0C41F02


As you have guessed, the pointer will point to the type table, what you did here is relocating the pointer to the new and (admittedly) more complete table.

Step 8
Save both files and close your hex editor.

Step 9
Back to Crystal Tile, right-click on overlay_0012.bin and click Compression, this will actually import the LZ-compressed of your file back into the ROM.


Step 10
Do the same for overlay_0018.bin, but be careful now the file is too large to be contained between ovl_17 and ovl_19 even when compressed ! But do not fret, Crystal Tile will take care of that for you.

Just click OK.

Step 11
Close Crystal Tile 2, and now your ROM is ready.

Want to make Poison super-effective against Water ? Sure thing mate.
Want to make Ice resistant to Dragon ? Knock yourself out !
Want to add all the Fairy type relationships ? That's the reason that drove me to think outside the box and find a way to present you this.

Works for both emulators and flashcards.

Now you can make Pokémon HGSS hacks even more awesome !

Again another tutorial by yours truly, Sharks
Posted on 09-02-14, 05:55 pm
Goomba


Karma: 126
Posts: 5/25
Since: 09-23-12
Hi, Sharks. I'm a NDS-Pokemon hacker (you can see my hack here: http://wahackforo.com/t-21923/pokemon-light-platinum-nds)

I've done what the tutorial says, but I've a problem to insert the fairy-type. The ROM uses the normal-type icon for the normal and the ??? types. I think the code to make this happen is somewhere in the arm9, but I don't know where exactly. Do you know how to change this, to the ???-type displays the ???-type icon?

Sorry for my english, and thanks a lot for the tutorial
Posted on 09-02-14, 08:11 pm
Death by cuteness

Karma: 6284
Posts: 117/598
Since: 05-01-13
Hi.

Technically speaking, the fairy type is fully functional, so that's a good point already.
Your problem seems to be of graphical order, isn't it ?
Posted by mikelan98
The ROM uses the normal-type icon for the normal and the ??? types.

I'm pretty sure this is about how the Pokedex displays the Normal-type icon for the ???-type, well there's only one solution, ASM (and I have yet to find the code).
Yep, the type icons for the Pokédex are located on folder a/0/6/8 and there's no icon for the ???-type, thus the game uses the icon for the Normal-type whenever it tries to display the ???-type.

Hey I have seen your hack thread (good thing I can understand Spanish) I have some discoveries to share, like :
_how to make a Roserade / Roselia always produce a Budew egg regardless of whether the parent hold a Rose Incense or not;
_how to make the Light Ball affects Raichu (or any other Pokémon) instead of Pikachu;
_add a functional item (for example the Pixie Plate);
if you're interested PM me
Posted on 09-06-14, 07:52 am
Death by cuteness

Karma: 6284
Posts: 122/598
Since: 05-01-13
Other discoveries by me : http://www.pokecommunity.com/showthread.php?t=335244

I, Sharks, hereby confirm to be the one who posted this thread under the nickname of MeroMero.



PS: and there's a part 2 coming.
Pages: 1