BG0_CR was not declared in this scope

Post Reply
IThinkSoIAm
Posts: 2
Joined: Fri Sep 11, 2009 5:32 pm

BG0_CR was not declared in this scope

Post by IThinkSoIAm » Fri Sep 11, 2009 5:36 pm

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?

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: BG0_CR was not declared in this scope

Post by Sylus101 » Fri Sep 11, 2009 7:33 pm

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,
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

IThinkSoIAm
Posts: 2
Joined: Fri Sep 11, 2009 5:32 pm

Re: BG0_CR was not declared in this scope

Post by IThinkSoIAm » Sat Sep 12, 2009 7:29 pm

Thanks!

elnanni
Posts: 23
Joined: Sat Nov 14, 2009 1:41 am

Re: BG0_CR was not declared in this scope

Post by elnanni » Wed Nov 18, 2009 8:58 pm

Ok, the old BG0_CR control was renamed to REG_BG0CNT.

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

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests