top of page

FEBuilder Primer V - HEX

What The Hex??

Hex Chart

Hexadecimal. It’s one of the most fundamental ways to view and edit binary data in programming out there. And what are video games if not programs? It should come as no surprise, then, that the Fire Emblem GBA games can be edited extensively via the use of a Hex Editor. You may be tempted to say “but what’s the point of editing hex in 2018? We have FEBuilder now!” To which I’d have to say:

Hex is the basis of ROM data. If you understand hex, you can understand what FEBuilder is doing and the limitations of your ROM. And knowing hex for the (few) things that FEBuilder doesn’t yet do can make the difference between making your dream hack come to life or not.

Scooby Hex

So, now that I’ve spewed jargon and technical terms for a paragraph or two, if any of this sounds foreign, please check out my earlier blogs, where I introduce Fire Emblem, hacking, and the rest. For the rest of you, let’s dive into the world of hex.

Learning By Doing

Baby Paint

For anyone that isn’t familiar with hex editing, I’d highly recommend following along with the rest of this blog with hex editor in-hand. Do some searching and looking for what I reference ahead and you’ll be that much more comfortable and familiar with the concept of hex editing. As far as external applications go, I can’t recommend HxD enough. I’d download and link it to FEBuilder via the “Options” menu whether you want to use FEBuilder’s Hex Editor or not.

For those wanting to practice FEBuilder’s Hex Editor, please open that through the advanced tools page now. The easiest way to find it is by typing “hex” into that handy search bar at the top.

FEB Hex

The Hex Factor

Hex Factor

So at the very top I made a chart that breaks down what hex is, how it compares to binary, and the value attached to each digit. One of the first and most important things of note is that hexadecimal is 16-base, making it much simpler to understand and smaller to look through than the comparable 2-base binary. All you need to remember for this is 0-9 A-F, in that order.

A single binary digit is called a bit, but the smallest form you will use while hex editing is a byte. A byte is comprised of eight bits and is displayed as two hex characters, side by side, for example AA. This results in 16 x 16 or 256 possible values held in a simple two digits! The same value in binary requires 9 digits and is made up of only 1’s and 0’s. Yuck!

10 people

Just look at the chart above if you don’t get this joke

The next smallest scale is a half-word. Half-words are two bytes like DEAD (like how I feel inside), for example. Half-words are even larger and are sometimes used to reference lists in Fire Emblem with a total possible of 65536 values! The portrait list is one such example, although it skips one set of 256 if I’m remembering correctly. Portraits are called (in reverse order in the code) as [00][xx] and then [02][xx] and up from there.

The next size reference is a word. Words are four bytes and are a very commonly used hex form, as every pointer in these games is a word in the form of 643d8008. Pointers are exactly what they claim to be: pieces of data that point to another location in the ROM. The 08 is the pointer aspect: this is what tells the ROM to look for your data in another place. FEBuilder handles A TON of this for you, but if you ever utilize a Hex Editor, you’ll see data in this form, and you’ll see it often.

As a quick addendum because most of us will be adding our new data to unused ROM space after the first 16MB: pointers beyond this actually use 09. So if you’re trying to point to data past 1000000, it will be pointed to with an 89/09. Think of it as adding 88 or 08 to 01. FEBuilder adds 88 to the last byte with expanded data so we'll stick with that, though I think adding 08 is acceptable, too.

The Beginning of the Endian

Let’s blast into our search function for a moment and try to find the pointer I mentioned above: 643D8008. Click the “Search” button (or type cntrl-F) and search with “reverse” selected (I’m not sure why you have to enable “reverse” for this result to show, but if you leave it unselected you won’t find a result) in FEBuilder’s editor and we’ll see that it’s highlighted our search, located it on a 16 byte line, and notated exactly what bytes of that line are involved in the party. But where is it pointing to?

Hex Editor Search
Address
Bytes

To figure out where it’s pointing, we have to reverse what is known as little endian. Start by separating our word into its individual bytes:

* 64 3D 80 08

Next we’re going to subtract 08 from the final byte because its only function is to serve as a pointer.

* 64 3D 80 00

Now we reverse the order:

* 80 3D 64

And 803D64 is the offset (or location) where our pointer’s data is located.

Let’s now build a pointer to expanded data. If you followed along with my character editor post, you should have something added at offset 01000000.

Split into Bytes

* 01 00 00 00

Reverse the order:

* 00 00 00 01

Now add 88:

* 00 00 00 89

And our pointer to this specific data is 00000089.

Back to our other offset, now that we’ve found it, it’s time to go to it. Click that “Jump” button and copy paste the three bytes 80 3D 64. Hit enter and we’ve found the start of our data. In this case, it’s the start of the Character Editor of FE8U.

Jump

So we don't have to hassle to find it next time, let’s “SetMark.” The first byte selected will turn red and be added to a list (a MarkList, if you will) of saved bytes that you can hop to at any time. This can be very useful for remembering the offset of a bit of code you really don’t want to forget.

In case anyone’s having trouble with Jump and Search; they differ from each other in what they search for: Jump searches for Offsets, Search searches for blocks of code. While Jump will always go to the same offset, search can find multiple offsets matching the values you’ve provided. For example, if a line of text is pointed to several times, we can repoint that text by using search and replacing the bytes with a new pointer without searching for each individual offset that this data occurs at.

What Do I Have to Sign Now?

One last principal of hex I’m going to touch on is signing. Signed hex sacrifices half of its numerical value to the dark side.

Dark Kermit

Well, the negative side anyway. If a piece of data is unsigned, it can never go negative. An example of a signed byte would be stats like HP, ATK, SKL, SPD, etc. Aside from HP, these have additional limitations that knock the maximum of 127 down even further, but all can have negative values in, say, the Character Editor to reduce a character's base stats beneath the base stats of their class. Knowing what is signed and unsigned can help you plan your edits accordingly.

Bring it Together

Let’s end this out with the most likely reason you’ll be using the hex editor: copying code to an offset. There was a question earlier this week on FEU about removing S-Rank limits in FE8U. I’m pretty late to the party at this point, as Attila already made an excellent YouTube video on how-to insert the

  • code of: “11 E0” at

  • offset 0x2C150

AND 7743 added a patch to FE8 to edit this in with a single click now!

Still, let’s do this for practice in case another hack isn’t FEBuilder-Equipped yet.

In FEBuilder’s Hex Editor, let’s “Jump” to 2C150. The first byte that we need to edit will be highlighted. In some Hex Editors, you’ll have to be careful here, as pasting won’t just override the data, it will PUSH the data backward. This is bad bad bad and will break your ROM. In those Hex Editors, ensure that you are overwriting and not inserting your copied code.

In FEBuilder’s Hex Editor, we don’t have to worry about that! It overwrites by default. Without further ado, let’s copy paste 11 E0 at our offset. There’s one last thing to do: Write!

Hit that highlighted Write button so all your hard work pays off and now we can S-Rank everything!

Hoo Rah!

You’re a Hex Machine

Hopefully... Maybe? I have to say that I find many less issues running HxD compared to FEBuilder’s Hex Editor, so I’d really recommend it (again), but HxD is lacking in one very valuable area: documentation. When you’re browsing through the code in FEBuilder’s Hex Editor, you’ll notice text filling the bar at the bottom. This text tells you what you’ve selected, and which byte you’re on if it’s a multi-byte grouping. This can be really useful for ensuring you’re in the right place.

Well, that’s it for this one. Once again, I’m well above my desired word count, so I apologize for that. Hopefully it paid off and hex editing makes a bit more sense now. What do you think, will you try hex editing now? Do you feel more comfortable with the idea, at least? Let me know in the comments. Until then, I’m Shindad the Great, and you’re pretty awesome, too.

bottom of page