Help me with this code
So, I found this code from a website (linked at the bottom) that explains how the glitch beams work in Super Metroid. There are few things that I don't understand about this code.
1. What are the numbers between $90/AD12 and LDA [$00],y
2. Why are some of the "positions in the ROM" (not sure what they are actually called) missing? (like $90/AD13)
3. What are the BMI and RTS?
4. What are the numbers inside the [ and ] ?
Here is the site I found this code. There are few other similar codes, so I just took this one as an example. If you want to fond the code that I used here, search for Spacetime beam (0psi0)
http://tasvideos.org/GameResources/SNES/SuperMetroid.html
EDIT: I forgot one thing. Is there a list of the "machine codes" for each "instruction" (like LDA and STA) that the SNES actually reads them. (like JSR is 20 in Hex if I remember correctly).
$90/AD12 B7 00 LDA [$00],y
$90/AD14 9F C0 C1 7E STA $7EC1C0,x
$90/AD18 E8 INX
$90/AD19 E8 INX
$90/AD1A C8 INY
$90/AD1B C8 INY
$90/AD1C C0 20 00 CPY #$0020
$90/AD1F 30 F1 BMI $F1 [$AD12]
$90/AD21 60 RTS
1. What are the numbers between $90/AD12 and LDA [$00],y
2. Why are some of the "positions in the ROM" (not sure what they are actually called) missing? (like $90/AD13)
3. What are the BMI and RTS?
4. What are the numbers inside the [ and ] ?
Here is the site I found this code. There are few other similar codes, so I just took this one as an example. If you want to fond the code that I used here, search for Spacetime beam (0psi0)
http://tasvideos.org/GameResources/SNES/SuperMetroid.html
EDIT: I forgot one thing. Is there a list of the "machine codes" for each "instruction" (like LDA and STA) that the SNES actually reads them. (like JSR is 20 in Hex if I remember correctly).
Comments
2. It's not missing. See the 00 on line 1? That is what you are missing. If you'll notice between line 2 and 3, there would be 3 bytes missing, but the missing bytes are actually c0 c1 7e.
3. BMI is branch on minus and RTS is return from subroutine.
4. The number inside the brackets after the BMI (I believe that is what you are referring to), is where the program branches to when the negative flag (tested by the BMI) is set. That is included by the disassembler for your own reference, because BMI is going to be an 8-bit branch, the $f1 is telling the program where to go. So that number on the right is just showing you so you don't have to bother counting to the place where the branch goes. And notice that the number they give is actually line 1? So when the negative flag is set, the program loops back to the beginning of this snippet you posted.
As for the question you edited in, do a search for 65816 opcodes and you should find what you want. And I'll throw in that since you weren't familiar with BMI, do a search for 65816 instruction set. You might even find them together somewhere : )
Hope this helps and is understandable!
That $f1 is telling it where to branch to. Let me try to illustrate with the code as if it were in the source file. THE_ROUTINE will be the name of this routine hehe
THE_ROUTINE:LDA [$00],ySTA $7EC1C0,xINXINXINYINYCPY #$0020BMI THE_ROUTINERTSThe BMI is actually checking the negative flag of the CPY right above (which means ComPare Y).
I took a look at SNES's opcodes and the machine-codes and now I'm kind of confused because there are so many different Addressing Modes and I can't find much information about them. Only site I have found has very lacking information about them.