Language…
8 users online: 1392year, Alice3173, DasFueller, Firstnamebutt, GRIMMKIN, Mario's GameBase,  NinCollin, tOaO - Guests: 159 - Bots: 430
Users: 64,795 (2,380 active)
Latest user: mathew

A sprite spawner?

Hello. I'm really new to ASM and barely know how to do anything with sprites. Could someone explain to me how I could make flashing throw blocks and Koopas without shells spawn at a certain location? Thanks in advance.


The basic code to spawn a sprite is this:
Code
	JSL $02A9DE
	BMI EndSpawn
	TYX
	LDA #!SpriteState
	STA $14C8,x
	LDA #!SpriteNumber
	STA $9E,x

	LDA #!XLo
	STA $E4,x
	LDA #!XHi
	STA $14E0,x
	LDA #!YLo
	STA $D8,x
	LDA #!YHi
	STA $14D4,x
	JSL $07F7D2
EndSpawn:
	RTS


Replace the SpriteNumber define with the sprite you want to spawn, and SpriteState with the state you want it to be in (01 for most sprites, 09 with sprite 4-7 for shells and with sprite 53 for throwblocks). Then set the position in place of the XLo/XHi and YLo/YHi values, or you can set it to be equal to an address as well.

You can stick this in LevelASM; you don't have to use a sprite. If you still want to, though, then to spawn it at the sprite's position you'd use this varient instead.

Also, for spawning a throwblock, if you want it to still disappear after a certain amount of time, add this between the last JSL and the EndSpawn label:
Code
	LDA #$FF
	STA $1540,x

(or you can change the #$FF to however many frames you want it to last)

Professional frame-by-frame time wizard. YouTube - Twitter - SMW Glitch List - SMW Randomizer
Thank you so much! This helped a lot.