BG flicker problem

Post Reply
Kazo
Posts: 14
Joined: Mon Aug 29, 2011 8:06 am

BG flicker problem

Post by Kazo » Tue Dec 18, 2012 7:37 pm

I need to know how to load a new background and move the scroll location in one frame, First I tried loading the new background and resetting the scroll, but then I get this flicker on the screen from the background being loaded and shown at the old scroll location before it was updated. Then I tried resetting the scroll first and then loading the background and then I get a flicker of the old background at the new scroll location before the new background is loaded.

Code: Select all

void DrawMap()
{
	x2 = 128;
	y2 = 160;
	int i = 0;
	bitmap = fopen("/Map/Johto_Bitmap.bin", "rb");
	for(i = 0; i < 512; i++)
	{
		fseek(bitmap, (7680 * i) + (y * 7680) + x, SEEK_SET);
		fread(fileData, 1, 512, bitmap);
		DC_FlushRange(fileData, 512);
		dmaCopy(fileData, mapData + (i * 128), 512);
	}
	fclose(bitmap);
	DC_FlushRange(mapData, 262144);
	dmaCopy(mapData, bgGetGfxPtr(BG), 262144);
}

Code: Select all

void MoveUp()
{
	int i = 0;
	if (y != 0)
	{
		for(i = 0; i < 16; ++)
		{
			y = y - 1;
			y2 = y2 - 1;
			if (y2 == 0)
			{
				DrawMap();
			}
			bgSetScroll(3, x2, y2);
			bgUpdate();
			swiWaitForVBlank();
		}
	}
}

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: BG flicker problem

Post by elhobbs » Tue Dec 18, 2012 8:34 pm

you want to update the map and scroll position during vblank. your code waits for vblank after the updating the map and scroll position.

EDIT: of course you are probably going to have issues trying to read that much data from disk during vblank.

Kazo
Posts: 14
Joined: Mon Aug 29, 2011 8:06 am

Re: BG flicker problem

Post by Kazo » Tue Dec 18, 2012 8:57 pm

how would I go about doing that?

elhobbs
Posts: 358
Joined: Thu Jul 02, 2009 1:19 pm

Re: BG flicker problem

Post by elhobbs » Tue Dec 18, 2012 9:57 pm

call swiWaitForVBlank then update your background

Kazo
Posts: 14
Joined: Mon Aug 29, 2011 8:06 am

Re: BG flicker problem

Post by Kazo » Wed Dec 19, 2012 5:13 am

After doing that and lower the background to 512x256 from 512x512 the problem is no longer an issue.

Thanks!

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests