Page 1 of 1

Need Remove All Sprites from VDP

Posted: Sun Sep 01, 2019 1:27 pm
by cloudstrifer
I want to remove all sprites from VDP, but i still see them.

My code:

Code: Select all

	//SPR_reset();
	//SPR_clear();
	VDP_resetSprites();
	VDP_updateSprites(0, FALSE);
	//SPR_defragVRAM();
	VDP_clearPlan(PLAN_A, TRUE);
	VDP_clearPlan(PLAN_B, TRUE);	
Can someone help me?
sprites.png
sprites.png (10.69 KiB) Viewed 10953 times
Thank you!

Re: Need Remove All Sprites from VDP

Posted: Sun Sep 01, 2019 2:58 pm
by Stef
What is important is that they don't appear anymore on screen. Filling the list with 0 and sending the complete list to the VDP would be a waste of time, so the sprites are cleared, it's just that we don't need to "clear" the list itself for that.

Re: Need Remove All Sprites from VDP

Posted: Sun Sep 01, 2019 6:07 pm
by Sik
I was going to say something like that but then I noticed that the first sprite isn't linking back to 0 so it's possible other sprites may be still shown (the pic doesn't show far enough to tell if it ever ends up linking to some sprite that's visible).

What is shown on screen?

Re: Need Remove All Sprites from VDP

Posted: Mon Sep 02, 2019 8:08 am
by Stef
indeed we do not see sprite 22 and normally SPR_clear() is enough to (temporary) hide all sprites until next SPR_update() call.
SPR_reset() will clear them definitely (releasing all attached resources). Also you should never mix high level methods (SPR_xxx) with low level ones (VDP_xxxSprites).

Re: Need Remove All Sprites from VDP

Posted: Mon Sep 02, 2019 5:00 pm
by cloudstrifer
Sik wrote:
Sun Sep 01, 2019 6:07 pm
What is shown on screen?
I don't see it at screen, I see on Gens VDP sprites list (Gens > CPU > Debug > Genesis > VDP Sprites).

Thank you.

Re: Need Remove All Sprites from VDP

Posted: Mon Sep 02, 2019 5:08 pm
by cloudstrifer
I want do release a sprite and replace it with another sprite.
Please, tell me if the code bellow is a good pratice.

Code: Select all

SPR_releaseSprite(arrRope[lastIndex]);
arrRope[lastIndex] = SPR_addSpriteSafe(&rope_2_32, shootStartX_p1 + 1, shootStartY_p1 - 2 - (lastIndex * 32) - 32, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
Sorry for ask too much questions.

OFF
@stef, if you have some time, please look my post about NM2WCH.

Thank you!

Re: Need Remove All Sprites from VDP

Posted: Mon Sep 02, 2019 5:22 pm
by Sik
cloudstrifer wrote:
Mon Sep 02, 2019 5:00 pm
Sik wrote:
Sun Sep 01, 2019 6:07 pm
What is shown on screen?
I don't see it at screen, I see on Gens VDP sprites list (Gens > CPU > Debug > Genesis > VDP Sprites).

Thank you.
Errrr that's exactly what the function is supposed to do then. It doesn't matter if the table is fully cleared as long as the player doesn't see any sprites on screen. In particular, any sprites not referenced in the linked list may as well not exist.

It sounds like your real problem is a different thing though, judging from the following post?

Re: Need Remove All Sprites from VDP

Posted: Mon Sep 02, 2019 7:56 pm
by cloudstrifer
Sik wrote:
Mon Sep 02, 2019 5:22 pm
cloudstrifer wrote:
Mon Sep 02, 2019 5:00 pm
Sik wrote:
Sun Sep 01, 2019 6:07 pm
What is shown on screen?
I don't see it at screen, I see on Gens VDP sprites list (Gens > CPU > Debug > Genesis > VDP Sprites).

Thank you.
Errrr that's exactly what the function is supposed to do then. It doesn't matter if the table is fully cleared as long as the player doesn't see any sprites on screen. In particular, any sprites not referenced in the linked list may as well not exist.

It sounds like your real problem is a different thing though, judging from the following post?
My problem is when I need to replace a sprite by another one.

Thank you.

Re: Need Remove All Sprites from VDP

Posted: Tue Sep 03, 2019 10:26 am
by Stef
cloudstrifer wrote:
Mon Sep 02, 2019 5:08 pm
I want do release a sprite and replace it with another sprite.
Please, tell me if the code bellow is a good pratice.

Code: Select all

SPR_releaseSprite(arrRope[lastIndex]);
arrRope[lastIndex] = SPR_addSpriteSafe(&rope_2_32, shootStartX_p1 + 1, shootStartY_p1 - 2 - (lastIndex * 32) - 32, TILE_ATTR(PAL1, FALSE, FALSE, FALSE));
Sorry for ask too much questions.

OFF
@stef, if you have some time, please look my post about NM2WCH.

Thank you!
Yeah, when you don't need a sprite, just release it using SPR_releaseSprite(..) method.
Then you can allocate new sprite using SPR_addSprite(..) (or SPR_addSpriteSafe(..) as well).
So you can definitely replace your sprite that way, but you can also use SPR_setDefinition(..) so you maintain partial information from your sprite (position for instance) while changing all the sprite definition.
About the NM2WCH question, to be honest i didn't really understood what was the problem with it (i don't use it myself).

Re: Need Remove All Sprites from VDP

Posted: Wed Sep 04, 2019 1:14 am
by cloudstrifer
Thank you.