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 > Faster Tile Copying...DMA

#33456 - QuantumDoja - Mon Jan 03, 2005 8:19 pm

Hi, Im writing a platform game in mode 0, I am writing to the map data (32*32) tiles from a larger 1d array, i am using a calculation to select the tiles one at a time to update the entire column that needs updating.

I need to know if there is a faster method to select the tiles i want, and copy them into a new column, i've heard of DMA....but i dont know if it can be applied.....i know too little about it.

If anyone has any suggestions, id like to read them.
_________________
Chris Davis

#33462 - sajiimori - Mon Jan 03, 2005 8:52 pm

If you think of DMA as memcpy except faster, that might help you understand when it could be useful.

That said, don't worry about optimizing until you are actually having a speed problem, and then find the code that is causing the problem. It may not be what you think.

#33497 - poslundc - Tue Jan 04, 2005 3:23 pm

Since you are loading in a column, no, you can't copy it into VRAM as a single contiguous block.

But if you're just copying map entries, they are only 1 or 2 bytes depending on the background format, and you only have 32 of them to copy, which is a really trivial thing to do during the VBlank period. Use a "for" loop and don't sweat it; if you run out of CPU time - as sajimori points out - it won't be due to this.

If you're streaming the actual tile data, they are only 32 or 64 bytes depending on the colour format, which while an order of magnitude bigger than the map entries, at only 32 entries isn't something you need to worry about. If it becomes a problem, as sajimori says, you can always optimize it later, but it probably won't.

Dan.