You are not logged in.
I'm trying to removing the badge requirements to use HM moves in the field in Yellow version. I'm pretty sure I've located the relevant code in start_sub_menus.asm.
Here is the code for badge requirement for Fly:
bit 2,a ; does the player have the Thunder Badge?
If I understand correctly, the 2 in the bold part represents 0x57, which is the hex value for the Thunder Badge.
When I changed the hex values for the required badges to 0x01 using a hex editor, it seemed to remove the badge requirements. But if 0-7 represent the eight badges in the disassembly, how can I set the the hex values to 0x01?
Last edited by _Q_ (2018-07-28 22:01:40)
Register 'a' is an 8-bit register, and at this point in the code, it is loaded with the value from 'wObtainedBadges'
This is an 8-bit ram value that is used as 8 flags, representing which badges the player has obtained.
Bit 0 is set to 1 if you obtained the Boulder Badge, bit 1 is set to 1 if you obtained the Cascade Badge, bit 2 is set to 1 if you have obtained the Thunder Badge etc.
The 'bit 2, a' instruction is an assembly instruction that sets the z flag if bit 2 of register 'a' is 0, and resets the z flag if bit 2 of register 'a' is 1.
The next instruction, 'jp z, .newBadgeRequired' jumps to the label '.newBadgeRequired' only if the z flag is set (if the player does not have the Thunder Badge).
If your goal is to remove the badge requirement, you simply need to remove the 'bit' instruction and the 'jp z' instruction.
The 0x57 you are referring to is not an item ID (in fact, the item ID for the Thunder Badge is 0x17).
That 0x57 is part of the opcode for the 'bit 2, a' instruction.
The 'bit' instruction is one of the few kinds of instructions with a 2-byte opcode (most instructions have a 1-byte opcode).
All the 2-byte opcode instructions have 0xCB as the first byte, and are referred to as the Prefix CB opcodes.
Take a look at these tables: http://pastraiser.com/cpu/gameboy/gameboy_opcodes.html
So when you changed the 0x57 to 0x01 in the hex editor, you actually changed the instruction from 'bit 2, a' to 'rlc c' which just happened to reset the z flag so that it seemed to remove the badge requirement by coincidence.