Page 41 - OSG Presents Video Game Trader Magazine #14
P. 41
To convert this into decimal we simply replace each second column displays the hexadecimal code in two
hexadecimal number with its decimal equivalent, and digit chunks and the third displays the text equivalent to
In my last article on ROM hacking add them together, so E64A will be: the hexadecimal code. We know that we need to find
the word ―1PLAYER‖ to get started, so we will go to
(E * 103) + (6 * 102) + (4 * 101) + (A * 100) Search / Relative Search, and type the word ―1PLAYER‖
= in the box (don‘t include the quotes). A box entitled
(Issue #6 June 2008) we discussed graphical hacking, (14 *163) + (6 * 162) + (4 * 161) + (10 * Data List will now pop up. This box has some useful
which unfortunately was the easy part. In this article I‘m 160) = information; it will state which line the hex equivalent to
going to discuss editing in-game text as this is how the word ―1PLAYER‖ is stored on, which will be the
translations are made. However, in order to edit text (57344) + (1536) + (64) + (10) = series of digits preceded by the ―$‖ symbol. It will state
you need to understand the hexadecimal number sys- the word we looked up, which is of course ―1PLAYER‖,
tem (―hex‖ for short). The problem with hex is that, 58954 and it will list the hex values for certain digits, which for
much like religion, it‘s inherently dull. Studies on hex Last, if we want to convert 58954 back to hex, it is eas- us is the value for ―A‖, ―a‖, and ―0‖. We will focus on the
are usually reserved for large textbooks that make a ―A‖ for this tutorial, which has the value of 41.
very loud creaking sound when opened. We are in luck, ies to use what I call the ―divide and conquer‖ approach.
however, because the subjects covered in this article will You begin by dividing your decimal number by its largest You will need to go through this procedure with each
game you edit, because the hexadecimal equivalents
place, which in our case is 163, or 4096. Therefore
only require you to understand how to count in hex; a
fairly simple task providing you already understand the 58954 / 4096 = 14.393 We are only concerned with the will be different in each game. Please note that this
concept of counting! whole number 14, so we know the first digit in our an- doesn‘t work with all ROMs because some games don‘t
swer is the hex equivalent to 14, which is E. Next we have the text stored as standard text. Now that we
All Your Base Are Belong To Us subtract our answer, 14, multiplied by its place value, know 41 represents the letter ―A‖ in ―Double Dragon‖ we
4096, from our original number 58954. This can be need to create a table file. A table file will hold all the
IBM was the first to use hex in computing (so all hate represented as 58954 – 57344 = 1610. We then take hexadecimal letter values for our game and will make
mail should be addressed to them) because it allows our remaining answer, 1610, and divide it by 162, or editing text much easier. A table file is created using a
large numbers to be represented using less digits, which 256. This gives us the answer 6.289; again we are only text editor so do not use Microsoft Word! Most people
in turn uses less memory. The common number system concerned with the whole number, the 6. So the next use Notepad, but I prefer Notepad2 which is available
taught today is, of course, the decimal system. The digit in our hexadecimal number is 6, giving us the run- for download at http://www.flos-freeware.ch/
decimal system is base 10 and consists of the numbers ning answer E6. Now we multiply 6 by its place value, notepad2.html. I prefer Notepad2 because it doesn‘t
0 – 9. Most people speculate that the reason the deci- 256 and subtract the answer from 1610. This can be automatically try to save files with the .txt extension, it
mal system is so popular is because we have 10 fingers. represented as 1610 – 1536 = 74. Hopefully you recog- displays line numbers and it has automatic formatting
On a side note, the Mayans used a base 20 number nize the pattern. We now divide 74 by its place value, when coding. The hexadecimal values for letters are
system, so it‘s possible that the Mayans liked counting 161, or simply 16, this gives us the answer 4.625, again, usually saved in ascending order, therefore if the value
their fingers and toes! While you may not have thought we are only concerned with the whole number 4, which for ―A‖ is 41, the value for ―B‖ should be 42. So in our
of it this way, the tens place in the decimal system sim- is the next number in our answer, giving us the running text editor the first line we should type is ―41=A‖, the
ply tells us how many groups of 10 are in our number. answer E64. Now we multiply 4 by its place value 16 second line should be ―42=B‖, and so on until you reach
Therefore the number 42 will have 4 groups of 10 and 2 and subtract the answer from 74. This can be repre- ―Z‖ (Don‘t use the quotation marks in the file). We will
singles. Next the hundreds place tells us how many sented as 74 – 64 = 10. Since the 10 is in the 160 place call the file ―DoubleDragon.tbl‖ and save it where ever
groups of 10 * 10, or 100, we have in our number, the we don‘t need to do anything to it except convert it to that‘s convenient for you. Just remember, all table files
thousands place represents groups of 10 * 10 * 10 and hex, which is A, and is the final digit of our answer, need to have the .tbl extension.
so on. For example, the decimal number 5842 can be giving us the final answer E64A.
represented as follows To use the table file in WindHex, with the ―Double
So that‘s it. The math lesson is over! If you understand Dragon‖ ROM still loaded, we will go to File / Open
(5 * 103) + (8 * 102 ) + (4 * 101) + (2 * everything I‘ve explained so far then you‘re well ahead Table File / Table #1 and select ―DoubleDragon.tbl‖ from
100) = of the game. If you don‘t understand it completely, the menu. You will notice that the values in your third
you‘re not alone; it usually takes people a lot of practice WindHex column will change. Now go to Edit and select
(5000) + (800) + (40) + (2) = to get these concepts down. If you‘d like more informa- Hex / Text Edit Mode. This will allow you to edit text
tion regarding number systems I recommend reading from the third column. Next go to Search à Text Search
5842
Assembly Language: Step-By-Step, by Jeff Duntemann. and type ―PLAYER‖ in the box. We were actually
I know this is a confusing way to think about the decimal Duntemann has a way of explaining number systems searching for ―1PLAYER‖, but since we haven‘t defined
system, but trust me, understanding this concept makes that is actually entertaining and simple and his books ―1‖ in our table file, it won‘t show up. The cursor will
comprehending other number systems (such as hex) don‘t make annoying creaking sounds when you open move to the first instance of the word ―PLAYER‖, which
much easier. Hex is simply a different way of grouping them. will be in the third column. Now you can edit the word
numbers, so don‘t think of it as anything else. The only ―PLAYER‖ by clicking on it in the third column and, with
difference between hex and the decimal system (other Hey, I Thought This Article Was About Hacking caps lock on, simply typing in text! However the length
than having a cooler name) is that hex is a base 16 Now we can finally get to some hacking! Before we get of the text cannot exceed the length of the word you are
number system. Hex consists of the numbers 0 – 15, started I would like to point out that RomHacks.net, replacing.
represented as 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, A, B, C, D, E, specifically http://www.romhacks.net, was an invaluable
F. Therefore, if I write the number B in hex, it means the resource when creating this tutorial and I recommend I have replaced the word ―PLAYER‖ with the word
same thing as 11 in the decimal system. Furthermore, if anyone interested in ROM hacking go there and check it ―GOOBER‖ and now that were done we need to save
I need to represent the decimal number 16 in hex, its 10, out. the ROM with a new name. Go to File à Save File As
and decimal 17 in hex is 11, and so on. Pretty easy and type the new name of the ROM in the menu. I‘m
going to use the name ―DoubleDragonGoober.nes‖. It‘s
huh? Now consider this, if I were to write the hexadeci- In order to hack the ROM text we will use a program
mal number E64A, it can be represented as follows: called WindHex, which is available at http:// important to remember to use the proper extension
www.romhacks.net/tools/WindHex.zip. WindHex is a when saving your game, which is ―.nes‖ for us.
(E * 103) + (6 * 102) + (4 * 101) + (A * 100) program that will display the code used in our ROM in
= hexadecimal format. So what we need is a ROM which Last it‘s time to open the ROM in an emulator and check
it out. After opening it, I can see the player selection
has some text we can change and that text should have
(E000) + (600) + (40) + (A) = screen now states ―1GOOBER ―, which means we have
the letter ―A‖ in it. Luckily this is pretty common because successfully hacked the text in ―Double Dragon‖!
E64A most games have the phrase ―GAME OVER‖ in them
somewhere. In this tutorial, I‘m going to hack one of my That‘s all there is to hacking the text in a ROM, just
(Just remember your calculating this in hex, not decimal, all time favorite games, ―Double Dragon‖. ―Double remember that you are not limited to upper case letters
so the 10 is equivalent to 16 in decimal) Dragon‖ displays the word ―1PLAYER‖ on the opening for your table files. You could also find the values for
screen, so we have the ―A‖ we were looking for. the numbers, punctuation and white space, which can all
The process of converting E64A to decimal isn‘t too be stored in your table file. That wraps up this article,
complicated so let‘s look at the beginning of our equa- In order to hack this game, in WindHex, we will go to now get hacking!
tion: File / Open File For Editing and select ―Double Dragon‖
from the menu. You will notice three columns displaying
(E * 103) + ( 6 * 102) + (4 * 101) + (A * different types of information. The first column is the line
100) number (which is used to help locate information), the
www.VideoGameTrader.com • Winter 2009/2010 • Issue #14 • Video Game Trader Magazine • 41