BG flicker problem
Posted: 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();
}
}
}