I made a block and tried to insert it with BTSD but it said: "Errors occurred during the assembly of block.asm error: temp.asm: line 12: invalid opcode or command [CMP #$02] error: temp.asm: line 15: invalid opcode or command [CMP #$02]". Is there any way to use CMP in a block?
CMP in a block
Usually CMP #$02 should work fine. Post the code of your full block.
db $42
JMP Mario : JMP Mario : JMP Mario
JMP Sprite : JMP Sprite
JMP Mario : JMP Mario
JMP Mario : JMP Mario : JMP Mario
Mario:
LDA #$19
CMP#$02
BEQ CoolThen
LDA #$19
CMP#$02
BNE GetOut
CoolThen:
RTL
GetOut:
LDA $7E
SEC
SBC #$20
STA $7E
RTL
Sprite:
RTL
JMP Mario : JMP Mario : JMP Mario
JMP Sprite : JMP Sprite
JMP Mario : JMP Mario
JMP Mario : JMP Mario : JMP Mario
Mario:
LDA #$19
CMP#$02
BEQ CoolThen
LDA #$19
CMP#$02
BNE GetOut
CoolThen:
RTL
GetOut:
LDA $7E
SEC
SBC #$20
STA $7E
RTL
Sprite:
RTL
There's your problem:
Fixed version:
Edit: On a side, that code most likely glitches Mario's position. What exactly are you trying to do?
Code
db $42 <- not really needed. JMP Mario : JMP Mario : JMP Mario JMP Sprite : JMP Sprite JMP Mario : JMP Mario JMP Mario : JMP Mario : JMP Mario Mario: LDA #$19 <- loading a value, but you want the powerup RAM CMP#$02 <- you forgot a space there BEQ CoolThen LDA #$19 <- loading a value, but you want the powerup RAM CMP#$02 <- you forgot a space there BNE GetOut CoolThen: RTL GetOut: LDA $7E SEC SBC #$20 STA $7E RTL Sprite: RTL
Fixed version:
Code
JMP Mario : JMP Mario : JMP Mario JMP Sprite : JMP Sprite JMP Mario : JMP Mario JMP Mario : JMP Mario : JMP Mario Mario: LDA $19 CMP #$02 BEQ Sprite GetOut: LDA $7E SEC SBC #$20 STA $7E Sprite: RTL
Edit: On a side, that code most likely glitches Mario's position. What exactly are you trying to do?
Still don't work. The same error appeared again...
EDIT: It worked
EDIT: It worked
Originally posted by Ice Man
Code
db $42 <- not really needed.
Actually, if he wants to be able to use the MarioCorner, HeadInside and BodyInside offsets, the db $42 is indeed very much needed.
My YouTube channel
Get the official ASMT resource pack here!
Oh, okay. I thought it had no purporse. I myself never used db $42 in any of my blocks and all of them work, then again, I didn't have to use the offsets.
I inserted it but it don't worked. It should bring mario back if mario touches it without cape but it did nothing.
That's probably because you're using the wrong address. If you want to move Mario, you should modify $94/$96 (Mario's position next frame) instead of $7E/$80. Also, you'll want to use 16-bit mode for this, or you'll run into trouble with screen boundaries.
My YouTube channel
Get the official ASMT resource pack here!
My YouTube channel
Get the official ASMT resource pack here!
You want to be modifying $94, not $7E. Also you want to be in 16 bit mode to avoid problems with screen boundaries.
Also of note due to how you set your offsets, hitting the block with a cape or a fireball would run the Mario code as well. Not important for fireballs since it'd go to the RTL anyway, but potentially an issue with the cape.
Furthermore, this will push Mario back equal to the distance of 2 blocks.... regardless of anything in the way. Careful not to have this block shove him into a wall or enemies.
Concerning db #$42:
It's a good idea to set these offsets since BTSD will use the new offsets regardless. Not including db #$42 just means they'll default to (iirc) MarioAbove's behavior. Not likely to be a problem, but still.
Code
db #$42 JMP Mario : JMP Mario : JMP Mario JMP Sprite : JMP Sprite JMP Mario : JMP Mario JMP Mario : JMP Mario : JMP Mario Mario: LDA $19 CMP #$02 BEQ Sprite GetOut: REP #$20 ; 16 bit mode set for A LDA $94 ; 94 is what mario's position on the level will be adjusted to next frame. ;7E is mario's position on the screen, used almost solely for graphical stuff and not interaction. SEC SBC #$0020 ; since we're in 16 bit mode, we work with 2 byte long numbers. Using just #$20 would make the game crash. STA $94 SEP #$20 ; back to 8 bit more for A Sprite: RTL
Also of note due to how you set your offsets, hitting the block with a cape or a fireball would run the Mario code as well. Not important for fireballs since it'd go to the RTL anyway, but potentially an issue with the cape.
Furthermore, this will push Mario back equal to the distance of 2 blocks.... regardless of anything in the way. Careful not to have this block shove him into a wall or enemies.
Concerning db #$42:
It's a good idea to set these offsets since BTSD will use the new offsets regardless. Not including db #$42 just means they'll default to (iirc) MarioAbove's behavior. Not likely to be a problem, but still.
DO you want credit?
Nope.
But why is needed to work in 16-bit mode in GetOut?
Because Mario's position is an 16-bit address, and manipulating 16bit addresses are much easier in 16bit mode.
You can do this:
But that's stupid if you can use 16bit mode.
<blm> zsnes users are the flatearthers of emulation
You can do this:
Code
LDA $94 SEC SBC #$20 STA $94 LDA $95 ;note the lack of SEC - it's intentional SBC #$00 STA $95
But that's stupid if you can use 16bit mode.
<blm> zsnes users are the flatearthers of emulation