News:

The forum has been updated to SMF (2.1.3)!
Please be patient as we work to polish up the place and update features as we can.

Main Menu

[Tutorial] Fox's Icon Compresor

Started by Caledor, 29, October, 2015, 09:04:31 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Caledor

Hi guys. This small tutorial will show how to make new icons using Fox's Icon Compressor (download from here, in the attachment)

What you'll need:
- Visual Boy Advance-M
- Golden Sun Rom
- BACKUP of your Golden Sun Rom
- Hex Editor
- Atrius' Golden Sun: The Lost Age Editor
- Fox's GS Icon Compressor

Preparation
I'll start by making Boon by editing Ply so i'll use Mia in her base class for this tutorial.
Download GS Icon Compressor, open it to view its content and look for gsiconcompressor.exe here: "gsiconcompressor\gsiconcompressor\bin\Release" (there is no need to extract the whole folder cause that file in the only one we need). Extract it somewhere (Desktop?).

Open your Golden Sun Rom in VBA-M. Enter the status screen, select a character by pressing A twice, in order to make the psynergy screen show.  Once you're in the right screen, from the tools menu open the Palette Viewer, the Tile Viewer and the Memory Viewer. From the Tile Viewer, select 0x6010000 under "char base": you should see the psynergy icons split up horizontally somewhere in the small screen in the upper right corner. Click on the first one from Ply and it will show up in the bottom-left screen. Copy the address shown in the Tile Viewer and paste it into the Memory Viewer.

Your screen should look something like this now.

From Ply to Boon
If you understood everything until now, you're more than halfway done, cause now comes the easy part.
HERE you can see that the only difference between Ply and Lord Squirtle's Boon is that the 3 small light blue particles become purple (download the gif and zoom it a lot to check). From the Tile Viewer, we know that light blue corresponds to the digit "7", while purple is "9" (see pic linked above). This means that if you change the three "7"s to "9"s inside the memory viewer, the blue particles will become purple (since those 3 particles are the only light blue pixels of the icon, we don't even have to worry that we change something else by mistake)! Do it and click on the VBA screen to see the change! (here's how it should look). The icon editing is done, but now we need to put the new icon back into the ROM.

Saving the icon
Saving the icon means dump the bytes from the Memory Viewer. Click on "Save". The "Address" is the address from where the dump starts: it has to match the start of the icon, so it's the address of the top-left corner of the icon in the Tile Viewer (the same one we pasted into the memory viewer). "Size" is always 80. Save it in the same folder of gsiconcompressor.exe.

Compressing the icon and putting it back into the ROM
First, make a backup of your dump. The compressor overwrites the input file so, in case something goes wrong, you won't have to start from scratch. Drag the dump into the compressor, and after ~1 second you'll have your compressed icon, ready to be put back into the game.

Now, open both your Golden Sun ROM and the compressed dump with an Hex Editor (I use Hex Workshop). We need some free space where we can put the icon into. Usually there's a lot of it near the end of the ROM. I'll use the space from "00FA0000" onwards. Within the Hex Editor, copy the whole hex part of the icon and paste it at 00FA0000 into the ROM. BE CAREFUL: Do not add nor remove bytes from the ROM. You have to overwrite the bytes! If you make the ROM bigger or smaller here, it won't work anymore! Check its size before and after you've pasted the dump into it! Result

Okay, so now we have our new icon into the ROM, so the only things left is to tell the game to use it. Open your edited ROM with Atrius' Editor. From the abilities screen, click on a random ability and then on its icon. Sadly, there's no free space to add new icons but we can replace an unused one (Magnet, Reflect or Arrow). Let's replace Reflect: count the icons, and you'll see that reflect is the 94th icon of the list (start counting from 0). Remember that number.

Open your Edited Rom with the Hex Editor again and go to the address 00054A14. This is the where the Ability Icon Pointer Table starts. Each sequence of 4 bytes is an address that tells the game where in the rom should look for the icon, stored in little endian (single bytes, each made of 2 digits, are in reverse order), with a 08 in the beginning (you see it at the end of it due to little endian) of the address. But how do we know which address is the one for Reflect? It's simple! Remember that Reflect was the 94th icon? Each address is made of 4 bytes so 94*4=376, which in hex is 178 (Windows' calculator can easily do these conversions). Now, since the table starts at 00054A14 (it's the address of the first ability icon, the red X), if we add 178 to it we'll have the address of the Reflect Icon. Our address is 00054A14+178 = 00054B8C.

We have to overwrite the 4 bytes at 00054B8C with the address of our new icon (remember? 00FA0000), but first we must add a 08 at the beginning, and convert it to little endian. So 00FA0000 -> 08FA0000 -> 0000FA08. Write 0000FA08 at 00054B8C (again, do NOT add nor remove bytes: overwrite them).

Before --- After

Congrats! Now you can open your ROM with the editor and use your new icon for any ability as normal!

For item icons
The process is IDENTICAL, but the item icon pointer table starts at 0004EB58 instead.

PS Tell me if something is wrong, not clear, etc... it's the first tutorial I've ever made :P. As for grammar or syntax blunders, tell me about those with a PM instead of replying here and i'll fix them, so we can keep the thread clean.

Daddy Poi's Oily Gorillas

#1
Looks good....

The only one piece of info I can imagine noting is that if you have VBA, I'd say you already have the only hex editor you would need. (The memory viewer.)  While changes in memory viewer are only temporary, you can still save a dump of the entire ROM to your hard drive from it, and rename .dmp to .gba.  Maybe it is the lazy method, but it works wonderfully!

Basically, ROM data in the memory viewer is:
GS1=0x08000000-0x087FFFFF (8 MB)
GS2=0x08000000-0x08FFFFFF (16 MB)
(...with mirrors at 0x0A000000 and 0x0C000000... Never seen those used before... most likely unused in most games..., but I think those are for different wait states...?)

GBA ROMs can be a max filesize of 32 MB (0x08000000- 0x09FFFFFF), I think, and easily expandable by just adding data to the end of it....
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)


Caledor

#3
Sadly, there's nothing i can do about those, Kyle...

@Fox: Of course that's an option, but i'd never use the memory viewer as an hex editor. It's too unrefined and lacks a lot of functions proper hex editors have.

Daddy Poi's Oily Gorillas

#4
I agree with that, but I just thought it'd be quicker to access when you need it for something basic as this.

An actual hex editor program for searching for specific hex values would be needed, in some cases, I'm sure. Some of them don't even allow you to display the data the way you want to... Like Windhex and HxD... You see it in byte format... and I don't think you can switch to 16-bit/32-bit little endian. (While HxD does do 16-bit and 32-bit,  I think it's only limited to big-endian?)

Anyway: Here is the next version of my program that should convert actual image files of the icons, not just dumps. (Make sure you are using the valid 15 colors, or else you will get transparent color.)

New file no longer replaces the one you used... it is now named iconout.dmp.

I only tested this with some of Role's .png icons... like the FlameEdge.png icon... However, it should support .bmp, .gif, .jpg, and .tif, as well.

Unused bits at end of compressed data are now turned on like original format.


Edit: At first I had a problem getting FlameEdge.png to work, but then I found out it wouldn't load in Paint.NET either... so then I had to go and download the media directly on photobucket, unfortunately.
Golden Sun Docs: Broken Seal - The Lost Age - Dark Dawn | Mario Sports Docs: Mario Golf & Mario Tennis | Misc. Docs
Refer to Yoshi's Lighthouse for any M&L hacking needs...

Sometimes I like to compare apples to oranges. (Figuratively) ... They are both fruits, but which one would you eat more? (If taken literally, I'd probably choose apples.)
Maybe it is over-analyzing, but it doesn't mean the information is useless.


The only GS Discord servers with significance are:
Golden Sun Hacking Community
GS Speedrunning
/r/Golden Sun
GS United Nations
Temple of Kraden

Can you believe how small the Golden Sun Community is?

2+2=5 Don't believe me? Those are rounded decimal numbers. Take that, flat earth theorists! :)