Language…
19 users online: anonimzwx, DanMario24YT,  Deeke, Golden Yoshi,  Gonzales555, Green, Heitor Porfirio, iamtheratio, imamelia, Irondill, koffe190, LightAligns, MorrieTheMagpie,  nycvega, PMH,  Segment1Zone2, steelrain859, TheOrangeToad, xxxblackangel2208xxx - Guests: 271 - Bots: 261
Users: 64,795 (2,375 active)
Latest user: mathew

Help using spawn_bounce_sprite routine with GPS

Hi, I was trying to make a brick block that when Mario hits it from below and has a mushroom it shatters and if he doesn't have a mushroom it spawns a bounce sprite, I have the shattering down but the bounce sprite is when I get a bit confused. I'm using the spawn_bounce_sprite.asm routine that comes with GPS and it comes with some guidelines on how to use it and although I thought I followed them ok I get an error on insert saying:
Code
27 Shared routines registered in "routines/"
An error has been detected:
blocks/solid_brick.asm:15 (called from blocks/solid_brick.asm:15): error: (E5100): Broken macro usage. [%spawn_bounce_sprite]

Here are the guidelines I followed:
Code
;~@sa1
;Input: A = Bounce sprite number,  X = $9C value, Y = bounce sprite direction,
;       $03-$04 = Map16 number (only if $9C or X is $1C or larger) (Requires Custom Bounce Block Sprites)
;Ouput: Y = Slot used
;Clobbers:
;       A, X, $05, $06, $07

and finally here is my code:
https://pastebin.com/VctLuB1B
Just add the parenthesis at the end, like this:

Code
%spawn_bounce_sprite()
Thank you, now it's not giving me any errors but it's still not working as intended, you see, what's confusing me is that I want it to keep the tile there even after the bump animation is over, so I need to set $9C to #$0301 (The map16 number of my block) however that is just the problem, address $9C is only 1 byte. The guidelines say to use $03-$04 for the map16 number if 9C or x is 1C or larger, however, I can't seem to figure out what it means by that, like if that is even the direct map16 value at all, I checked, and both seem to just change it to what seems like a random tile. (For example, even though I have te high byte as #$03 and the low byte as #$01 and so it should be #$0301 it spawned a tile which seemed to just be blank)

Here is my updated code:
Code
db $42 ; or db $37
JMP MarioBelow : JMP MarioAbove : JMP MarioSide
JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireball
JMP TopCorner : JMP BodyInside : JMP HeadInside
; JMP WallFeet : JMP WallBody ; when using db $37

MarioBelow:
LDA $7E0019
CMP #$00
BNE brick_shatter
LDA #$03
LDX #$03
STX $03
LDX #$01
STX $04
LDY #$00
%spawn_bounce_sprite()

RTL

brick_shatter:
LDA #$00
%shatter_block()
RTL

MarioAbove:
MarioSide:

TopCorner:
BodyInside:
HeadInside:

;WallFeet:	; when using db $37
;WallBody:

SpriteV:
SpriteH:			

MarioCape:
MarioFireball:
RTL

print "A solid brick block that mario can break if he has a mushroom"


Use it like this:

Code
	REP #$20
	LDA #$0301	; map16 tile
	STA $03
	SEP #$20
	LDA #$03	; bounce sprite
	LDY #$00	; bounce direction
	LDX #$1C	; X >= 1C (indicates to use the tile in $03 instead of one of $9C's values)
	%spawn_bounce_sprite()


Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
I used your code but whenever I hit the block it does bounce but the background just turns black and the game freezes. Here is the code I used:
Code
db $42 ; or db $37
JMP MarioBelow : JMP MarioAbove : JMP MarioSide
JMP SpriteV : JMP SpriteH : JMP MarioCape : JMP MarioFireball
JMP TopCorner : JMP BodyInside : JMP HeadInside
; JMP WallFeet : JMP WallBody ; when using db $37

MarioBelow:
LDA $7E0019
CMP #$00
BNE brick_shatter
REP #$20
LDA #$0301	; map16 tile
STA $03
SEP #$20
LDA #$03	; bounce sprite
LDY #$00	; bounce direction
LDX #$1C	; X >= 1C (indicates to use the tile in $03 instead of one of $9C's values)
%spawn_bounce_sprite()

RTL

brick_shatter:
LDA #$00
%shatter_block()
RTL

MarioAbove:
MarioSide:

TopCorner:
BodyInside:
HeadInside:

;WallFeet:	; when using db $37
;WallBody:

SpriteV:
SpriteH:			

MarioCape:
MarioFireball:
RTL

print "A solid brick block that mario can break if he has a mushroom"


Oh actually, do you have this patch installed? It's required to use the X >= 1C stuff.

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Oh, I didn't, I applied the patch and now the screen just turns white after I hit the block and the music keeps playing.

EDIT: I added GFX to them and now it turns the screen red and keeps the music playing.
Is this thread closed?
Have you considered trying this brick block? It doesn't require the patch, and Erik helped me make a small modification to it, making it breakable from above if any form of Mario that isn't small makes a spin jump on it (though it uses the same bounce sprite as turn blocks). If you wish, you can give it a try (though you should have a backup of your rom made prior to inserting the patch; try inserting the block without that patch just to see if it works for you).

I once attempted to use that patch myself, but unfortunately I didn't quite get the hang of it, hence why I'm using this version of the brick block.
Yes, I ran across this while doing research and although this looks like what I've been looking for, however, I'm coding this not necessarily to just have a brick block but to practice my ASM and get a better understanding of the routines, subroutines, etc. that I have at my disposal, so if I can find a way to get around the problem now I theoretically wouldn't run into the same problem in the future. (hope that makes sense)