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 > Can't get tiled backgrounds working right. Please Help

#160820 - BigKevSexyMan - Wed Jul 23, 2008 1:06 am

First off, I'll start with what I currently have.

Code:
   
    powerON(POWER_ALL_2D);

    irqInit();
    irqEnable(IRQ_VBLANK);

    lcdMainOnBottom();

    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_MAIN_BG_0x06040000,
                     VRAM_D_LCD);

    vramSetBankE(VRAM_E_MAIN_SPRITE);

    videoSetMode(MODE_5_2D |
                 DISPLAY_BG3_ACTIVE |
                 DISPLAY_SPR_ACTIVE |
                 DISPLAY_SPR_1D
                 );

    videoSetModeSub(MODE_4_2D |
                    DISPLAY_BG3_ACTIVE);


    BG3_CR = BG_BMP8_512x256;
    BG3_XDX = 1 << 8;
    BG3_XDY = 0;
    BG3_YDX = 0;
    BG3_YDY = 1 << 8;
    BG3_CX = 0;
    BG3_CY = 0;
    BG3_X0 = 0;
    BG3_Y0 = 0;

    dmaCopyHalfWords(DMA_CHANNEL,
         scrollingbackgroundTiles,
         &BG_GFX[0],
         128000);

    dmaCopyHalfWords(DMA_CHANNEL,
         scrollingbackgroundPal,
         &BG_PALETTE[0],
         256*2);


Now, I'm using a file that I converted using grit and I'm not using any form of compression. I converted using 256 color tiled 8bpp, and I'm not using any metamap features or tile reduction.

Now, after I load all that and run the program I get a semi-jumbled mess on my screen. What am I doing wrong? Any help would be appreciated.

#160821 - eKid - Wed Jul 23, 2008 1:16 am

You're setting up a bitmap-mode BG instead of a tile-display [text] BG.

#160827 - BigKevSexyMan - Wed Jul 23, 2008 2:50 am

Are you refering to me doing something like this?

Code:

    BG3_CR = BG_BMP8_512x256 | BG_TILE_BASE(0);

    dmaCopyHalfWords(DMA_CHANNEL,
         scrollingbackgroundTiles,
         BG_TILE_RAM(0),
         128000);

    dmaCopyHalfWords(DMA_CHANNEL,
         scrollingbackgroundPal,
         &BG_PALETTE[0],
         256*2);


Because I get the same result.

#160833 - DensitY - Wed Jul 23, 2008 5:51 am

no he means the BG_BMP8_512x256

you use that if you are doing a 8bit Linear bitmap back ground

for tiled backgrounds you use one of the following

BG_32x32
BG_64x32
BG_32x64
BG_64x64

thats 64x64 tiles or 512x512 pixels.

in yoru case you'd want

BG_64x32, if you want 512x256 pixel resolution for the background.

From there you'll need to populate both Tile ram and Map ram (tile being the tile map, and Map ram being where the tile graphical data is stored).

#160895 - BigKevSexyMan - Thu Jul 24, 2008 4:14 am

That worked. Thanks. Now it's on to my next problem. :D