Welp, here you probably are, either embarking on your first ASM tutorial or have tried countless others and none have worked. In either case, I think this ASM tutorial is for you. It's designed to be simple, SMW-relative, easy, and most of all very explicit and plain. I'll teach you the easy stuff, and spell everything out. That way, you can do at least a LITTLE asm, right? Better than nothing. Then, if you're lucky, we'll do the harder stuff later. It's for the stuff you can use to make cool gimmicks in levels, but at the same time only being a few lines of code. Mostly, this is for cool stuff that you can add to levels for effects. Nothing complicated.
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:
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!)
Accumulator-
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.
You need:
Lunar Magic
A ROM saved once with Lunar Magic, named smw.
LevelASM (go to patches section, make sure it's Ersanio's.)
Windows Calculator
Notepad
Xkas
Here's what I have:
Here
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...
4. Aha!
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:
LDA #$__
STA $_____
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:
LDA #$02
STA $7E0019
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.
Type in
xkas level.asm smw.smc
or
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
LDA #$01
STA $7E0073
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.
LDA #$03
STA $7E0DC2
Cool!
Now, let's do another template.
LDA $_______
CMP #$___
BEQ equal
RTS
equal:
LDA #$__
STA $_____
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.
BEQ equal
RTS
equal:
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.
LDA $7E0019
CMP #$02
BEQ equal
RTS
equal:
LDA #$0A
STA $7E0DBF
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.
LDA $7E0DBF
CMP #$0A
BEQ equal
RTS
equal:
LDA #$02
STA $7E0019
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.
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:
Decimal 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | Hexadecimal: (Hex) 1 2 3 4 5 6 7 8 9 A B C D E F 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F 20 21 22 23 24 25 |
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!)
Accumulator-
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.
You need:
Lunar Magic
A ROM saved once with Lunar Magic, named smw.
LevelASM (go to patches section, make sure it's Ersanio's.)
Windows Calculator
Notepad
Xkas
Here's what I have:
Here
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...
4. Aha!
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:
LDA #$__
STA $_____
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:
LDA #$02
STA $7E0019
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.
Type in
xkas level.asm smw.smc
or
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
LDA #$01
STA $7E0073
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.
LDA #$03
STA $7E0DC2
Cool!
Now, let's do another template.
LDA $_______
CMP #$___
BEQ equal
RTS
equal:
LDA #$__
STA $_____
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.
BEQ equal
RTS
equal:
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.
LDA $7E0019
CMP #$02
BEQ equal
RTS
equal:
LDA #$0A
STA $7E0DBF
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.
LDA $7E0DBF
CMP #$0A
BEQ equal
RTS
equal:
LDA #$02
STA $7E0019
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.