View Full Version : [Tutorial] Swapping Sprites in RBY

May 4th, 2008, 1:36 PM
Using Yellow Sprites in Red/Blue
This is a tutorial to change some of the sprites in Red/Blue/Yellow roms.
What you need:

A hex Editor (duh?) (I used Hexeccute because of it's Copy/paste functionality)
A debugger (I used Virtual Gameboy Color)
An emulator to test the result (Either VBA or just use the debugger mentioned above.)

First you have to choose which sprite you want to replace of course. I want to use the Nidorino sprite from Pokemon Yellow, and insert it into a Pokemon Red rom. Now that we've chosen the sprite we need to edit the Yellow rom slightly. To find where the sprite is in Yellow we need to go to the base stat data of Nidorino. So in your hex editor goto &H383DE. You're at Bulbasaur's data. Now go to &H383DE + &H1C * (Pokemon's Pokedex Number - 1) or &h383DE + &h1C * (33-1). So we're going to now look at &H383DE + &H39C or &H3875E.
We're now at Nidorino's Stat Data. The Pokemon's image data starts at the 11th byte of the base stats, so add 10 to where you are. You should now be at &H38768. And you should be seeing &H66. This just means that the image is 6 * 6. That's important if the image in Pokemon red is a 5 * 5, or 7 * 7. After this byte we have the pointers to the image data. 7F53 and DC54. The first pointer points to the front sprite and the second points to the backsprite. We're going to change the front sprite, but we still need to find the bank for both.
Now that we have that, find your preferred Debugger. I used Virtual Game Boy Color. So this explanation applys to that program. But before we open your rom in a debugger, we need to change a certain byte in the Pokemon Yellow rom. We need to view the the Nidorino image in the Pokemon Yellow rom to fin the bank for the offset. So in your Yellow rom, goto the address, &H5EDB. This is the byte for the Pokemon in the Oak Introduction. Change this to A7, which is the byte for Nidorino. Save.
Now open your Yellow rom in a debugger. Press F11 to enter the debugger mode. Set a breakpoint at &H251A, which is the beginning of the decompression routine, and then press F5, to continue the emulation.
As soon as you hit 'A' on 'New Game', the game will break. This isn't the image we want. This is breaking because of the Oak image. Just keep pressing F5 until the emulation begins again. You may have to press it 5-6 times. The next break is the one we want.


AS you can see the bank is 0D. (For more info on Pointers, go to bottom of post)
We now have our offsets, 0D:7F53, and 0D:DC54. Now turn these into a hex address.
0D 7F 53 = &h3537F
0D DC 54 = &h354DC

Now we need to find the size of the image. &h354DC - &h3537F = &h15D bytes. Pretty big image. Now we need to do the same process for the Nidorino sprite in Pokemon Red. (NOTE: Base Stat data begins at the same spot in both Red/Blue/Yellow. So the info will be in the same spot in each of those roms.)

Here, I'll even save you some time. The pointers in a Red rom, the Nidorino front and back sprites are at 35282, and 353F0 respectively. So that's a difference of &h16E bytes.
That means we don't need to repoint anything. Now in your Yellow Rom, go to the hex address 3537F, and highlight &h15D bytes or, every byte between the front and back sprites, then 'copy' it.
Now go to your red rom and go to 35282, and click 'paste'. Save. But I bet your asking about those extra 17 bytes left over from the paste. Don't worry about them. They won't effect your sprite in any way. The rom knows when the decompression of the image ends. All that's left is to look at the finished product.
Open your Red rom in your emulator. And you should have this.


Basic Pointer Information
Hex Address to pointer
Note: All values are hex.
3537F / 4000 = 0D ' This is the first byte.
Since Bank 0D is 34000 - 37FFF
For the last two bytes 3537F - 34000 = 13 7F.
Now we flip those and we get: 0D : 7F 13
That last byte needs to between 40 and 7F.
So if the byte is from:
0 - 3F 'Add 40 to it
40 - 7F 'Leave it as it is
80 - DF 'Subtract 40 from it
E0 - FF 'Subtract 80 from it.
My example lies in that first category so we add 40 to it.
Finished pointer is 0D: 7F53

Pointer to Hex Address
Note: All values are hex.
xx * 4000 = 0D * 4000 = 34000
Flip yy and zz.
34000 + 54DC = 394DC
394DC / 4000 = 0E. WRONG BANK.
So subtract 4000 from 54DC = 14DC
34000 + 14DC = 354DC

Thanks to the unkown author of an older document
And Coolboyman for the guide on GB pointers.
For tools, search for them on google.
Any more clarification needed, please post your problem.

May 6th, 2008, 9:33 PM
Wow thethethethe, this is a great tutorial!

