• 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?".
  • 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] Need help removing badge restrictions on HMs (Emerald)

3
Posts
5
Years
I'm just starting off on my first ROM hack and I've been picking up on a few things as I go along but Hex editing is still a headache for me.

I was wondering if there is a way to remove badge restrictions from HMs, e.g. using Rock Smash before Wattson or Strength before Flannery?

My end goal of this is to change up the order of events in Emerald, the first of which being going through Rusturf tunnel after Roxanne instead of going to Dewford.

Thanks in advance for any help! :3
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
The best way to remove badge checks is to change which flags restrict use of HMs and divorce them from the badge system entirely. Some badge checks are really easy to edit, like the HMs where you interact with an NPC in the overworld (Cut, Rock Smash and Strength) as their badge checks are in the scripts attached to them and can be simply opened up in XSE. The water-related HM badge checks (Surf, Waterfall and Dive) are a bit trickier as they are tile-based and have pre-checks which complicate the matter. Hardest of all are the party menu-based HM badge checks (Flash and Fly) as there isn't much information out there as the Pokemon menu is complicated and isn't something that most people would mess with. Anyway, since they're the hardest to play around with, its best to start with removing the badge restrictions from the menu-based HMs, which also has the side effect of letting players use other HMs from the menu if their correct flags are set.

Starting at 0x615D7E and ending at 0x615D7C, there's an array of Move IDs which corresponds to all of the moves that you can use in the party menu. The array is comprised of all of the HM moves in their proper badge order, starting with Cut (0F 00) and ending with Waterfall (7F 00) and then other field moves that don't require badges to use (e.g Softboiled and Teleport). Anyway, there's a function that checks if you're selecting one of the HM moves (and if you are), adds the the move's position in the array to flag 0x867 (Roxanne's badge) and checks if you have that particular flag set. If you have that flag set you will be allowed to use the move, but if you don't, you won't be able to. For example: if you want to use Fly, its position in the array is 0x5 so its added to 0x867, giving the result of 0x86C which is the flag that's set when you beat Winona. Anyway, since we're trying to dislocate the badges from the flag checks, we only need to change the flag that we add the array position to and we'll have achieved our objective. This function's flag (0x867) can be found at 0x1B5514 in a hex editor. Just change it to a flag that you're not using and save the game. For example, if I wanted to change it to flag 0x200, I would replace the 67 08 with 00 02. Now if you set flags 0x201 and 0x204, you'll be able to use Fly and Flash respectively, even if you don't have their respective badges. From this point onward in my explanation, flags 0x200 - 0x207 will control HM use in the field, but you can use a different set of flags if you want.

Since we've got the hardest set of HMs out of the way, its time to deal with the water HMs. At this point, if you set flag 0x202 and interacted with a body of water, you wouldn't be given a prompt to Surf, but if you selected Surf in the party menu, you would jump on your Pokemon and sail away. Whenever you interact with a surfable tile, the game checks three things: If the tile is surfable, if flag 0x86B is set (5th gym badge) and if you have a Pokemon with Surf on your team. If all three conditions are met, it will then move onto the the actual Surf script and ask if you want to Surf. If any of the three checks returns false, then the routine will terminate early and you won't even be given a chance to swim. Anyway, to edit the flag that's used in the second check, go to 0x09C81C and change the two bytes there to the flag you want to use. In a clean ROM its says 6B 08 and since I want to use flag 0x202 to match up with the changes we made in the first part, I would change it to 02 02. Now whenever you interact with a body of water, you'll get the prompt to Surf if you have a Pokemon that knows the move! Waterfall and Dive are in the same boat as Surf in that they have pre-checks before you can use them. Waterfall's flag check is at 0x09C850 - Change it to 07 02. Dive has two flag checks; one for ascending and another for descending. These can be found at 0x09C88C and 0x09C8C8 respectively - Change them to 06 02.

Finally, for the easiest of all, the remaining HMs are easily edited in their scripts. Open up any Cut tree, Strength boulder or Rock Smash rock's script from Advance Map and search for their respective gym badge flags. Change them to 0x200, 0x203 and 0x205 respectively.

