Homebrew Garbage on top of screen when displaying text over background

Wolfgange

Well-Known Member
Member
Joined
Feb 9, 2012
Messages
231
Trophies
0
XP
237
Country
United States
I asked this same question on the devkit pro forums, but the posts dont seem to be going through.

Another newb question..

I am currently using the 16-bit libnds example as a basis and am trying to display text and the png background image on the same screen (in this example it is the top sceen). I am having a similar issue as this post:
http://devkitpro.org/viewtopic.php?f=6&t=3222&hilit=background and text

I have garbage on the top of the screen (only if consoleInit(...) is called), similar to the first problem in the thread. The only problem is that I am displaying the background image in a different method so the fixes they made in that thread did not apply to this.

All I am looking for is whether there is a way to fix the garbage on the top of the screen. If there is a more efficient/better way to do display the image, I am willing to accept it, just I haven't found a detailed enough tutorial on how to load an image as a background without using this method. Thank you in advanced for any help whatsoever.

(The project is attached)
 

Attachments

  • Garbage_Error.zip
    315.7 KB · Views: 165

KazoWAR

Well-Known Member
Member
Joined
Aug 12, 2008
Messages
1,949
Trophies
0
Age
33
Location
Winter Haven
XP
1,957
Country
United States
i tried looking at it but i am not sure how to fix it. i know the problem, when you init the console the graphic data for the characters is overwriting the top of the image, since its a 4bpp data and not 16bpp it looks like random garbage in 16bpp mode. the solution is the same as in the tread, the are using the same memory and you need to move one of them elsewhere, but i dont know how to do that with a 16bit image.
 
  • Like
Reactions: Wolfgange

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
28,152
Trophies
0
Location
Gaming Grotto
XP
25,570
Country
Poland
You really don't want to display .PNG's on the DS - you're far better off using native raster images or tiled backgrounds. The project you attached doesn't actually display a .PNG file, the image goes through GRIT conversion.

My suggestion is to download a copy of WINGRIT, converting your backgrounds and attaching them to your project that way rather than relying on convoluted makefiles. Yeah, I know it automates things, but "my way" lets you choose the more intricate options when it comes to converting.

As for the jumbled text, I'm guessing that the area of VRAM you were trying to use was already occupied, you were trying to output tiled text to a layer which does not support it in the selected MODE or the font you were trying to use was improperly sized.

Can't tell for sure as I haven't looked into the source yet, I'm kinda in a hurry right now. :P

EDIT: Yep, it's a memory overlap. Gimme a sec, I'll try to find a tilebase/mapbase calculator I used to use.

EDIT2: Got it, perfect!
http://mtheall.com/vram.html

Use this tool to properly allocate your memory in VRAM.

You can also check out my DS programming tutorial here:
http://gbatemp.net/threads/ds-programming-for-newbies.322106/

It's not strictly for libnds, but it will teach you the bare basics as well as introduce you to NightFox Lib which will deal with such issues for you automatically.
 
  • Like
Reactions: Wolfgange

Wolfgange

Well-Known Member
Member
Joined
Feb 9, 2012
Messages
231
Trophies
0
XP
237
Country
United States
You really don't want to display .PNG's on the DS - you're far better off using native raster images or tiled backgrounds. The project you attached doesn't actually display a .PNG file, the image goes through GRIT conversion.

My suggestion is to download a copy of WINGRIT, converting your backgrounds and attaching them to your project that way rather than relying on convoluted makefiles. Yeah, I know it automates things, but "my way" lets you choose the more intricate options when it comes to converting.

As for the jumbled text, I'm guessing that the area of VRAM you were trying to use was already occupied or the font you were trying to use was improperly sized.
Thank you very much for the response, and wingrit seems like a plausible alternative. The only thing is I still don't understand how to load in the tiled background (as in, is there any tutorial that would help me at all?).

EDIT: THANKS SO MUCH!!!!!!!
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
28,152
Trophies
0
Location
Gaming Grotto
XP
25,570
Country
Poland
Thank you very much for the response, and wingrit seems like a plausible alternative. The only thing is I still don't understand how to load in the tiled background (as in, is there any tutorial that would help me at all?).

Loading Tiled Backgrounds is very easy.

Code:
    videoSetMode(MODE_0_2D);  //Set Video Mode
    vramSetBankA(VRAM_A_MAIN_BG);  //Assign VRAM Bank
 
    int bg = bgInit(0, BgType_Text8bpp, BgSize_T_256x256, 0,1); //Init a Background
 
    dmaCopy(TextBackgroundsTiles, bgGetGfxPtr(bg), sizeof(TextBackgroundsTiles));  //dmaCopy Tiles data
    dmaCopy(Layer256x256Map, bgGetMapPtr(bg),  Layer256x256MapLen);  //dmaCopy the Map
    dmaCopy(TextBackgroundsPal, BG_PALETTE, sizeof(TextBackgroundsPal));  //dmaCopy the Palette
 
    scroll(bg, 256, 256); //Scroll the background to the desired position

This is really all there is to it - GRIT does the rest for you.

This example code (minus my comments) can be found in your devkitPro folder under Examples/Graphics/Backgrounds/All_in_One which show all of the Tiled Background types you can use.
 
  • Like
Reactions: Wolfgange

Site & Scene News

General chit-chat
Help Users
  • ILeo @ ILeo:
    ok doin it now
  • ILeo @ ILeo:
    i might just mod it? my pc had only 1 fan with 80 temp now i added 4 fans and has 30 temp to 40 while on load
  • ILeo @ ILeo:
    might put it in a pc case?
  • ILeo @ ILeo:
    sounds good?
  • IanSkinner1982 @ IanSkinner1982:
    What is the recommended banner resolution for groups?
  • Flame @ Flame:
    i dont think they is one just get the biggest banner you find for your 70's computer group
  • IanSkinner1982 @ IanSkinner1982:
    70's and 80's! (maybe 90's too, I forgot when CBM went bankrupt)
    And alright.
  • DinohScene @ DinohScene:
    putting a 360 in a pc case is a big project... I'd just leave it at upping the fan
  • RedoLane @ RedoLane:
    so much for making a decent group.
  • IanSkinner1982 @ IanSkinner1982:
    What do you mean?
  • RedoLane @ RedoLane:
    I wasted my time coming up with a cool group idea, only to end up being the only member.
  • IanSkinner1982 @ IanSkinner1982:
    What was it?
  • RedoLane @ RedoLane:
    The Post-Apocalypse Survivors Association
  • IanSkinner1982 @ IanSkinner1982:
    gtg, been nice talking for this whole minute.
  • RedoLane @ RedoLane:
    welp
  • D34DL1N3R tempBOT:
    D34DL1N3R has left the room.
  • CPG @ CPG:
    oh hi tempbot
  • tsao @ tsao:
    hi @CPG
  • RAHelllord tempBOT:
    RAHelllord has left the room.
  • lemonmaster @ lemonmaster:
    wow wow
  • VashTS @ VashTS:
    oh hai chat
  • RedoLane @ RedoLane:
    oh hai mark
  • Hleb tempBOT:
    Hleb has left the room.
    Hleb tempBOT: Hleb has left the room.