Archived

This topic is now archived and is closed to further replies.

Arek the Absolute

GBA- DMA question...

Recommended Posts

Anyone know a way to copy a part of an array with DMA? I''m using the function from the PERN Project, but in case you''re not familiar with it, here it is.
  
void DMA_Copy(u8 channel, void* source, void* dest, u32 WordCount, u32 mode)
{
	switch (channel)
	{
		case 0: 
			REG_DMA0SAD = (u32)source;
			REG_DMA0DAD = (u32)dest;			
			REG_DMA0CNT = WordCount | mode;
			break;
		case 1:
			REG_DMA1SAD = (u32)source;
			REG_DMA1DAD = (u32)dest;
			REG_DMA1CNT = WordCount | mode;
			break;
		case 2:
			REG_DMA2SAD = (u32)source;
			REG_DMA2DAD = (u32)dest;
			REG_DMA2CNT = WordCount | mode;
			break;

		case 3:
			REG_DMA3SAD = (u32)source;
			REG_DMA3DAD = (u32)dest;
			REG_DMA3CNT = WordCount | mode;
			break;

	}
}

  
Anyway, my question is this. I have a large array containing the image data for a number of different frames of animation. The first 512 items are the first frame, etc. Can I use DMA to copy just the data in, for example, the third frame? Meaning, can I tell it to start at array[1024] and progress from there? If so, how? Any advice would be, in a word, keen. -Arek the Absolute

Share this post


Link to post
Share on other sites
Oh well. I think I solved the problem anyway. For anyone interested, just manually adjust the position of the pointer. Something like:
DMA_Copy(3,(void*)array+0x400,(void*)OAMData,amount,rate);
Of course, the specifics change on how much you''re skipping, but it does seem to work.

-Arek the Absolute

Share this post


Link to post
Share on other sites
Not really a DMA issue but for faster code you''d be better of using a macro rather than a function especially if your transfering small amounts of data as often the overhead of the function call may be more than that of the transfer. :D

Share this post


Link to post
Share on other sites