Palette Modifications of an NES file using a Hex Editor

written by ~* aStROcReEp 2000 *~ (that's ME!!!)

*** For a text version, click here


NOTICE : all thanks go out to Zelan at the ROM Hack page for his original
documentation on this process...this text file here was written merely
to help him better explain things to his page's visitors, but I have decided
to release it here also, since his page is no more (thanks to all the whining
cry babies who couldn't keep their mouths shut about how he should run HIS OWN
DAMN PAGE...)

 Welcome all! Yes, the same person who brought you the "Dummy guide
to NES emulation and using the NESticle emulator", as well as "Hacking
Your Way to Super Stardom with NESticle", is now bringing you a text file
on how to modify a specific game's palette! Why do you want to do this,
you say? Because every game has a pre-set amount of colors it uses, and
often times once you've hacked a game, some of these colors don't match
what you're trying to do! Color conflicts in hacking happens often! Also,
graphics that have been cut and pasted from different games use totally
different palettes and cause the new game to look odd (as in Metroid
Mario). So that's why you need this text file!

     First of all, you need a Hex Editor program. I suggest Hex Workshop
(though Windows95 is required for this particular program). You can down-
load it at the following URL :

Hex Workshop - latest addition (tons of mirror sites to download from)

Look at the right and click on where Windows95 is highlighted in hypertext
link underneath Download. This will bring you to a new screen that takes a
while to load but retrieves ALOT of locations from where you can download
this fab program. Download the file, run it, and it will install the program
to your hard drive.

     Now that you're ready with your hex editor, here is where things get
rough. Open up the Hex Editor program from within Windows. Now minimize it.
Trust me. You'll go back to it later...for now, just click on the horizontal
bar in the upper right corner to minimize the window. Now, open up your
NESticle emulator and load the ROM into play. Get to where you can see the
sprite you want to modify. You may want to pause the game. Make sure you know
exactly which color of the sprite it is you wish to change.

     Click on Settings from the menu bar, then click on Palette. Or, just press
F4, either way. It should bring up a rectangular window, 2x16. Each box in this
window represents a color the game uses for certain sprites, etc. Yes, there will
be multiples of many different colors. Some sprites even share colors. Don't worry
about that. Just look at your window as being 8 sets of 4 sets of 4-part rectangles.
In example, this is what the palette looks like and what each box means :
 
 

0 1 2 3 4 5 6 7 8 9 A B C D E F
0 1 2 3 4 5 6 7 8 9 A B C D E F
 

The top row is background colors, the bottom row - sprite colors. So
find what you need to modify. For example, let's say the color you're
looking to modify is the one on the bottom row labeled A. This is called
Sprite Color A. Now remember this is set up in pairs of 4. So 0-3 all has
to do with one sprite, 4-7 with another, 8-B with a third, and C-F with
the 4th. Well, A lies within the 8-B range. So you'll need to know what
each color in that range is. Click on color 8, and write down what number
you get (16, 30, 27, whatever...) where it says Sprite Color # XX.

     Do this for each box in the range. Make sure to keep tabs of each number.
And make sure to remember which number goes with the color you're modifying.
Now, re-write the set of numbers somewhere else. Click on the color you want to
the modified-to-be color to become, and obtain the number of that color. For
example let's use the color A example. Let's say box 9 of that row has the
color you want to use in place of color A. Click on box 9 and get the color
number from the Sprite Color part of the new window that is opened. This will
be what you will want to write down in place of the old color, wherever it was
you wrote down the set of numbers the second time. Now is where the hex editor
comes into play...

     Yes, this means go back to your Hex Editor program through your Windows
multi-tasking capabilities (i sure hope to God you've got Windows95 with the
smooth taskbar to click on to make it all easy...otherwise, just use the infamous
ALT+TAB combo)  With the hex editor, use the menu bar commands to "Open File"
or click on the open folder icon...and show the bad boy where the NES file is
corresponding to your hack.

     Use your Hex Editor to do a search. The command will most likely be
"Find" and represented by an icon of a magnifying glass. Click on this
icon or use the menu bar to find the "Find" command, or "search", or
whatever. What you're seaching for here is a string of numbers correspond-
ing to what you wrote down the first time. Let's say the first time you
ended up writing down 16, 22, 27, and 30. So your search would be for
16222730. Yes, it must be like that, Hex Editors look for things that way
because that is how Hex is written. Whenever it finds a group of numbers
containing that string, it will let you know by highlighting it or something
to that effect. Also, it helps narrow things down more if you can use the
corresponding numbers of other colors around the set of 4.

     You're almost done now!!! Just use the menu bar to find a replace
command, and click on Replace. When it asks you for a string to replace
the old numbers with, type in the new numbers you wrote down the 2nd
time!!! Just like the first time, all as one long jumbled string with no
spaces. Save your work with the save command (or an icon represented by a
disk) and that's it!!! You've done it!!! Go back to NESticle and load the
ROM image to test and be sure that changes were made...

     If you happen to get a "search string not found error", then here is what
happened and how to fix it. Let's use the example above. You searched for
16222730. Well, sometimes, it will happen to be that the 1622 is at the end
of one line of hex and the 2730 is at the beginning of the next line. There-
fore, hex cannot recognize your search because of how it is read. How do you
fix this? Just modify your search by shrinking it down some and then getting
specifics later.

     In the example above, let's say you decide to change your search to just
1622, since 22 is the color you want to change. Well, you'll notice that you'll
more than likely get multiple results if you keep clicking on FIND AGAIN...So
check each result to see if the next line of the SECOND COLUM ONLY contains the
2730 you wanted. This way you can know for sure that the 1622 corresponds to the
game's palette and not some other part of the game :)

     NOW once you've narrowed it down to specifics from using a broader search,
use the Replace command and replace the set of numbers in the FIND box with the
same set of numbers, only replacing the 2 numbers/letters corresponding to the
color you wanted to change with the 2 numbers and/or letters of the color you
wanted to change it to. Save all changes you make with the icon represented by
a disk (or Save under the File section of the menu bar) and IT MIGHT BE A GOOD
IDEA TO MAKE A BACKUP COPY ALSO, in case the changes you intended did not come
how you intended, or had wrong effects.

     Now, you should be done and ready to play your newly modified game! Just
load it with NESticle and go to it!!! If you ever have any questions or problems
concerning the procedure explained in this document, ALWAYS feel free to e-mail
me WITH A COMPLETE, DETAILED, ELABORATE description of the
problem. I'll do whatever I can to help :) It's especially good to let me know
what game you're modifying and what you're trying to modify, I may be able to do
it in my own time and get back to you.
     Also, feel free to distribute this document fully and freely to any and all
persons who might need it, just make sure you do not change it in any manner unless
credit is thrown in both mine AND Zelan's direction (for his original document).
Last, but not least, if you think you can do a better job of explaining it - GO FOR
IT. AND LET ME KNOW. Thank you, good evening, hold on to the bars, hands inside the
car at all times, and exit stage left when the ride is over. ;)