VDP_fadeIn question.

SGDK only sub forum

Moderator: Stef

Post Reply
ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

VDP_fadeIn question.

Post by ronin68k » Wed Jun 21, 2017 11:26 am

Hi everyone! The problem is...
When I use VDP_fadeIn function for the first time, it works just fine. But at second and further times, this function works way-way faster. So fast, i need to times the value x10 to slow it down a bit. Is it a bug or just me? :)

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

Re: VDP_fadeIn question.

Post by Stef » Wed Jun 21, 2017 1:49 pm

Can we see your code ? can you try to isolate part of your code to see if it reproduces always ?

ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: VDP_fadeIn question.

Post by ronin68k » Wed Jun 21, 2017 2:52 pm

Sure, here it is... https://www.dropbox.com/s/y8qcmk7q1ur2l ... e.rar?dl=1
Update - this bug is only active after button pressed. (see codescreen.c)
Last edited by ronin68k on Wed Jun 21, 2017 4:47 pm, edited 2 times in total.

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

Re: VDP_fadeIn question.

Post by Stef » Wed Jun 21, 2017 3:29 pm

Corrupted file ? I can't unpack the rar file..

Hik
Very interested
Posts: 68
Joined: Thu Jul 30, 2015 11:39 pm
Location: Iceland

Re: VDP_fadeIn question.

Post by Hik » Wed Jun 21, 2017 3:53 pm

The rar unpacks just fine for me Stef. Also you can put dl=1 in the link for direct download.
I'm not sure what's going on with the fades.

ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: VDP_fadeIn question.

Post by ronin68k » Wed Jun 21, 2017 4:46 pm

Here is the part of code. Once i press the button, VDP_fadeIn speeds up for the further and no matter how its called.
But before its called by controller (for example, sega screen with time out), it works fine.

Code: Select all

	if (changed & state & BUTTON_START)
	{
		VDP_fadeOut(0, 16, 30, FALSE);
		Scene_CodeScreen();
	}
Hik wrote:Also you can put dl=1 in the link for direct download.
Fixed link, thanks :)

Also, here is the zipped archive to try https://www.dropbox.com/s/ojy6f2cod7hgp ... c.zip?dl=1

Hik
Very interested
Posts: 68
Joined: Thu Jul 30, 2015 11:39 pm
Location: Iceland

Re: VDP_fadeIn question.

Post by Hik » Wed Jun 21, 2017 6:03 pm

I think this has to do with the way you're calling the JOY_setEventHandler()

Code: Select all

void Scene_CodeScreen()
{
	...
	JOY_setEventHandler(Ctrl_CodeScreen);
}

void Ctrl_CodeScreen(u16 joy, u16 changed, u16 state)
{
	if (CheatCounter0...)
	{
		...
		Scene_CodeScreen();
	}
	else if (changed & state & BUTTON_START)
	{
		...
		Scene_CodeScreen();
	}
}
This might be making it loop in some strange way between Scene_CodeScreen() and the JOY_setEventHandler(Ctrl_CodeScreen) which is within the Scene_CodeScreen() is that a good idea...? I think you only need to set JOY_setEventHandler() initially and have it trigger things.
I think its not a good idea to have the JOY_setEventHandler() looping like that with processing within it..

It says in the documentation "It update controllers state at each V Blank period and fire event if a state change is detected."

ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: VDP_fadeIn question.

Post by ronin68k » Wed Jun 21, 2017 8:05 pm

Oh... well, im still newbie at programming, even tho i used SGDK long time ago, i code very rarely :oops:
Thanks for the reply :) <3

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

Re: VDP_fadeIn question.

Post by Stef » Thu Jun 22, 2017 9:47 am

Oh indeed, you're doing something insane here for sure ^^
also calling VDP_fadeIn() directly from the JOY callback is not a very good idea, at least call it with async parameter set to TRUE in this case ;)

ronin68k
Interested
Posts: 29
Joined: Mon Nov 02, 2015 5:28 am
Location: Krasnodar, Russia

Re: VDP_fadeIn question.

Post by ronin68k » Fri Jun 23, 2017 12:04 am

Stef wrote:at least call it with async parameter set to TRUE in this case ;)
Yep, this is what i did and now i got rid of this bug. :D
Thank you, guys. Getting programming skills is so much fun for me :3

Post Reply