[solved] 512x512 backgrounds not displaying

Post Reply
awesomejuice
Posts: 3
Joined: Thu Mar 05, 2009 12:39 pm

[solved] 512x512 backgrounds not displaying

Post by awesomejuice » Thu Mar 05, 2009 12:55 pm

Hi there, I'm working with a team trying to make an NDS game, and we're stumped trying to get 512x512 backgrounds displaying. Our code is below; we have no idea what we're doing wrong or simply not doing what we should be because the documentation we've found is sparse and tutorials covering this all seem to stop immediately before making this work. Any help is appreciated.

Code: Select all

#include <nds.h>
#include <stdio.h>
#include "rah.h" // our grit-generated graphics header

int main(void)
{
   // Turn on 2d graphics core
   powerOn ( POWER_ALL_2D );
   
   // Video mode
   videoSetMode ( MODE_5_2D | DISPLAY_BG3_ACTIVE );

   // Tried these three as well as vramSetMainBanks, equally unsuccessful:
   //
   //vramSetBankA ( VRAM_A_MAIN_BG_0x06000000 );
   //vramSetBankA(VRAM_A_MAIN_BG);
   //vramSetBankB(VRAM_B_MAIN_BG);

   vramSetMainBanks(
            VRAM_A_MAIN_BG_0x06000000,
            VRAM_B_MAIN_BG_0x06020000,
            VRAM_C_MAIN_BG_0x06040000,
            VRAM_D_MAIN_BG_0x06060000);

   consoleDemoInit();

   // Taken from one of the examples
   iprintf("\n\n\tHello DS devers\n");
   iprintf("\twww.drunkencoders.com\n");
   iprintf("\t256 color bitmap demo");

   // Initialize our background and place it in memory
   int bg1 = bgInit( 3, BgType_Bmp8, BgSize_B8_512x512, 0, 0 );
   dmaCopy( rahBitmap, bgGetGfxPtr(bg1), rahBitmapLen );
   dmaCopy( rahPal, BG_PALETTE, rahPalLen );

   while(1)
   {
      swiWaitForVBlank();
   }

   return 0;
}
Last edited by awesomejuice on Sun Mar 08, 2009 4:19 am, edited 1 time in total.

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: 512x512 backgrounds not displaying

Post by Sylus101 » Fri Mar 06, 2009 5:32 pm

If you've updated to the latest libnds...

You don't need powerOn ( POWER_ALL_2D );

videoSetMode ( MODE_5_2D ); is fine, the bg will be made active inside the bgInit function.

Instead of using bgGetGfxPtr(bg1) when coping the bitmap data, try just BG_GFX. I think bgGetGfxPtr(bg1) should work, but just for sake of argument...

Everything else looked fine as far as I can tell.
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

awesomejuice
Posts: 3
Joined: Thu Mar 05, 2009 12:39 pm

Re: 512x512 backgrounds not displaying

Post by awesomejuice » Sun Mar 08, 2009 3:36 am

Nevermind. Using memcopy instead of dmacopy seems to have worked for us.

mido
Posts: 7
Joined: Tue Feb 24, 2009 8:53 am

Re: 512x512 backgrounds not displaying

Post by mido » Sun Mar 08, 2009 11:03 am

awesomejuice wrote:Nevermind. Using memcopy instead of dmacopy seems to have worked for us.
I believe that you can't DMA Copy onto the stack (which your bg1 variable is).
I could be wrong but that's my understanding. I've had issues with DMA Copy before and it had to do with moving memory to/from the stack. Has to be global I think.

Sylus101
Posts: 179
Joined: Wed Dec 24, 2008 5:08 am

Re: 512x512 backgrounds not displaying

Post by Sylus101 » Sun Mar 08, 2009 11:22 am

mido wrote:
awesomejuice wrote:Nevermind. Using memcopy instead of dmacopy seems to have worked for us.
I believe that you can't DMA Copy onto the stack (which your bg1 variable is).
I could be wrong but that's my understanding. I've had issues with DMA Copy before and it had to do with moving memory to/from the stack. Has to be global I think.
The dmaCopy wouldn't have been writing to bg1, it would have been writing to the location that bgGetGfxPtr(bg1) returns which is a pointer to a VRAM memory address. I should have worked...
-Sylus "Not Stylus..." McFrederickson

Come visit my web site.

Post Reply

Who is online

Users browsing this forum: Google [Bot] and 5 guests