Views: 807,561,082
17 users online: aknightofwands, ExONightZ, Falaflame, GbreezeSunset, Hayashi Neru, JamesD28, LuigiTime, meatloaf, plasticdog6, PokerFace, RetroYoshi, Rykon-V73, Seifire, SheePSeff, Sixcorby, sss cs, thejhonny-ador - Guests: 72 - Bots: 186 Users: 42,381 (1,965 active)
Latest: IoriYasakani
Tip: When you're about to release your hack, make a patch first, patch it to a clean ROM, and then test that. This way, you are testing both the hack AND the patch.Not logged in.
Help with sprite on sprite interaction [fixed]
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Help with sprite on sprite interaction [fixed]
Pages: « 1 »
I'm working on a fairly complex sprite that I want to have interaction with a lot of the vanilla sprites. I wrote a loop that is run every frame that checks for contact between my sprite (sprite A) and all other sprite's. I then index with the other sprite's number to see what interaction routine will be called (this is not as absurdly large a task as it sounds because a lot of sprites will use a default interaction).

At the end of the routine however, $00 is not equal to INTERACTION_TABLE indexed by sprite B's sprite number (at least it's not equal to what Lunar Magic says the sprite number is). I don't know if I've been at this thing for too damn long or I'm just really stupid.

I mean, sprite number does mean what sprite it is, right? For example a bullet bill has $9E,x = #$1C.

This is my code:


	TXY				;Store X to Y
	PHX				;Push X
	LDA #$FF			;\This starts the loop off at X=#$FF
	STA $1695			;/

LOOP	LDX $1695
LOOPX	INX				;Increment X (the first time this happens X is set to zero)

	TXA				;\
	CMP #$0C			; |Terminate loop if it has been run 12 times this frame

	TXA				;\
	CMP $15E9			; |Loop if sprite is trying to compare clipping values with itself

	JSL $03B6E5			;Get sprite B's clipping values (sprite B is whichever one being checked)

	STX $1695			;Store X value for sprite B
	TYX				;Restore X from Y
	JSL $03B69F			;Get sprite A's clipping values
	JSL $03B72B			;Check for contact (if they touch the carry flag will be set)
	BCC LOOP			;Loop if carry is clear

	LDX $1695			;Load sprite B's X value (sprite B is now confirmed to touch sprite A)
	LDA 9E,x			;Load sprite B's sprite number
	TAX				;Store sprite B's sprite number to X
	LDA INTERACTION_TABLE,x		;Load specific interaction value indexed by sprite number
	STA $00				;Store to scratch RAM




The table is 256 bytes long to work with any possible sprite number. I will shrink it when I find out how many sprite numbers are actually used.

Edit: I had simply been at it for too long. I missed the '$' in LDA $E9,x. Derp.

Sorry for wall of text.

We’re looking for level designers to work on Extra Mario World!
Pages: « 1 »
Forum Index - SMW Hacking - SMW Hacking Help - ASM & Related Topics - Help with sprite on sprite interaction [fixed]

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

Copyright © 2005 - 2020 - SMW Central
Legal Information - Privacy Policy - Link To Us

Total queries: 7


Follow Us On

  • YouTube
  • Twitch
  • Twitter


  • Super Mario Bros. X Community
  • Mario Fan Games Galaxy