Page 1 of 1

displaying raw image

Posted: Mon Jun 22, 2009 7:39 am
by Tomdev
hey everyone,

it try to display a raw image, but every time i get a black screen. but when i use dsorganize it displays perfect. can anyone tell me how to display a raw image. i'm doing it like this now:
Code:

Code: Select all

#include <nds.h>
#include <fat.h>
#include <stdio.h>

int main(void) {
//---------------------------------------------------------------------------------
 
videoSetMode(MODE_5_2D);

vramSetBankA(VRAM_A_MAIN_BG_0x06000000);

int bg = bgInit(3, BgType_Bmp16, BgSize_B16_256x256, 0,0);

u16* backBuffer  = (u16*)0x06000000;
fatInitDefault();
FILE * pfile;
pfile = fopen("decoded.raw", "rb");
fread(backBuffer, 1, 256*192*2, pfile);
fclose(pfile);

bgUpdate();

   while(1) {
      swiWaitForVBlank();
   }

}

Re: displaying raw image

Posted: Mon Jun 22, 2009 9:26 am
by RyouArashi
I looked up Bmp BGs in the examples, it is the same code there.

Possible Problems might be:
- File Access (Check the return values of fatInitDefault, fopen, fread, etc.)
- fread may be writing the data to the destination bytewise, however VRAM can only be
accessed by 16bit or 32bit reads or writes. 8bit access is ignored on ARM9 side.

Try to fread your image to a buffer in Main RAM and then copy it to VRAM with dmaCopy.

Re: displaying raw image

Posted: Mon Jun 22, 2009 12:31 pm
by Tomdev
actually this was not the problem, it was somewhere else in the code. but thanks anyway :P