Bg pallete doesn't work

Post Reply
OdnetninI
Posts: 19
Joined: Sat Nov 20, 2010 12:38 pm

Bg pallete doesn't work

Post by OdnetninI » Sat Jul 09, 2011 1:56 pm

hello, sorry for my repeted post
whith this codes, I iniciate and load the backgrounds but, it doesn't load palette

Code: Select all

void ODI_Init(void){
	//Modo de Video
		REG_DISPCNT = MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE;
		REG_BG0CNT = BgType_Text8bpp | BG_32x32 | BG_PALETTE_SLOT0 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY(0);
		REG_BG1CNT = BgType_Text8bpp | BG_32x32 | BG_PALETTE_SLOT1 | BG_COLOR_256 | BG_MAP_BASE(1) | BG_TILE_BASE(2) | BG_PRIORITY(1);
		REG_BG2CNT = BgType_Text8bpp | BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(2) | BG_TILE_BASE(3) | BG_PRIORITY(2);
		REG_BG3CNT = BgType_Text8bpp | BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(3) | BG_TILE_BASE(4) | BG_PRIORITY(3);
	
		REG_DISPCNT_SUB = MODE_0_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG1_ACTIVE | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE | DISPLAY_SPR_ACTIVE;
		REG_BG0CNT_SUB = BgType_Text8bpp | BG_32x32 | BG_PALETTE_SLOT0 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY(0);
		REG_BG1CNT_SUB = BgType_Text8bpp | BG_32x32 | BG_PALETTE_SLOT1 | BG_COLOR_256 | BG_MAP_BASE(1) | BG_TILE_BASE(2) | BG_PRIORITY(1);
		REG_BG2CNT_SUB = BgType_Text8bpp | BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(2) | BG_TILE_BASE(3) | BG_PRIORITY(2);
		REG_BG3CNT_SUB = BgType_Text8bpp | BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(3) | BG_TILE_BASE(4) | BG_PRIORITY(3);
 
	//Memoria Vram
		REG_DISPCNT |= (DISPLAY_BG_EXT_PALETTE);
		REG_DISPCNT_SUB |= (DISPLAY_BG_EXT_PALETTE);
		REG_DISPCNT |= (DISPLAY_SPR_ACTIVE);
		REG_DISPCNT_SUB |= (DISPLAY_SPR_ACTIVE);
		vramSetBankA(VRAM_A_MAIN_BG);
		vramSetBankE(VRAM_E_LCD);
		vramSetBankC(VRAM_C_SUB_BG);
		vramSetBankH(VRAM_H_LCD);
		vramSetBankB(VRAM_B_MAIN_SPRITE_0x06400000);
		vramSetBankF(VRAM_F_LCD);
		vramSetBankD(VRAM_D_SUB_SPRITE);
		vramSetBankI(VRAM_I_LCD);
		memset((void*)0x06880000, 0, 32768);
		memset((void*)0x06898000, 0, 32768);
		memset((void*)0x06890000, 0, 8192);	
		memset((void*)0x068A0000, 0, 8192);	

}

Code: Select all

