Page 1 of 1

How to Render Bitmaps

Posted: Tue Dec 15, 2009 2:30 pm
by vralfy
Hi,

i'm trying to render bitmaps in my NDS-Homebrew app. The problem, the don't look like they should.

I'm using grit with the following options:

Code: Select all

-W3
-p
-gb
-gB8
My init function looks like this:

Code: Select all

vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000,
                     VRAM_B_MAIN_BG_0x06020000,
                     VRAM_C_SUB_BG_0x06200000,
                     VRAM_D_LCD);
    
    vramSetBankE(VRAM_E_MAIN_SPRITE);
    vramSetBankD(VRAM_D_SUB_SPRITE);

    //MAINSCREEN
    videoSetMode ( MODE_5_2D | DISPLAY_BG2_ACTIVE | DISPLAY_BG3_ACTIVE 
            | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D 
            );
    //SUBSCREEN
    videoSetModeSub( MODE_5_2D | DISPLAY_BG3_ACTIVE 
            | DISPLAY_SPR_ACTIVE | DISPLAY_SPR_1D 
            );
My initSpriteFunction looks like this:

Code: Select all

SpriteInfo *coverInfo = &this->spriteInfo[i];
        SpriteEntry *coverEntry = &this->oam->oamBuffer[i];
        coverInfo->oamId = i;
        coverInfo->width  = 32;
        coverInfo->height = 32;
        coverInfo->angle  = 0;
        coverInfo->entry  = coverEntry;

        coverEntry->y = 10+(i-OAMID_THUMB0)*33;
        coverEntry->x = 10;
        coverEntry->isRotateScale = false;
        coverEntry->isSizeDouble = false;
        coverEntry->blendMode = OBJMODE_NORMAL; //on OBJMODE_BITMAP, the sprite disapears
        coverEntry->isMosaic = false;
        coverEntry->colorMode = OBJCOLOR_256;
        coverEntry->shape = OBJSHAPE_SQUARE;
        coverEntry->rotationIndex = coverInfo->oamId;
        coverEntry->size = OBJSIZE_32;
        coverEntry->priority = OBJPRIORITY_0;
        coverEntry->palette = coverInfo->oamId;
        coverEntry->gfxIndex = nextAvailableTileIdx;

        nextAvailableTileIdx += thumb0000BitmapLen / BYTES_PER_16_COLOR_TILE;
my copy over funtion:

Code: Select all

 //Copy over the sprites palettes
        dmaCopyHalfWords(SPRITE_DMA_CHANNEL, 
            data->Pal, 
            &SPRITE_PALETTE[info->oamId * COLORS_PER_PALETTE], 
            data->PalLen);

        //Copy the sprite graphics to sprite graphics memory
        dmaCopyHalfWords(SPRITE_DMA_CHANNEL, 
            data->Tiles, 
            &SPRITE_GFX[entry->gfxIndex * OFFSET_MULTIPIER], 
            data->TilesLen);
    }
and finaly my update function

Code: Select all

DC_FlushAll();
dmaCopyHalfWords(SPRITE_DMA_CHANNEL, this->oam_sub->oamBuffer, OAM_SUB, SPRITE_COUNT * sizeof(SpriteEntry));
so what am i doing wrong?

Re: How to Render Bitmaps

Posted: Fri Dec 18, 2009 10:19 pm
by WinterMute
It might help if you told us what you expect the bitmaps to look like and what their actual appearance is. Screenshots are probably the best way to explain it.

Re: How to Render Bitmaps

Posted: Tue Jan 05, 2010 12:21 pm
by vralfy
i fixed the problem by replacing the -gB8 with -gB4 in the grit file, now everything looks perfect.

What i'm trying to code is a list of NDS-Games (with thumbs and cover). My problem now that my ewram is overflowed like this.

Code: Select all

linking DSListe.elf
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: /home/nspecht/proggen/DSListe/DSListe.elf section `.rodata' will not fit in region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: address 0x24e4a78 of /home/nspecht/proggen/DSListe/DSListe.elf section `.ewram' is not within region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: address 0x24e572c of /home/nspecht/proggen/DSListe/DSListe.elf section `.data' is not within region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: address 0x24e4848 of /home/nspecht/proggen/DSListe/DSListe.elf section `.ewram' is not within region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: address 0x24e54fc of /home/nspecht/proggen/DSListe/DSListe.elf section `.data' is not within region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: address 0x24e4848 of /home/nspecht/proggen/DSListe/DSListe.elf section `.ewram' is not within region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: address 0x24e54fc of /home/nspecht/proggen/DSListe/DSListe.elf section `.data' is not within region `ewram'
/home/nspecht/proggen/devkit/ARM/bin/../lib/gcc/arm-eabi/4.4.2/../../../../arm-eabi/bin/ld: region `ewram' overflowed by 943356 bytes
collect2: ld returned 1 exit status

I know its the amount of images which makes it overflow, but is there a way to fix that?

Re: How to Render Bitmaps

Posted: Tue Jan 05, 2010 3:12 pm
by StevenH
How about loading the images from the SD card at run time? I've got a feeling that your trying to do something like DSKiosk, if that's the case I'd really sugest that you use external data files for the games (each game in it's own folder) with a file containing the icon and the other images in it for that game. This way you are only loading the images needed and only when you need them as storing every image for the games inside your nds application would kill the 4 MB limit of the DS very fast (depending on how the images are stored).

Re: How to Render Bitmaps

Posted: Wed Jan 06, 2010 11:37 am
by vralfy
Ok, thanks for the reply. I will try that soon.

But now i have an other problem. I have a M3i Zero. But everytime i try to run my app, the message "DLDI compatible" appears, and after that i can only see my background (no sprites, no console). I have tested that with 20Games in my app. The app's size is about 450KB.

The Problem also appears on a Desmume 0.9.4 but not on a Desmume 0.7.3.

Did i miss something?