Need Remove All Sprites from VDP

SGDK only sub forum

Moderator: Stef

Post Reply
cloudstrifer
Very interested
Posts: 72
Joined: Mon Feb 19, 2018 7:31 pm

Need Remove All Sprites from VDP

Post by cloudstrifer » Sun Sep 01, 2019 1:27 pm

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 351 times
Thank you!

Stef
Very interested
Posts: 2982
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Need Remove All Sprites from VDP

Post by Stef » Sun Sep 01, 2019 2:58 pm

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.

Sik
Very interested
Posts: 889
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Need Remove All Sprites from VDP

Post by Sik » Sun Sep 01, 2019 6:07 pm

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?
Sik is pronounced as "seek", not as "sick".

Stef
Very interested
Posts: 2982
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Need Remove All Sprites from VDP

Post by Stef » Mon Sep 02, 2019 8:08 am

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).

cloudstrifer
Very interested
Posts: 72
Joined: Mon Feb 19, 2018 7:31 pm

Re: Need Remove All Sprites from VDP

Post by cloudstrifer » 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.

cloudstrifer
Very interested
Posts: 72
Joined: Mon Feb 19, 2018 7:31 pm

Re: Need Remove All Sprites from VDP

Post by cloudstrifer » 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!
Last edited by cloudstrifer on Mon Sep 02, 2019 11:28 pm, edited 1 time in total.

Sik
Very interested
Posts: 889
Joined: Thu Apr 10, 2008 3:03 pm
Contact:

Re: Need Remove All Sprites from VDP

Post by Sik » 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?
Sik is pronounced as "seek", not as "sick".

cloudstrifer
Very interested
Posts: 72
Joined: Mon Feb 19, 2018 7:31 pm

Re: Need Remove All Sprites from VDP

Post by cloudstrifer » Mon Sep 02, 2019 7:56 pm

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.

Stef
Very interested
Posts: 2982
Joined: Thu Nov 30, 2006 9:46 pm
Location: France - Sevres
Contact:

Re: Need Remove All Sprites from VDP

Post by Stef » Tue Sep 03, 2019 10:26 am

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).

cloudstrifer
Very interested
Posts: 72
Joined: Mon Feb 19, 2018 7:31 pm

Re: Need Remove All Sprites from VDP

Post by cloudstrifer » Wed Sep 04, 2019 1:14 am

Thank you.

Post Reply