Language…
7 users online: Firstnamebutt, Gro, Hayashi Neru, Majorasmaskkingdom, Slash-18, SomeGuy712x, Zavok - Guests: 720 - Bots: 192
Users: 61,708 (2,255 active)
Latest user: Elias31

Official Hex/ASM/Etc. Help Thread

  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 418
  • 419
  • 420
So i decided to mess up with asm, so, maybe, in future, i can do something of decent. otherwise, i still have my art skills.

Ok, i tried to use edit1754's level asm tool and i would like to clarify something:
Code
{InitCodeLabel}:
	;INIT CODE GOES HERE
	RTL
{MainCodeLabel}:
	lda $1420
	cmp #$05
	beq makebig
	rtl
makebig:
	lda #$01
	sta $19
	rtl

Pratically, this code should make Mario big when it gets five yoshi coins. and IT WORKS DOGGAMN! But i also have some questions:
- What does "INIT CODE" mean? what should i place there?
- I also want to use multiple branching paths, kinda:

Code
If Mario is Small
and
If Yoshi Coins = 5
vvv
Mario gets Big
and
Yoshi coins reset to 5


I think that with normal branching commands this is not doable (once i tried that and it didn't work). So, how could i make that? Are there some commands that can do it?
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Originally posted by Dinomar
- What does "INIT CODE" mean?

Any code placed there will only run once, when the level loads. Useful if you want to do stuff like make Mario always enter a level big, reset a freeRAM address used somewhere in the level, or for static HDMA gradients.

Originally posted by Dinomar
- I also want to use multiple branching paths

You can do that by just putting several branching commands in a row, like this:

Code
	LDA $19
	BNE .DontMakeBig
	LDA $1420
	CMP #$05
	BNE .DontMakeBig

	LDA #$01
	STA $19
	RTL

.DontMakeBig
	RTL

My YouTube channel
Get the official ASMT resource pack here!

So init code will make Mario Big if i insert a code in it but will run only for one frame at the beginning of the level, but not while playing it? And does an HDMA grandient work in the MAIN CODE?

Then, i see that code works as i wished to. but why doesn't this code work?
Code
	lda $1420
	cmp #$05
	beq makebig
	lda $19
	cmp #$00
	beq makebig
	rtl
makebig:
	lda #$01
	sta $19
	rtl

If Mario gets five yoshi coins and if he is small... he becomes big. But why doesn't that code above work? Do i miss some command there?
In the code you posted i can deduce that "Mario will be big if mario is not small and if he doesn't have five yoshi coins". But why only LDA? Shouldn't be "STZ" for 00 values?

Originally posted by yoshicookiezeus
Originally posted by Dinomar
- What does "INIT CODE" mean?

Any code placed there will only run once, when the level loads. Useful if you want to do stuff like make Mario always enter a level big, reset a freeRAM address used somewhere in the level, or for static HDMA gradients.

Originally posted by Dinomar
- I also want to use multiple branching paths

You can do that by just putting several branching commands in a row, like this:

Code
	LDA $19
	BNE .DontMakeBig
	LDA $1420
	CMP #$05
	BNE .DontMakeBig

	LDA #$01
	STA $19
	RTL

.DontMakeBig
	RTL

My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Originally posted by Dinomar
Then, i see that code works as i wished to. but why doesn't this code work?

I think the easiest way I'll be able to explain this is to add some comments to your code:

Code
	lda $1420	;\ if Mario has five Yoshi coins,
	cmp #$05	; |
	beq makebig	;/ branch
	lda $19		;\ if Mario is small,
	cmp #$00	; |
	beq makebig	;/ branch
	rtl		;  return
makebig:
	lda #$01	;\  make Mario big
	sta $19		;/
	rtl		;  return

So the code you have created here turns Mario big if he has five Yoshi coins or if he is small.

Originally posted by Dinomar
But why only LDA? Shouldn't be "STZ" for 00 values?

If you leave out the CMP in a branch statements, it gives the same effect as if you put in a CMP #$00; what the CMP command actually does is subtract the value in the CMP from the value in the accumulator (but without actually affecting the accumulator itself), and then the result is used to determine whether or not the branch statement is executed. And STZ just sets a RAM address to zero (it's pretty much the same as LDA #$00 STA), so it isn't applicable in this case at all.
My YouTube channel
Get the official ASMT resource pack here!

Oh, i see, So, if i do like that, it will be like "Or" isntead of "And", i suppose. I wonder if there is a way to make it "And" instead of "Or" with my code: Is BNE required instead of BEQ in those cases? (Which i suppose BNE is the opposite of BEQ, ie, activates the code if there are not certain conditions, just to clarify i know that)
And if, to the code, i want to reset the Yoshi Coin counter, if i do this:
Code
	LDA $19
	BNE .DontMakeBig
	LDA $1420
	CMP #$05
	BNE .DontMakeBig

	LDA #$01
	STA $19
	
	STZ $1420
	RTL

.DontMakeBig
	RTL

See, i added "STZ $1420": It resets the Yoshi coin counter, and it works, actually, but i was wondering if it is a better way to do that... kinda a shortcut.
Also: Why there is a "." behind "DontMakeBig"? Is that a kind of shortcut that makes you not required to add a colon ":" front of "DontMakeBig"?
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Originally posted by Dinomar
(Which i suppose BNE is the opposite of BEQ, ie, activates the code if there are not certain conditions, just to clarify i know that)

That's pretty much exactly what it is, yes: BEQ is Branch if Equal, and BNE is Branch if Not Equal.

Originally posted by Dinomar
See, i added "STZ $1420": It resets the Yoshi coin counter, and it works, actually, but i was wondering if it is a better way to do that... kinda a shortcut.

Yes, STZ is just that: a shorter way to write LDA #$00 STA (and a way that doesn't involve changing the value in the accumulator). It doesn't work with all addressing modes, though; STZ $xx,y, STZ $xxxx,y and all of the variations of STZ $xxxxxx plain out don't exist, so you'll need to use the longer method in those cases.

Originally posted by Dinomar
Also: Why there is a "." behind "DontMakeBig"? Is that a kind of shortcut that makes you not required to add a colon ":" front of "DontMakeBig"?

Those are sublabels; LevelASMTool require you to use them. I think that an example is the best way to explain them:

Code
Label1:
; code here
.Sublabel1
; more code here
.Sublabel2
; even more code here

This code is parsed by the assembler like this:

Code
Label1:
; code here
Label1_Sublabel1:
; more code here
Label1_Sublabel2:
; even more code here

Now, in this example, the sublabels aren't all that useful, but now look at this:

Code
Label1:
; code here
.Sublabel1
; more code here
Label2:
; even more code here
.Sublabel1
; even still more code here

You see that unlike with normal labels, I can have two sublabels with the same name as long as they belong to different main labels, since their actual names as parsed by the assembler are different (in this case Label1_Sublabel1 and Label2_Sublabel1). Useful for label names that come up a lot; coming up with a new label name for each generic loop you need is kind of annoying when you can just name them all .LoopStart.
My YouTube channel
Get the official ASMT resource pack here!

So you are saying me that this story of labels are pretty much like folders/arrays? For example, i have a folder called LOLMAN and into this folder i have two files called LMAO and ROFL, then i have another separate folder called LOLMAMA, that isn't in LOLMAN, but even in this folder i have two files called LMAO and ROFL. Just an example: Do you think those labels and sublabels work pretty much like this?
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
That's a pretty good way to put it, yes. It also brings me to another thing I forgot to mention; much like with your folders example, you can't access a sublabel from outside of its main label.
My YouTube channel
Get the official ASMT resource pack here!

Originally posted by yoshicookiezeus
That's a pretty good way to put it, yes. It also brings me to another thing I forgot to mention; much like with your folders example, you can't access a sublabel from outside of its main label.


So, if i want to try to access a sublabel from outside it's label direclty, there is a way to do so with some paths? Or i just need to write that code again?
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Code
Main1:
.Sub

Main2:
JSR Main1_Sub

This will work fine.
<blm> zsnes users are the flatearthers of emulation
Originally posted by Alcaro
Code
Main1:
.Sub

Main2:
JSR Main1_Sub

This will work fine.


Isn't JSR one of those "Jump to subroutine" commands? I see many of these in all custom sprite codes. So, if i get it right, i just need to add the main label name behind the sublabel name (then adding "_") to call a subroutine. Very well, it should help me very much in future. thanks for the helps. The only problem is that i think i won't create something of awesome in one day, he.
P.S.
Luck i read Iceguy's basic smw asm tutorial, otherwise i wouldn't have understood what would JSR/JSL mean basically.
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Originally posted by Dinomar
Isn't JSR one of those "Jump to subroutine" commands?

Yes, but that's not relevant. I just pulled out some random opcode that usually targets a label.

Quote
So, if i get it right, i just need to add the main label name behind the sublabel name (then adding "_") to call a subroutine.

Correct. It works for all label uses, not just JSR.
<blm> zsnes users are the flatearthers of emulation
I'm trying to modify the carriable springboard so that it moves back and forth horizontally in the air (picture the barrels from DKC). I've got the sprite moving around correctly, but when mario lands on the springboard his x position doesn't change to account for the horizontal movement. I know all I have to do is change the player x speed to match the sprite x speed, but I don't know how to make it only happen when mario is standing on the springboard. Is there a specific "check if mario is standing on a sprite" code that I can use?
New problem:
With my new code:
Code
	LDA $19
	BNE .DontMakeBig
	LDA $1420
	CMP #$05
	BNE .DontMakeBig

	LDA #$01
	STA $19
	STZ $1420
	RTL

.DontMakeBig
	RTL


The condition that Mario becomes big only if it is small mario and gets yoshi coins works, but the problem is that if i get a powerup, then getting all yoshi coins, Mario doesn't change its status, naturally, since it should change only if it is small mario, but then, after i get hurt, instead of small mario gets to big mario, then if i get hurt again, i become small mario. Same if i try to get 5 yoshi coins 3 times.
Then, if i get the first 5 yoshi coins, the counter resets, but not the one in the status bar (since i suppose those are separate addresses, i think), if i get other 5 yoshi coins, the counter acts normally, but the status bar counter doesn't show how many coins you got (still, separate address), but in the third time, the counter doesn't resets: bunch of 1ups instead. This happens if you don't get hurt, but if you get hurt, it resets. Seems like that the code is trying to store the times that mario becomes "big mario"
What's about this problem? Why this happens, actually? As said, it really seems like that the code is trying to store the times that mario becomes big.
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level

Maybe its just the wording, but what exactly is this code suppose to do. You want small mario to become big if he gets 5 coins?
Layout by LDA during C3.
Originally posted by Lightvayne
Maybe its just the wording, but what exactly is this code suppose to do. You want small mario to become big if he gets 5 coins?


Ok, as i mentioned in the previous posts here, i want that Mario becomes Big Mario only when he is Small Mario AND gets 5 Yoshi Coins. Then, after getting all 5 Yoshi coins, the counter should reset (So Mario will not be forever Big even if he gets hurt. But it suffer of some problems though, and i wrote them above.
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Originally posted by wiiqwertyuiop
That code seems like it should work. Maybe its where you running it from?


Yes, it works, but if you do certain actions, it reveals to be unadapted, buggy.

Look yourself, so you'll be sure of what i was talking about.

For example, get a fire flower, then get all yoshi coins. then, get hurt. And this is why i am asking about this. Or get all the 15 yoshi coins i placed in the level: the first 5 work normally, the seconds 5 work normally too (except for the status bar counter), but if you don't get hurt frist, the latest 5 give you 1ups (just like you got all yoshi coins).
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
Originally posted by Dinomar
Originally posted by wiiqwertyuiop
That code seems like it should work. Maybe its where you running it from?


Yes, it works, but if you do certain actions, it reveals to be unadapted, buggy.

Look yourself, so you'll be sure of what i was talking about.

For example, get a fire flower, then get all yoshi coins. then, get hurt. And this is why i am asking about this. Or get all the 15 yoshi coins i placed in the level: the first 5 work normally, the seconds 5 work normally too (except for the status bar counter), but if you don't get hurt frist, the latest 5 give you 1ups (just like you got all yoshi coins).


Dinomar, The following code should fix the bugs

Code
LDA $19
CMP #$00
JSR YOSHI
RTS
YOSHI:
LDA $1420
CMP #$05
BEQ Big
RTS
Big:
LDA #$01
STA $19
JSR NOCOIN
RTS
NOCOIN:
STZ $1420
JSR CAPE
JSR BLOCK
JSR FIRE
RTS
FIRE:
LDA #$03
STA $19
RTS
BLOCK:
RTS
CAPE:
LDA #$02
STA $19
RTS 


Put that code in LevelASM.The extra code is to fix some bugs with the flower and cape powerups.
@smwstar: aside the fact i replaced RTS/JSR with RTL/JSL, that are required in LevelASM tool, your code works much better! The only problem is that when i get all coins, it becomes CAPE Mario or FIRE Mario instead of BIG Mario. Actually, i suppose it's a problem of the final code, after STZ $1420. There should be a way to make it big only if it is small, and not even when it is big.
If i don't get it wrong, the code makes sure that if Mario is Small, then directly jumping to the routine that makes sure that Mario gets all Yoshi Coins, it makes Mario Big, then jumping to the routine that makes sure that the Coin counter resets to 0, the jumping to the powerups routine... may that be the reason Mario becomes CAPE/FIRE instead of BIG? Because, yes, it loads the BIG routine, but then it immediately loads the CAPE/FIRE/BLOCK routine (i still don't understand what is the BLOCK routine for), if i am not wrong.
My deviantART
My Youtube channel
My avatar
Watch, i made a Super Mario 64 level
  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 285
  • 286
  • 287
  • 288
  • 289
  • 290
  • 291
  • 292
  • 293
  • 294
  • 295
  • 418
  • 419
  • 420