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 > Question on DMA transfer

#12143 - yaustar - Fri Oct 31, 2003 8:38 pm

at the moment I have this for loop going on in the main game loop but it slows the game to heck
Code:

for(var_loop = 1536; var_loop < 3584; var_loop++) //96   = radar
   {OAMData[var_loop] = radar[var_loop-1536];}

so I though of using DMA transfer but not sure how to have that I start transfering from OAMData[var_loop]
At the moment I have this
Code:

REG_DM3SAD = (u32)radar;//source of data
REG_DM3DAD = (u32)OAMData[1536];//target for data
 REG_DM3CNT = (2048 | DMA_16NOW);//start copying NOW, in 16bit values

which I know is wrong.

Help
_________________
[Blog] [Portfolio]

#12147 - tepples - Fri Oct 31, 2003 8:46 pm

You need to divide the copy size by the word size, and if you're copying to a specific point in an array, you need to take the address of that array element. Does this work any better?
Code:
REG_DM3SAD = (u32)radar;//source of data
REG_DM3DAD = (u32)&OAMData[1536];//target for data
REG_DM3CNT = (2048/2 | DMA_16NOW);//start copying NOW, in 16bit values

_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12149 - yaustar - Fri Oct 31, 2003 9:06 pm

it works, that's the good news.

bad news is that the actual function to work out the data is too slow :( (running way too many loops and functions)

*back to the drawing board*
_________________
[Blog] [Portfolio]

#12155 - tepples - Sat Nov 01, 2003 1:43 am

GBA has lots of sprite blitting power. The 128 OAM entry limit is no real limit; in theory, you could have well over 1000 sprites running around on screen using hblank DMA to OAM. Try making each radar blip a separate sprite.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12159 - yaustar - Sat Nov 01, 2003 6:20 am

I am not sure how to do what you have just said (in truth I have no idea)

using the reg_ie register, you would want me to use h blank with dma3:
0000 1000 0000 0100

Every time there is a blip, I would use this with each blip?

The mnimap that i am trying to get working is similar to the one in Metal Gear Solid if it helps.
_________________
[Blog] [Portfolio]

#12160 - tepples - Sat Nov 01, 2003 8:08 am

yaustar wrote:
Every time there is a blip, I would use this with each blip?

You don't need to worry about DMA unless you start running up against the 128 OAM entry barrier.

Quote:
The mnimap that i am trying to get working is similar to the one in Metal Gear Solid if it helps.

Are you trying to do it with field of vision cones? Or would you be happy with just dots (as in Goldeneye 007 multiplayer)?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12161 - yaustar - Sat Nov 01, 2003 8:19 am

vision cones is not a problem at the moment, it's more to do with the level outline (cross referenced with the collision map). Not sure how many sprites that would take.

Also I am intrigued with the hardware trick when coming up to the 128 sprite limit if you have time. (a hint will do)
_________________
[Blog] [Portfolio]

#12162 - tepples - Sat Nov 01, 2003 3:58 pm

The gist of vertical sprite multiplexing has been the same since the Commodore 64. During vblank, sort the sprites by Y coordinate and load the first 128 into OAM. Then on the vcount interrupt, set up hblank triggered DMAs to replace each sprite that has been completely drawn (i.e. VCOUNT >= y + h) with another sprite.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#12163 - yaustar - Sat Nov 01, 2003 4:07 pm

Would it be possible to use the same sprite to appear twice on the screen at the same time using this method?
_________________
[Blog] [Portfolio]

#12164 - tepples - Sat Nov 01, 2003 6:04 pm

yaustar wrote:
Would it be possible to use the same sprite to appear twice on the screen at the same time using this method?

This is the essence of the method. You use a sprite, and once the scan has passed below the sprite, you reuse the same HW sprite to display another object.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.