Language…
14 users online:  Anorakun, Arthuzin, Burning Loaf,  GlitchCat7, Jackpot, Jaozin712, lobo22, MegaSonic1999, Metal-Yoshi94, Quaza, Steven Atauchi C.,  Tahixham, Xane123, Yutuz - Guests: 113 - Bots: 141
Users: 67,620 (2,005 active)
Latest user: Lap84

Grinder + Block = fail?

So while I was working on my custom block, I have come across my problem.
The block I am working on behaves like this:
When a (non-)lineguided grinder hits the block, the block should shatter.

Problem: The block displays the shatter effect when it gets hit from the left ( ->[ß]). But it doesn't erase the tile itself!
Everything else works perfectly fine. How come? Here is the code:
Code
JMP Return : JMP Return : JMP Return : JMP Start : JMP Start : JMP Return : JMP Return

Start:			LDA $9E,x		;\
			CMP #$67		; |
			BEQ Exec		; |Make sure the sprite really is a grinder!
			CMP #$B4		; |
			BEQ Exec		;/
Return:			RTL

Exec:			LDA $D8,x
			STA $98
			LDA $E4,x
			STA $9A
			LDA $14D4,x
			STA $99
			LDA $14E0,x
			STA $9B

			PHB			;\
			LDA #$02		; |
			PHA			; |
			PLB			; |shatter the block
			LDA #$00		; |
			JSL $028663		; |
			PLB			;/

			LDA $D8,x
			STA $98
			LDA $E4,x
			STA $9A
			LDA $14D4,x
			STA $99
			LDA $14E0,x
			STA $9B
			
			LDA #$02		;\
			STA $9C			; |Generate invisible map16 tile.
			JSL $00BEB0		;/
			RTL


As you can see, I pasted the 'block position routine' twice. Yet, nothing happens. The problem remains. why
My blog. I could post stuff now and then

My Assembly for the SNES tutorial (it's actually finished now!)
I belive that the main problem is that the sprite position sometimes isn't the same as the block position. I'm not sure how to fix this, so go look up some other shattering block. Maybe it'll work better if you simply remove the position code(s)?
Oh, I doubt and pasting the position code twice will have any effect except wasting some bytes and cycles.
<blm> zsnes users are the flatearthers of emulation
Which reminds me, perhaps Charging Chuck's block shatter code will help me. ...I think.

Of course, I still need help unless I say otherwise.

EDIT: Even charging chuck's code didn't work. sigh
My blog. I could post stuff now and then

My Assembly for the SNES tutorial (it's actually finished now!)
It looks like you don't have the code to erase itelf.

Code
LDA #$02 ; Replace block with blank tile
STA $9C
JSL $00BEB0
Originally posted by Majora252
It looks like you don't have the code to erase itelf.

Code
LDA #$02 ; Replace block with blank tile
STA $9C
JSL $00BEB0


Originally posted by Ersanio
Code
LDA #$02 ;\
STA $9C ; |Generate invisible map16 tile.
JSL $00BEB0 ;/ 


lolwut

Oh, and by any chance, is your level a vertical level? That can do bad things to coordinates.
Now with extra girl and extra hacker
Nope, the level isn't a vertical level.
My blog. I could post stuff now and then

My Assembly for the SNES tutorial (it's actually finished now!)
You aren't initially indexing XA with $15E9, so that could be an issue. I'm not sure though.
BTSD automatically does that.
My blog. I could post stuff now and then

My Assembly for the SNES tutorial (it's actually finished now!)
Oh, ok.

I just tested the code you posted in your initial post, and the block partially works (with sprite B4), it gets erased sometimes.

I believe what Alcaro said is true, the sprite's X position isn't the same as the block's X position. Actually, I'm not sure.
I just realized that sprites aren't aligned to a 16x16 like blocks are, so I tossed in some AND #$F0 between the low byte setup.

...That still didn't fix it, though. Right now I have this:

Code
JMP Return : JMP Return : JMP Return : JMP Start : JMP Start : JMP Return : JMP Return

Start:			LDA $9E,x		;\
			CMP #$67		; |
			BEQ Exec		; |Make sure the sprite really is a grinder!
			CMP #$B4		; |
			BEQ Exec		;/
Return:			RTL

Exec:			LDA $D8,x
			AND #$F0
			STA $98

			LDA $E4,x
			AND #$F0
			STA $9A

			LDA $14D4,x
			STA $99
			LDA $14E0,x
			STA $9B

			PHB
			LDA #$02
			PHA
			PLB
			JSL $028663
			PLB

			LDA #$02
			STA $9C
			JSL $00BEB0
			RTL


...I think I have found a way to fix it this time though. I'll edit this post once I couldn't fix it after all.
My blog. I could post stuff now and then

My Assembly for the SNES tutorial (it's actually finished now!)
  
  
 



It works from the right, but not from the left? If so, try adding #$08 to the sprite's position before you compare it to the block's. I had a similar problem but resolved it through that, but your setup may be different.


 
 
       

Fluffy video games by me and Raibys!
 
 
   
 
 
Glad to see you're working on this for me.
Another thing you can consider if the block is impossible, is to make a custom sprite grinder based off of that chargin chuck thing, and make it so the custom grinder actually destroys turn and throw blocks, instead of a block that gets destroyed by grinders. And make hte extra bit determine if it's line guided or not. (Then again a line guided one would be sorta useless since the lines take up tiles.)
I own a community of TF2 servers!

ASMT - A new revolutionary ASM system, aka 65c816 ASseMbly Thing
SMWCP - SMW Central Presents a Product- tion long name

frog

http://esolangs.org/wiki/MarioLANG
Actually I just finished it. Keep an eye on the custom blocks section.

...The solution was rather simple. I just set the block position according to the direction of the grinder.

Code
JMP Return : JMP Return : JMP Return : JMP Start : JMP Start : JMP Return : JMP Return


!Colorful = $01		;set to $00 to make the shatter brown. Otherwise, rainbow colors

Start:			LDA $9E,x	;\
			CMP #$B4	; |vital check. We check our sprite number
			BEQ Exec	;/
Return:			RTL

Exec:			LDA $D8,x	;\Set Y pos low & high
			AND #$F0	; |
			STA $98		; |
			LDA $14D4,x	; |
			STA $99		;/

			LDA $157C,x
			BNE leftshatter

			LDA $E4,x	;\
			AND #$F0	; |
			CLC		; |When sprite direction is right.
			ADC #$10	; |
			STA $9A		;/
			LDA $14E0,x
			ADC #$00
			STA $9B
			BRA Continue

leftshatter:		LDA $E4,x	;\
			AND #$F0	; |When the sprite direction is left
			STA $9A		;/
			LDA $14E0,x
			STA $9B

Continue:		PHB
			LDA #$02
			PHA
			PLB
			LDA #!Colorful
			JSL $028663
			PLB

			LDA #$02
			STA $9C
			JSL $00BEB0
			;LDA $157C,x ;
			;EOR #$01 ;uncomment these so the grinder goes
			;STA $157C,x ;through the blocks without trouble
			RTL


This code does not make the sprite cut 'smoothly' through the bricks though, like charging chuck does (horizontally). It just turns directions.

EDIT: nevermind above. just uncomment those 3 lines near the bottom to make the grinder cut through the blocks smoothly
My blog. I could post stuff now and then

My Assembly for the SNES tutorial (it's actually finished now!)