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 > Setting memory adresses for DMA

#5078 - lordmetroid - Sun Apr 20, 2003 9:17 am

I'm trying to make an automatic upload of the tiles that aren't allready in VRAM with my dynamic tile engine... however it doesn't seem to work... perhaps it's my pointer arithemtics that is faulty...

I got this, from various files but paste it together so it will be easier to see:
Code:

#define MEM_VRAM        ((volatile u16*)0x6000000)
u16 mge2d_manager_upload[896], mge2d_manager_upload_num, *mge2d_manager_tiledata, mge2d_manager_physical2logical[896];

REG_DM3DAD = (u32)(MEM_VRAM + 0x20*mge2d_manager_upload[mge2d_manager_upload_num-1]);

REG_DM3SAD = (u32)(mge2d_manager_tiledata + 0x40*mge2d_manager_physical2logical[mge2d_manager_upload[mge2d_manager_upload_num-1]]);

REG_DM3CNT = 16 | SET_TRANSFER_32BIT | SET_SYNC_VBLANK | SET_ENABLE;

mge2d_manager_upload[896] is a database over what physical tiles to upload
mge2d_manager_upload_num keeps track of where in the database we are active
*mge2d_manager_tiledata a pointer to the tiles in ROM
mge2d_manager_physical2logical[896] a Database over what VRAM tileslot number has what ROM tilenumber

What happends is that it only uploads one tile of the three that is in the upload database, and it is the last one which should place itself on tileslot 0 however there isn't even a trace of the other 3 in the DB... if I change 0x20=> 0x40 then it ends up uploading the last tile in the DB to tileslot 0 but noone else.
What am I doing wrong?

please help...
[/quote][/code]
_________________
*Spam*
Open Solutions for an open mind, www.areta.org

Areta is an organization of coders codeing mostly open source project, but there is alot of sections like GBA dev, Language learning communities, RPG communities, etc...

#5079 - jenswa - Sun Apr 20, 2003 1:18 pm

Seems to me your trying to load an array of tiles,
shouldn't it then be u32* instead of u32 ??

Just a thought
_________________
It seems this wasn't lost after all.

#5080 - DekuTree64 - Sun Apr 20, 2003 3:21 pm

You're using 256 color tiles, right? Try changing the 0x40 to 0x20 in the DM3SAD line, since all your pointers are 16-bit, so all your sizes should be /2, but that shouldn't be causing the problems you described, just make it so tile 1 doesn't make it load tile 2, tile 2 load tile 4, etc.
But I really can't find anything else wrong with it. I'd say it's somewhere in your setting up of mge2d_manager_upload and/or mge2d_manager_physical2logical, but that's just a guess.

#5082 - lordmetroid - Sun Apr 20, 2003 6:48 pm

Well I checked the multiplication variables by priniting them as tilenumbers in the mapdata... and they are all working as they should giving the right source tilenum and destination tilenum.
However 0x20 doesn't work either I tried with everything, however when I accidently wrote 0x32 on both places because I thought I would do it with decimal numbers... half the tile were uploaded and another half of the other... even thought it's in a loop... I don't get this at all!

And the tiles are just laid out one after the other in the memory, it's place in memory decidse it's logical tilenum... so the pointer points to the start of where the tiles are.
_________________
*Spam*
Open Solutions for an open mind, www.areta.org

Areta is an organization of coders codeing mostly open source project, but there is alot of sections like GBA dev, Language learning communities, RPG communities, etc...

#5113 - lordmetroid - Mon Apr 21, 2003 12:42 pm

I found out what was the problem... apperently when I synced with Vblank it only uploaded one of the tiles and then the Vblank was over or something else happend that makes DMA only send once per Vblank even thought the loop rolled on and removed all requirments of uploading new tiles...
So when I removed sync with VBlank it uploaded everything nicely.
_________________
*Spam*
Open Solutions for an open mind, www.areta.org

Areta is an organization of coders codeing mostly open source project, but there is alot of sections like GBA dev, Language learning communities, RPG communities, etc...