Language…
19 users online: Chambo, codfish1002, cohimbra, Dennsen86, deported, Dispace, Fozymandias, Golden Yoshi, Green, Green Jerry, LightAligns, mio, Mischievous Marc, neidoodle, RicardoDeMelo, RZRider, sinseiga, synthie_cat, tOaO - Guests: 293 - Bots: 252
Users: 64,795 (2,375 active)
Latest user: mathew

Official Hex/ASM/Etc. Help Thread

  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 418
  • 419
  • 420
1. ?

2. Except a few edge cases (there's no such thing as LDA $000000,y, for example), they're pretty much the same. Also you've got to watch out for what the routines you're hijacking are using; blocks store part of the "acts like" setting in Y, so you need to preserve it somehow if you want to use it in a block's code.
Originally posted by JTA777
Thank you. Two more last questions.

1. When do I know that I'm out of data?
2. When do I use LDX instead of LDY or vis versa?


You have THREE REGISTERS to use to STORE DATA. Use one of the three when you need to! It doesn't matter really although most people use A then X then Y just for consistency.
So right now I'm really trying hard to learn ASM, but I just don't understand Jumping... I do realize that it jumps to a different part of the code. Here is the example I saw in the tutorial I was using.
Code
LDA #$02
JSR Jump        ; after jumping to this subroutine, the below code gets executed.
RTL

Jump: 
STA $19
RTS                 ; subroutines accessed with JSR MUST end with RTS, NOT RTL.


So if I'm right, this person is taking the cape power-up, jumping to a sub-routine, storing it in the power-up, and then finishes the code. So basically, Mario just got the cape power-up. Buy what is the significance of the jump? Couldn't he just use this code?:

Code
LDA #$02
STA $19
RTL


Could someone explain what the purpose of jumping is, and give me a good example? Thanks in advance!
He could've yes.


Just to allay some potential ambiguity, though...

JSR means "Jump To Subroutine." It's a special command that pushes a return address onto the stack. That's why the RTS is able to bring the code back to where the original JSR was.

(JSL also exists, which is "Jump To Subroutine Long." The difference is you have to use RTL instead of RTS (else it crashes), and JSL can go anywhere in the game's code while JSR is limited to the current bank)

JMP means, well, Jump. It's different from JSR in that it doesn't push anything on the stack, so a RTS will not bring the code to the position after the JMP.



The point of JSR is to have code usable in multiple places. You might have a subroutine that draws sprite tiles. That subroutine can then be reused in multiple sprites, each one only having to JSR to it rather than re-write it.


That example's JSR is pointless since the STA takes less time and space. There are plenty of situations where you want repetitive code, though, where JSR becomes monumentally useful.
So would this example be good? (I do realize that this code doesn't make any sense, as far as what it is going to result in, but would that be a propper use of the JSR?)

Code
LDA #$00
JSR Jump
RTS

LDA #$01
JSR Jump
RTS

LDA #$02
JSR Jump
RTS

LDA #$03
JSR Jump
RTS

Jump:
STA $19
RTS

Fix'd

Is that a proper use?

And one other question, when using a table, what is [db] and those types of things?
1.) No, it would not work. The Jump subroutine needs to end in RTS, as you JSR'd to it. If you JSL'd to it, it would need to end in RTL.
2.) db, dw, dl, dd stand for direct byte, direct word, direct long, and direct double respectively; they allow you to insert bytes/words/longs/doubles directly.
For example, say I had
Code
org $9001
db $20

If I viewed the patched ROM in a hex editor at SNES address $009001, the value of the byte there would be $20. Same for words, longs, and doubles, but remember it's little endian, meaning if I did org $9001 : dw $2000, it would show up in a hex editor as $00 $20.
Thanks! So now that I have RTS's instead of RTL's, would it work?
Yeah, i know that the code wasn't efficient or even has a real purpose. I just wanted to know if I had the right idea about jumping. Thanks for all the help!
After reading some tutorials, using AlcaRobot, I've created a block. Is supposed to be a Shop Block, but... it did'nt worked.

Code, set to act like 130.
Code
!Cost = #15
!Powerup = #$01

Try #$15. That appears to be the only thing I can see that could cause a problem.

e: Also, defines should only be addresses. Try !Cost = $15 and !Powerup = $01, and in the code, #!Cost and #!Powerup.
Yea, the syntax seems to be right, but the block is still not working... thanks for the help, anyways.

Edit: Ok. I will try. I'll edit this post with the results.
AnotherEdit: Heh. It works. But now... even if Mario have the coins, the block plays the incorrect sound. >.>'
AnotherEdit²: about the sound, nevermind. The MasterLink's method worked to me.
Code
BRA ByeCoins


Maybe this is the problem, you didn't check anything and, well, using BRA is almost useless because it always branch.

This should work:

Code
ItemBuy:
               LDA !Powerup					;Load !Powerup
               STA $0DC2						;Store the item to the item box.
               LDA $0DBF						;Load Coin Status
               SEC
               SBC !Cost							;Subtract the coins...
               STA $0DBF						;Store to coin status
               RTL
Originally posted by Me.
AnotherEdit²: about the sound, nevermind. The MasterLink's method worked to me.


Thanks MSA and MasterLink. Now you're on the credits. ^-^
Originally posted by MSAhm3d59113
e: Also, defines should only be addresses. Try !Cost = $15 and !Powerup = $01, and in the code, #!Cost and #!Powerup.

Wrong. Defines can contain any string you want. For example, the following will assemble without problems:
Code
!a = 93
LDA #$FF
STA $14!a

(It's obviously a horrible idea to write this kind of messy codes, but that's not relevant.)
<blm> zsnes users are the flatearthers of emulation
So I've had this question for a while now, and it seems the thread it was in is pretty much dead, so I came here in hope that my question would be answered... anyway, onto the question:

I'm trying to make a block that when Mario steps on it (at full speed), it will send it flying. But the block doesn't do anything... Mario just runs right off the edge.
Here's the code:
Code
JMP Return : JMP Mario : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return

Mario:
LDA $7B
CMP #$2F	;if mario is at full speed
BEQ Launch	;Branch if equal
RTL
Launch:
LDA $7F		;Load x position
CLC		;Take away extra "1"
ADC #$10		;send Mario 10 pixels [x]
STA $7F		;store it
LDA $80		;Load y position
CLC		;take away extra "1"
ADC #$5		;send Mario 5 pixels [y]
STA $80		;store it
Return:
RTL


Things you should note:

- If the RTL command is changed to RTS, Mario will freeze when he touches the block (even if he isn't at full speed)
Code
JMP Return : JMP Mario : JMP Return : JMP Return : JMP Return : JMP Return : JMP Return

Mario:
LDA $7B
CMP #$2F	;if mario is at full speed
BNE Return	;Branch if equal
REP #$20
LDA $94		;Load x position
CLC		;Take away extra "1"
ADC #$0010		;send Mario 10 pixels [x]
STA $94		;store it
LDA $96		;Load y position
CLC		;take away extra "1"
ADC #$000	;send Mario 5 pixels [y]
STA $96		;store it
SEP #$20
Return:
RTL


I'm not sure why none of the people from the other thread noticed this, but you can't store to $80 and have it have any effect. You need to use $94 for that, which is a 16-bit address, so you have to REP #$20 before and SEP #$20 afterwards.
Thanks for that code buddy, it really helped! With it (and a few minor edits), I have created this effect:



Now, there are a few glitches:
First of all, i want the jump from one place to another be natural, like shooting out of a pipe, that type of movement. Another weird glitch, is that once Mario is launched, a group of 8 cement blocks move infront of him.

Any fixes for these?
The 8 blocks are a graphical glitch from scrolling too fast.
So is there a way I could make the block send Mario on a natural jump, as if he were bouncing off one of the egg-like blocks shown in this video: http://youtu.be/sFxcuG5sZfE ?? Help would be EXTREMELY appreciated
  • Pages:
  • 1
  • 2
  • 3
  • 4
  • 5
  • 277
  • 278
  • 279
  • 280
  • 281
  • 282
  • 283
  • 284
  • 285
  • 286
  • 287
  • 418
  • 419
  • 420