Page 1 of 1

BG0_CR was not declared in this scope

Posted: Fri Sep 11, 2009 5:36 pm
by IThinkSoIAm
Hi!

I'm following a tutorial for learning some DS programming, but I've got a problem. I was able to solve all my previous problems using Google, but this time my Google skills have proven to be lacking. =(

Here's the code:

Code: Select all

#include <nds.h>
 
//create a tile called redTile
u8 redTile[64] = 
{
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1,
	1,1,1,1,1,1,1,1
};
 
//create a tile called greenTile
u8 greenTile[64] = 
{
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2,
	2,2,2,2,2,2,2,2
};
 
 
//---------------------------------------------------------------------------------
int main(void) {
//---------------------------------------------------------------------------------
	int i;
	
	//set video mode and map vram to the background
	videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE);
	vramSetBankA(VRAM_A_MAIN_BG_0x06000000);
 
	//get the address of the tile and map blocks 
	u8* tileMemory = (u8*)BG_TILE_RAM(1);
	u16* mapMemory = (u16*)BG_MAP_RAM(0);
	
	//tell the DS where we are putting everything and set 256 color mode and that we are using a 32 by 32 tile map.
	BG0_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1);
 
	//load our palette
	BG_PALETTE[1] = RGB15(31,0,0);
	BG_PALETTE[2] = RGB15(0,31,0);
	
  
	//copy the tiles into tile memory one after the other
	swiCopy(redTile, tileMemory, 32);
	swiCopy(greenTile, tileMemory + 64, 32);
	
	//create a map in map memory
	for(i = 0; i < 32 * 32; i++)
		mapMemory[i] = i & 1;
 
	return 0;
}
And the error is in the title. Anyone got an idea about what I did wrong?

Re: BG0_CR was not declared in this scope

Posted: Fri Sep 11, 2009 7:33 pm
by Sylus101
Well, unfortunately most written tutorials (and that looks like dovoto's) are sorely out of date. That particular background control register define no longer exists...

The best way to learn as libnds is now, is to explore the examples thoroughly. You'll find that there is a new API that helps with initializing backgrounds. What will be really good to be clear on and where tutorials are going to still be quite valuable is in understanding the mapbase and charbase (tile base) parameters of a background.

Best of luck,

Re: BG0_CR was not declared in this scope

Posted: Sat Sep 12, 2009 7:29 pm
by IThinkSoIAm
Thanks!

Re: BG0_CR was not declared in this scope

Posted: Wed Nov 18, 2009 8:58 pm
by elnanni
Ok, the old BG0_CR control was renamed to REG_BG0CNT.

Hope it helps, and sorry to open an old thread.