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 with tiles

#172852 - sylvestersteele - Mon Mar 08, 2010 3:46 pm

Hi,

I got a background to display properly- but when I use tiles nothing happens.

My init code is:
Code:

     vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_D_LCD);

    videoSetMode(MODE_5_2D |
                 DISPLAY_BG3_ACTIVE);

   
    videoSetModeSub(MODE_5_2D |
                    DISPLAY_BG3_ACTIVE);


REG_BG3CNT = BG_RS_64x64 |
                 BG_TILE_BASE(1) |
                 BG_PRIORITY(0);

   
    REG_BG3PA = 1<< 8;
    REG_BG3PB = 0;
    REG_BG3PC = 0;
    REG_BG3PD = 1<< 8;

   
    REG_BG3X = 0;
    REG_BG3Y = 0;


To display I use:

Code:
  dmaCopyHalfWords(DMA_CHANNEL,
                     shuttleBitmap,
                     (uint16 *)BG_TILE_RAM(1),
                     shuttleBitmapLen);

 dmaCopyHalfWords(DMA_CHANNEL,
                     shuttlePal,
                     (uint16 *)TILE_PALETTE(1),
                     shuttlePalLen);



And my command line params to grit- which I used to convert a 64x64 png are:

-fts -W3 -gT! -gt -gB4

I looked at the following post- but I couldn't figure what I am missing.
http://forum.gbadev.org/viewtopic.php?t=16828

#172853 - elwing - Mon Mar 08, 2010 3:55 pm

mode 5 is for bitmap, not tilemap...

#172856 - sverx - Mon Mar 08, 2010 5:26 pm

you can have tilemaps too in mode 5...

btw when I encounter those errors I check with an emulator if
- I am using the correct video mode & the background is activated
- I load the tiles correctly
- I load the palette correctly
- I load the maps correctly
at least one of these should be wrong if you don't see anything.

#172862 - sylvestersteele - Mon Mar 08, 2010 6:10 pm

sverx wrote:

- I load the maps correctly


I don't think I am loading the maps at all. I just load the tiles and the palette. I copy the "Bitmap" part of the grit output into the BG_TILE_RAM(1) location. How do I go about loading maps?

When I check the palette in the emulator- I see no colors- its all black. Does that mean that my palette isn't being loaded correctly? What could be the problem here? I notice that the palette is in half words and the bitmap part is in a complete word- do I have to do something different to copy this etc?

Sylvester

#172866 - Cearn - Mon Mar 08, 2010 8:11 pm

sylvestersteele, there are several inconsistencies and errors in what you've written here.

Firstly, inconsistencies between the grit arguments, its output and the way it is used in the code. This makes it hard to see what your actual intentions are.
  • The `-gt' flag indicates the creation of tiled data, but the "-Bitmap" in the output suggests bitmapped data. So which are you looking for, tiles or bitmaps?
  • BG 3 in mode 5 is an extended affine BG, for which the options are an 8bpp affine tiled BG, and 8bpp or 16bpp bitmap BG. But in the grit options you use `-gB4', which creates 4bpp data.
  • Related to the last point, you're trying to copy the palette to a 16-color palette bank, but that's option is only available for 4bpp tilemaps.
What are you actually after here, a tilemap or a bitmap? And at which bitdepth? How to set the background control and where/how to copy data depends very much on these questions.

The only real error here is the following: TILE_PALETTE is not an address, but a macro to tell a tile which 16-color palette bank it should use. There are no macros to get the address of a 16-color palette-bank, you'll just have to get it by using BG_PALETTE.

#172892 - elwing - Wed Mar 10, 2010 9:41 am

sverx wrote:
you can have tilemaps too in mode 5...


doh... my bad... => going back to the GBA dev section....