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 > Fonts and using more than one rotation background

#145924 - FireSlash - Sun Nov 25, 2007 7:02 pm

Ok, here's my conundrum. I've initialized a font based on the rotscale_text example. Works great.

But I'm already using BG3 for some other graphics, so I switched it over to BG2

However, if I use either one at the same time, bad things(tm) happen.

Here's the font code:
Code:
      // Setup our 2d font
      unsigned int i;
      const int char_base = 0;
      const int screen_base = 20;

      //tex2d subFont;
      //subFont.loadTex("/data/pi/textures/BG2_font.bmp", true);

      SUB_BG2_CR = BG_TILE_BASE(char_base) | BG_MAP_BASE(screen_base) | ROTBG_SIZE_256x256;

      u16* sub_tile = (u16*)CHAR_BASE_BLOCK_SUB(char_base);
      u16* sub_map = (u16*)SCREEN_BASE_BLOCK_SUB(screen_base);

      consoleInit((u16*)fontData, sub_tile, 95, 32, sub_map, CONSOLE_USE_COLOR255, 8);
      
      for(i = 0; i < fontDataSize; ++i) {
         sub_tile[i] = fontData[i];
      }

      // extended palettes are written with bank mapped to lcd
      vramSetBankH(VRAM_H_LCD);

      // each background has it's own set of 16 256 color palettes
      for(i = 0; i < fontPaletteSize; ++i) {
         VRAM_H_EXT_PALETTE[2][0][i]= fontPalette[i];
      }

      // map bank to extended palette after writing data
      vramSetBankH(VRAM_H_SUB_BG_EXT_PALETTE);
      printf("AAA BBB CCC DDD\n ");

And here's how I'm copying data to BG3:
Code:
   memcpy(BG_GFX_SUB,tContainer->get16(),65536);
   memcpy(BG_PALETTE_SUB,tContainer->getPal(),256);

I think the problem here is BG_GFX_SUB really doesn't tell the code WHICH exrot background to put it on. Both code segments work, just not at the same time. I've seen this method of moving data to the screen used in a lot of examples, but none of them deal with using BOTH backgrounds in mode 5.
_________________
FireSlash.net

#145928 - knight0fdragon - Sun Nov 25, 2007 9:01 pm

I am not quite following you here, perhaps both BG code would be nice. Are you perhaps overwriting your BG graphics?

BG_GFX_SUB is never going to tell the code which background to put it on, that is your job

you need to tell BG2 to point to 1 part of BG_GFX_SUB, and tell BG3 to point to another part

to avoid some of the confusion, do not use BG_GFX_SUB

use BG_MAP_RAM_SUB(screen) and BG_TILE_RAM_SUB(char)
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206


Last edited by knight0fdragon on Sun Nov 25, 2007 10:23 pm; edited 1 time in total

#145929 - FireSlash - Sun Nov 25, 2007 10:11 pm

Perhaps you know of some documentation for this? I can't seem to locate any that goes past "Oh, just copy stuff here, don't ask why"
_________________
FireSlash.net

#145930 - knight0fdragon - Sun Nov 25, 2007 10:22 pm

no I do not
_________________
http://www.myspace.com/knight0fdragonds

MK DS FC: Dragon 330772 075464
AC WW FC: Anthony SamsClub 1933-3433-9458
MPFH: Dragon 0215 4231 1206

#145937 - Lick - Sun Nov 25, 2007 11:34 pm

Read this, perhaps it can help you understand the background system better.
_________________
http://licklick.wordpress.com