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 > Tiled sub BG not showing up

#119149 - outphase - Tue Feb 20, 2007 4:02 am

I'm trying to get a tiled bg to show up, but only static and other garbage appears. The image was generated using "git haruhi_logo.gif -ftb -m" Any thoughts as to why it won't show up? maybe a missed declaration or so. If more code is needed let me know as I thought this would be the vital block.

Code:
   videoSetModeSub(MODE_5_2D | DISPLAY_BG3_ACTIVE);
   vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_SUB_BG, VRAM_D_LCD);
   vramSetBankE(VRAM_E_MAIN_SPRITE);
   lcdMainOnBottom();

   SUB_BG3_CR = BG_BMP8_256x256 | BG_MAP_BASE(0) | BG_TILE_BASE(1);
   SUB_BG3_XDX = BIT(8);         // scale x
   SUB_BG3_XDY = 0;            // rotation x
   SUB_BG3_YDX = 0;            // rotation y
   SUB_BG3_YDY = BIT(8);         // scale y
   SUB_BG3_CX = 0;               // translation x
   SUB_BG3_CY = 0;               // translation y
   
   memcpy((uint16 *)BG_PALETTE_SUB,haruhi_logo_pal_bin,haruhi_logo_pal_bin_size);

   memcpy((void *)BG_MAP_RAM_SUB(0),haruhi_logo_map_bin,haruhi_logo_map_bin_size);
   memcpy((void *)BG_TILE_RAM_SUB(1),haruhi_logo_img_bin, haruhi_logo_img_bin_size);

#119571 - VRMLGHOST - Sat Feb 24, 2007 11:32 am

your enabling background 3 which in mode 5 (http://liranuna.drunkencoders.com/nds-2d-tuts/lesson-1/) is extended rotation background (like a big bitmap) not a text tile based background. change to using bg0 or bg 1 and you should be fine.

NOTE: you cant use the following on a text/tile background

SUB_BG3_XDX = BIT(8); // scale x
SUB_BG3_XDY = 0; // rotation x
SUB_BG3_YDX = 0; // rotation y
SUB_BG3_YDY = BIT(8); // scale y
SUB_BG3_CX = 0; // translation x
SUB_BG3_CY = 0; // translation y

JUST USE:

BG0_X0 = 0;//offset (or translation) of left of background relative to screen
BG0_Y0 = 0;//offset (or translation) of top of background relative to screen


try somethign like

Code:

videoSetModeSub(MODE_5_2D | DISPLAY_BG0_ACTIVE);
   vramSetMainBanks(VRAM_A_MAIN_BG, VRAM_B_MAIN_BG, VRAM_C_SUB_BG, VRAM_D_LCD);
   vramSetBankE(VRAM_E_MAIN_SPRITE);
   lcdMainOnBottom();

   SUB_BG0_CR = BG_BMP8_256x256 | BG_MAP_BASE(0) | BG_TILE_BASE(1);
   SUB_BG0_X0 = 0;
   SUB_BG0_Y0 = 0;
   memcpy((uint16 *)BG_PALETTE_SUB,haruhi_logo_pal_bin,haruhi_logo_pal_bin_size);

   memcpy((void *)BG_MAP_RAM_SUB(0),haruhi_logo_map_bin,haruhi_logo_map_bin_size);
   memcpy((void *)BG_TILE_RAM_SUB(1),haruhi_logo_img_bin, haruhi_logo_img_bin_size);