gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

Beginners > How do I quickly clear the screen?

#20121 - LunarCrisis - Sun May 02, 2004 5:35 pm

Hi, I'm new to GBA programing, and I'm trying to make a mode 4 double buffered program that displays a line moving around the screen. The problem is that the function I'm using to clear the screen:
Code:
void ClearLCD()
{
   int loop;
   for(loop = 0; loop < 19200; loop++)
   {
      VideoBuffer[loop] = 0x0101;
   }
}

is very slow. How can I do it any faster?

#20124 - zazery - Sun May 02, 2004 6:39 pm

You could use DMA since the sole purpose of DMA is to transfer data fast. It's actually a separate chip so it can complete while the rest of your program continues. It's really fast and it's used for many different tasks on the GBA.

#20127 - dagamer34 - Sun May 02, 2004 7:15 pm

You should look around using the search function for a clear screen function. There should be one around here somewhere.
_________________
Little kids and Playstation 2's don't mix. :(

#20136 - SmileyDude - Sun May 02, 2004 11:28 pm

zazery wrote:
You could use DMA since the sole purpose of DMA is to transfer data fast. It's actually a separate chip so it can complete while the rest of your program continues. It's really fast and it's used for many different tasks on the GBA.


Well, this is a perfect use for DMA, you are incorrect that the DMA is a separate chip and completes while the rest of your program continues. DMA on the GBA halts the CPU until the DMA is complete. But, for something like this, it's pretty fast. It may not be the fastest, but certainly better than a for loop in C.
_________________
dennis

#20137 - sajiimori - Sun May 02, 2004 11:39 pm

I can't think of anything faster. The video buffer has to physically be cleared somehow.

Of course, you may not actually have to clear the whole screen for your particular application, but that's a different matter.

#20139 - zazery - Mon May 03, 2004 12:25 am

SmileyDude wrote:

Well, this is a perfect use for DMA, you are incorrect that the DMA is a separate chip and completes while the rest of your program continues. DMA on the GBA halts the CPU until the DMA is complete. But, for something like this, it's pretty fast. It may not be the fastest, but certainly better than a for loop in C.


I guess I heard wrong from a friend of mine. I'm new to the DMA as well. Sorry for the wrong info.