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 > Help With backgrounds

#138413 - ubercatch22 - Thu Aug 23, 2007 9:30 pm

I cant seem to get my backgrounds to work with the devkitpro example 256bmp background

when i compile my code i get only 3 errors:

error: test01.h : no such file or directory
error: test01_Bin : was not declared in the scope
error: test01_pal : was not declared in the scope

what am i doing wrong?

Code:

#include <nds.h>

#include <stdio.h>

// git adds a nice header we can include to access the data
// this has the same name as the image
#include "test01.h"

int main(void)
{
   // irqs are nice
   irqInit();
   irqSet(IRQ_VBLANK, 0);

    // set the mode for 2 text layers and two extended background layers
   videoSetMode(MODE_5_2D | DISPLAY_BG3_ACTIVE);

   // set the sub background up for text display (we could just print to one
   // of the main display text backgrounds just as easily
   videoSetModeSub(MODE_0_2D | DISPLAY_BG0_ACTIVE); //sub bg 0 will be used to print text

    // set the first bank as background memory and the third as sub background memory
    // B and D are not used
    vramSetMainBanks(VRAM_A_MAIN_BG_0x06000000, VRAM_B_LCD,
                     VRAM_C_SUB_BG , VRAM_D_LCD);

   // set up background for text
    SUB_BG0_CR = BG_MAP_BASE(31);

   BG_PALETTE_SUB[255] = RGB15(31,31,31);//by default font will be rendered with color 255

   // consoleInit() is a lot more flexible but this gets you up and running quick
   consoleInitDefault((u16*)SCREEN_BASE_BLOCK_SUB(31), (u16*)CHAR_BASE_BLOCK_SUB(0), 16);

   iprintf("TEST SUCCESS");

   // set up our bitmap background
   BG3_CR = BG_BMP8_256x256;

   // these are rotation backgrounds so you must set the rotation attributes:
    // these are fixed point numbers with the low 8 bits the fractional part
    // this basicaly gives it a 1:1 translation in x and y so you get a nice flat bitmap
        BG3_XDX = 1 << 8;
        BG3_XDY = 0;
        BG3_YDX = 0;
        BG3_YDY = 1 << 8;
    // our bitmap looks a bit better if we center it so scroll down (256 - 192) / 2
        BG3_CX = 0;
        BG3_CY = 32 << 8;

   dmaCopy(test01_Bin, BG_GFX, 256*256);
   dmaCopy(test01_Pal, BG_PALETTE, 256*2);


    while(1)swiWaitForVBlank();

   return 0;
}

#138420 - ThousandKnives - Thu Aug 23, 2007 11:25 pm

GIT would name the header after the image source file name, so unless your image name was test01.* you won't get a test01.h.

Also since this is a background you need to have the .git file of the same name so GIT doesn't attempt to tile the data.

Check the readout more carefully and see if you see any messages earlier in the make process with regard to GIT (you made need to do a "clean" first). Also check the contents of the "build" subfolder, this is where the header file is stored after GIT runs.

Otherwise it could be a makefile issue but if you are using the code from the example and haven't mod'd the makefile that shouldn't be an issue.

#138427 - ubercatch22 - Fri Aug 24, 2007 1:46 am

Thanks for the help but i found out what was worng and it is fixed thanks

but you know how to add spites into the code i supplied?

#138464 - PypeBros - Fri Aug 24, 2007 11:39 am

ubercatch22 wrote:
Thanks for the help but i found out what was worng and it is fixed thanks

but you know how to add spites into the code i supplied?


basically, by activating sprites on videoSetMode (at least DISPLAY_SPR_1D is required), dedicating some VRAM to sprite storage through MAIN_SPRITE in vramSetMainBanks, define attributes in the OAM memory and fill pixels in sprite VRAM.

I suggest you get a look at examples/Graphics/2D/Sprite_Bitmap/source/main.cpp ...
_________________
SEDS: Sprite Edition on DS :: modplayer