• Our software update is now concluded. You will need to reset your password to log in. In order to do this, you will have to click "Log in" in the top right corner and then "Forgot your password?".
  • Staff applications for our PokéCommunity Daily and Social Media team are now open! Interested in joining staff? Then click here for more info!
  • 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.

Flags, Vars, & Script Tiles

karatekid552

What happens if I push it?....
  • 1,771
    Posts
    12
    Years
    Flags, Vars, and Script Tiles

    This subject has received more questions and caused more confusion than just about everything else in hacking combined, and we still don't have a guide for it. So, I'm making one. My goal here is to never have to answer another question about these again. So, here we go:

    Flags

    So, let's begin with flags. Flags are simple: they can be turned on and turned off and are used for the purpose of showing progression of events. Most are used to tell if an event has taken place or not. Fairly simple. However, many flags have special purposes which is what I am going to show you now.

    A man named DavidJCobb did some very nice research for us in going through FireRed's engine and scripts and noting every single flag he saw and what it did. So, here is the flag section from his list:

    Out of boredom, I dug through every single script and OW in a clean FireRed BPRE ROM and wrote down every single flag and variable I could find. My findings are below, and include OW-visibility flags, item ownership flags, and more. (Not trainer or world map flags, though.)

    Summarized flag findings:
    Flags 0x000 - 0x006, at minimum, are temporary flags and are directly manipulated by the game engine.

    Flags 0x011 - 0x01F are used to control the visibility of destructible OWs, i.e. Rock Smash boulders. They are probably cleared by the game engine every time a map is loaded, as no level scripts clear them. Do not use them on standard OWs.

    Flag 0x266 appears to be directly manipulated by the game engine. If set, there is an EGG waiting for you in the Four Island Daycare Center. It is unset manually by scripts if you choose to discard the egg.

    The game does not use checkitem to see if you have an item; instead, Game Freak scripts will always check for flags that were set as part of the event sequence that gave you the item (or it may even check for the OW-visibility flags if it was a pickup). E.x. the game uses "checkflag 0x271" after manually setting it, not "checkitem ITEM_BICYCLE 0x1".

    A similar thing is done with badges. The "champ-in-making" guy that always chills next to a Gym statue doesn't check badge flags directly; there are eight flags (4B0-4B7) that are set along with those flags, which he checks. Redundant...

    Not all of the listed OW-visibility flags are set/cleared directly. Most of them correspond to Person IDs in AMap, and are indirectly altered when one uses "hidesprite" on the Persons (referring to them by Person event number rather than ID).

    Notable flags:
    Flags 0x011 - 0x01F are used to control the visibility of destructible OWs.

    Flag 0x266 is set by the game engine if an Egg is in the Daycare.

    Flags 0x4B0 - 0x4B7 affect the "champ-in-making" guy's dialogue in Gyms.

    Flags 0x4B8 - 0x4BC are set if the player has beaten {whoever} in the Elite Four during their current attempt at it. They're cleared upon entering the Hall of Fame registration room.

    Flags 0x500 - 0x700 are trainer flags.

    Flags 0x820 - 0x827 are read directly by the game engine and determine Badge acquisition. But we already knew this.

    Flag 0x82D is set if you customize your profile by talking to some woman in some PokeCenter. Apparently directly set by the game engine.

    If Flag 0x834 is set, then the player knows the name of Bill's PC (as opposed to "Someone's" PC). Don't know if this affects the PC menu, but it affects dialogue shown when receiving a Pokemon and having it sent to the PC.

    Flag 0x842 may have something to do with wireless functionality or some minigame. It's checked after healing at a PokeCenter.

    Flag 0x844 is set when Celio connects to Lanette -- IOW when you can trade with R/S/E. Don't mistake it for the E4 completion flag like I almost did.

    Flag 0x849 is set when you solve the Tanoby Key.

    If Flags 0x84A and 0x84B are cleared, the Vermilion City dockworker won't even bother checking for the MysticTicket and AuroraTicket, respectively. You won't be able to use them. I don't know what sets or clears these flags.

    Flags 0x890 - 0x8FD are world map flags.

    Flags 0x900 and up overlap the RAM used for script variables and hence ARE NOT SAFE TO USE.


    Full findings:
    Spoiler:




    *Please note that the above list is only for FireRed. There is no list for Ruby or Emerald. Feel free to make one if you wish, however, the flag (and later var) engines are quite similar on all games, so the same general rules that I am about to share do apply to all games.


    Now, the above list goes over every single known flag. As you can see, there are quite a few. However, most are temporary or, from what you can see, a lot have descriptions like "Set by GAME START SCRIPT" and "Used for a CUT tree...", which obviously means you can't use these for other purposes. In fact, the only flags you can use are those which are used only by specific events and scripts that you have removed.

    For example, flag 250: "Set if the player received the MASTER BALL from the SILPH CO. PRESIDENT". If you removed the script in which the Master Ball is given, then this flag is safe to use.

    Another example is flag 03A: "Controls visibility of the POKEDEX OWs in OAK's Lab (PALLET TOWN (4.3)". If you remove the Pokedexes, then this flag is safe to use also.

    A very common misconception is that if the flag is not on the list, then it is safe. This is not true. In general, only flags 200-2FF that are not listed are safe. Other than that, if it isn't on the list or you haven't removed the event that uses it; DON'T USE IT.

    So, in general, flags that are safe:

    Code:
    [B]200-2FF
    Flags for events that have been removed.[/b]
    
    A lot of flags in the 100's are used to control the visibility of items found on the ground. I personally recommend keeping these for new items you want to leave in the ground however, if you do delete that item location, then there is no reason not to use that flag.
    The above rules generally work for all games, you just won't have a list to check for RSE.


    Unless you have the skill of Knizz, Jambo, or JPAN, then these are all you have to work with. There are ways (with ASM) to repoint flags and make more safe, but that is very advanced and I will not be teaching it. However, Jambo51 may release his code for more flags and vars in the near future, but don't bug him about it.


    So, let's explain the reasons why flags outside of those ranges aren't safe:

    -Many are temporary. Meaning they get reset every time the map changes.
    -500-700 are used for Trainer Flags.
    -Flags over 900 take up the same space as variables.

    That is pretty much it. Fairly simple, huh?




    Vars

    Vars are like the X in math. They can be anything up to 0xFFFF which is a little over 65,000. Like flags, they are used to track progression throughout the game, but they are also used to store information.

    DavidJCobb also documented all of the variables used by FireRed and identified which ones are safe:

    Summarized variable findings:
    0x4020 - 0x4024 are all pedometers, the first of them controlling REPEL expiration.

    0x4036 is used for Selphy's Pokemon-fetching game. (She's the woman at Resort Gorgeous). I don't know what modifies this var -- possibly the game engine itself?

    0x403A is used in elevator scripts and is directly modified when special 0xD8 is called. Don't store anything that you want to be permanent in this variable.

    Vars 0x4064 through 0x4066 are used as part of the boulder puzzles in Victory Road. They're also cleared upon entering Route 23, along with 0x4067.

    0x4069 sets which fossil is being revived in Cinnabar Island, and 0x406A sets the progress (1 = active, 2 = complete).

    Code:
    LIST OF IDENTIFIED IN-GAME VARS (FIRERED)
    
    4000        Temporary/disposable variable.
                Written to by special E7.
    4001        Temporary/disposable variable.
    4003        Temporary/disposable variable? Used in TRAINER TOWER.
    4006        Temporary/disposable variable? Used in TANOBY KEY.
    4008        Temporary/disposable variable? Used in TANOBY KEY.
    400E        Temporary/disposable variable? Used in TRAINER TOWER.
    400F        Temporary/disposable variable? Used in TRAINER TOWER.
    4010        Temporary/disposable variable.
                Written to by (incomplete?) special 142.
    4020        Pedometer. It counts down, and upon reaching 0x0000, REPEL expires.
    4021        Pedometer. Max value 0x007F; it loops back to 0x0000 after.
    4022        Pedometer. Max value 0x0004; it loops back to 0x0000 after.
    4023        Pedometer. Max value 0x05DC; it just stays at that value after?
    4025        Pedometer? Used for DAISY's script? Haven't seen it in action myself yet.
                Set to 0x01F4 (500) by GAME START SCRIPT.
    4031        The starter that the player chose (0, 1, 2).
                Accessed directly by special 129.
    4036        Multi-use, for SELPHY's Pokemon-fetching-and-showing game.
                Apparently set to 0x0000 when it's time for a new "round" to start.
                Apparently set to 0xFFFF if you're out of time.
    4037        Box that a newly-received (givepokemon) Pokemon was sent to. Is directly manipulated by the game engine 
            itself.
                Read by special 165.
    4038        Unknown.
                Read by specials A6 and A9.
                Written to by special A8.
                Used by special AA.
    4039        Unknown.
                Written to by specials A6, A7, and A9.
    403A        Used in elevator scripts (current floor?). Written to by special 0xD8.
    403C        0xXXYY -- the current bank and map, respectively.
    403E        Unknown.
                Accessed directly by special 1AC.
    4042        Unknown.
                Read by special 167.
    4043        Unknown.
                Written to by special 167.
    4049        Unknown. Something to do with the sticker kid on FOUR ISLAND.
    404A        Unknown. Something to do with the sticker kid on FOUR ISLAND.
    404B        Unknown. Something to do with the sticker kid on FOUR ISLAND.
    404E        Unknown.
                Written to by special 197.
    4050        Unknown or multi-use.
                Set to 0x1 after the "Don't go out yet!" OAK Script event.
                Set to 0x2 during the Hall of Fame room level script, if the National Dex is NOT already unlocked.
                Set to 0x3 after OAK's chat with the player in PALLET TOWN after beating the E4.
    4051        Set to 0x2 to disable the "Old Man Needs Coffee" Script event in VIRIDIAN CITY.
    4052        Set to 0x1 to disable Script events for Gary in CERULEAN CITY.
    4053        Unknown. Set to 0x0 after the player watches the S.S. ANNE depart.
    4054        Unknown or multi-use.
                Set to 0x2 to disable Script events for a Rival encounter on ROUTE 22.
                Set to 0x3 after VIRIDIAN CITY Gym Leader GIOVANNI is defeated. Enables next Rival.
                Set to 0x4 to disable Script events for a second Rival encounter on ROUTE 22.
    4055        Unknown.
                Is set to 0x0 when the player hasn't encounted PROF. OAK yet.
                Is set to 0x1 when OAK is escorting the player to his lab.
                Is set to 0x2 when the player needs to choose a starter.
                Is set to 0x3 when the player and their Rival have both chosen starters.
                Is set to 0x4 after the player's first battle with their Rival.
                Is set to 0x5 when the player needs to deliver OAK's PARCEL.
                Is set to 0x9 when the player enters PROF. OAK while it is set to 0x8.
                If >= 0x1 and no other events pending, then DAISY comments on a recent Rival battle.
                Set to 0x7 after OAK's chat with the player in PALLET TOWN after beating the E4.
    4056        Unknown. If equal to 0x0, "sethealingplace" runs whenever the player enters their bedroom in 
            PALLET TOWN. Another level script then sets the variable to 0x1.
    4057        Multi-use.
                Set to 0x1 to disable the OAK's PARCEL level script in VIRIDIAN CITY's PokeMart.
                Set to some other value to enable VIRIDIAN CITY's normal PokeMart script.
    4058        Unknown. Checked by DAISY's script in PALLET TOWN. Apparently part of the sequence of events 
            that makes her give away the TOWN MAP.
                Set to 0x2 when DAISY gives away the TOWN MAP.
    4059        If != 0x0, then the player beat the Ghost MAROWAK at POKeMON TOWER.
    405A        Set to some value to disable the Old Man that blocks the VIRIDIAN CITY Gym.
    405B        Multi-use.
                Set to 0x1 to disable Script events for a Rival encounter on the S.S. ANNE.
                Is set to 0x1 when entering LAVENDER TOWN.
    405C        If != 0x0, then the player beat Gary at SILPH CO.
    405D        If != 0x0, then the player beat Gary at POKeMON TOWER.
    405E        Set to 0x0 to disable Script events on the tiles bordering the exits to the CYCLING ROAD 
            gatehouse. Set to 0x1 to disable Script events on the tiles bordering the entrances.
    405F        Controls various badge-checking Script events on Route 23.
    4060        If >= 0x1, then TEAM ROCKET has left SILPH CO.
    4061        Set to 0x1 to disable the Pay-To-Enter Script events in PEWTER CITY's Museum.
    4062        Set to 0x1 to disable the thirsty-guard roadblock Script events in the SAFFRON gatehouses.
    4064        Unknown or multi-use.
                Reset to 0x0000 when entering Route 23.
                Used as part of the Boulder puzzle scripts in VICTORY ROAD.
    4065        Unknown or multi-use.
                Reset to 0x0000 when entering Route 23.
                Used as part of the Boulder puzzle scripts in VICTORY ROAD.
    4066        Unknown or multi-use.
                Reset to 0x0000 when entering Route 23.
                Used as part of the Boulder puzzle scripts in VICTORY ROAD.
    4067        Unknown. Reset to 0x0000 when entering Route 23.
    4068        Set to 0x2 after an Elite Four chamber level script forces the player to walk up. Rechecked 
            later after the E4 battle in that chamber has ended. Reset to 0x0000 in the Hall of Fame room.
    4069        Set to 0x1, 0x2, or 0x3 depending on which fossil is being revived at the CINNABAR ISLAND 
            lab.
    406A        Fossil revival process. 0x1 means that a revival is in progress. 0x2 means that it is 
            complete.
    406B        Set to 0x1 to disable Script events for the Nugget Bridge challenge.
    406C        Unknown or multi-use.
                Set to 0x1 to disable the man that traps you in PEWTER until you beat Brock.
                Set to 0x2 to disable Script events for the man that gives Running Shoes at PEWTER.
    406E        Safari Zone status.
                Set to 0x0 when not in the SAFARI ZONE.
                Set to 0x1 ...?
                Set to 0x2 after paying to enter the SAFARI ZONE.
    406F        I haven't the faintest idea. Used in Pokemon Center 2F level scripts.
    4070        Set to 0x1 when talking to some chick in PALLET TOWN that mimics a sign or whatever.
    4071        See 408A.
    4073        Affects dialogue in the SAFFRON CITY TRAINER FAN CLUB building.
                Is set to 0x1 when the occupants -- your new fans -- swarm you.
    4074        Unknown. Checked if != 0x0 in a level script for the woman-who-likes-battles's house (map 
            31.0).
    4075        Used in a ONE ISLAND level script. If it equals 0x2, BILL will welcome you to ONE ISLAND, 
            bring you into the PokeCenter to see CELIO, and then the variable will be set to 0x3.
    4076        Multi-use, for the RUBY/SAPPHIRE subplot.
                Set to 0x4 if hasn't beaten the ROCKET GRUNTs they eavesdrop on at MT. EMBER?
                Set to 0x5 when the RUBY has been delivered to CELIO on ONE ISLAND.
                Set to 0x6 when the subplot is complete.
                If >= 0x5, VERMILION dockworker acknowledges your RAINBOW PASS. (Travel to SEVII)
                If >= 0x1, VERMILION dockworker acknowledges your TRI-PASS. (Travel to SEVII 1-3)
    4078        Affects the commentary and items offered by the shopkeeper on One Island. The variable's 
            value is managed by a TWO ISLAND level script that checks various flags.
                0x4078 == 0x2 means that Lostelle has been rescued.
                0x4078 == 0x3 means that you've beaten all Gyms, but not the Elite Four. (?)
                0x4078 == 0x4 means that the shopkeeper offers items "from distant lands". (Beat E4)
    4079        Multi-use, for the LOSTELLE event.
                Set to 0x1 after dealing with a Biker at the TWO ISLAND GAME CORNER.
                Set to 0x2 after rescuing LOSTELLE in BERRY FOREST, before warping to her home.
                Is set to 0x3 when LOSTELLE is reunited with her father.
                Is set to 0x4 when the subplot is complete.
    407B        Unknown or multi-use.
                Set to 0x2 to enable the first Script events for the Bikers in THREE ISLAND?
                Set to 0x3 to disable the first Script events for the Bikers in THREE ISLAND.
                Set to 0x4 to disable the second Script events for the Bikers. (They leave.)
    407C        Unknown or multi-use.
                Set to 0x1 to ...?
                Set to 0x2 to disable the Pokemon Center 2F level script (TEALA's tutorial).
    407D        Set to 0x1 to disable the ROCKET GRUNT Script events behind the broken home in CERULEAN.
    407E        Unknown or multi-use.
                Is set to 0x1 after the player helps the S.S. ANNE's captain.
                Is set to 0x2 when the player is stepping out of a boat and into VERMILION CITY or the S.S. ANNE harbor.
                Is set to 0x3 when the S.S. ANNE has departed VERMILION CITY.
    407F        Set to 0x2 after a Script event on MT. EMBER, in which the player hears ROCKET GRUNTs talk.
    4080        Set to 0x1 after a Script event in ICEFALL CAVE, in which the player assists LORELEI.
    4081        Set to 0x1 to disable a Script event blocking access to the Pokemon in the FIGHTING DOJO.
    4082        Multi-use.
                Set to 0x0 to enable a Script event at the TRAINER TOWER counter. (A level script 
                on the tower's exterior (Map 3.62) does this.)
                Set to 0x1 to disable a Script event at the TRAINER TOWER counter.
    4083        Set to 0x1 upon entering the LOST CAVE room with the lost woman.
    4084        Multi-use, for the SELPHY event.
                Set to 0x1 upon rescuing SELPHY from LOST CAVE, before warping to RESORT GORGEOUS.
                Set to 0x2 upon being promptly dismissed from her front door (level script).
    4085        Unknown. Used in two level scripts for INDIGO PLATEAU (3.9). Does something if it equals 1.
    4086        Set to 0x1 to disable a FOUR ISLAND level script (Gary encounter without battle).
    4088        Set to 0x1 to disable Script events in ROCKET WAREHOUSE.
    4089        Set to 0x1 to disable a SIX ISLAND (37.0) level script (Gary encounter without battle).
    408A        Multi-use, for an event where you meet BILL at CINNABAR ISLAND's PokeCenter, and he leaves on 
            a boat.
                Set to 0x1 upon meeting BILL in the PokeCenter. The same script makes you both leave.
                Is set to 0x1 when used in level scripts that show BILL's departure from the island.
    408B        Set to 0x1 to disable the Script events for the fossil guy in MT. MOON.
    ...
    5EF4 - 7FFF    CONFIRMED UNSAFE! In PC box space!

    Variables under 4000 can't be used because:

    • They overlap RAM used for flags
    • Most script commands don't recognize them as variables
      • Most commands basically do this: "If argument > 0x3FFF, then find the value of variable number argument and use that value. Else, use argument itself as a value."
    Some of them have been confirmed unsafe since I last updated that document. The rest are a mystery and could be safe or unsafe.

    • Variables 0x4100 to 0x417F (inclusive) overlap the RAM used for a special data type called "hidden variables" -- a set of 64 dwords used by certain script commands whose purpose is unknown.
    • Variables 0x5084 to 0x55CC overlap RAM used for seemingly-arbitrary data. I haven't noticed any ill effects from overwriting this data, but it changes frequently, so the variables themselves are unreliable.
    • Variables 0x56F4 - 0x5EF3 appear to also overlap RAM used for the PC. This doesn't match with JPAN's findings (the 0x5EF4 figure is from him) so either one of us is wrong, or this variable range overlaps non-essential parts of the PC data.
    My suspicion -- an unconfirmed one -- is that the only safe variables are those from 0x4000 to 0x40FF (inclusive), excluding variables in that range that are set or read by the core game engine (as opposed to those used by scripts that can be safely removed).

    Basically, you're better off keeping your variables to a minimum. If you find yourself running short on variables, see if flags (or perhaps key items) could be used instead of variables to track the player's progression through different scripts.

    In general, only vars 0x4011-0x40FF are the safe. All others overlap different RAM such as PC Boxes or flags, or they are temporary/disposable. That being said, some of the ones in that range are also temporary or used by the games engine. So, just like with flags, you have to be careful. Check the lists, run some tests, delete old events; these are the only ways to truly know of they are safe. Outside of that range; forget about it, you'll end up ruining other events or causing bad eggs.

    (Once again, these general rules apply to RSE too, you just won't have a list.)

    Script Tiles

    This is probably the most confusing thing for a beginner: how to use those green s-tiles in A-map.

    Essentially, these tiles will activate the script, which you put in the Script Offset box in the settings, when stepped on. However, it isn't that simple. Look at the picture below:

    Spoiler:


    You will notice that I circled the boxes for "Var Number" and "Var Value". These are pretty cool. What they allow you to do is prevent a script from running again. As we learned above, vars can be any value up to a little over 65,000. So, what do these have to do with a script running? Well, it is quite simple:

    The script will run, if and only if, the var in the box is equal to the value​

    So, let's say you put the var 0x4050 in the space for a var and 0 in the space for the value. Can you guess what happens? If you said that the script will only run if the var 0x4050 is 0, then you are correct.

    Even if you want the script to run every time you step on it, you have to provide a valid var. If you leave the var space blank or at 0, then the script won't run. Just make sure that nothing else changes the var and you will be good.

    Now, if you only want your script to run the first time you step on it, or to not run again, just add this line to the end of your script:

    Code:
    setvar 0x[valid var] 0x[another number other than the one in the value box]

    (Remember, all vars that haven't ever been used will be at 0 to begin with.)

    So, if we take the situation above where we had the var as 0x4050 and the value at 0 and we don't want the script to run again, simply add this to the end of your script:

    Code:
    [Center]setvar 0x4050 0x1[/center]

    Make sense?

    Now, one last thing: the Unknown. As you can see in the image, the Unknown is set to 0003. This is not necessary. I almost never use it, but most people do use it simply for continuity. It is something that Game Freak, or their compiler for that matter, inserted that has no real purpose that has been identified. It is simply a constant whose use is just personal preference.

    Edit: Yeah, I'm awesome and identified the purpose:

    Spoiler:





    So, let's recap:


    Safe Flags:
    ->200-2FF
    ->Flags from events or OWs that have been removed


    Safe Vars:
    ->0x4011-0x40FF
    ->Make sure you check the list! Some vars have specific functions!


    Script Tiles
    ->Used to make a script run when you step on a specific tile.
    ->You must provide a var.
    ->The script will only run if var = value
    ->To prevent the script from running again, set the var to something else in your script.


    If I was unclear about anything or there is something that is still confusing, feel free to leave a message and ask. I will be happy to clear up things and improve this guide!

    Credits:

    DavidJCobb- for his massive amount of work dealing with flags and vars and what they control.

    Jambo51- for helping me understand what is wrong with flags over 0x900 and exactly what vars are safe.

    Until next time!
    ~karatekid552
     
    Last edited:
    Yey, I was the second person (after karatekid) to view this thread! Heads up to 2 views!

    This is IMMENSELY useful. I'm saying this, because I had a confusion about going-out-of-map-resetting flags. This is what I need.

    And vars is something I used to avoid when I was a beginner, and only recently discovered the magic of script-tile vars.

    But I do think there is SOME use of the Unknown? Or is there? I'm just really curious.

    I'm gonna constantly check this for safe flags/variables.

    But can you tell me more about the trainer flags which are 500-700. I want to know if they're safe with JPAN's Hacked FireRed Engine.
     
    Yey, I was the second person (after karatekid) to view this thread! Heads up to 2 views!

    This is IMMENSELY useful. I'm saying this, because I had a confusion about going-out-of-map-resetting flags. This is what I need.

    And vars is something I used to avoid when I was a beginner, and only recently discovered the magic of script-tile vars.

    But I do think there is SOME use of the Unknown? Or is there? I'm just really curious.

    I'm gonna constantly check this for safe flags/variables.

    But can you tell me more about the trainer flags which are 500-700. I want to know if they're safe with JPAN's Hacked FireRed Engine.

    I'm going to write this big so that people scrolling through will notice it, not because I'm yelling at you.:p

    JPAN's engine does NOT make any flags or vars safe.

    In fact, it only makes vars not safe because some of its features restrict certain vars to doing certain things.

    On regards to the trainer flags, there is flag for each trainer. Just add 0x500 to the trainer's number in A-Trainer to get the flag associated with it. When you beat a trainer, its flag is automatically set by the game. So, the only safe flags in that section are flags for trainers which you will not use, or don't exist.

    I'm glad this helped you, hopefully it will help others. The unknown, is just that, unknown. There are quite a bit of things like this in the coding and are often called fillers or constants and they don't do anything other than separate data.
     
    Awesome tut! So this means if you plan your script tiles you should only need a single var for 65000 events... mind blown!

    Also how do script tiles world with strength boulders? They are used in tanoby key but overworlds don't trigger scripts do they..?
     
    Awesome tut! So this means if you plan your script tiles you should only need a single var for 65000 events... mind blown!

    Also how do script tiles world with strength boulders? They are used in tanoby key but overworlds don't trigger scripts do they..?

    If all of the events take place in order, then why not? Jambo told me that he has only used 3 vars for Platinum Origins so far.

    Overworlds do trigger scripts, they are a type of person event.
     
    Can you make a List for Emerlad pls. Thats very nice Work thx.
     
    Congrats, I hate to admit it, but I probably jacked up my roms. I've been using flags 1000 all the way to 103E! I'm going to have to do major rearanging...
     
    Awesome tutorial!
    just a few things i'm wondering though
    i opened up the script for the tree in viridian city and it didn't have flag0x011.
    also could someone explain to me what the variables from 8000 and above do? they weren't on the list of variables. I've guessed what some of them do, but for others i'm clueless. Help?
     
    Can you make a List for Emerlad pls. Thats very nice Work thx.

    No. I'm sorry but I do not have the time. I have my own hack to worry about, I am still pushing for the community hack, I write many amazing tutorials(:p), I am researching particle effects for moves, I have a life, I play sports, I do volunteer work, I am still in school, and, well, I don't hack Emerald. Why don't you make a list?

    Awesome tutorial!
    just a few things i'm wondering though
    i opened up the script for the tree in viridian city and it didn't have flag0x011.
    also could someone explain to me what the variables from 8000 and above do? they weren't on the list of variables. I've guessed what some of them do, but for others i'm clueless. Help?

    Thank you!

    Variables over 8000 are completely temporary. Simple as that. Some have special functions, like one (the number escapes me at the moment) keeps track of the last sprite you talked to, and 0x800D is used as LASTRESULT which is the main var used by ASM to return temporary items.

    The flag for the tree goes in its Person ID to keep it hidden after you cut it, but once you leave the map, the flag gets reset and the tree appears again.
     
    Thank you!

    Variables over 8000 are completely temporary. Simple as that. Some have special functions, like one (the number escapes me at the moment) keeps track of the last sprite you talked to, and 0x800D is used as LASTRESULT which is the main var used by ASM to return temporary items.

    The flag for the tree goes in its Person ID to keep it hidden after you cut it, but once you leave the map, the flag gets reset and the tree appears again.

    I see. Thank you!
    And this might be a stupid question, but would it be possible to change the person id of a tree or rock and thus change the flag it corresponds to?
     
    Yay! Finally! I can keep a copy of a tutorial (that never existed before) to keep from forgetting those things! Great job again, karatekid552!
     
    Okay, so today, I finally decided to look into the "unknown" in script tile and person event making in A-Map. You know, the one that everyone says should be 3, if nothing but for consistency's sake? Well, here is the routine that deals with it for script tiles:

    r0= First thing, it gets the byte in question loaded to it.
    r4= Offset of data for script tile. +4 is the byte in question.
    r5= Same as r4.
    r6= Nothing (00000000).
    r7= 00000003 <- Number of script tiles on map, I believe.
    r8= 00000003 <- Compared to r0.

    ROM:0806DDF8 LDRB R0, <R4,#4>
    ROM:0806DDFA CMP R0, R8
    ROM:0806DDFC BEQ loc_806DE02
    ROM:0806DDFE CMP R0, #0
    ROM:0806DE00 BNE loc_806DE0C
    ROM:0806DE02
    ROM:0806DE02 loc_806DE02 ; CODE XREF: sub_806DDC0+3Cj
    ROM:0806DE02 MOVS R0, R5
    ROM:0806DE04 BL sub_806DD80
    ROM:0806DE08 CMP R0, #0
    ROM:0806DE0A BNE loc_806DE18
    ROM:0806DE0C
    ROM:0806DE0C loc_806DE0C ; CODE XREF: sub_806DDC0+30j
    ROM:0806DE0C ; sub_806DDC0+36j ...
    ROM:0806DE0C ADDS R4, #0x10
    ROM:0806DE0E ADDS R5, #0x10
    ROM:0806DE10 ADDS R6, #1
    ROM:0806DE12 CMP R6, R7
    ROM:0806DE14 BLT loc_806DDEC

    If you can read this, you will see that if the byte is set to 0 or 3, it goes to the exact same place. This place is some code at 0806DD80 which reads the rest of the data, like the var value and script offset and runs them accordingly.

    If it is anything but 03 or 00, it jumps ahead to 0806DE0C prematurely, adds 10 to r4 and r5, (which had the offset of the event data). Event data is 10 bytes long, so guess what, it just reads the next event in line.Tongue I haven't actually tested that his happens, but it is a possibility. This belief is reinforced by the two lines at 0806DE12, which only allow the loop to run if there are script tiles remaining to be run.

    So, in all reality, it makes no difference if you change this byte at all, just as long as you only change it to 03 if you do change it. Hope this clears some things up!
     
    How do you identify the free flag and free vars? :( BTW I am hacking Pokemon Ruby :)
     
    So, what exactly happens if/when you use flags over 0x900, because I used a bunch over that and nothing happened to my ROM yet.
     
    So, what exactly happens if/when you use flags over 0x900, because I used a bunch over that and nothing happened to my ROM yet.

    Nothing happens, until you try to use vars. Flags over 0x900 are stored in the exact same ram location as vars 0x4000 and up. Do you see the issue? And then, all vars above 0x40FF are in PC Box space. There are 8 flags per byte, and two bytes per var, so, that is 0xFF x 16d, which is 0xFF0. So, that + 0x900 flags, is flag 0x18F0. That will be the first flag that will corrupt the pokemon in your PC, but you don't know which slot or pokemon it will be due to DMA shifting, if I remember correctly.

    So:
    flags 0->0x8FF are flags.

    flags 0x900->0x18F0 are in the same area as vars 0x4000->0x40FF

    and finally:

    vars 0x40FF+ and vars 0x18F0+ are in the same place as the pokemon in your PC.


    You may no notice the effects yet, but once you want to use vars for events, you will find that flags become unset and other issues will arise.
     
    Back
    Top