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 > Using DMA_Copy for sprite data

#12724 - zdean - Mon Nov 24, 2003 5:44 pm

Hello, I recently tried using the DMA_Copy function from the Pern project website to copy sprite data, but the sprite data is never loaded? It seems to be working fine for the background data and palette and the sprite palette is also copied in, but the sprite data is not. Does anyone know why this might happen? I have been using the following. Thanks

REG_BG0CNT = BG_COLOR256 | TEXTBG_SIZE_256x256 | (31 << SCREEN_SHIFT) | WRAPAROUND;

SetMode(MODE_0 | BG0_ENABLE | OBJ_ENABLE | OBJ_MAP_1D);

DMA_Copy(3,(void*)level1Map.pal,(void* BGPaletteMem,256,DMA_16NOW);

DMA_Copy(3,(void*)level1Map.tiledata,(void*)CharBaseBlock(0),level1Map.tileDataSize/4,DMA_32NOW);

DMA_Copy(3,(void*)spritemyPalette,(void*)OBJPaletteMem,256,DMA_16NOW);

DMA_Copy(3,(void*)spritemyData,(void*)OAMData,128,DMA_16NOW);

OAMData is defined as ((u16*)0x6010000)

#12744 - yaustar - Tue Nov 25, 2003 2:42 am

Do you ahve more info on the sprite?
_________________
[Blog] [Portfolio]

#12757 - zdean - Tue Nov 25, 2003 6:42 pm

The sprite is a 32 by 32 bit sprite converted using Dovoto's pcx->gba. It is defined as const u16 spritemyData[] which contains 4 animation frames of 512 elements each. I had used the same sprite with a simple loop to copy from the sprite's data array to OAM which worked, but for some reason now using the DMA copies only the palette from the header is loaded currectly? I did notice that if I used a higher DMA privlidge level 0 that I got some pixels from the sprite on the screen, but not nearly complete. Thanks for any advice!

#12759 - zdean - Tue Nov 25, 2003 7:35 pm

correction above I meant the sprite image is 32 x 32 pixels not bits.

#12770 - dagamer34 - Wed Nov 26, 2003 1:26 am

Hmm... although when you load a BG into BG Mem and it is automatically displayed, this is not the same for sprites.

Every frame you need to copy your local copy of OAM to OAM memory. Look at the Pern Project tutorials site (www.pernproject.com) to see how to do it.

My advice is to please thoroughly look at that site. It has really helped me and should help you.
_________________
Little kids and Playstation 2's don't mix. :(

#12800 - zdean - Wed Nov 26, 2003 8:20 pm

I found the problem I had downloaded a new version of the gba.h file which had the OAM Memory pointer defined as 32 bit while everything else had been set up for 16 bits. I made the change in the header and everything seems to be working now. Thanks