How to Render Bitmaps

support for the ARM toolchain
Post Reply
vralfy
Posts: 4
Joined: Tue Dec 15, 2009 2:10 pm

How to Render Bitmaps

Post by vralfy » Tue Dec 15, 2009 2:30 pm

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?

WinterMute
Site Admin
Posts: 1986
Joined: Tue Aug 09, 2005 3:21 am
Location: UK
Contact:

Re: How to Render Bitmaps

Post by WinterMute » Fri Dec 18, 2009 10:19 pm

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.
Help keep devkitPro toolchains free, Donate today

Personal Blog

vralfy
Posts: 4
Joined: Tue Dec 15, 2009 2:10 pm

Re: How to Render Bitmaps

Post by vralfy » Tue Jan 05, 2010 12:21 pm

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?

StevenH
Posts: 133
Joined: Sun Feb 22, 2009 7:59 pm

Re: How to Render Bitmaps

Post by StevenH » Tue Jan 05, 2010 3:12 pm

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).

vralfy
Posts: 4
Joined: Tue Dec 15, 2009 2:10 pm

Re: How to Render Bitmaps

Post by vralfy » Wed Jan 06, 2010 11:37 am

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?

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest