c++ - Garbage on top of screen when displaying text over image in devkit pro -


i using 16-bit libnds (whith devkitpro) example basis , trying display text , png background image on same screen (in example top sceen). having similar issue this post.

i have garbage on top of screen (only ifconsoleinit(...) called), similar first problem in thread. problem displaying background image in different method fixes made in thread did not apply this.

all looking whether there way fix garbage on top of screen. if there more efficient/better way display image, willing accept it, haven't found detailed enough tutorial on how load image background without using method. appreciated. answer further questions has not working.

you can find project attached here.

sorry long delay there few issues code. first in mode 4 background can set 16 bit bitmap layer 3. http://answers.drunkencoders.com/what-graphics-modes-does-the-ds-support/

next, layers share single chunk of background memory , garbage coming overwriting part of bitmap in video memory characters font , map console background. simple solution move bitmap settings map base 1. offsets in graphics memory 16kb leaves 16kb of room text layer (this works because cant display entire 256x256 image on screen @ once due the resolution of ds 256x256x2bytes fills of memory bank a...to more correct should assign memory bank main background...but since cant see bottom 70 or lines of pixels of our image anyway okay didnt quite make video memory).

libnds has macro make finding memory background bit simpler called "bggetgfxptr(id)" pointer background gfx in video memory after set dont have try calculate via offset bg_gfx.

in changes code should (i added version of libnds code faq @ : http://answers.drunkencoders.com/wp-admin/post.php?post=289&action=edit&message=1)

int main(void) {       //top screen pic init     videosetmode(mode_4_2d);     vramsetbanka(vram_a_main_bg);     int bg = bginit(3, bgtype_bmp16, bgsize_b16_256x256, 1,0);     decompress(drunkenlogobitmap, bggetgfxptr(bg), lz77vram); //displays/decompresses top image      //videosetmode(mode_4_2d);     consoleinit(0,0, bgtype_text4bpp, bgsize_t_256x256, 4,0, true, true);     iprintf("\x1b[1;1hthe garbage here ^^^^^.");     iprintf("\x1b[21;1htesting text function...");      while(1) {         swiwaitforvblank();         scankeys();         if (keysdown()&key_start) break;     }     return 0; } 

Comments