Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

#1 2015-08-27 03:31:57

MattC
New member
Registered: 2015-08-27
Posts: 2

Clear screen and write some text after displaying a backgnd image

Hello,

[Background/cute/useless story]

For the 40th birthday of my sister, i get an old gameboy, and bought an everdrive cardridge, and i filled it up with the good old games we played together when we where young. And i got an idea : Why don't I program some special rom for her birthday ? I am a developper, so, yesterday evening, i searched and tried to create my own rom.

[End of useless story ;-)]

So I have a made a rom which, for now :
- Display some text, wait for button to be pressed, and display again ...
- Display some full screen images (created with GB Tile Data Generator)

My question is : How to display some text after having displayed a full screen image ?
When I do that, the picture is scrolling up (like it was some text), and the text characters are replaced by some unknown char.
Maybe I need to do some clear/refresh screen before writing some text ?

Thank a lot in advance for the help, I need to finish that for tomorow evening, and i will try to go the further I can ! wink

Code :


How I display Image :
-------------------------

Code:

void displayImg()
{
    set_bkg_data(0,255,clem_tile_data);
    // Switch to VRAM
     VBK_REG = 1;
     // Switch out of VRAM
     VBK_REG = 0;
     // Set screen x,y pos to 0,0 and draw the map 20,18 (size of the screen)
     set_bkg_tiles(0,0,20,18,clem_map_data);
     // Show the background
     SHOW_BKG;
     // Turn the display on
     DISPLAY_ON; 
}

How I display text :
----------------------

Code:

printf("Some text\n\n");

Last edited by MattC (2015-08-27 03:35:32)

Offline

 

#2 2015-08-27 05:55:46

a cat
Member
Registered: 2014-07-27
Posts: 98

Re: Clear screen and write some text after displaying a backgnd image

if i remember right you must turn the display off and hide the background before printing text again
so everything you did to set the display up but reverse

*been a while since i did gbdk


a cat in need of knowledge!!

Offline

 

#3 2015-08-27 16:18:23

ek82
Member
Registered: 2015-08-12
Posts: 10

Re: Clear screen and write some text after displaying a backgnd image

I had a tile for each letter/digit in my app. I updated tile data based on the numbers/letters that should be displayed. This is one solution. So your text is really part of your background tile data. If the text is going to be static, then that will be a lot easier to do.

Offline

 

#4 2015-08-27 20:21:02

l0k1
Member
Registered: 2014-10-23
Posts: 44

Re: Clear screen and write some text after displaying a backgnd image

Disclaimer: I do assembly coding, not C/GBDK.
It sounds like printf() is using leftover tile data from the images, rather than using letters. I'm not sure how printf() works in GBDK exactly, but try clearing out the vram before using printf(). Failing that, you could always create a letter tileset, and create the text like you did with the images (use GBMB with the letters to create the screens/map data).
It'd be possible to be a lot more specific if you uploaded the ROM so we could see it, but do to the personal data on the ROM I wouldn't fault you for not doing that. =]

Offline

 

#5 2015-08-28 03:21:35

MattC
New member
Registered: 2015-08-27
Posts: 2

Re: Clear screen and write some text after displaying a backgnd image

Thanks everyone.

I wasn't able to clear completly the left over tile data from the image.
I tried things like (But with no real luck) :

Code:

     HIDE_BKG;
     DISPLAY_OFF; 
     VBK_REG = 0;
     set_bkg_data(0,255,NULL);
     set_bkg_tiles(0,0,20,18,NULL);

etc

in any possible order.

But I was approaching with these two :

Code:

     set_bkg_data(0,255,NULL);
     set_bkg_tiles(0,0,20,18,NULL);

The text was ok, but the backgnd was some wierd almost completly black artifacts.

So, because I have to finish that today, I created a 1x1 White background, and so, I apply it before to print text on the screen. (i know this is shit but i'm not proud wink

Oh and you need to init font again to be able to print correctly

Code:

font_init();

Last edited by MattC (2015-08-28 03:22:10)

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson