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.

DS development > Question concerning dmaCopy.

#77685 - Dark Knight ez - Sun Apr 02, 2006 12:23 pm

Hey all,

I'm currently using a memcpy to copy a specified amount of bytes to another location. In some topics I noticed that dmaCopy would be a faster way to do the exact same thing, so I tried using that.
The memcpy way worked flawlessly (music played), but using dmaCopy instead (and changing nothing else) did not work. Are there some restrictions concerning dmaCopy (for instance, it only working for some memory regions)?

This was my memcpy code:
memcpy(ptr, music_it + file_pos, items * size);
And this what I tried to replace it with:
dmaCopy(music_it + file_pos, ptr, items * size);

(where size is of type size_t, if that makes any difference)

Thanks in advance.

#77748 - waruwaru - Sun Apr 02, 2006 9:46 pm

I think the memory space needs to be aligned on 32 bit boundaries. There are also some functions to let you check to see if the dma channel is busy or not before you re-use the channel.
_________________
DSLua - a scripting language for your DS!

#77757 - HyperHacker - Sun Apr 02, 2006 10:19 pm

FYI, I haven't done any speed tests, but a ldmia/stmia loop should blow even DMA out of the water. These instructions load and store multiple registers at a time. You need one for source, one for destination, and one for count (you can save the stack pointer and return address to RAM), so that leaves 11 registers - 44 bytes copied on each iteration of the loop! (You have to do it in ASM, though.)