• 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.
  • Ever thought it'd be cool to have your art, writing, or challenge runs featured on PokéCommunity? Click here for info - we'd love to spotlight your work!
  • Which Pokémon Masters protagonist do you like most? Let us know by casting a vote in our Masters favorite protagonist poll here!
  • Red, Hilda, Paxton, or Kellyn - 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.

[ASM & Hex] ASM Variables Question

  • 15
    Posts
    4
    Years
    Where or how are global variables stored in Fire Red?
    If I for example, wanted to know where to find the variable that had my rival select a starter that was strong against my selected Pokemon.

    Where are the player's current badges stored?

    Where is the data for all of the Pokemon in the party, such as their typing.

    Where is the data stored for the opponent's Pokemon party?

    I would like to see where I can find this information to start more advanced rom hacking with the tools given to me by a user who answered my last question.

    Thank you!
     
    https://www.pokecommunity.com/posts/6856053/
    Here is a post with the RAM layout for Fire Red. Most of the data you are looking for are in various memory addresses in the RAM as they are temporary things that the game overwrites over time as necessary.

    For individual answers of your questions:
    the variable that had my rival select a starter that was strong against my selected Pokemon: By default, Fire Red uses the variable 0x4001 to determine which pokeball you picked in Oak's lab. It is equal to 0 if you picked Bulbasaur, 1 if you picked Squirtle, and so on. However, 0x4001 is a temporary/disposable variable that the game uses only to apply movements for your rival in the lab at the start of the game during the starter selection. The game also uses 0x4031 to determine which starter you picked. (Credits to this post)

    As for the memory address of where the values of these variables are stored, I myself am unsure (still a novice here). They are apparently DMA-protected. DMA stands for Dynamic Memory Allocation. That is their memory addresses are dynamic instead of static. If they were static instead, there would have been fixed memory addresses for them using which you could change or manipulate their values through your scripts or ASM routines.

    the player's current badges stored: IIRC, there are no variables of any kind in Fire Red that keeps track of HOW MANY badges you have. Instead, the game checks various flags to see WHETHER you have a particular badge or not. Here is a list of the flags that get set once you get the corresponding badges:
    Spoiler:

    Technically, you could use one of the temporary/disposable variables to keep track of how many badges a player has. Just at every gym battle script, add something like "addvar 0x4069 0x1" right after when the gym flag is set. Then 0x4069 will have the value equal to the number of gym badges the player has. You could use a different variable though but make sure it is not used for other stuffs in the game and make sure it is safe. Just in case you don't know: variables from 0x4000 to 0x4100 are the safe ones IIRC. Still cross check from other Pokecommunity posts!

    the data for all of the Pokemon in the party, such as their typing: There is the memory address for the data for each of the player's Pokemon and also each of the opponent's Pokemon mentioned in the very first link of my reply. Still for clarity:
    The data for trainer's party Pokemon is stored at 0x02024284 in the RAM. 0x0202402C contains the data for the wild Pokemon / opponent's Pokemon. Each Pokemon's data takes 100 bytes of space. You can find even more details about them from these two Bulbapedia pages:
    Pokémon data structure in Generation III
    Pokémon data substructures in Generation III

    the data stored for the opponent's Pokemon party: same places as above

    I hope these helps! Feel free to ask for further simplification!
     
    Hi! I want to ask something about RAM variables.

    How can I reach the RAM variables on scripts? I used this script in my game but it didn't work.

    setvar 0x4001 0x00
    compare 0x4001 0x0300500C
    if 0x1 goto @true
    if 0x5 goto @false

    I got a "Wrong parameter type" error on XSE. Am I missing something?

    I am still a newbie on this. Your help is greatly appreciated ^^
     
    Back
    Top