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 > AAS and DMA3

#80359 - Orion - Fri Apr 21, 2006 6:54 pm

Hey.

I've been fiddling around for hours now trying to get this to work, but I can't figure it out.

Any ideas on how I would convert this:

Code:
#define DMACopy(source, dest, WordCount, mode)\
   REG_DMA3CNT = 0;\
   REG_DMA3SAD = (u32)source;\
   REG_DMA3DAD = (u32)dest;\
   REG_DMA3CNT_L = (WordCount >> 1);\
   REG_DMA3CNT_H = mode;


to work using this:

Code:
#define DMACopy(source, dest, WordCount, mode)   AAS_DoDMA3( source, dest, (WordCount >> 1) | mode );


So that I can do DMA3's with AAS without changing every single one in my project?

Thanks

#80362 - poslundc - Fri Apr 21, 2006 7:00 pm

What error are you getting, exactly?

Without knowing what AAS_DoDMA3() is coded to do, I can tell you that one thing you definitely need to start doing is shielding your macro terms.

Code:
#define DMACopy(source, dest, WordCount, mode)     AAS_DoDMA3((source), (dest), ((WordCount) >> 1) | (mode))


Always, always enclose your macro parameters in parentheses to guard against term expansion-related errors. In particular, (WordCount >> 1) is highly vulnerable to errors if WordCount is anything other than a variable or literal value.

Dan.

#80366 - Orion - Fri Apr 21, 2006 7:09 pm

AAS_DoDMA3(etc) writes to the DMA3 registers using a single stmia instruction.. it comes with the AAS sound library.

THere's no error, just the DMA doesn't work - there's no copying at all.

#81575 - jd - Sun Apr 30, 2006 4:28 am

Try this:

Code:
#define DMACopy(source, dest, WordCount, mode)   AAS_DoDMA3( (source), (dest), ((WordCount) >> 1) | ((mode)<<16) );