News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Text Box Sizing Help - London Seirei Tanteidan  (Read 1026 times)

bigbanana23

  • Newbie
  • *
  • Posts: 2
    • View Profile
Text Box Sizing Help - London Seirei Tanteidan
« on: February 23, 2019, 12:17:39 pm »
Hey all,

Long time lurker and follower of the scene here. I was looking to try my hand at a translation patch for the lesser known PSX RPG London Seirei Tanteidan and have made some decent initial progress but have hit a bit of a snag. I've managed to locate various parts of the script, the font, and generate the table, all the basic stuff. I've also dug into the ASM and have managed to perform a very basic hack to change the spacing of font characters on screen so that they aren't as distant from each other. Nothing fancy at all, just a 1 byte change from 13 (12px font width + 1 space) to 9.

The main snag that I've hit though is that while the characters are now closer together, the text boxes/speech bubbles still remain the same width as if they were fully spaced apart. The more characters in the string, the more empty space at the end of the textbox. I've combed through several traces of the code when a text box is drawn onscreen, and there are no other instances of a constant of 13 that affect the width of the actual text box. I've managed to make changes to the border, but I've been unable to find any way to change the width of the centre part with darker brown backgrounds and the actual text. I've also managed to move the textbox around onscreen to different positions, but so far I can only do this for text boxes and not speech bubbles.

Through experimentation, I've determined that the text box is drawn before the font is ever displayed. It's also clear that the textbox dynamically resizes itself based on the length of the lines within it. If I were to add a line break in the following screenshot, the box would narrow.



I've of course measured the width of the width of the text area in pixels and have checked trace logs to find it. When stepping through in a debugger, any changes to register values that contain the width of a textbox (as I've calculated it) only change its position on screen, never the actual width.
 
I was very kindly hoping that someone could point me in the right direction as to what I should look for/try next, as I've probably sunk as more time into trying to fix this one issue than anything else so far. I almost wish the game just used simple fixed-size text boxes like most other RPG's.

Thanks so much!

VicVergil

  • Hero Member
  • *****
  • Posts: 710
    • View Profile
Re: Text Box Sizing Help - London Seirei Tanteidan
« Reply #1 on: February 23, 2019, 09:30:23 pm »
It would make sense, if the message box frame is rendered before the characters themselves, that the game does a first pass for the whole text box to count how long each line is, then how long the longest line is. That maximum is the width of the message box frame (not counting the edges).

Chances are that, in your case, instead of counting pixels, it's counting how many letters there are, then using that count to repeat an instruction elsewhere (drawing the message box in chunks?).

You could put a breakpoint on the text itself to find the routine.
Then you could make it so that count is fixed, or determined by the game when it detects a character at the very beginning (shift-jis standard has many to spare, either for this, or even dictionary compression with a dictionary reference you could stuff in the otherwise useless huge font graphic) or deduced with a formula from that maximum count.

I find it more impressive that you figured out where the fixed width value was, and how you modified that. If you don't mind, please share your method :)
It's amazing that you figured out something for London Seirei Tanteidan. It was high time it got translated :) Did you change the text routine internally to detect 1-byte characters to keep memory shortages from happening?

I've also dug into the ASM and have managed to perform a very basic hack to change the spacing of font characters on screen so that they aren't as distant from each other. Nothing fancy at all, just a 1 byte change from 13 (12px font width + 1 space) to 9.

An 8 pixel wide font would be good, but a 6px one (like this one from Xenogears, that ended up being rendered as 8px because of technical issues) would fit even more text, and more importantly would make message box frame width calculations (should you decide to go the more complicated route of reworking it) much, much easier since it would be a division by 2.


mz

  • Sr. Member
  • ****
  • Posts: 433
  • Whore
    • View Profile
Re: Text Box Sizing Help - London Seirei Tanteidan
« Reply #2 on: February 24, 2019, 11:15:15 am »
Hey, bigbanana23, I would have loved to help you with this, but I'm extremely burned out with ROM hacking.

In short, you can use pSX's GPU->Capture function or no$psx debugger. They can tell you what each "sprite" on screen is, where it came from, etc.

Although I can't even think about hacking right now, I have a lot of experience with PSX hacking (and love the system), so if you have any specific questions or want to voice chat with me via Discord, feel free to add me: mz#9923
There has to be a better life.

bigbanana23

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: Text Box Sizing Help - London Seirei Tanteidan
« Reply #3 on: February 24, 2019, 10:47:42 pm »
Hey mz and GHANMI, thanks a million for your suggestions. I'll definitely give them a try. It actually dawned on me last night after I'd already posted that the game is probably just constructing the textbox in chunks rather than per pixel. I poked around a bit this morning but didn't have any success, but I'll definitely dig deeper and try to isolate the code for the text windows to study it and understand it better.

I find it more impressive that you figured out where the fixed width value was, and how you modified that. If you don't mind, please share your method :)
It's amazing that you figured out something for London Seirei Tanteidan. It was high time it got translated :) Did you change the text routine internally to detect 1-byte characters to keep memory shortages from happening?

Thank you so much, but it was definitely nothing to be impressed with. I just edited the font so that the first few lines of characters were 100% filled in and took a screenshot of the font displayed on screen. When I saw that it was displaying the characters 12 pixels wide with a 1 pixel space in between them, I just traced for a couple frames while a textbox was being drawn. I looked for each instance in the trace log for any ADDI or ADDIU instructions where the immediate was $0D and changed it to $09 until I found the right one that pulled the font closer together.

I also really like your idea of the 6px font. I didn't realize that there were any that were that skinny, but it would really simplify things once I get this textbox issue nailed down, especially if I can pull off a doubletext hack like you had mentioned which will be next on the to do list. Thanks so much!

Hey, bigbanana23, I would have loved to help you with this, but I'm extremely burned out with ROM hacking.

In short, you can use pSX's GPU->Capture function or no$psx debugger. They can tell you what each "sprite" on screen is, where it came from, etc.

Although I can't even think about hacking right now, I have a lot of experience with PSX hacking (and love the system), so if you have any specific questions or want to voice chat with me via Discord, feel free to add me: mz#9923

Thanks so much for the tips mz. I'll definitely hit you up on discord in the next couple of days for some advice.

Cheers!
« Last Edit: February 25, 2019, 06:55:33 am by bigbanana23 »

aaronfox55

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Text Box Sizing Help - London Seirei Tanteidan
« Reply #4 on: March 21, 2019, 12:55:49 am »
Hi!! everyone  ;D. Thanks for been working on this title, I saw it on youtube at moment ago and looks awesome. I would like to play it as soon has you finished with the translations to english.  :thumbsup: