I'll start at the very beginning. This tutorial might have a lot of words, but it's made for skimming or heavy reading depending on how much you care.
What is ASM?
ASM, or Assembly, is the very basic code that the SNES runs to keep everything going. Sprites, blocks, LevelASM, EVERYTHING, uses this code. On one hand, you can get very very complicated, making 3Dish effects and fancy, gamechanging codes, but on the other, you can create simple things in quick, easy, steps. Note that this information will not try to be accurate, but simply easy to learn, as the accuracy doesn't matter yet in this stage. You can learn the hard stuff later, right? You learn single-digit subtraction first, and then your teacher teaches you all the exceptions and special rules.
Some important terms:
ROM- This is that code that I talk about above! This is all the code for Super Mario World, made into numbers (that's not important; your assembler does that for you!) that the game reads. The sad part about this is that it can't be edited with other code. Sorry, but that's how it works!
RAM- This is a whole bunch of numbers, variables, that the game uses to determine everything. Think of it like a street, actually. Here you are at RAM Lane. The first house, with the address 1, has the number 4 in it. The second house, with the address 2, has the number 66 in it. Each address- we'll talk about this later- is just a "holding place" for a number, and you can access those numbers to find out what they are.
Hexidecimal- Sometimes refered to as hex, this is the proper number system for SNES programming. I know what you're thinking- what? I have to learn all-new numbers? Well, not quite. Hex simply works like this:
| Hexadecimal: (Hex)|
Notice how those "ABCDEF" got stuck in there! It adds (tens-place)A,B,C,D right after (tens-place)9. Lucky for you, this is all you have to learn for now. Use Windows Calculator to switch from decimal to hexidecimal whenever. (All Programs > Accessories > Calculator. Then, go to view > scientific. Type in your value, then press "hex." There you go!)
This is like a RAM spot, but it can be changed using commands instead. It's the "holding place" for the number you are currently dealing with.
Now, let's finally just set up some actual code.
A ROM saved once with Lunar Magic, named smw.
LevelASM (go to patches section, make sure it's Ersanio's.)
Here's what I have:
Alright. Put all of these things in a folder. Now, some of you are probably worried we are using xkas and LevelASM (complicated stuff, right?) But not to worry- I'll go through that step-by-step too.
Firstly, let's install LevelASM into your rom.
1. Open up the Start Menu. (You know, that little button at the bottom-right part of your screen.)
2. Near the bottom of the panel is "search..." type in "cmd" without the quotes.
3. Wait as it searches...
5. Right-click on the top one.
6. Select "copy."
7. Now, go to your folder that has all that stuff listed above in it.
8. Right click on a empty space and press "paste."
7. Good, first part over.
Now, let's actually get it working.
1. Double-click that new "cmd" you just put in.
2. Now, this box pops up.
3. Type this, exactly:
xkas level.asm smw.smc
4. This should be the result. If it's not, and you get a error,
type "xkas smw.smc level.asm" instead (without quotes.)
5. Open your rom and start a level to make sure it still works.
6. Now, close your rom. Congrats, you have inserted levelasm. Now you just have to put in the code.
Putting in the code
First, I'm going to teach you two things: LDA and STA. These are codes, that tell the game what to do, the first you will learn. LDA will put a value in the accumulator (that variable that you put stuff in, remember?) and STA will take that value, and put it somewhere you want.
This all simply goes in a notepad document, but in this case do this:
1.Open up levelcode.asm.
2.Press "ctrl+f" at the same time.
3.In the box that comes up, type in "105" (no quotes.)
4. Press enter.
5. That area, right under the level105: and the RTS, is where you will put your code! Now, let's get started.
First, let's talk about what we will be doing. We are going to make some of the game's numbers, like lives, coins, and so on, stay at a value. We will do this by taking a number (LDA) and putting it in the address of the "house" that the game's other number, like lives, go in. So, you'd take a number like 5 and put it in the house for 19, which will make that house, 19, have the number 5. (STA)
Okay, now we get to run wild. Follow this format:
The first blank is the number you want some number in the game to be. Let's say, 15. Well, just to be sure, you need to convert it to hex. So, get out the calculator, type in 15, and then put in the number you get into that blank. You can only use two-digit numbers. If you have a one digit number, like 3, you have to put a 0 in front, 03, 05, 08, 0B, and so on. More than two? Sorry, you're out of luck.
Now, let's go here! That wonderful little page has all the addresses for the "houses" that each number of SMW lives at. Almost all of them, anyway. So, let's find a entry that we like. How about this?
$7E:0019----1 byte-----Player-----Powerup. #$00 = Small, #$01 = Big, #$02 = Cape, #$03 = Fire.
Oho! The powerup the player has! That's right, it's just a number too.
Now, we can wreak havoc all over! The only thing you need to worry about is that first number, $7E:0019. Get rid of the colon, so it's $7E0019, and then that's it! That's the address to the house! So:
That would make mario have a cape, all the time, in level 105. This is what it looks like to me. Save the file.
Now, go back to the command prompt (that black box) again.
xkas level.asm smw.smc
xkas smw.smc level.asm
depending on which worked last time.
Now, go to level 105 in your game.
Aha! Mario has a cape, awesome.
Now, I'll show a few more examples. Run wild!
Please note that not all addresses you choose will work. Some are bigger than what you can use right now, some have different ways of working, crazy stuff like that. But for now, just find a few and experement.
$7E:0073------1 byte----Flag---Mario is ducking flag.
Oh yeah, flags. Just a FYI, flags are easy. Value 01 is yes, value 00 is no. Okay, so
Save the file, and then do that command prompt thing. Hahaha! Mario is aways ducking.
$7E:0DC2---1 byte----Player-----Reserved item aka Item Box. #$00=None; #$01=Mushroom; #$02=Fire Flower; #$03=Star; #$04=Cape
Oh, sweet. Mario can always have a star in the item box.
Now, let's do another template.
Now, this one is a little trickier. You can only have one copy of this code running in your entire file, so make sure that's the case.
This code checks to see if some number in SMW is equal to a number of your choosing, and then, if it is, you can load and store a number to it.
LDA $_______ ; Put a address to one of those values in SMW here.
CMP #$___ ; Put the number you want that address to be for it to do the store code here.
LDA #$__ ; The value you want to load
STA $_____ ; the address you want to store it.
Now, how about this: If the powerup is a flower, (number 2,) then mario will have 10 coins. Okay.
This is what it looks like for me. Save, and do the command prompt thing.
The CMP has the same rules as the LDA from the first code we did.
Okay, here is another. If you have 10 coins, then ,make mario have a cape.
There you are. Not too hard at all.
If anything goes wrong, if you have any trouble, or questions, etc, just give a post here and I'll try to solve your problem. It makes the tutorial better, so it seems fair it goes here.