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.

Beginners > DS: Mapping output to the same screen?

#149914 - Tor - Sun Jan 27, 2008 7:30 am

Is there any way that i can map the console output and a bitmap background to map to the same screen so that i can use printf() while manipulating the pixels also? I tried just writing to the VRAM_* but instead it just over wrote the text i outputted with stripes.

#149924 - silent_code - Sun Jan 27, 2008 2:16 pm

if you mean you want to have a background image layer and a console text layer all on one screen, it is possible. look at my page, there's my shadow volume demo, that demonstrates that. (as well as other things... ;^D )

ps: the demo is only compatible with slot2 devices (gba port), but no$ runs it just fine (well, good enough).

#149933 - nipil - Sun Jan 27, 2008 5:01 pm

Just to give some pointers on how it could work:
- the console output is usually on BG0
- your background picture could be on any other BG (let's say BG3)
- set BG0 as higher prio (2) than BG3 (3) : prio rank is inverse the prio value
- enable both BG when you enable your display

#149963 - Tor - Mon Jan 28, 2008 5:15 am

I've set the priority correctly and enabled both backgrounds, but i only get the text showing on the screen and i cant seem to change pixels in the BG3 and have it display.

Could someone possibly post a short example of how to do this? Ut would be very much appreciated (especially how to set up all of the SUB_BG*_CR and consoleInitDefault() which is what seems to be the issue if all of the other threads on this topic are correct).

silent_code: your demo uses a custom font, which seems to change some things because i copied your code into my program and it didnt work.

#149971 - nipil - Mon Jan 28, 2008 9:28 am

Have you tried switching the prios so your BG3 shows above BG0 (console) ? Another thing is that if you're using 8-bit backgrounds, the pallets are shared among the backgrounds (afaik), so as the console initialization only sets color for entry 255, maybe your BG3 graphics draw using an uninitialized color (ie one that's defaulted to black). Or if you load a bitmap background, did you load the palette ? And remember you can't draw on BG3 using 8-bit read/write accesses (as it sits in VRAM, you must read/write 16- or 32-bit values).

Anyway, as silent_code said, his demo shows how to do it. I remember it works in no$gba, so you can even modify his source and test it to better understand how it works. As he provides source code, well, logically there's everything needed in there =)

#149979 - eKid - Mon Jan 28, 2008 11:16 am

Here's my example :)

http://ekid.nintendev.com/bitmap_console.zip
I hope it helps.

#150073 - silent_code - Tue Jan 29, 2008 4:53 pm

oh, yes, my demo uses a custom font, but you can allways use the build in font of libnds, too! iirc there's also some helping code in the libnds examples.
it's really all about setting up the registers correctly. get libnds' sources and check out the console initialization functions, that should give you a hint where to start, if my code doesn't work for you.

happy coding! :?)