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.

Hardware > DMA3 with source fixed from cartridge

#11516 - poslundc - Thu Oct 09, 2003 4:56 am

Here's a hard-earned lesson to share with everyone:

Don't use the SOURCE_FIXED parameter with DMA3 if your source is the cartridge. It works in emulation, but it doesn't seem to work on hardware.

I don't know if the problem extends to other DMAs or other types of memory; I just know that my data was getting garbled under those circumstances.

(One bug down... about a million to go...)

Dan.

#11525 - tom - Thu Oct 09, 2003 2:19 pm

probably you messed up something else. never had problems with stuff like that. besides, if you use a fixed source address you might aswell use the cpu, as its faster.

#11526 - poslundc - Thu Oct 09, 2003 2:39 pm

tom wrote:
probably you messed up something else. never had problems with stuff like that. besides, if you use a fixed source address you might aswell use the cpu, as its faster.


Have you tried specifically DMA3 with fixed source, 16-bit, reading from the cartridge, on a GBA?

Cuz I'm saying that unless your GBA is different from my GBA, it doesn't work. I know I didn't screw something else up because it works just fine in emulation.

Are you certain that CPU transfers are faster? I'd like to hear your reasoning behind it. (I wouldn't think that the DMA timings on the Cowbite spec would apply to a fixed-source transfer; I'd imagine it would be at least as fast as writing to the locations yourself.)

Dan.

#11529 - tepples - Thu Oct 09, 2003 3:05 pm

If you have a fixed source address, a somewhat-unrolled loop of STMIA instructions can be faster than DMA. DMA needs to reread data from the source address every time; STMIA doesn't and can write 12 u32s for every instruction fetch.

DMA: set up registers, read source, write dest, read source, write dest, read source, write dest, ...

STMIA: read source, copy to all CPU registers, read instruction, write dest * 12, read instruction, write dest * 12, read instruction, write dest * 12, ...

Notice how there are several times fewer reads once the STMIA loop gets going. The result can be at least 75% faster than DMA.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#11531 - tom - Thu Oct 09, 2003 4:27 pm

poslundc wrote:
I know I didn't screw something else up because it works just fine in emulation.


this doesn't mean anything. except that the emulator you're using might be buggy =)

seriously, dma *does* work the same on all memory areas of the gba.(except sram and bios rom. you can't access those with dma)


Last edited by tom on Thu Oct 09, 2003 4:36 pm; edited 1 time in total

#11532 - tom - Thu Oct 09, 2003 4:34 pm

btw, you can use the cpufastset syscall to try out wether it's faster.
it uses an

Code:

stmia r0!,{r1-r8}


instruction (or similar) to write 32 bytes at once.

but you might be better off with a handcoded routine that uses 4 more registers and writes 48 bytes at once.