Banner
Views: 236,815,896
Time: 2013-05-26 03:10:37 AM
6 users online: aterraformer, o Ersanio, leod, Nesquik Bunny, Pokeymeister80, yoshicookiezeus - Guests: 35 - Bots: 7Users: 22,897 (1,293 active)
Latest: BlitzonLP
Tip: Verify that your hack's IPS patch is functioning correctly before submitting it.
Official Hex/ASM/Etc. Help Thread
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - Official Hex/ASM/Etc. Help Thread
Pages: « 1 ... 288 289 290 291 292 ... 319 320 »
Originally posted by Kaijyuu
I'm not seeing anything that would make it crash, but that's hellishly overcomplicated.


For one, you only need to check if $7D is below $80 once. Just branch to a RTS if it is.
Two, using intermediate addressing isn't needed for RAM addresses below 100. So you can use LDA $7D instead of LDA $007D.


Alright, I'll change that then; Thanks. I'm not used to writing code.

EDIT: changed the code in the previous post. Now the level doesn't crash, but when I hit the jump button Mario jettisons off to the left and is crushed against the edge of the screen.
Last edited on 2012-03-07 06:05:13 PM by jesus.
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?
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
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
Last edited on 2012-03-10 05:58:14 AM by Alessio.
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.
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"?
Last edited on 2012-03-10 06:37:28 AM by Alessio.
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.
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?
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.
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?
Code
Main1: .Sub Main2: JSR Main1_Sub

This will work fine.
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.
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.
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.
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?
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.
That code seems like it should work. Maybe its where you running it from?
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).
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.
Pages: « 1 ... 288 289 290 291 292 ... 319 320 »
Forum Index - SMW Hacking - General SMW Hacking Help - ASM & Related Topics - Official Hex/ASM/Etc. Help Thread

The purpose of this site is not to distribute copyrighted material, but to honor one of our favourite games.

Copyright © 2005 - 2013 - SMW Central
Legal Information - Link To Us


Total queries: 29

Menu