Maco
learning the ropes...
- 72
- Posts
- 14
- Years
- Sydney, Australia
- Seen Aug 3, 2010
After looking through every tutorial I could find, each with their own confusing text and some with incomplete steps, I've decided to make my own guide to replacing Pokemon sprites for the GBA generation. I use Photoshop for any spriting, and the ROM is FireRed, so this guide is focused on that.
Tools you will need:
Tools you might need (if not using Photoshop):
What we are going to do:
General Knowledge and Definitions:
Part 1: Locating and exporting a sprite
Part 2: Colouring and indexing the sprite
Part 3: Finding Free Space
Part 4: Importing the New Sprite
Well I sincerely hope this guide works for you. I've tried to integrate the theory of inserting sprites too, instead of just putting up instructions. If you like this guide or have any comments feel free to drop me a message sometime, although I am quite busy at the moment so I mightn't be able to reply.
Special Thanks
...to HackMew, Deviation and other forum members for answering my own noob questions, and for various guides. Thanks to HackMew again for his great toolset too.
:bandit:
Before Starting
Tools you will need:
- A graphics editing program.
The most popular program for this is Microsoft Paint, simply because it comes for free with every copy of Windows. Personally I do not recommend it because it is a very basic program, and not that easy to use. I use Photoshop, simply because it is the best graphics editing program money can buy. A decent free alternative is Graphics Gale. (link) - unLZ GBA (link, scroll down to it).
This little program reads through your Pokemon ROM and displays all the compressed images within the ROM. It also can replace compressed images within the game. (Compressed means that the image file is shrunk in size to save space on the ROM). Every Pokemon sprite and trainer sprite is compressed in the GBA ROMs, so you will need this tool to edit your Pokemon. - Free Space Finder (link, scroll down to it).
This program does what its name says: it finds free space in your ROM. If your new sprite is bigger than the original sprite, it is impossible to write over the original without ruining the rest of the ROM. Instead, we can write the new picture into the empty space, and tell the game to use that image instead of the original.
Tools you might need (if not using Photoshop):
- IrfanView (link)
This program is primarily for indexing your new Pokemon sprite. I will explain what indexing is and how to do it later in the guide.
Overview
What we are going to do:
- Use unLZ to locate a sprite in the ROM, and export this sprite so we can edit it.
- Properly colour and index the new edited sprite.
- Use Free Space Finder to find a suitable location for the new sprite.
- Import the new sprite into the ROM and replace the old one.
General Knowledge and Definitions:
- A sprite in a ROM is made up of two parts: a palette and the indexed image itself
- What is indexing?
In our case, the second matrix is in fact our palette.An indexed image stores an image as two matrices. The first matrix has the same size as the image and one number for each pixel. The second matrix is called the color map and its size may be different from the image. The numbers in the first matrix is an instruction of what number to use in the color map matrix.- A palette is just a file that contains the colours to be used in the indexed image. For the Pokemon games, a palette can only contain 16 colours. This means your edited sprite can only use 16 colours (one of which must be the background colour, so only 15 usable colours in the palette).
- For Pokemon sprites, the image file must be 64x64 pixels in size, no more, no less.
- The first colour in the palette is transparent in-game.
Method
Part 1: Locating and exporting a sprite
- Open up your clean ROM with unLZ. Wait a little bit for it to load the images.
Now you have to find the sprite you wish to replace. Pokemon sprites begin at around Goto 670 in Fire Red (may be different for R/S). Just type in 670, click goto, and click "Next" until you find the sprite you want to replace. I went to Goto 674, Charmander.
- Click "Save As" and save the picture as a .png somewhere memorable.
There, Part 1 done! :)
Part 2: Colouring and indexing the sprite
- Make a new document in your graphics editing program. Make sure it is 64x64 pixels in size.
- Draw or copy/paste your new sprite into this window. You can use the saved image from Part 1 as reference. Remember to only use 15 colours in the picture. If you accidentally use more than 15 colours, you can use Photoshop/IrfanView to reduce the colours to 15 (more on that later). In my case I created a Charmander in a different pose, based on the sprite from Pokemon Yellow.
- Choose a colour for the background of your new sprite. Make sure that this colour is not used in the actual sprite itself. I used a creamy-greeny-white.
- Indexing time! This is the hard part, although if you have Photoshop, this is quite easy:
Spoiler:Click Image, Mode, Indexed Colour...
You will see a box like this come up:
Uh Oh! As you can see, when the palette is exact (i.e. every colour will be shown in the palette), I have used 17 colours in the image :surprised: If I had done it right, the Colours number should be 16.
Luckily for me Photoshop has a feature to limit the colours to a certain number (click the drop-down palette menu, click 'Local (Selective)' and type 16 in the colours box)
If the colours box says 16, you can proceed to the next step.
Also, untick transparency, since this adds another colour (transparent) to the palette. Pokemon ROMs don't handle transparency in this way, so it'd just be a waste of a palette slot.
Now that we have a 16-colour image, we have to index it and create the palette. If we just clicked OK now, Photoshop may not put the background colour in the first slot of the palette, which is really bad. The first colour in the palette will be transparent in the game, so we want the creamy-greeny-white colour to be in the first slot.
Click the drop-down menu under Forced, and choose Custom. Another box will pop up:
Click the first square in the new box, and a colour selection box will pop up. Click on the background colour of your new sprite, and click OK, OK, OK.
Guess what? Your new sprite is indexed, ready to be imported into your ROM. Click File, Save As and choose .png in the drop down menu. Save this file somewhere memorable. Proceed to Part 3.
But what if you don't have Photoshop? Here's my guide to indexing using IrfanView:
Spoiler:
Firstly, to index your sprite using IrfanView, open up your sprite in the program.
Click Image, Decrease Colour Depth. Choose 16 Colors (4 BPP), and make sure the 2 boxes are unticked. Click OK.
Now click Image, Palette. See the 16 colours there? Remember, the first colour in the palette will be transparent in game. For my Charmander sprite, we want the first colour to be the greeny-creamy-white background colour.
As you can see from this picture, IrfanView has made the first colour black. So how do we solve this problem? We swap the background colour with the first colour in the palette.
Click on the background colour in the palette:
Notice the circled bit in red down the bottom? These are the Red/Green/Blue values identifying that colour. Write this down somewhere. Click on the first colour in the palette and write down its RGB value too. My RGB values ended up being
Background Colour = [204, 202, 172]
First Colour = [20, 18, 20]
Replace the values in the box (circled in red in the pic) with the values of the background colour you just wrote down. Click OK. Do the same for the background colour, replace its RGB values with the first colour's values. Click OK.
Now your palette should have the background colour and first colour swapped:
Click OK again.
Your sprite will now look messed up. This is normal.
My sprite looks like this after swapping the colours:
Just click File, Save As, and save this picture as a .PNG file. Close up IrfanView, and open your graphics editing program. I will use paint just as an example.
Open up the messed-up version of your sprite you just saved from IrfanView. Also open up the correctly coloured version of your sprite:
Now just copy all of the correct sprite across to the messed up sprite (I used Ctrl+A, Ctrl+C, then Ctrl+V into the other window):
Save this fixed up file as a .PNG file. Guess what? Your sprite is now correctly indexed and ready for insertion. Move to the next step :)
Part 3: Finding Free Space
- Open up Free Space Finder. Click File, Open ROM, and browse to the ROM you want.
- Now look at the file size of the indexed sprite you wish to insert. For my Charmander, it is 3.99KB (let's just round up to 4KB)
Convert this number to bytes here. In my case, 4KB = 4096 bytes. Enter this value into Free Space Finder, and click search.
See the "800000" in the box on the right? This is the location in the ROM of some free space big enough to hold you new sprite. There, Part 3 done. We are maybe 20 seconds away from your new sprite being in-game.
Part 4: Importing the New Sprite
- Open up unLZ again. Open up the ROM you want. Browse to the sprite you want to replace, for me it is Goto 674 (Charmander).
- Now click Import. Browse to your freshly indexed sprite. You should see your new sprite as the picture on the left. Click Write to ROM. Tick all three boxes up top, and change the image offset value to the number that came up in Free Space Finder.
Click OK, and close unLZ. Open up the ROM in your emulator of choice, and behold the magnificence of your new sprite! Here's how mine turned out:
Bugs Guide
- Picture all scrambled, dots/lines randomly everywhere:
Either your sprite wasn't 64x64 pixels or you have inserted the sprite in a place where there isn't enough room for it. Also, you may have inserted something else over the top of sprite by accident.- Colours all messed up:
Either you made a mistake with the palette, or just didn't replace it somehow.- Background colour showing:
Make sure the first colour in your palette is the background colour.- Crashing:
Probably have inserted the sprite over some important data. Make sure you are using FSF properly, and start afresh with a new ROM.- "Image is not indexed, aborting" error in unLZ:
Exactly what it says. If you used the IrfanView method to index, make ABSOLUTELY sure you used only 16 colours in the correctly coloured sprite.
Conclusion
Well I sincerely hope this guide works for you. I've tried to integrate the theory of inserting sprites too, instead of just putting up instructions. If you like this guide or have any comments feel free to drop me a message sometime, although I am quite busy at the moment so I mightn't be able to reply.
Special Thanks
...to HackMew, Deviation and other forum members for answering my own noob questions, and for various guides. Thanks to HackMew again for his great toolset too.
:bandit:
Last edited by a moderator: