Zal0 / ZGB

Game Boy / Color engine with lots of features

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

FadeOut() is broken on DMG

mhughson opened this issue · comments

The fade functions found in "Fade.h" appear to be broken when running the non-color version of a game. FadeIn() works (fading the screen to pure white, but FadeOut() appears to have no effect. If called after calling FadeIn() the screen stays pure white. If called without first calling FadeOut(), the color does not change.

I wrote a simple example game with this Update:

void UPDATE() {
	if(KEY_TICKED(J_START))
	{
		FadeIn();
	}
	
	if (KEY_TICKED(J_SELECT))
	{
		FadeOut();
	}

These 2 gifs are the same game compiled as Color and Non-Color. In both cases I press START and shortly after I press SELECT. Note that while both versions fade up to white, the DMG version does not fade back down.

gb1_dmg_broken_fade

gb1_color_working_fade

NOTE: This can be worked around by forcefully setting the DMG palettes prior to calling FadeOut() like so:

	FadeIn();
	DISPLAY_OFF;

	...

	// Fade function on DMG reads the colors directly from registers before fading.
	// As a result, the FadeOut fails when called after FadeIn() because it tries to fade to a solid
	// color.
	// To fix this, we set the real colors right before FadeOut to set the proper
	// destination colors.
	BGP_REG = OBP0_REG = OBP1_REG = PAL_DEF(0, 1, 2, 3);
	
	DISPLAY_ON;
	FadeOut();