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 > DS VRAM specs (mode 0)

#148249 - doudou - Thu Jan 03, 2008 10:59 pm

I was wondering how to use the BG vram to increase my GBA to DS ported game and I had this answer in a previous post:

Quote:
Going from 64k to 128k of BG VRAM, we figured that's perfect for increasing the color depth from 4 bit to 8 bit without much trouble on the art side.


I had a look at this code from libnds background.h:

Code:
#define CHAR_BASE_BLOCK(n)         (((n)*0x4000)+ 0x06000000)


Does the 64k to 128k is reflected by having 8 slots on the DS versus only 4 on the GBA? (n going from [0, 8[ instead of [0, 4[)

#148250 - Lick - Thu Jan 03, 2008 11:07 pm

1 byte can store two 4-bit values, or, only one 8-bit value. (1 byte = 8 bits)

That means 8-bit BGs use twice as much memory as 4-bit BGs.

I don't think the base offsets are relevant in your question. But if you have any doubts about the block sizes, refer to gbatek.
_________________
http://licklick.wordpress.com

#148252 - doudou - Thu Jan 03, 2008 11:56 pm

The quote important part is the 64k to 128k, I kept the 4 bit to 8 bit part just to show an "improvement" example (in my case, I would increase the number of tiles instead of color depth).

The offset is used to show that 4 * 0x4000 is 64k. If it would have been 0x8000 instead for DS, I would have tought "right, we have the same number of slots has on the GBA but they are twice the size", but it's not the case.

So, the only explanation for the doubled VRAM mentionned in the quote I can see is that I can use CHAR_BASE_BLOCK from 0 to 8 on DS instead of 0 to 4.

Is it the case?

#148253 - edwdig - Fri Jan 04, 2008 12:02 am

doudou wrote:
So, the only explanation for the doubled VRAM mentionned in the quote I can see is that I can use CHAR_BASE_BLOCK from 0 to 8 on DS instead of 0 to 4.


Actually, you can specify values from 0-15, giving you up to 256 KB of tiles if you use 256 color tiles. It's enough for every tile on all 4 layers to be unique.

#148323 - doudou - Fri Jan 04, 2008 4:19 pm

I must do something wrong in my engine because when I try to use a CHAR_BASE_BLOCK >= 4, it doesn't work (I also offset my screen base block according to that).

I first thought it could be due to a bad setup of my VRAM banks, but first, according to this I allocate 256k to the MAIN BG:

Code:
vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_MAIN_BG_0x06020000, VRAM_C_SUB_BG_0x06200000, VRAM_D_SUB_SPRITE);


And second, even if there was just the 0x6000000, it's still 128k, storing tiles at 0x6010000 as I do using CHAR_BASE_BLOCK(4) should not be a problem.

Any clue?

#148336 - edwdig - Fri Jan 04, 2008 5:49 pm

doudou wrote:
I must do something wrong in my engine because when I try to use a CHAR_BASE_BLOCK >= 4, it doesn't work (I also offset my screen base block according to that).


Screen base is totally independent of character base. I'm guessing that's where your issue is.

#148339 - doudou - Fri Jan 04, 2008 6:43 pm

Ok, do we have the same 32 screen base block we had on GBA?

#148351 - edwdig - Fri Jan 04, 2008 8:52 pm

doudou wrote:
Ok, do we have the same 32 screen base block we had on GBA?


Yes, you get 32 values.

#148676 - doudou - Tue Jan 08, 2008 8:21 pm

Everything is now fine, thanks.

Just to let following readers know, the actual limit for tile count / layer in 16 colors backgrounds is 1024 since tilemaps are using 10 bits for tile indexing (reserving remaining 6 bits for palette and flipping flags).