Tuesday, April 14, 2009

Text Hacking/Translating

A few weeks ago I made a nice breakthrough on text hacking, as I think I mentioned somewhere earlier. Though it wasn't my initial goal when setting out that week, I think it's a valuable skill to have that can have quite a bit of power to it. The process itself, however, not so user friendly. Or rather, just a pain to go through. I'll try to explain it as simply as I can.

All of the text in a game is stored as hex data. Basically, each character is assigned a graphic tile, and a hex address will bring up that graphic to create words. Our first objective in text editing is to find out what hex symbols which character. You can basically think of it as cracking a translation code. I start off by finding a very specific word or phrase in a game, one that will probably only appear once. In this case, I'll translate the word "battle" from Mario RPG.

1. We have to start somewhere, so we can hypothesize that "01" is equal to "A". Thus, "02" would be "B," "03" would be "C," etc. all the way up to "1A" for "Z" (Remember, we're working with hex, so after 09 would be "0A, 0B, 0C," not "10, 11, 12"). After we have our alphabet-to-hex key, we can translate the word "battle" as 02-01-18-18-0c-05 in hex. This isn't to say that the programmers in Mario RPG chose "01" as "a" and "02" as "b" etc. However, there is a relative change in hex value to the word "battle" regardless of where "a" starts at. Using a program called Windhex, there is a function called "relative search" that does all the hard work for you. If you load up a Mario RPG rom and do a relative search for 02-01-18-18-0c-05, it will go through all the possible translations of that pattern, and if you did everythign right, it will tell you what your "b-a-t-t-l-e" values are, giving you enough information to decode the alphabet for Mario RPG. Also, be aware of capitalization, because they do affect the result. If the original word you looked at was "BATTLE" as opposed to "battle" or even "Battle," you will get two different character sets (one for capital letters and one for lowercase, obviously).

2. Now that we know what characters represent what in Mario RPG, we have to make what's called a table to translate the hex to alphabet. This is exactly what it sounds like, and the program that I found to be the simplest was TaBuLar. Just go in and fill in what your table should be.
You can save from TaBuLar to a .TBL file for thingy.

3. When you start Thingy you are asked for a rom location and a .tbl location. If you load both, you'll see on the right hand side a translation of the hex and voila, you can go about editing the text as you wish. A little bit of a roundabout way of doing it, but it works. Pretty simple right? Well here's the best part.

Personally, I can't stand Thingy's GUI and just overall design, and it hurts my head to look at it for more than ten minutes. So I switched to a different Hex editor that I happened to stumble upon during my various endeavors: Translhextion. Translhextion lets you edit hex in a rom, save it, and it can also read Thingy .tbl files. But wait, it gets even better. Turns out Translhextion has its own relative search function, which, if it finds what you're looking for, will automatically translate the hex to english characters. And even more, you don't even have to do that original "hypothetical" translation like in step one. If you type in the word "battle" it will do the rest of the work for you. all with the press of an enter key. Sweet, right?

So what was the point of all that other garbage I just went through? Well, it was actaully a great way to understand it conceptually and poke around various pieces of software. It kind of does take the glory out of doing what I was doing, but after using that original method a few times, I am quite glad to say that I happened to notice that feature in Translhextion, because it's saved me hours of work now. Radical!


No comments:

Post a Comment