Once you've edited those scripts, you're all done and have dislocated all the HMs from their badge checks! Now whenever you make a gym leader's script, you will need to set the flag corresponding to the HM you want to allow, along with the original badge flag as they still have other uses like showing which badges you have on your trainer card.
 
3
Posts
5
Years
So, thanks to your advice, I think I managed to get Cut working without a badge, but I'm having diffculties finding where Fly would correspond to in hex. I'm not experienced with hex code so please excuse me if I'm being really dumb and overlooking something really obvious. :3
 

DrFuji

[I]Heiki Hecchara‌‌[/I]
1,691
Posts
14
Years
Go to 0x1B5514 in a hex editor and you should see the two bytes "67 08". Change them to "00 02". Now when you use the command "setflag 0x201" in a script, you will be able to use Fly without getting the sixth badge.
 

TheBatPrince

Banned
76
Posts
4
Years
Thank you very much, turns out my script was wrong, now I just have to do this for all the rest of the HM's, thank you again! If you have any other advice I'd love some. :3

Basically, ASM is a file type for a Program written in Assembly Language! It was first made around the 60s or something, and was used in the more "basic" environment of Computers. The skill behind it comes from knowing how to think like a Basic Machine would, and remove any other clutter from higher level languages. I'm not sure how it's used in ROM Hacking, or WHY it even is used for ROM Hacks as it's usually not used for that from 1980s to now.

There's a simple Architecture they teach in most Schools today, where it has the CPU, the Memory, and the Devices. Imagine them all as Rectangles in a drawing in a Triangle shape, connected by another Square in the middle called the Bus! The Bus is also called the System Bus, or you can call it a Master Bus. Basically the 3 Sub Buses of Address Bus, Control Bus, and Data Bus are all used with the System Bus to relay Data back and forth between the 3. The Address Bus will determine what the Address is of each Byte of Memory! Addresses depending on the CPU architecture, can range from being relatively massive to just plain GIGANTIC numbers (which makes sense, given how much Data is on the Machine).

So essentially, all of the Instructions that are being computed by the CPU are being stored in the Console's RAM, a section of the Memory Board that is erased every time the device powers off. The core BIOS of the Machine that are used to start up the Console's OS (it's not OS like you know it as in the Desktop Computer world, with a big logo saying "Windows XP" or something) are stored in the ROM of the Memory Board. The ROM is not erased ever, and if it is, you can have trouble booting your Machine. What the Emulator does is, it tries to make a Virtual version of these components to be all ran condensed into 1 Emulator Application!

That being said, the Instructions you write in an Assembly program are all converted into Binary, which is then interpreted by the CPU. It will store the Instructions used for the Game on a type of "Hard Drive" in the Cartridge, which would be written in a more Human language. Then they are sent to the RAM of the Console through the Electrical Pins inside the Slot, and it will execute each Instruction smoothly; generating a nice boot-up logo and all! However often times it's just standard to use Hexadecimal instead of Binary, with Decimal being the normal Number Set we use of 0 to 9. As in, we can make 10 by mixing 1 and 0, 11 with 1 and 1, etc. It's only just 10 numbers repeated. This is because of the Prefix "Dec", and with Binary, it uses "Bi", Hexa uses "Hex" for 16; essentially giving you 16 characters that loop. So when you start at 0 and get to 9, you instead make 10 into an A, 11 into B, 12 is C, 13 is D, 14 is E, and 15 is F! That's why to say 15 in Hex, you just write "F".

Any time you see a "0x" followed by some type of code as you showed above, that is an old way of noting in an Assembly Program that you are using Hexadecimal numbers. Another way might be to add the letter "h" at the end, depending on what this System uses. However as to this "setflag" command I couldn't tell you, as I don't know the languages these Pokemon games use. Usually a Flag refers to something else, it's in the subject of Control Flags. Not the type of thing that would have so many values like it seems to in this case, it was originally only 16 and under Control Flags that were used to determine things.

Hope this helps a tad! :P
 
Last edited:
Back
Top