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 > Trouble displaying background image on sub screen

#124431 - Stuk - Thu Apr 05, 2007 11:22 pm

Hi,
I can get a nice background image displayed on the main screen, however no matter what I do I cannot get anything to be displayed on the sub screen.

I have been following the Patatersoft tutorial, however I could not get the example code to work with my images, and so I'm using the techniques demonstrated in liranuna's.

This is the code I am using:
Code:

void initVideo() {

    // Setting up video mode
   videoSetMode(MODE_0_2D | DISPLAY_BG0_ACTIVE);
    videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE);

   vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_SUB_BG, VRAM_D_LCD);

    BG0_CR     = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(0) | BG_TILE_BASE(1);
    SUB_BG0_CR = BG_32x32 | BG_COLOR_256 | BG_MAP_BASE(2) | BG_TILE_BASE(3);

   //put main on the bottom
   lcdMainOnBottom();

}

void displayBottom() {
   // Copying the tiles to tile base 1
   memcpy((void*)BG_TILE_RAM(1), bottombg_img_bin, bottombg_img_bin_size);
   // Copying the map to map base 0
   memcpy((void*)BG_MAP_RAM(0), bottombg_map_bin, bottombg_map_bin_size);
   // Copying the palette to the palette area
   memcpy((void*)BG_PALETTE, bottombg_pal_bin, bottombg_pal_bin_size);
}


void displayTop() {

   // Copying the tiles to tile base 1
   memcpy((void*)BG_TILE_RAM(3), topbg_img_bin, topbg_img_bin_size);
   // Copying the map to map base 0
   memcpy((void*)BG_MAP_RAM(2), topbg_map_bin, topbg_map_bin_size);
   // Copying the palette to the palette area
   memcpy((void*)BG_PALETTE_SUB, topbg_pal_bin, topbg_pal_bin_size);
}

int main () {
      //turn on the 2D core
      powerON(POWER_ALL_2D);
      irqInit();
      irqSet(IRQ_VBLANK, 0);

      initVideo();
      displayBottom();
      displayTop();

      while(1){};

      return 0;
}

In BG_MAP_BASE(#) and BG_MAP_RAM(#) (and equivalent TILE functions) # can be changed to almost any number (<31 and >1) without making any difference.

Both of the images (in .bin files) are ok, as I can display them both by swapping around the topbg_/bottombg_ bits. The sub palette also works fine, as I can see the colour of the first pixel in the image across the whole sub screen.

I've tried looking around for an answer, and searching the forums, but had no luck :(

Any help would be really appreciated,
Stuk

(I hope I've posted this in the right place, rather than the Beginners forum.)

#124435 - Lick - Thu Apr 05, 2007 11:45 pm

For the subscreen, use BG_TILE_RAM_SUB(#), BG_MAP_RAM_SUB(#) and BG_BMP_RAM_SUB(#).

Note that there is no ..._SUB when setting the BASE in the BG_CR.
_________________
http://licklick.wordpress.com

#124495 - Stuk - Fri Apr 06, 2007 9:32 am

Ahh brilliant, thank you very much. Now I can start on some proper coding :)