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 > DMA transfer registers

#92592 - devmelon - Fri Jul 14, 2006 1:09 am

http://www.work.de/nocash/gbatek.htm#dmatransfers
Quote:
0B0h,0B2h - DMA0SAD - DMA 0 Source Address (W) (internal memory)
0BCh,0BEh - DMA1SAD - DMA 1 Source Address (W) (any memory)
0C8h,0CAh - DMA2SAD - DMA 2 Source Address (W) (any memory)
0D4h,0D6h - DMA3SAD - DMA 3 Source Address (W) (any memory)
The most significant address bits are ignored, only the least significant 27 or 28 bits are used (max 07FFFFFFh internal memory, or max 0FFFFFFFh any memory - except SRAM ???!).


Are these mapped registers 16 or 32 bits?
I am having a hard time understanding if I should write a 16 bit adress to 0x0400 00b0 or 0x0400 00b2, or if I just should write a 32 bit adress to 0x0400 00b0?

Jonathan S. Harbour ( http://www.jharbour.com/gameboy/default.aspx ), explains in chapter 6, page 208, about DMA transfers very vaugely. He uses unsigned int, and I don't know if that is 16 or 32 bits. Well, when I'm thinking about it, hes using shorts at places and ints at others so it should be 32 (although I use short and long for clarity).

How come the GBATEK writes that register as 2 16-bit registers? Are they meant as high and low registers in that case?

#92623 - devmelon - Fri Jul 14, 2006 4:59 am

Never mind, it worked with 32bit.

#92928 - poslundc - Sat Jul 15, 2006 6:19 pm

1. Generally speaking, the IO registers may be accessed freely in either 16 or 32 bit mode. Many defines provide _H and _L for High and Low variants of the register names, but you should rarely ever need to use them, as it's just as fast (sometimes faster) to work with 32-bit values on the ARM, and there is no penalty in IO-RAM to access 32 bits at a time (as opposed to ROM and EWRAM).

(I think GBATEK breaks up the DMAXCNT registers because it is possible to write to one half without affecting the other... ie. I can screw up and turn on my DMA before setting the copy count if I'm not paying attention to what I'm doing. But I've always treated the DMA control register as a single 32-bit value.)

2. On the ARM platform, int and long are 32-bit, short is 16-bit, and char is 8-bit.

3. Please, please don't use the Harbour book if you are new to GBA programming. It will mislead you and teach you bad coding practices... use TONC instead.

Dan.

#93287 - devmelon - Tue Jul 18, 2006 10:44 am

Thanks. I noticed several wierd things, and even false teachings.