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.

DS development > removing sections

#176002 - Samu - Thu Mar 17, 2011 12:27 am

hello

I was wondering if its possible to delete part of a tiled background at runtime, or at least simulate it. Its hard to explain what i mean so ill attach a picture showing what i mean.

[Images not permitted - Click here to view it]

is it possible to do this, remove part of a tiled background, leaving the background behind it visible?

thanks.

#176003 - Dwedit - Thu Mar 17, 2011 7:05 am

Normally, you do this by using more tiles. So you have your original tile, and you need a section cut out of it. Just copy it to another tile, change the map ram to indicate that you are using a different tile, and do your drawing on the new tile.
_________________
"We are merely sprites that dance at the beck and call of our button pressing overlord."

#176004 - Ruben - Thu Mar 17, 2011 7:48 am

Building on what Dwedit said:
You could probably build a VRAM managing system to make this easier.
Something like...
Code:
//! Number of internal structures
#define VRAM_ALLOC 8

//! Allocation structure type
typedef struct {
        void *base;
        void *next;
} vid_Alloc_t;

//! Internal structure
static vid_Alloc_t vid_iVRAMAlloc[VRAM_ALLOC];

//! Get new 'section' (or increase length)
void *vid_VRAMNew(u32 len, vid_Alloc_t *sect) {
        if(!sect) {
                //! Create new section
                int i;
                for(i=0;i<8;i++) {
                        if(!vid_iVRAMAlloc[i].base) {
                                //! Each 'section' has 10000/x bytes of RAM
                                void *base = (void*)(0x06000000 + i*(0x10000/VRAM_ALLOC));
                               
                                //! Set base+end
                                vid_iVRAMAlloc.base = base;
                                vid_iVRAMAlloc.next = base + len;
                               
                                //! Return base
                                return base;
                        }
                } return 0;
        } else {
                //! Resize section and return new base
                void *old = sect->next; sect->next += len;
                return old;
        }
}

//! Delete 'section'
void vid_VRAMDel(vid_Alloc_t *sect) {
        sect->base = 0;
        sect->next = 0;
}


EDIT:
You could probably get rid of the 'base' member if you don't need to know the beginning address for the current section.

#176011 - sverx - Fri Mar 18, 2011 1:09 pm

if the part you want to remove isn't convex you could try windowing and HDMA...

... or object windows.

#176013 - headspin - Fri Mar 18, 2011 1:19 pm

If you don't have repeating tiles you can also edit the tile data directly.
_________________
Warhawk DS | Manic Miner: The Lost Levels | The Detective Game