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 > Want to write text over an image in sub background

#144176 - koala33 - Mon Oct 29, 2007 10:53 pm

Hi all!

I'm just starting some DS programming in order to learn great stuff
on this nice machine.

My first test was :
1- draw 3D in the top screen (main)
2- draw text (printf chars) over an image (256x192x8bits with palette)
in the sub background

the first item was done, the second one generates fuzzy stuff :weirds pixels over the first part of my background image.

VRAM config is the following:
vramSetMainBanks(VRAM_A_TEXTURE,VRAM_B_TEXTURE,VRAM_C_SUB_BG, VRAM_D_TEXTURE);

I've tried several things, but none work.

Does somebody can post a sample code to do this kind of effect ?

thx.

#144177 - silent_code - Mon Oct 29, 2007 11:02 pm

well, i did it in my volume shadows demo. check my page (www button under my post). the sources are there. i guess you'll have to look into main9.cpp. it has all to do with base blocks etc. read them up in tonc (it's by cern, so look for his page).

ps: there'll be an update sometime soon. ;^D

EDIT:

WELCOME TO THE SCENE! :^D

some excerpts to ease your life a bit. (it's very likely you'll have to adjust the values.)

Code:

   vramSetBankC(VRAM_C_SUB_BG_0x06260000);
   vramSetBankE(VRAM_E_MAIN_BG);   // BEWARE: LIBNDS USES E FOR TEXTURE PALETTES BY DEFAULT

// ...

   videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE | DISPLAY_BG3_ACTIVE);
   SUB_BG0_CR = BG_256_COLOR | BG_MAP_BASE(31) | BG_TILE_BASE(4);
   SUB_BG3_CR = BG_BMP8_256x256 | BG_PRIORITY(3);

   SUB_BG3_XDX = 1 << 8; //scale x
   SUB_BG3_XDY = 0; //rotation x
   SUB_BG3_YDX = 0; //rotation y
   SUB_BG3_YDY = 1 << 8; //scale y
   SUB_BG3_CX = 0; //translation x
   SUB_BG3_CY = 128; //translation y

// after loading the palette:

// loading a custom font

   consoleInit((u16*)font_image, (u16*)CHAR_BASE_BLOCK_SUB(4), 95, 32, (u16*)SCREEN_BASE_BLOCK_SUB(31), 0, 8);

   for(u16 i = 0; i < imgSize; i++)
   {
      ((uint32*)CHAR_BASE_BLOCK_SUB(4))[i] = ((uint32*)font_image)[i];
   }


// loading the bg image

   for(u16 i = 0; i < imgSize; i++)
   {
      ((uint32*)SCREEN_BASE_BLOCK_SUB(0))[i] = ((uint32*)bg_image)[i];
   }


works for me.

#144219 - koala33 - Tue Oct 30, 2007 10:31 am

Thank you silent_code,

but i've tried your code and it does not work with my code/data.
I don't understant all block_base/char_base stuff, could you explain more
precisely ?

I think there is some mismatch values for memory map : tile againt full bitmap.

For whatever purpose it may serve, I put my code on shared space,
available from the following link:
http://www.4shared.com/dir/4386040/1fb1ad27/sharing.html


thx.

#144238 - silent_code - Tue Oct 30, 2007 4:47 pm

i'll have a look at it as soon as i set up my dev environment on the new computer (vista). can't promisse you anything, though! :^C