How do I check a byte and how do I replace the opcodes
Open up the ROM in your favorite hex editor (I use Windhex). To help you get started, I'll show you the location of one ASM string: at offset 5FB1. When you start a new game, this ASM string gets run during Oak's speech.
I've attached a list of ASM opcodes to this post. It's probably got a few errors, but for the most part it's correct. If you need to know what an opcode does,
check out this list.
A register is essentially a storage place inside the Game Boy that stores a value of one byte. Some can be paired to hold two bytes. The most prominent registers in the Game Boy CPU are a, b, c, d, e, f, h, and l -- they can be paired as af, bc, de, and hl. Note that a (also known as the
accumulator) is the most versatile of these registers, f is the least (you can't change its values directly), and all the others are about equal.
Okay, let's get going. At 5FB1, you'll see this in your hex editor:
Let's start with the first byte. According to asmopcodes.txt (attached to this post), 11 YY XX means "load the next two values into de." So our first opcode is
The next one is CD. According to our list, CD means "call the ASM function starting at this location, and then return."
There are two ways to figure out what a function does. The first way would be to go to offset 3D98 and start disassembling there, but if this happens you might spend all day disassembling something that started with one function call (I've done this more than once!). The second way would be to blank out the call and determine what doesn't happen. So let's replace the CD 98 3D with 00 00 00 (3 NOPs, or "no operation"s). Save the ROM in your hex editor and load it in VBA. When you start a new game and listen to Oak's speech, what's different?
If you noticed there was no music, that's great! We can
assume that the function at offset 3D98 starts playing music, but it needs more testing. How can we change what music is being played? Generally, we would change what data is loaded into registers before the function is called. Replace the original code with
Did the music change? Then you've made your first ASM hack -- changing the music during Oak's speech! What's more, we've learned how to play music in ASM. If you know the location of some ASM for a specific point in the game, you can just load de with the song number and call $3D98 to play it!
Keep disassembling at that location. See if you can figure out what functions print text and play Pokemon cries. See if you can figure out how to display a Pokemon picture (it doesn't use a function!).