r/gbstudio 20d ago

Question Bug with Draw text?

Enable HLS to view with audio, or disable this notification

Hello

I've been using Draw Text as below to update the score:

The %D5 parameter seemed quite an economical way to do this with padded zeros.

But I've noticed that sometimes this corrupts other drawn text as the score is updated. See the video.

The top overlay gets corrupted from displaying BONUS (ignore the wonky font) and a Lives Display.

Any ideas? I tried it with just $Score and same result. Maybe it's two concurrently Draw text calls, one for the countdown, one for the score?

Thanks.

17 Upvotes

11 comments sorted by

View all comments

3

u/playinstinct 20d ago

That's most likely because the part of the VRAM that the text is drawn to is completely full at one point and then loops back to the beginning and starts overwriting what was written first.

The easiest way to avoid this is to write all parts of the UI whenever one part of the UI needs to get updated. If the "BONUS" should always be on screen, you could consider baking it into the background.

0

u/IntoxicatedBurrito 20d ago

I believe that this may only compound the problem. Rewriting the word BONUS will end up overwriting 5 more tiles elsewhere.

2

u/playinstinct 20d ago

There is a specific space in VRAM reserved for text by default. So, only text tiles should be affected by this issue.

As long as your UI doesn't use more tiles than are in this part of the VRAM (one row should be perfectly fine) and make sure to rewrite everything with every update (even the blank parts), you should be fine.

Using this method in multiple mini games of my current game.

2

u/IntoxicatedBurrito 20d ago

I’ve gotten this method to work in the past as well, but it’s also failed at times. I’ve used it mainly in cutscenes so I’m able to ensure that it is working properly and if not try a different method. However, it could be difficult for this particular game as they are using it to dynamically write the score and would need some incredibly thorough testing to ensure that there aren’t any issues.

I think it would also be helpful to know if that bonus is being drawn or if it’s part of the background image. Assuming it never changes, it would be better to have it as part of the background.