Confining text to text box limits

Have a thought on how NESmaker can be improved? We are a small team with limited means, but we'd love to hear your ideas!
Post Reply
User avatar
stevenshepherd
Posts: 236
Joined: Sun Feb 18, 2018 5:25 pm

Confining text to text box limits

Post by stevenshepherd » Sat Jan 12, 2019 4:28 am

I really like the addition of the green box that shows how your text will fit in the text box. However, even with that, I am going back and forth a lot editing it, finding that somehow text keeps going over the edge. It would also be nice to be able to auto center it as well. I don't really like my text going right to the edge (like to have a bit of buffer on each side) just as a personal preference. I also like it all centered as opposed to left justified.

Of course, I could be missing something completely about the textbox that makes this moot. It might not be possible either. Just thought I would mention it :)
User avatar
FrankenGraphics
Posts: 120
Joined: Wed Mar 07, 2018 11:36 am

Re: Confining text to text box limits

Post by FrankenGraphics » Sat Jan 12, 2019 1:27 pm

I haven't had time to play around with the text function, but you'd only be wasting 1 byte per row if you let it begin with an empty space tile to create a padded left adjustment. You can fake center-adjusted texts the same way if there isn't a routine to let the printout know on what x offset to begin a row.

General tip: Sometimes you need to space words with two tiles to have it look aesthetically formatted that goes for center-adjusted and box-spread text especially.
www.frankengraphics.com - NES homebrew blog
User avatar
stevenshepherd
Posts: 236
Joined: Sun Feb 18, 2018 5:25 pm

Re: Confining text to text box limits

Post by stevenshepherd » Sat Jan 12, 2019 2:51 pm

Thanks for the suggestions. I have basically been trying to do that but it is a bit of a pain. In some cases I have to have several spaces because I can't fit the next word on a line. Each space takes up a character and you can only have 256 characters per textbook.
User avatar
FrankenGraphics
Posts: 120
Joined: Wed Mar 07, 2018 11:36 am

Re: Confining text to text box limits

Post by FrankenGraphics » Mon Jan 14, 2019 12:57 pm

I took a really quick glance in the files. In macros, there's a function called DrawText.asm. It'll call the more general function getUpdateTileOffsetPosition. You don't want to modify that one if it is used elsewhere. But in DrawText.asm, you should be able to replace the following:

Code: Select all

LDA arg0
STA tileX
LDA arg1
STA tileY
with

Code: Select all

LDA arg0
INC
STA tileX
LDA arg1
INC
STA tileY 
to get a hard-wired permanent padding by adding an offset of 1 tile on both x and y axes. If you only want padding on the x axis (indentation), remove the INC before "STA tileY". Let me know if that worked. You're still left to manual editing to ensure that the text doesn't go out of bounds, though.

This is also the place where you could add center-alignment. On top of my head, if you can get the length of the text string (needs a new routine to count it, i'm afraid - that's the stuff that comes for free in high level languages (like so: len(myString)) but needs to be coded when in assembly), then divide it by 2 to get the center aligned offset, then store it in a user variable (let's call it MyCenterAlignmentVariable), then replace the x-axis "INC" with "ADC MyCenterAlignmentVariable". Note that without any decisionmaking, ALL text printout will then be center aligned.
www.frankengraphics.com - NES homebrew blog
User avatar
stevenshepherd
Posts: 236
Joined: Sun Feb 18, 2018 5:25 pm

Re: Confining text to text box limits

Post by stevenshepherd » Mon Jan 14, 2019 3:37 pm

Thanks! I will try this out :)
Post Reply