Re-posting the tutorial here in full from the
discord messages, since not everyone who came here from google is on the discord server:
My first step was getting the icon itself, onto the type chart. this was simplest with Hex Maniac Advance, so open a firered rom in the latest version of that program. Adding the fairy type for binary is made simple because that program has a simple drag and drop method for adding it. So do that in HMA to add the fairy type to the vanilla rom, (or make your own).
Once thats done use the goto menu (CTRL G) input type.icons and then press enter, that will bring you to your type chart image. Export that and save somewhere easy to get to. (if you're planning to add multiple types you'd need to expand the image first, only ever touch the height, and make sure its divisible by 8. Expanding the image in HMA is as simple as changing the 3rd number in the top bar. defualt is 4x16x16 most people will only ever need 4x16x24.)
Now after you've exported your image you'll need HMA for one other thing, and that's knowing the coordinates of your new type within the image. use the goto menu again, but this time input type.map and then press enter.
This takes you to the coordinates within the image, now if you want to compare the numbers here with the picture you had before, just press that image tab to the left and you'll be able to see your image instead of that left menu.
There's a whole methodology to understanding how the coordinates are setup, and you need to know that the order of the types within the image
isn't the order of the types within the roms, but HMA makes it simple so you can just find where it says FAIRY, and just click the values in parenthesis. in HMA most formatted values are shown in decimal but for our purposes what we need is the hex values. But that's easy to get, once you've selected the cell I mentioned you can see the hex value for the selection in the bottom right corner. for me that's the "08 00"
Now I don't know the name of the method for rearranging the value, here but in your pokefirered the values will need to be in "0x00" format, so my value is below FF it only takes the first byte shown there. For those its simple, I just put a "0x" in front of whatever byte value is shown at the bottom. So mine in the decomp file was "0x08" (that's because my type was added at the top, instead of the end of the chart) If you add to the end your value will be above FF so 2 bytes.
Luckily I have another type added, that one was 00 01. (one more than FF) so for values like that, you take reverse the numbers, so you put the 01 in front of the ones on the left and read it that way. If the second byte was in the single digits, I usually think of it as remove the 0 in front of the value, and then reverse it. Done that way you can see you get 100. So for a 00 01, the hex value is 0x100.
Step 2. Moving on, keep hma open, but you're not going to need it for a while. The next step is replacing the type chart image in the repository with the exported image you created, and making sure it has the correct pallete for your new icon. Presently HMA doesn't have a way to export indexed pngs (which is what's needed for your repository to build correctly) That's where graphics gale comes in.
But before that open your msys2 compiler and run this command I was given from the root folder, this will create a new type chart image, with the correct palette, (before this it was just a monochrome image that I couldn't work with at all) I believe you don't need to delete the original image beforehand. Here's the command.
Code:
tools/gbagfx/gbagfx graphics/interface/dex_caught_pokeball_and_pokemon_types.4bpp graphics/interface/dex_caught_pokeball_and_pokemon_types.png -width 16 -palette graphics/interface/pokemon_types.gbapal
It's all on one line, so all you need do, is copy and paste that whole thing into your msys2 compiler in your rom master folder (for anyone else reading the paste command is SHIFT INSERT) Also when I keep saying msys 2 compiler I'm talking about the Windows Batch File, in your msys 2 folder. the one named msys2_shell
So more quick info for those not in the know. you use the cd command to change directories(move to different folders) type cd then press enter, to make sure you start at your home menu. (which is usually your "username" folder. if you need to move into a folder that has two words as its name just put the folder name in quotation ex. "New Folder"
But if you setup your decomp stuff correctly, you should have it right there in your username folder so this step should be as simple as typing cd pokefirered (yes you need a space between cd & the rom name also while I'm at it, if you check pinned messages above, follow lunos' tutorial on setting up with msys2, if you need more help on that.) after that its as simple as pressing SHIFT INSERT to paste in the code I have above and then pressing "Enter"
Step 3. That will create the image in the folder. To find it open your pokefirered folder goto graphics then interface, the file you're looking for is
Code:
dex_caught_pokeball_and_pokemon_types
Now open GraphicsGale and open that file in it. Also open the image chart you previously exported from HMA. All we need to do here is copy the image from the exported file into the one from our repository. Luckily that's really simple, right click the the top of the imagea window of the exported image select copy, Then right click the top of the dex_caught image and select paste.
you're done. save. Close GraphcisGale (if you expanded your image you need to make the dex_caught file the same size before you can paste into it. [also when you add an image to GG its really squashed so you'll need to drag the bottom right corner to expand them a little first, before you're able right click it] To expand the dex_caught file click it, then in the menu above click "All Frames" Then click "Enlarge Canves" like I mentioned earlier we never touch the width here the height is shown in pixels to convert it to a recognizable dimmenssion divide the height by 8. that should give you 16. So for example if your expanded image was set to height 24 in HMA, multiply that by 8, and you'll have the value your height needs to be here.
Step.4 Ok now that the image stuff is done, the data is actually there for the new type, all we need to do from here, is to make some code adjustments so the game will no where to look. It's pretty fast from here, I think we only need to edit like 6 files. Those being
battle_main.c & battle_main.h, pokemon.c &
pokemon.h (the one from the include/constants folder) ,
list_menu.c, battle_message.c,
graphics_file_rules.mk, &
type_constants.inc, hold_ effects.h & base_stats.h for applying the type to pokemon.
Step.5 I think that's the essential stuff, by changing those you'll be able to have type effectiveness and have your icon show up in all relevant menus, (this doesn't cover the tms though as I'm still figuring that out. Pull up HMA again for your coordinates, then open
list_menu.c and go to
line 75 the side comments let you know what is what, but comparing to HMA its pretty clear what you need to add, make a new line at the end in the same format as the rest, put in 32 for your width and 12 for your height, then use the hex value found earlier for your coordinates. Like I said for mine its 0x08. Now in the below Image I have my file screenshotted where I made note of certain things, that can cause issues, while its not listed in the actual types if you look at the type image you'll see there are other icons there besides the them, listed directly afterwards, if you just count normal types and your new type value in after dark as 0x12
it'll be wrong you need to count the additional types and list yours after like I have mine below in the comments (ignore different dimmensions for my icon, that's on purpose just 32 for yours.)
Step 6. Adjusting the other files, open graphcis_file_rules.mk goto line 28 add fairy to the end of the types listed. Next open include/constants/
pokemon.h goto
line 95, here's where you define the type. Add FAIRY to the list under the dark type, (same format) but make sure you list fairy as 0x17 like I showed from the link above. Then change the number of types from 12 to 0x13.
Step 7. Open battle_message.c, line 1276, here type is referenced in some string, not sure what its for but, I created one for fairy, you can just copy paste this in either at the end or under the dark type like I did.
Code:
const u8 gFairymovetype[] = ("a FAIRY move");
Open type_constants.inc, add FAIRY to the end, and again make sure the listed value is 0x17. That's most of the work done, finally we handle
type effectiveness open battle_main.c can't give a line name since my edited file is very different, but search for "gtypenames" and in the same format as the others add fairy to the bottom.
Next go up to line 312, this type effectiveness, put in what you want here, if you want the same as in game use these values from pokemondb
https://pokemondb.net/type/fairy
Now that value on line 313, that says 336, I believe is meant to represent every possible variation of the options written there. That number is the number of entries in the array, multiplied by 3. (That's either No Effect, Super Effective, or Not Effective the three options seen in that array)
When you're done subtract the line that end table is on from the line 313, where the open brackets is, then multiply that by 3. To get the new value you should replace 336 with.
Finally go to battle_main.h we need to put that same number in on line 60, so it matches. That's all the necessary changes to get the fairy type to show up in your menus. Other optional stuff is going to hold_effect.h and adding "Fairy Power" to the list for a fairy boost hold item. you can just paste this in at the end
Code:
#define HOLD_EFFECT_FAIRY_POWER 67
And that's it, you can follow the same process for adding any type, but you'd just need to create the icon manually in HMA instead of relying on the paste script.