Quantcast
Channel: nesdev.org
Viewing all articles
Browse latest Browse all 746

Newline when writing text as background tiles

$
0
0
Hello, all! I'm sure this is a solved problem but I'm not sure what the best practice is.

I have a simple routine that writes text (dialogue, story text, whatever) to the screen using background tiles, mapping ASCII code to tile location (so the tile that looks like an A is at $41, etc., you know the drill). It works fine, except text will continue to the edge of the screen and continue on the next line of the nametable, breaking in the middle of words. So of course I'd like the ability to encode newlines into my text.

I arbitrarily chose $5C to represent a newline (because I don't expect to need backslashes in my dialogue). My question is, when my text processor routine sees a $5C, what's the best way to move down a line in the nametable, while keeping the same starting X position, so I can keep writing from there? So for example:

Code:

     HELLO($5C)     WORLD
I can't simply write empty background tiles to the end of the line, because I might want to put other background graphics around the text (a speech bubble, character art, something like that.) It seems to me that if I could learn the current location in the nametable, there would be a way to set it to the next correct spot and write from there, but PPUADDR is write-only.

I bet there's an elegant answer I'm missing, but I can't think of it. How would you handle this? Thanks!

Statistics: Posted by nat20 — Sun Jul 07, 2024 7:25 am — Replies 2 — Views 148



Viewing all articles
Browse latest Browse all 746

Trending Articles