Banner
Views: 737,605,885
Time:
4 users online: Alfio, Hiro-sofT, Infinity, o Plasmodium00 - Guests: 31 - Bots: 173Users: 38,803 (1,931 active)
Latest: rocketfire
Tip: It's recommended to use these when ripping graphics.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:

Code
GET_SPRITE_CLIPPING:

	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
	BEQ RETURN_INT			;/

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

	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

RETURN_INT

	PLX

	RTS


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 - 2019 - SMW Central
Legal Information - Privacy Policy - Link To Us


Total queries: 25

Menu

Follow Us On

  • Facebook
  • Twitter
  • YouTube

Affiliates

  • Talkhaus
  • SMBX Community
  • GTx0
  • Super Luigi Bros
  • ROMhacking.net
  • MFGG
  • Gaming Reinvented