Alright, this is a Block Tutorial for ASM!
Let's get started!
1: OFFSETS!
Ok. The first thing you need for your custom block are the offsets. Offsets
are basically what tells the game to do in a certain case. Here's what I
mean:
That is an offset. It says to JuMP to a certain section of the code, or a
LABEL, and execute the Code. Pretty simple. They are seperated by a
Colon, : To keep things organized, you should set your labels to every action:
Now, offsets can be named ANYTHING as long as there is a corresponding LABEL. If you don't know what that means, it means that as long as the OFFSET is linked with a LABEL, you're fine =)
Offsets can also be combined. EX.
JMP Mario and JMP Return can be used if you want to have it work ONLY with specific things and don't want to write out the offsets, like so:
Honestly, I prefer writing them all out, but whichever works for you is better for you, obviously!
Also, there are 3 other offsets that can be used. They are JMP MarioCorner, JMP HeadInside, and JMP BodyInside. These require you to place a
at the top.
So, what do all of these do???
Here:
MarioBelow = If mario hits the block from below.
MarioAbove = If mario touches the block from Above.
MarioSide = If mario hits the block from either sides.
SpriteV = If any sprite touches it vertically.
SpriteH = If any sprite touches it horizontally.
MarioCape = If mario hits it with his cape.
MarioFireball = If mario hits it with his fireball.
*MarioCorner = If mario hits any of the 4 corners.
*HeadInside = If mario's head is INSIDE the block.
*BodyInside = If mario's body is INSIDE the block.
*REQUIRES
That's It for Offsets!
2: Labels!
This ones a quicky. Set up your labels like so:
That's all.
3: THE CODE!
Here's the fun part. Here is where you create your code. The possibilities are nearly endless! Let's start
with something simple:
Ok, if you don't know any ASM, you are going to look at this and say "What is he talking about!?"
It's actually quite simple. We LOAD a value using LDA, and STORE it with STA. When we load a value,
then store it into an address, we are telling the game to take our Value and make the address respond
to that value. Think of this:
You step on something sharp. Your Foot sends a signal to your brain and tells it "OUCH!"
like the game sends the Value we LDA'd to the Address and STA's it. Then your brain sends your foot
PAIN. Just like our Address says, "Yeah, uh, he touched the block, so, uh let's make him big." to the Game!
Let's get more complicated:
Ok. Let's break it down:
This loads mario's coins.
Now, this one is new, but is VERY useful! CMP means CoMPare. #50. A # means a Decimal value. So,
this:
Checks if mario has 50 coins!
Ok. BEQ means Branch if EQual. Branch means to go to a section of the code. BEQ will only branch if
the above is true. (In our case, if mario has 50 coins)
Otherwise, do nothing.
This is a LABEL. When we branch, we need something for the branch to identify.
Load mario's lives.
If you do not know ASM, then I might lose you here. Pay attention.
First, CLC. CLC pairs with ADC. What do they do? Well, ADC means to take an address that was loaded
with LDA and ADD a Value to it, in our case 5.
So, we are checking if mario has 50 coins. If he does, we Branch. If not, we do nothing. In the HasCoins
LABEL, we are taking mario's lives, and using CLC and ADC to add 5 to them.
If you want to make this a shop/trade block, just use STZ.
STZ will STore Zero to an Address. So it will look like this:
If you really want to make a shop block, you would use SDC to subtract 50 from your coins, but I won't
go into that.
So, all together it should look like this:
4: MORE TO DO!!!
There is A LOT more you can do than explained here. To learn more ASM use either Schwa's or Maxx' Tutorials. They are very good, detailed tutorials.
One more thing I will show you is what I call a Dictionary. What it is is defining something(Address, Value, or whatever) using something like a Variable.
This can be very useful if you are making a large coded block or a customizable block.
So, the way it is used is like this:
Now, the VAR would be whatever, whether it be !Coins, !Powerup, !KillPlayer, as long as it has the ! in front.
The VALUE is where your address or value goes.
Ex.
So, whenever you want to change a value or address, it is always waiting at the top!
Think of this:
The Dictionary is all of your ! codes are. You need a word, or VAR, and you need a definition, VALUE! It's really easy once you get used to it.
So, to use it you do this:
See, it's as simple as that!
Thanks for reading my tutorial. I have seen A LOT of people requesting CUSTOM BLOCK TUTORIALS specifically.
I will almost ALWAYS be adding on to this. PM me or post if you have a question!
Your layout has been removed.
Let's get started!
1: OFFSETS!
Ok. The first thing you need for your custom block are the offsets. Offsets
are basically what tells the game to do in a certain case. Here's what I
mean:
Code
JMP MarioBelow
That is an offset. It says to JuMP to a certain section of the code, or a
LABEL, and execute the Code. Pretty simple. They are seperated by a
Colon, : To keep things organized, you should set your labels to every action:
Code
JMP MarioBelow : JMP MarioAbove : JMP MarioSide : JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireBall
Now, offsets can be named ANYTHING as long as there is a corresponding LABEL. If you don't know what that means, it means that as long as the OFFSET is linked with a LABEL, you're fine =)
Offsets can also be combined. EX.
JMP Mario and JMP Return can be used if you want to have it work ONLY with specific things and don't want to write out the offsets, like so:
Code
JMP Mario : JMP Mario : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return
Honestly, I prefer writing them all out, but whichever works for you is better for you, obviously!
Also, there are 3 other offsets that can be used. They are JMP MarioCorner, JMP HeadInside, and JMP BodyInside. These require you to place a
Code
db $42
at the top.
So, what do all of these do???
Here:
MarioBelow = If mario hits the block from below.
MarioAbove = If mario touches the block from Above.
MarioSide = If mario hits the block from either sides.
SpriteV = If any sprite touches it vertically.
SpriteH = If any sprite touches it horizontally.
MarioCape = If mario hits it with his cape.
MarioFireball = If mario hits it with his fireball.
*MarioCorner = If mario hits any of the 4 corners.
*HeadInside = If mario's head is INSIDE the block.
*BodyInside = If mario's body is INSIDE the block.
*REQUIRES
Code
db $42
That's It for Offsets!
2: Labels!
This ones a quicky. Set up your labels like so:
Code
MarioAbove: MarioSide: MarioBelow: SpriteV: SpriteH: MarioCape: MarioFireBall:
That's all.
3: THE CODE!
Here's the fun part. Here is where you create your code. The possibilities are nearly endless! Let's start
with something simple:
Code
LDA #$01 ;LoaD the value 01. STA $19 ;STore it into the Address $19, the power-up Address RTL ;This is important! It ends your code. DO NOT USE RTS!
Ok, if you don't know any ASM, you are going to look at this and say "What is he talking about!?"
It's actually quite simple. We LOAD a value using LDA, and STORE it with STA. When we load a value,
then store it into an address, we are telling the game to take our Value and make the address respond
to that value. Think of this:
You step on something sharp. Your Foot sends a signal to your brain and tells it "OUCH!"
like the game sends the Value we LDA'd to the Address and STA's it. Then your brain sends your foot
PAIN. Just like our Address says, "Yeah, uh, he touched the block, so, uh let's make him big." to the Game!
Let's get more complicated:
Code
LDA $0DBF CMP #50 BEQ HasCoins RTL HasCoins: LDA $0DBE CLC ADC #$05 STA $0DBE RTL
Ok. Let's break it down:
Code
LDA $0DBF
This loads mario's coins.
Code
CMP #50
Now, this one is new, but is VERY useful! CMP means CoMPare. #50. A # means a Decimal value. So,
this:
Code
LDA $0DBF CMP #50
Checks if mario has 50 coins!
Code
BEQ HasCoins
Ok. BEQ means Branch if EQual. Branch means to go to a section of the code. BEQ will only branch if
the above is true. (In our case, if mario has 50 coins)
Code
RTL
Otherwise, do nothing.
Code
HasCoins:
This is a LABEL. When we branch, we need something for the branch to identify.
Code
LDA $0DBE
Load mario's lives.
Code
CLC ADC #$05
If you do not know ASM, then I might lose you here. Pay attention.
First, CLC. CLC pairs with ADC. What do they do? Well, ADC means to take an address that was loaded
with LDA and ADD a Value to it, in our case 5.
So, we are checking if mario has 50 coins. If he does, we Branch. If not, we do nothing. In the HasCoins
LABEL, we are taking mario's lives, and using CLC and ADC to add 5 to them.
If you want to make this a shop/trade block, just use STZ.
STZ will STore Zero to an Address. So it will look like this:
Code
LDA $0DBF CMP #50 BEQ HasCoins RTL HasCoins: LDA $0DBE CLC ADC #$05 STA $0DBE ClearCoins: STZ $0DBF RTL
If you really want to make a shop block, you would use SDC to subtract 50 from your coins, but I won't
go into that.
So, all together it should look like this:
Code
JMP MarioBelow : JMP MarioAbove : JMP MarioSide : JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireBall MarioAbove: MarioSide: RTL MarioBelow: LDA $0DBF ;Load coins CMP #50 ; Check if we have 50 BEQ HasCoins ; If so, branch RTL ; Otherwise, do nothing HasCoins: LDA $0DBE ;Load lives CLC ; Add 5 to lives ADC #$05 ;| STA $0DBE ;Store it to our lives ClearCoins: STZ $0DBF ;Set coins to 0 RTL ; End code SpriteV: SpriteH: MarioCape: MarioFireBall: RTL
4: MORE TO DO!!!
There is A LOT more you can do than explained here. To learn more ASM use either Schwa's or Maxx' Tutorials. They are very good, detailed tutorials.
One more thing I will show you is what I call a Dictionary. What it is is defining something(Address, Value, or whatever) using something like a Variable.
This can be very useful if you are making a large coded block or a customizable block.
So, the way it is used is like this:
Code
!VAR=VALUE
Now, the VAR would be whatever, whether it be !Coins, !Powerup, !KillPlayer, as long as it has the ! in front.
The VALUE is where your address or value goes.
Ex.
Code
!Powerup=$19
So, whenever you want to change a value or address, it is always waiting at the top!
Think of this:
The Dictionary is all of your ! codes are. You need a word, or VAR, and you need a definition, VALUE! It's really easy once you get used to it.
So, to use it you do this:
Code
LDA #$03 STA !Powerup
See, it's as simple as that!
Thanks for reading my tutorial. I have seen A LOT of people requesting CUSTOM BLOCK TUTORIALS specifically.
I will almost ALWAYS be adding on to this. PM me or post if you have a question!
Your layout has been removed.