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 > Moving the console to another VRAM bank

#119772 - simonjhall - Mon Feb 26, 2007 1:34 am

Yo,

I got a pretty dumb question here. I realised only today that I'd been using the stock consoleDemoInit() function and I'd been effectively typing up the whole of VRAM C for this.
As I want to use banks A-D for textures, how do I move it to something a little less useful?

It's gotta be something obvious but I just can't seem to get it to work!
_________________
Big thanks to everyone who donated for Quake2

#119775 - chishm - Mon Feb 26, 2007 2:58 am

Use
Code:
void consoleInitDefault(u16* map, u16* charBase, u8 bitDepth);

For even more control use
Code:
void consoleInit(u16* font, u16* charBase, u16 numCharacters, u8 charStart, u16* map, u8 pal, u8 bitDepth);

Both are defined in <nds/arm9/console.h>.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#119790 - simonjhall - Mon Feb 26, 2007 10:27 am

Yeah...
I just dunno what I'm doing with that SCREEN_BASE_BLOCK_SUB and CHAR_BASE_BLOCK_SUB lark! By the looks of thost macros it seems that you're setting an offset from some address, and that address is bound to a particular bank...

Again, I'm sure it's obvious what the answer is - but it was pretty late when I was tring to sort it out!
_________________
Big thanks to everyone who donated for Quake2

#119794 - chishm - Mon Feb 26, 2007 11:48 am

Try this (I haven't tested it):
Code:
   
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);   //sub bg 0 will be used to print text
vramSetBankH(VRAM_H_SUB_BG);

SUB_BG0_CR = BG_MAP_BASE(31);

BG_PALETTE_SUB[255] = RGB15(31,31,31);   //by default font will be rendered with color 255

//consoleInit() is a lot more flexible but this gets you up and running quick
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);


This was taken from the libnds consoleDemoInit function with the VRAM block changed to H instead of C.
_________________
http://chishm.drunkencoders.com
http://dldi.drunkencoders.com

#119795 - simonjhall - Mon Feb 26, 2007 12:09 pm

Do you have to change any of those screen base or char base numbers?
_________________
Big thanks to everyone who donated for Quake2

#119818 - elhobbs - Mon Feb 26, 2007 6:08 pm

here is the code I use for the sub screen console in VRAM bank H

Code:

// Subscreen as a console
videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);
vramSetBankH(VRAM_H_SUB_BG);
SUB_BG0_CR = BG_MAP_BASE(15);
consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(15), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);
BG_PALETTE_SUB[0]=0;   
BG_PALETTE_SUB[255]=0xff00;

#119840 - simonjhall - Mon Feb 26, 2007 9:08 pm

elhobbs: awesome, that worked first time! Thanks!

Thanks guys. Another 128k for me to piss around with...
_________________
Big thanks to everyone who donated for Quake2