Confusion about VRAM banks, backgrounds, and map bases

Post Reply
Posts: 3
Joined: Thu May 28, 2015 4:13 pm

Confusion about VRAM banks, backgrounds, and map bases

Post by chickendude » Thu May 28, 2015 4:54 pm

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

//	vramSetBankH(VRAM_H_SUB_BG);

	REG_DISPCNT_SUB = MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE;   // sub screen, use bg0 and bg1
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!
Both bg0 and bg1 enabled
(1.64 KiB) Not downloaded yet
Only bg0 enabled
(1.7 KiB) Not downloaded yet
Only bg1 enabled
(2.46 KiB) Not downloaded yet

Posts: 3
Joined: Thu May 28, 2015 4:13 pm

Re: Confusion about VRAM banks, backgrounds, and map bases

Post by chickendude » Fri May 29, 2015 5:34 pm

Ok, after a lot of confusion i think i finally figured out what the problem was, and it was the last place i expected it to be: the palette! I assumed that grit took the first color it came across and added that as the transparent color, but it was adding black as the transparent color. So my text was actually all transparent, which is what was causing the AND effect when layering the two together. I passed grit the transparent color manually ("-gT ff0000" in the grit file to mark red as the transparent color) and now everything is working perfectly! I just spent the past two days reading up on everything i could about the video hardware trying to figure out what the problem was :oops:

The video stuff is a lot to get down, but i think it's starting to get clearer :)

Posts: 355
Joined: Thu Jul 02, 2009 1:19 pm

Re: Confusion about VRAM banks, backgrounds, and map bases

Post by elhobbs » Fri May 29, 2015 11:50 pm

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest