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

Author Topic: Cramped UI? Cramped Strings?  (Read 3456 times)

Strill

  • Newbie
  • *
  • Posts: 3
    • View Profile
Cramped UI? Cramped Strings?
« on: May 30, 2011, 11:18:33 am »
I came across a Japanese indie game I liked so I figured I'd try my hand at translating it.  I've finally managed to get an insertion script written and working, unfortunately much of my translations are too big to fit in the game's UI elements, and end up overflowing off the side.  Even worse, some strings have little to no padding giving me a hard limit of around 15 characters to write what should be 26.

Are there any special tricks to dealing with limited UI space other than just abbreviating things?  And for the limited length strings, is there some decompiler that can add padding to an executable without misaligning everything and invalidating pointers?

I'm probably asking for impossible things, but I figured if they existed, people here would probably know.
« Last Edit: May 30, 2011, 11:55:55 am by Strill »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Cramped UI? Cramped Strings?
« Reply #1 on: May 30, 2011, 01:28:42 pm »
Welcome to the wonderful world of translation hacking, my friend.

Hacking a Windows executable (I'm assuming it's a Windows executable) isn't much different from hacking a ROM - it requires its own set of specialized knowledge, but the things you ask for are well within the realm of possibility.

Mind, I'm just here to let you know that. ^_^; I know a fair bit about romhacking, but hacking a PC game is outside my realm of expertise and experience. But if you've already gotten started on a translation, you're sure to find some help.
In the event of a firestorm, the salad bar will remain open.

Jorpho

  • Hero Member
  • *****
  • Posts: 4194
  • The cat screams with the voice of a man.
    • View Profile
Re: Cramped UI? Cramped Strings?
« Reply #2 on: May 30, 2011, 02:13:23 pm »
Are there any special tricks to dealing with limited UI space other than just abbreviating things?  And for the limited length strings, is there some decompiler that can add padding to an executable without misaligning everything and invalidating pointers?
I reckon the possibilities include rearranging the UI or finding some way to hack whatever routine adds the text to the UI.  (In particular, are you still using fixed-width Shift-JIS?)

If you want to avoid misaligning everything, it stands to reason that the best way would be to find the pointer to the text you want to change, and instead direct that pointer to a space at the end of the file.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Strill

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Cramped UI? Cramped Strings?
« Reply #3 on: May 30, 2011, 02:32:46 pm »
The primary font is the game designer's own custom SHIFT-JIS encoded font created with a table of 8x8 pixel characters in bitmap format.  The second font for 8-bit ASCII is also 8x8 pixels, so  there's no advantage there. 

I tried finding the routine that prints text by decompiling the program with a demo version of IDA and setting breakpoints at every DirectX call that looked relevant.  It passes three breakpoints before the window pops up, but I never seem to hit any breakpoints after that.  I don't know if it uses something else or if the decompiler's just unreliable.

Thanks a lot for the idea of redirecting the pointers.  It might not work if the code tries to access that memory via an address and an offset rather than just one hardcoded address, but it's worth a try.

Jorpho

  • Hero Member
  • *****
  • Posts: 4194
  • The cat screams with the voice of a man.
    • View Profile
Re: Cramped UI? Cramped Strings?
« Reply #4 on: May 30, 2011, 03:13:22 pm »
The primary font is the game designer's own custom SHIFT-JIS encoded font created with a table of 8x8 pixel characters in bitmap format.  The second font for 8-bit ASCII is also 8x8 pixels, so  there's no advantage there.
Well, if you can find the font and identify its pixel-format, then instead of inserting new text, the brute-force way of doing it would be replacing the characters with parts of the word you want to insert.  (That is, if you wanted to insert the word "TEXT", you could replace one Japanese character with "TE" and another one with "XT".)

Of course, if there's a gigantic script that's supposed to go into this UI, then this would involve identifying all suitable character pairs in the text and sticking them into the font, possibly expanding the font in the process – but in the case of a Windows executable, you don't have to deal with the same restrictions as a console ROM, at least.
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

Strill

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Cramped UI? Cramped Strings?
« Reply #5 on: May 30, 2011, 03:37:56 pm »
Interesting idea.  The bitmap containing the SHIFT-JIS isn't big enough to hold the entire character set, just around 500 or so characters.  There's about 80 lines I need to insert, a good portion of which are just one or two words.  I can't figure offhand whether 500 characters is sufficient, but in case it isn't I'll see if I can lengthen the file and have the game will recognize the new additions or if it's programmed to only load a specific chunk.

« Last Edit: May 30, 2011, 03:48:34 pm by Strill »

Klarth

  • Sr. Member
  • ****
  • Posts: 484
    • View Profile
Re: Cramped UI? Cramped Strings?
« Reply #6 on: May 30, 2011, 04:05:42 pm »
You have a ton of options when it comes to PC game hacking.  It just depends on your skill level.  You can do anything from repointering the text to hacking in a DLL reference and rewriting the string-grabbing routine to grab from an external text file instead.

I'd set a breakpoint on the text string to be printed first and the printing routine should be nearby.  I'd read up some on how you can print text using DirectX.  At a minimum, it involves creating a new texture (dimensions based on string size) and copying characters from a preloaded font texture.  Then rendering to screen (may be relevant if you need to reposition).  There are some simplified functions in the D3DX library that may be used too.  Such as using ID3DXFont but I think that's unlikely because it's just a bitmap file.  It's probably the first scenario.

henke37

  • Hero Member
  • *****
  • Posts: 643
    • View Profile
Re: Cramped UI? Cramped Strings?
« Reply #7 on: May 31, 2011, 06:29:00 am »
Or it could be using GDI in combination with directX.