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.

Coding > ClearBuffer() troubles

#3195 - Corum - Wed Feb 19, 2003 7:00 pm

Hi all.
I've a little problem when trying to clear an u16* buffer by using a dma32 copy.
I'm referring to the well-known function by which we can made a brute copy of a 0x0000 sequence to clean the display buffer (my version is called ClearBuffer()).
I'm able to plot everything by using PlotPixel() and similar, but I cannot clear nothing.
I also use the Flip() function in my code, and I'm sure to achieve the buffer flipping AFTER a complete drawing of the screen and to "clean" the correct buffer (the hidden one) at the beginning of the rendering phase.
I compile my .bin by using a minimum set of switches (-mthumb-interwork, -04, -wall, -mlongcalls).
Every damned function is positioned within the iwram segment.
Anyone could explain why it happens?
Had you ever had this kind of problem?

Thanks in advance for your replies.

Corum.

#3196 - jenswa - Wed Feb 19, 2003 8:24 pm

Why clean, if you can just over-write it?

One way of cleaning is just over-writing the (back) buffer with
one color, probably black or something.
_________________
It seems this wasn't lost after all.

#3213 - Corum - Thu Feb 20, 2003 10:21 am

jenswa wrote:
Why clean, if you can just over-write it?


Cleaning by a dma copy is faster than cleaning by plotting each "blank" pixel. And I need cleaning to deal with transparent areas.
The surprising thing is that in another test I made into a separate project, the same function is fully working.
Anyway, I'm using the sm's library v6 code... For tiled modes is amazing, but it lacks if applied to bitmap modes, IMHO.

But I think I've to assemble my own library for achieving basic stuffs.
Thanks.

Corum.

#3220 - Arjan - Thu Feb 20, 2003 4:41 pm

Maybe the buffer isn't on a word boundary??
_________________
dus.... http://www.bombaman.net

#3224 - col - Thu Feb 20, 2003 5:29 pm

Corum wrote:
jenswa wrote:
Why clean, if you can just over-write it?


Cleaning by a dma copy is faster than cleaning by plotting each "blank" pixel....
Corum.


IIRC from a discussion on the yahoo list, dma is not the fastest way to set a block of memory all to the same value! because dma will load the source data every time!
I think its faster to use a partially unrolled loop with stm instructions. This will work best if the size of the block is constant...

cheers

col.