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 2020-12-18 11:19:15

rune-dev-matt
Member
From: Germany
Registered: 2020-11-30
Posts: 12

Good practices for displaying Text - GBDK

Hello everyone,

I'm try to get my head into GB-Dev with C (+GBDK) and try some own little projects.
On of them should be very text-heavy and I was wondering if there is some best practice for this?

Maybe you could share some expericene with me?

I looked into Zelda: Links Awaking for reference and found something interessing in the VRAM:

https://i.postimg.cc/gjPzhzLT/ezgif-7-1c607003e3d0.gif

It looks to me that always only the nesserary text is loaded into sprites and then displayed.
Is this also possible with GBDK? Or is this one of the many many ASM Hacks they build into this game?

Sorry for the many question and thank you for the time sharing your knowledge,

Matt

Offline

 

#2 2020-12-18 12:49:07

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: Good practices for displaying Text - GBDK

set_bkg_data() + set_bkg_tiles()

Offline

 

#3 2020-12-18 15:56:42

rune-dev-matt
Member
From: Germany
Registered: 2020-11-30
Posts: 12

Re: Good practices for displaying Text - GBDK

I guess this more of a Sprite on top of the BKG layer.
But I think I get it. Simple switching the tiles.

I'll come back when I have more Code to show...

Last edited by rune-dev-matt (2020-12-18 15:57:13)

Offline

 

#4 2020-12-19 04:29:49

toxa
Member
Registered: 2020-02-13
Posts: 309

Re: Good practices for displaying Text - GBDK

That text is likely to be drawn either on window or directly on the background.

Offline

 

#5 2020-12-20 10:16:34

Jonas
Member
From: Frankfurt, Germany
Registered: 2016-06-06
Posts: 112
Website

Re: Good practices for displaying Text - GBDK

This is done by replacing some tiles in VRAM and simply drawing them on the background layer. If you slow the emulator down to a few frames per second you can clearly see that the game replaces only two tiles per frame and then draws them on the background map ($9800). And yes, you could do that in GBDK.

It is not possible to achieve the same result using sprites. As you have more than 10 letters in each line, you would exceed the maximum number of sprites per scanline which would cause the rightmost letters to disappear.

The window could be used to display a text box like this, but in Link's Awakening it is used for the HUD on the bottom of the screen (probably to have an easy solution to scroll the HUD area upwards when you enter the pause menu).

Offline

 

#6 2020-12-22 11:18:25

rune-dev-matt
Member
From: Germany
Registered: 2020-11-30
Posts: 12

Re: Good practices for displaying Text - GBDK

So i gave it a try. I put it on the window layer in my example.
Maybe someone wants to check it out and give me some feedback.

https://github.com/Smartis2812/gbdk-text-system

// I also want to point out, I'm a noob. I started reading the GBDK Wiki as bedtime lecture and have no previous C experiences.
// So I'm open for constructive critic or when someone pointing out where I programed some nonsense.

Last edited by rune-dev-matt (2020-12-22 11:24:46)

Offline

 

#7 2020-12-22 11:20:06

rune-dev-matt
Member
From: Germany
Registered: 2020-11-30
Posts: 12

Re: Good practices for displaying Text - GBDK

@Jonas Thanks for the input.

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson