I''m a bit confused as to how these all work together on the DS. The VRAM banks appear to be locations which can get mapped into certain areas of memory, for example VRAM A can be mapped to 4 locations at 128kb intervals, and this is where you store your tiles, sprites, tilemaps, and other data. The backgrounds can be assigned information, eg. which map base and tile base to use. Map base and tile base seem to be the offset within that VRAM bank, map base at 2kb (32x32 tiles, 2 bytes per tile) intervals and tile base at 16kb intervals. Also, if i'm not mistaken, each screen (main and sub) has access to four backgrounds, ie. the main screen can use 4 backgrounds and the sub screen can use four backgrounds. Though BG_MAP_RAM(_SUB) appear to be limited to 31 (64kb), so it's a bit unclear to me how you'd access a tilemap mapped to the first 128kb bank and another mapped to the second 128kb bank.
Anyway, i'm trying to set up the sub screen to have two layers, bg0 and bg1, but i've been having some pretty weird results. Maybe weird stuff is happening when the tiles in the two layers overlap? I dunno. Here's the code i've used to set them up:
Code: Select all
REG_DISPCNT_SUB = MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE; // sub screen, use bg0 and bg1
REG_BG0CNT_SUB = BG_PRIORITY_0 | BG_32x32 | BG_COLOR_16 | BG_MAP_BASE(0) | BG_TILE_BASE(1);
REG_BG1CNT_SUB = BG_PRIORITY_3 | BG_32x32 | BG_COLOR_16 | BG_MAP_BASE(1) | BG_TILE_BASE(1);
I initially had VRAM H mapped to the sub screen, but didn't know if that had some weird restrictions to it. I believe this
is how i've set it up. The priority doesn't seem to make any difference, either. I'm really not sure what's going on here. I've attached a couple screenshots showing the screen with bg0 enabled, bg1 enabled, and both enabled. The all pink tiles are tile 0, i assumed the first color in the palette would be treated as a transparent color. Can anyone shed some light on what exactly is going on? Figuring the hardware out is turning out to be the most complicated part of the process, both fun and frustrating at the same time
Thanks for any help!