void ODI_Crear_Fondo(u8 pantalla, u8 capa, int slot,int ancho, int alto){
	
	s32 bg;

	if ((ancho == 256) && (alto == 256)) {
		bg = BG_32x32;
	}
	if ((ancho == 512) && (alto == 256)) {
		bg = BG_64x32;
	}
	if ((ancho == 256) && (alto == 512)) {
		bg = BG_32x64;
	}
	if ((ancho == 512) && (alto == 512)) {
		bg = BG_64x64;
	}
	
	if(pantalla==1){
		switch (capa){
			case 0:
				REG_BG0CNT = BgType_Text8bpp | bg | BG_PALETTE_SLOT0 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY_0;
				
				vramSetBankE(VRAM_E_LCD);
				memcpy((void*)((((1)*0x4000) + 0x06000000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((0)*0x800) + 0x06000000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((0)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((0)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((0)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)(((((0)*0x800) + 0x06000000))+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06880000) + (0 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankE(VRAM_E_BG_EXT_PALETTE);
				break;
				
			case 1:
				REG_BG1CNT = BgType_Text8bpp | bg | BG_PALETTE_SLOT1 | BG_MAP_BASE(1) | BG_TILE_BASE(2) | BG_PRIORITY_1;
				
				vramSetBankE(VRAM_E_LCD);
				memcpy((void*)((((2)*0x4000) + 0x06000000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((1)*0x800) + 0x06000000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((1)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((1)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((1)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)(((((1)*0x800) + 0x06000000))+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06880000) + (1 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankE(VRAM_E_BG_EXT_PALETTE);
				break;
				
			case 2:
				REG_BG2CNT = BgType_Text8bpp | bg | BG_PALETTE_SLOT2 | BG_MAP_BASE(2) | BG_TILE_BASE(3) | BG_PRIORITY_2;
				
				vramSetBankE(VRAM_E_LCD);
				memcpy((void*)((((3)*0x4000) + 0x06000000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((2)*0x800) + 0x06000000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((2)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((2)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((2)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)(((((2)*0x800) + 0x06000000))+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06880000) + (2 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankE(VRAM_E_BG_EXT_PALETTE);
				break;
				
			case 3:
				REG_BG3CNT = BgType_Text8bpp | bg | BG_PALETTE_SLOT3 | BG_MAP_BASE(3) | BG_TILE_BASE(4) | BG_PRIORITY_3;
				
				vramSetBankE(VRAM_E_LCD);
				memcpy((void*)((((4)*0x4000) + 0x06000000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((3)*0x800) + 0x06000000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((3)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((3)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((3)*0x800) + 0x06000000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)((((3)*0x800) + 0x06000000)+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06880000) + (3 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankE(VRAM_E_BG_EXT_PALETTE);
				break;
		}
	}
	if(pantalla==0){
		switch (capa){
			case 0:
				REG_BG0CNT_SUB = BgType_Text8bpp | bg | BG_PALETTE_SLOT0 | BG_MAP_BASE(0) | BG_TILE_BASE(1) | BG_PRIORITY_0;
				
				vramSetBankH(VRAM_H_LCD);
				memcpy((void*)((((1)*0x4000) + 0x06200000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((0)*0x800) + 0x06200000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((0)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((0)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((0)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)(((((0)*0x800) + 0x06200000))+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06898000) + (0 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
				break;
				
			case 1:
				REG_BG1CNT_SUB = BgType_Text8bpp | bg | BG_PALETTE_SLOT1 | BG_MAP_BASE(1) | BG_TILE_BASE(2) | BG_PRIORITY_1;
				
				vramSetBankH(VRAM_H_LCD);
				memcpy((void*)((((2)*0x4000) + 0x06200000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((1)*0x800) + 0x06200000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((1)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((1)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((1)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)(((((1)*0x800) + 0x06200000))+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06898000) + (1 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
				break;
				
			case 2:
				REG_BG2CNT_SUB = BgType_Text8bpp | bg | BG_PALETTE_SLOT2 | BG_MAP_BASE(2) | BG_TILE_BASE(3) | BG_PRIORITY_2;
				
				vramSetBankH(VRAM_H_LCD);
				memcpy((void*)((((3)*0x4000) + 0x06200000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((2)*0x800) + 0x06200000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((2)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((2)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((2)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)(((((2)*0x800) + 0x06200000))+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06898000) + (2 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
				break;
				
			case 3:
				REG_BG3CNT_SUB = BgType_Text8bpp | bg | BG_PALETTE_SLOT3 | BG_MAP_BASE(3) | BG_TILE_BASE(4) | BG_PRIORITY_3;
				
				vramSetBankH(VRAM_H_LCD);
				memcpy((void*)((((4)*0x4000) + 0x06200000)), TILES[pantalla][slot], tiles_size[pantalla][slot]);
				if(ancho==256&&alto==256){
					memcpy((void*)((((3)*0x800) + 0x06200000)), MAP[pantalla][slot], map_size[pantalla][slot]);
				}
				if(ancho==512&&alto==256){
					memcpy((void*)((((3)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==256&&alto==512){
					memcpy((void*)((((3)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
				}
				if(ancho==512&&alto==512){
					memcpy((void*)((((3)*0x800) + 0x06200000)), MAP[pantalla][slot], 4096);
					u16 siguiente;
					siguiente = ((((ancho - 1) >> 8) + 1) << 11);
					memcpy((void*)((((3)*0x800) + 0x06200000)+4096), MAP[pantalla][slot]+siguiente, 4096);
				}
				memcpy((void*)((0x06898000) + (3 << 13)), PAL[pantalla][slot], pal_size[pantalla][slot]);
				vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
				break;
		}
	}
	ODI_Scroll_Fondo(pantalla,capa,0,0);
}
please help

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Bg pallete doesn't work

Post by zeromus » Sat Jul 09, 2011 6:24 pm

hello, sorry for my repeted post
whith this codes, I iniciate reading, but it doesn't load in my brain
please help by uploading a zip of your project
p.s. did you enable BG extended palettes?

OdnetninI
Posts: 19
Joined: Sat Nov 20, 2010 12:38 pm

Re: Bg pallete doesn't work

Post by OdnetninI » Sat Jul 09, 2011 10:49 pm

the proyect is too big to post it, but if yu read I put in the first code the extender palette iniciation
please read it, I need an answer

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Bg pallete doesn't work

Post by zeromus » Sun Jul 10, 2011 8:40 am

the internet has a lot of gigabytes. i dont think its too big.

OdnetninI
Posts: 19
Joined: Sat Nov 20, 2010 12:38 pm

Re: Bg pallete doesn't work

Post by OdnetninI » Sun Jul 10, 2011 10:52 am

the problem is that the proyect is a lybrary

zeromus
Posts: 212
Joined: Wed Mar 31, 2010 6:05 pm

Re: Bg pallete doesn't work

Post by zeromus » Mon Jul 11, 2011 7:43 am

the internet contains the equivalent of 100,000 lybrarys of congress. i dont think one more is going to hurt anything.

OdnetninI
Posts: 19
Joined: Sat Nov 20, 2010 12:38 pm

Re: Bg pallete doesn't work

Post by OdnetninI » Mon Jul 11, 2011 12:13 pm

leave it nothing happens, I put on a homebrew project for a normal and going well, not to be but it works

Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests