Sign Up connects you to ROM Hackers around the world.

FireRed German (maybe for English as well) RAM Offsets


I found some interesting RAM-Offsets you might need as well. I will update this everytime i reserached something relevant.

1. Pokemons Picture Buffer
In Battles all Pokemon Sprites are not loaded directly from the ROM into the VRAM, but first in the WRAM. From there they are simply copied into ROM. To find these WRAM Buffer Offsets you can use this formula:

ldr rM, = 0x0202401C
ldr rM, <rM>
add r1, #X
ldr r1, <r1>

for X = 0 it is the buffer for your pokemon, and for X = 4 it is the buffer for your opponents pokemon. this can be very usefull if you want to change a pokemons sprite inbattle. You have to decomp the grafik in this buffer and the Vram to make a new sprite work.

2. The current Map
If you want to get the Current Map just do this:

ldr rM, =0x03004f58
ldr rM, <rM>

you will get an offset where the data is stored like this:
Hword: X-Position of the camera Hword: Y-Position of the camera Byte: Mapbank Byte: Map#

3. Manipulate pressed Keys
All keypresses are read from ROM: loc_5FA (in german Firered, but it shouldnt differ very much in a english one, since it is a very soon offset). You can bypass this function to customize keypresses for certain conditions, e.g. disabeling keys during events or switching their function (<- equals -> ; -> equals <-).

This is from GBATEK and it shows how the keypresses are loaded in GBA. Single bits in a hword at 0x04000130 show weather a key is pressed or not:

Bit Expl.
0 Button A (0=Pressed, 1=Released)
1 Button B (etc.)
2 Select (etc.)
3 Start (etc.)
4 Right (etc.)
5 Left (etc.)
6 Up (etc.)
7 Down (etc.)
8 Button R (etc.)
9 Button L (etc.)
10-15 Not used

4. Allocate Memory
You need some bytes in the RAM to use? Then just use the malloc function in the game, which will give you an save RAM-Offset to use. This RAM-Offset will be locked for other functions using malloc until you free this offset with the free function.

In FRD the malloc looks like this:
u32 malloc ( int i ). You give in r0 a number of bytes you need in the WRAM, and the function returns in r0 an offset to use. You can call this function via:

ldr r1, = 0x08002b1D
bl label

Then of course you need the free cuntion as well, which looks like this:
void free (u32 offset). You give in r0 the offset you want to free. Always use an offset which was malloced before, otherwise strange things will happen.

ldr r1 = 0x08002B45
bl label
bx r1

Reseraching these offsets for a english Firered Rom shouldnt be too hard.

5. Update Stats of a Pokemon

Sometimes you may need an function which updates the stats of a pokemon after you used an function to increase e.g. the IVs or EVs. Then you should use the update function, which recalculates every stat of a pokemon. But notice that PP and HP are recalculated as well, so the pokemon will be full healed afterwards. If you want to keep those values save them in RAM and apply them to the recalculated pokemon data in RAM afterwards.

ldr r0, = source
ldr r1, = destination
ldr r2, = 0x0803E675
bl label
bx r2

This is the way you can call this function. In source you must have an Offset to the Pokemons Data in RAM (0x64 Bytes per Pokemon, visit bulbapedia for more information) and in r1 there is an offset, where the new data is written. r0 and r1 CAN BE THE SAME.