• Just a reminder that providing specifics on, sharing links to, or naming websites where ROMs can be accessed is against the rules. If your post has any of this information it will be removed.
  • Our friends from the Johto Times are hosting a favorite Pokémon poll - and we'd love for you to participate! Click here for information on how to vote for your favorites!
  • Cyndy, May, Hero (Conquest), or Wes - which Pokémon protagonist is your favorite? Let us know by voting in our poll!
  • Welcome to PokéCommunity! Register now and join one of the best fan communities on the 'net to talk Pokémon and more! We are not affiliated with The Pokémon Company or Nintendo.

[Other✓] Var location

  • 88
    Posts
    14
    Years
    • Seen Jun 18, 2020
    Hi everyone, I'm sorry if I'm not in the good section, and I'm sorry for my bad English too, I'm French... :(

    After many researches, I haven't been able to find the location where variables are stored.

    For example, I know thanks to many tuts that the var 0x8000 is stored at 0x20370B8. But I want to find, for example, the location where the var 0x4200 is stored.

    Can someone help me ?

    Thanks ! :)
     
    I believe the variables start at 0x020275D8 for Emerald and 0x020270B8 for FireRed. To get the correct offset, you need to multiply the desired number by 2, because each variable is a half-word stored in the RAM.

    Although, not every offset is actually a variable, so be careful with what you use.


    EDIT: If you wanna access a variable you don't know the address to, try using the variable decrypter. It's documented here: Click
     
    Last edited:
    So if I want to find the location of the var 0x4200 :

    20270B8 + (4200 * 2) = 202F4B8

    But the value at 0x202F4B8 doesn't change when I set the var 0x4200 to any value.

    I don't understand how to use the variable decrypter...
     
    I can't understand the problem... What's wrong in my routine ?

    Code:
    .align 2
    .thumb
    
    main:
    	push {r0-r1}
    	ldr r0, var4200
    	ldr r1, decrypt
    	bx r1
    	pop {r0-r1}
    
    .align 2
    var4200:
    	.word 0x4200
    
    decrypt:
    	.word 0x0806E455

    Ps : Is it possible that the offset of the variable decrypter is different in a French ROM ? Because I found the same data at 0x6E454 in the English ROM and at 0x6E478 in the French ROM. But even with this second offset, the routine doesn't work...
     
    I can't understand the problem... What's wrong in my routine ?

    Code:
    .align 2
    .thumb
    
    main:
    	push {r0-r1}
    	ldr r0, var4200
    	ldr r1, decrypt
    	bx r1
    	pop {r0-r1}
    
    .align 2
    var4200:
    	.word 0x4200
    
    decrypt:
    	.word 0x0806E455

    Ps : Is it possible that the offset of the variable decrypter is different in a French ROM ? Because I found the same data at 0x6E454 in the English ROM and at 0x6E478 in the French ROM. But even with this second offset, the routine doesn't work...

    Yes, the routine is probably located somewhere else in the French ROM.
    Another thing with your routine is that while it works, it will never return. So if you want to know the var address, you'll have to find the end of the var decrypter. To make it return so you can read the addres with a break at the end of your routine (and let the game safely continue after) you will need something like this:

    Code:
    .text
    .align 2
    .thumb
    .thumb_func
    .global getvar
    
    main:
    	push {lr}
    	ldr r0, var4200
    	ldr r1, decrypt
    	bl bxr1
    	pop {pc}
    bxr1:
    	bx r1
    
    .align 2
    var4200:	.word 0x4200
    decrypt:	.word 0x0806E478+1

    Also, why hack a French ROM? Foreign ROMs aren't usually documented that well and some tools don't support them.
     
    Oh, sorry, I was in holidays. Thanks a lot for your help !

    I'm French, so I usually use French ROMs :)
     
    Oh, sorry, I was in holidays. Thanks a lot for your help !

    I'm French, so I usually use French ROMs :)

    Yeah, I understand that. I just personally think it would be easier to translate an English ROM to French than to find all offsets we know in BPRE in BPRF.
     
    Yeah, I think so, but I realized that when my projet was aleready started...
     
    Back
    Top