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 > rectangular copying

#21854 - ProblemBaby - Tue Jun 08, 2004 12:01 am

does it exist hardware support for rectangular copying?

#21859 - sajiimori - Tue Jun 08, 2004 2:24 am

The only hardware copying feature is DMA.

#21860 - tepples - Tue Jun 08, 2004 2:48 am

If you really need hardware-accelerated copying of rectangular sections of bitmaps, then you probably need to design your engine to use mode 0 and/or sprites.

What are you trying to do?
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.

#21863 - ProblemBaby - Tue Jun 08, 2004 10:19 am

I use mode 0 I want to copy map data (rects)
to backgrounds

#21864 - ampz - Tue Jun 08, 2004 11:25 am

If I understand you correctly, a for loop with a DMA request in it should do the trick.

Assuming your memcpy implementation use DMA, something like this should work for copying rectangles of data:
Code:

for(row=start_row; row<=end_row; row++)
  memcpy(target_base+row*row_length+start_column, source_base+row*row_length+start_column, rect_width);


start_row == upper row of rectangle.
end_row == lower row of rectangle.
target_base == target map base address.
source_base == source map base address (if there is one).
row_length == total map width in bytes.
start_column == left column of recangle in bytes.
rect_width == rectangle width in bytes.