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 > EFS black screen loading background [fixed]

#166530 - Emmanuel - Mon Feb 09, 2009 1:06 pm

I added this to the EFS example:

Code:
      FILE* gfx;
      gfx = fopen("title_back.img.bin", "rb");
      size = ftell(gfx);
      i = 0;
        while(i < size) {
            fread(&buffer[i], 1, 1, gfx);
            i++;
        }
      int bg3 = bgInit(3, BgType_Bmp8, BgSize_B8_256x256, 0,0);
      static const int DMA_CHANNEL = 3;
      dmaCopyHalfWords(DMA_CHANNEL,
                     buffer, /* This variable is generated for us by
                                       * grit. */
                     (uint8 *)BG_BMP_RAM(0), /* Our address for main
                                               /* background 3 */
                     size); /* This length (in bytes) is generated
                                           /* from grit. */


The idea is to load title_back.img.bin from EFS. I know this is messy, but this is my first attempt to load a resource from a FAT or something similar... what's wrong? I get a black screen without even the text when I have the dmaCopy uncommented...

I added it before the text that tells to press A


Last edited by Emmanuel on Tue Feb 10, 2009 3:12 pm; edited 1 time in total

#166531 - Odorules - Mon Feb 09, 2009 1:21 pm

If you use EFS with the lastest version of libnds it won't work.
We've made a fix for this problem : http://www.dev-fr.org/index.php/topic,4067.0.html
Or use NitroFS.

#166533 - Emmanuel - Mon Feb 09, 2009 1:39 pm

WOW.... I still can't believe it wasn't my code.... all that I wrote it almost from scratch... but now I see it works...

ONE IMPORTANT QUESTION: I'm getting the first pixels on the upper left side black! Only those, the rest looks ok... in the emu they look fine, but not on hardware, how do I fix it?

Well, I just reset my ds and it's not happening anymore...

One more question: That background is a BMP converted into .bin by grit, but it seems to take some time to load... I see the screen black, then the lower half, and then complete... this "lag" is due to FAT loading speed?
And with this code, I'm loading from FAT, right? not from RAM?
I really need to start this project good from it's very foundations... it's actually pretty big

#166549 - Odorules - Mon Feb 09, 2009 5:31 pm

I'm not sure of what I say but it seems dmaCopy is asynchronous. So the background is drawn while you are filling it.
You may use memcpy instead of dmaCopy.

#166551 - Emmanuel - Mon Feb 09, 2009 5:38 pm

Odorules wrote:
I'm not sure of what I say but it seems dmaCopy is asynchronous. So the background is drawn while you are filling it.
You may use memcpy instead of dmaCopy.


I searched for memcpy in http://libnds.devkitpro.org/ but didn't found it... so:
How does memcpy work? Will I need more intermediate steps? which arguments those it takes?

And about those black pixels at top left: They are only drawn when I turn the "R" button red in my R4... a weird button in the menu, which I don't know what's for.... but when it's green, the pixels are black...
Apart from always turning it red: How could this be fixed?

#166552 - Odorules - Mon Feb 09, 2009 5:49 pm

The "R" buttom activate the reset function of the linker. It allow you to reset the NDS by pressing a some buttons.

memcpy is well known :)
Here is its reference : http://www.cplusplus.com/reference/clibrary/cstring/memcpy.html

#166583 - Emmanuel - Tue Feb 10, 2009 3:11 pm

Now, using memcpy, that error disappeared...

thanks