GBA- Problems with Character Base Block 0

Started by
1 comment, last by Arek the Absolute 21 years, 12 months ago
I''m a bit confused here... I''ve got a GBA project going in Mode 0, and I''m using four backgrounds. However, some of the data I put for BG0 is always corrupted... And frankly, I don''t understand what''s going on. Here''s a code clip:
  
// set up backgrounds

REG_BG0CNT = TEXTBG_SIZE_256x256  | CHAR_BASE(3) | SCREEN_BASE(0) | BG_COLOR_256 | BG_PRIORITY(0);

REG_BG1CNT = TEXTBG_SIZE_256x256  | CHAR_BASE(2) | SCREEN_BASE(20)| BG_COLOR_256 | BG_PRIORITY(1);

REG_BG2CNT = TEXTBG_SIZE_256x256  | CHAR_BASE(1) | SCREEN_BASE(3) | BG_MOSAIC_ENABLE | BG_COLOR_256 | BG_PRIORITY(2);

REG_BG3CNT = TEXTBG_SIZE_256x256  | CHAR_BASE(0) | SCREEN_BASE(9)    | BG_MOSAIC_ENABLE | BG_COLOR_256 | BG_PRIORITY(3);

// load the background palette

for (i = 0; i < 256; i++)
    BGPaletteMemory[i] = BGPalette[i];

// copy the tiles to the background memory

u16* Background3Mem = (u16 *)CharBaseBlock(0);
u16* Background2Mem = (u16 *)CharBaseBlock(1);
u16* Background1Mem = (u16 *)CharBaseBlock(2);
u16* Background0Mem = (u16 *)CharBaseBlock(3);

// the tileset intended for each layer is 128x128, or 16x16 tiles

for (i = 0; i < 128*128/2; i++){
	Background3Mem[i] = image[i];
	Background2Mem[i] = image[i+8192];
	Background1Mem[i] = image[i+16384];
	Background0Mem[i] = 0x0000; // I have my reasons.

}

// set the screen mode

SetMode(MODE_0 | BG2_ENABLE | BG3_ENABLE | BG0_ENABLE | BG1_ENABLE  | OBJ_ENABLE | OBJ_MAP_1D);
  
Just for your information, most of the constants, etc. come from Dovoto''s tutorials, but a few might be from Staring Monkey''s also. You can probably get the point, even if you haven''t seen them, though. When I run this code, the data for a number of the tiles on the bottom layer (BG3) is just blue garbage. It''s almost like some of the data in CHAR_BASE(0) is unavailable to me, or edited elsewhere. I can''t find anywhere in my code that I might be messing with the image data for the backgrounds though. Is it possible that I''m using more space than is given to me in each base block? If that''s the case, I don''t get why it only happens on the layer assigned to base 0. That, and the tiles at the end of the array don''t always get garbled... Anyone have any ideas? -Arek the Absolute
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
Advertisement
Well... Can someone just give me a quick example in Mode 0 that uses Character Base Block 0? I've been playing around with it, and even if I don't use any layers (other than the one using character base 0), base block 0 never works for me... Ick. This is depressing sometimes, no?

-Arek the Absolute

[edited by - Arek the Absolute on May 14, 2002 10:26:42 PM]
-Arek the Absolute"The full quartet is pirates, ninjas, zombies, and robots. Create a game which involves all four, and you risk being blinded by the sheer level of coolness involved." - Superpig
If this "(u16 *)CharBaseBlock(0);" does what i think it does then you are indeed overwriting the information in bg0. The reason behind this is that SCREEN_BASE(0) = 0. and CharBaseBlock(0) = 0 also. The vram on the gba is very flexible, but at the same time it makes it easy to shoot yourself in the foot.

The system I use is to initialize all layer to use character base 0. Then I set up the layers on screen base 28,29,30 and 31. This works great if you aren''t doing 4 bit layers and allows you to mix tiles across layers which also saves on vram.

Hope this helps!

This topic is closed to new replies.

Advertisement