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 > loop copying and dma copying

#150940 - krozen - Fri Feb 15, 2008 4:10 pm

Hi guys,
I'm just trying to get my head around the operation of the dma. I have a single 8 x 8 sprite in 16 colour mode, which is 32 bytes. I wish to copy this into VRAM. So, I was just trying out different mechanisms to copy in the data. So far Ive tried:

Option 1:
u32* spriteMem = (u32*)SPRITE_GFX;
u32* spot = (u32*)example_bin;
u32 i;
for (i = 0;i<8;i++)
spriteMem[i] = spot[i];

Option 2:
u16* spriteMem = (u16*)SPRITE_GFX;
u16* spot = (u16*)example_bin;
u32 i;
for (i = 0;i<16;i++)
spriteMem[i] = spot[i];

Option 3:
memcpy(spriteMem,spot,32);

Option 4:
dmaCopy(spot,spriteMem,32);

Now, all work fine, but my question is - why does dmaCopy require 32 as the third parameter, when it's copying 16 bits at a time? I would have thought Option 4 is just a faster version of Option 2?

#150941 - eKid - Fri Feb 15, 2008 4:51 pm

the dmaCopy functions just take the transfer length in bytes to keep things simple

#150949 - Dwedit - Fri Feb 15, 2008 7:45 pm

The OAM is 32 bits wide. Doing copies at 16 bits per element is half as fast as doing full 32 bit copies.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."