Yay! First post! (I'm suprised no-one has posted in this thread yet.)

May 6th, 2008, 11:54 PM
Just to add to this document, here is somthing Dammedmoose wrote a few years ago:

In a Pokémon's stat data (starting at 383DEh, 1Ch bytes for each pokemon, in pokedex order) there will be a byte,either 55h, 66h, or 77h followed by the pointers to the graphics..
I don't know how to tell the bank that the graphic is in apart from this way;

In NO$GMB, put a breakpoint at the start of the graphic decompression routine (251Ah), and then make the game display the Pokémon's picture - the game will break just before the graphic is decompressed, and the ROM bank will be shown in the bottom right on the statusbar. Simply multiply this by 4000h to get the bank's address.

The two pointers that you have are for the front and back picture respectively, and they are placed one after another in most circumstances (well, all circumstances I've looked at anywho).

Here's how I did Pikachu... First I went to Pokémon Yellow, and looked up Pikachu's stat bytes, 383DEh + (25 * 1Ch), because Pikachu is number 25.
1923 371E 5A32 1717 BE52 5555 4D49 4E54 2D00 0000 B183 8DC1 C318 4200

The highlighted bytes are the ones we're interested in. The 55h means the picture is 5x5 tiles (66h and 77h mean 6x6 and 7x7), and then the 554D and the 494E are the pointers to the graphic.
Using standard knowledge, we convert these to 0D55 and 0E49 respectively. The distance between these addresses is F4h, henceforth is the size of the compressed graphic.

By using the method mentioned above, we can determine that the bank Pikachu's picture is in, is bank 0Bh (address 2C000h)
so, apply the pointer to get 2CD55 as the address for Pikachu's graphic. Grab the F4h bytes from there.


Simple. Now do the same with Pokémon Red to find Pikachu's graphic at 2CD7D (note you should also check the stat bytes just to make sure that there is enough room to copy the graphic, in this case we have 10Eh bytes to use, when the graphic we are copying is only F4h so it's all good) and all you need to do is overwrite the F4h bytes from Yellow, to that address! No need to worry about padding with 00's or anything, as the compression scheme works in such a way that it stops decompressing when it has the required amount of bytes (ie it can tell when the picture is complete).

May 7th, 2008, 3:46 AM

Pokemon Green (Japanese) - Where the stats begin...
The 1st 150 PKMN = $38000
Mew(Green) = $04200

Pokemon Red/Blue/Yellow Stat Offsets
(Pokedex Order) (Hex Offset)
#001 Bulbasaur = 383DE
#002 Ivysaur = 383FA
#003 Venusaur = 38416
#004 Charmander = 38432
#005 Charmeleon = 3844E
#006 Charizard = 3846A
#007 Squirtle = 38486
#008 Wartortle = 384A2
#009 Blastoise = 384BE
#010 Caterpie = 384DA
#011 Metapod = 384F6
#012 Butterfree = 38512
#013 Weedle = 3852E
#014 Kakuna = 3854A
#015 Beedrill = 38566
#016 Pidgey = 38582
#017 Pidgeotto = 3859E
#018 Pidgeot = 385BA
#019 Rattata = 385D6
#020 Raticate = 385F2
#021 Spearow = 3860E
#022 Fearow = 3862A
#023 Ekans = 38646
#024 Arbok = 38662
#025 Pikachu = 3867E
#026 Raichu = 3869A
#027 Sandshrew = 386B6
#028 Sandslash = 386D2
#029 Nidoran(F) = 386EE
#030 Nidorina = 3870A
#031 Nidoqueen = 38726
#032 Nidoran(M) = 38742
#033 Nidorino = 3875E
#034 Nidoking = 3877A
#035 Clefairy = 38796
#036 Clefable = 387B2
#037 Vulpix = 387CE
#038 Ninetales = 387EA
#039 Jigglypuff = 38806
#040 Wigglytuff = 38822
#041 Zubat = 3883E
#042 Golbat = 3885A
#043 Oddish = 38876
#044 Gloom = 38892
#045 Vileplume = 388AE
#046 Paras = 388CA
#047 Parasect = 388E6
#048 Venonat = 38902
#049 Venomoth = 3891E
#050 Diglett = 3893A
#051 Dugtrio = 38956
#052 Meowth = 38972
#053 Persian = 3898E
#054 Psyduck = 389AA
#055 Golduck = 389C6
#056 Mankey = 389E2
#057 Primeape = 389FE
#058 Growlithe = 38A1A
#059 Arcanine = 38A36
#060 Poliwag = 38A52
#061 Poliwhirl = 38A6E
#062 Poliwrath = 38A8A
#063 Abra = 38AA6
#064 Kadabra = 38AC2
#065 Alakazam = 38ADE
#066 Machop = 38AFA
#067 Machoke = 38B16
#068 Machamp = 38B32
#069 Bellsprout = 38B4E
#070 Weepinbell = 38B6A
#071 Victreebel = 38B86
#072 Tentacool = 38BA2
#073 Tentacruel = 38BBE
#074 Geodude = 38BDA
#075 Graveler = 38BF6
#076 Golem = 38C12
#077 Ponyta = 38C2E
#078 Rapidash = 38C4A
#079 Slowpoke = 38C66
#080 Slowbro = 38C82
#081 Magnemite = 38C9E
#082 Magneton = 38CBA
#083 Farfetch'd = 38CD6
#084 Doduo = 38CF2
#085 Dodrio = 38D0E
#086 Seel = 38D2A
#087 Dewgong = 38D46
#088 Grimer = 38D62
#089 Muk = 38D7E
#090 Shellder = 38D9A
#091 Cloyster = 38DB6
#092 Gastly = 38DD2
#093 Haunter = 38DEE
#094 Gengar = 38E0A
#095 Onix = 38E26
#096 Drowzee = 38E42
#097 Hypno = 38E5E
#098 Krabby = 38E7A
#099 Kingler = 38E96
#100 Voltorb = 38EB2
#101 Electrode = 38ECE
#102 Exeggcute = 38EEA
#103 Exeggutor = 38F06
#104 Cubone = 38F22
#105 Marowak = 38F3E
#106 Hitmonlee = 38F5A
#107 Hitmonchan = 38F76
#108 Lickitung = 38F92
#109 Koffing = 38FAE
#110 Weezing = 38FCA
#111 Rhyhorn = 38FE6
#112 Rhydon = 39002
#113 Chansey = 3901E
#114 Tangela = 3903A
#115 Kangaskhan = 39056
#116 Horsea = 39072
#117 Seadra = 3908E
#118 Goldeen = 390AA
#119 Seaking = 390C6
#120 Staryu = 390E2
#121 Starmie = 390FE
#122 Mr. Mime = 3911A
#123 Scyther = 39136
#124 Jynx = 39152
#125 Electabuzz = 3916E
#126 Magmar = 3918A
#127 Pinsir = 391A6
#128 Tauros = 391C2
#129 Magikarp = 391DE
#130 Gyarados = 391FA
#131 Lapras = 39216
#132 Ditto = 39232
#133 Eevee = 3924E
#134 Vaporeon = 3926A
#135 Jolteon = 39286
#136 Flareon = 392A2
#137 Porygon = 392BE
#138 Omanyte = 392DA
#139 Omastar = 392F6
#140 Kabuto = 39312
#141 Kabutops = 3932E
#142 Aerodactyl = 3934A
#143 Snorlax = 39366
#144 Articuno = 39382
#145 Zapdos = 3939E
#146 Moltres = 393BA
#147 Dratini = 393D6
#148 Dragonair = 393F2
#149 Dragonite = 3940E
#150 Mewtwo = 3942A

#151 Mew(Red/Blue) = 0425B
#151 Mew(Yellow) = 39446

May 7th, 2008, 6:43 AM
Ah! For a minute I thought I had read thethethethe's before, but it was really DamnedMoose's that I had read some time ago. Thanks, thethethethe and Cartmic.

FYI, Virtual Game Boy Color is a bad debugger to use. ;) Very old (hasn't been updated since 2000), and inaccurate -- try opening Pokemon Crystal to see what I mean. A better choice would be BGB or no$gmb. (though the free version of no$gmb can't debug games in color)

Chimchar 9
May 13th, 2008, 6:56 AM
thanks this is a really good tutorial!

Platinum Lucario
May 13th, 2008, 7:12 AM
This is a good tutorial for Pokémon Red, Blue, and Yellow versions.

June 5th, 2008, 3:13 PM
1.- I have BGB but i need help on how to do this on it.
2.- can somebody give me the RB pointers to the front images of the pokes. (i´m doing this the other way -> R/B to Y)

thanks in advance

July 29th, 2008, 12:49 PM
Yes, I´m back.
I need help with doing what this tut, but inverse way (RB sprite to Y)
I don´t know how to repoint the sprites, because RB sprites are bigger than Y sprites.

Can somebody help me?

July 30th, 2008, 9:08 AM
well i think some yellow ones are bigger than rb ones, i think that a picture is generally smaller when there's more of the white colour because of RLE or something

if you know about gameboy rom banks then you can just repoint the picture to the free space near the end of the bank you found the original picture in, provided it's not used up

for the front pics, from giegue's guide:
# : Effect on pokemon
1st: pokemon number
2nd: HP rating 0-255 higher is better
3rd: ATK rating 0-255
4th: DEF " "
5th: SPEED
7th: Type ##1
8th: Type ##2
9th: Rarity factor 0-255, higher is rarer
10th: EXP factor, 0-255, higher is more points
1th: Picture size? (not completely sure how this affects the picture)
12, 13: Pointer value for picture facing you (enemy)
14, 15: pointer value for picture facing enemy (your pokemon)
16-19: attacks known at level 1
20-27: Which HM's and TM's the pokemon learns. (probably 64 binary switches in order)

i wrote locations for pokemon in rby further up this page, when you go to them in your hex editor you'll land at the pokemon number you should be able to find the pointers from there

February 26th, 2009, 12:10 PM
Does anyone have the stat offsets for pokemon green?

February 27th, 2009, 3:59 AM
Do not revive month old threads.