ROM Hack Japanese Programming Madness

Auryn

Well-Known Member
OP
Member
Joined
Jul 21, 2011
Messages
559
Trophies
1
Age
51
XP
706
Country
Swaziland
While bored at work I started parsing my NDS japanese game collection and naturally take a look at the file structure.
It didn't take long to find a game that had something strange: apparently no font.
The game I am talking about is Kenshuui Tendo Dokuta (Japan); a sort of Trauma Center Clone.
It's looking like this game has sections of text compressed in one file. This file contains a NCLR/NCGR and many NSCRs all without header and pointers.
The NCGR is all letters that are needed for that section of text only and there is a NSCR for each screen of text.
Here a pic of the first text screen and the NCGR (note the か that is reused):


Do you have some other japanese programming crazyness to share??
 

rastsan

8 baller, Death Wizard,
Member
Joined
May 28, 2008
Messages
1,002
Trophies
1
Location
toronto
Website
rastsan.wordpress.com
XP
413
Country
Canada
7th dragon... its 250+ font files intermixed in the one text file. There is the one block font file of the basic characters with then every file (with text) adds it own more complex letters onto that font table. could be one extra font grouping per file up to the aforementioned 250+. it goes text block font text block font. each text block has its own different new font table for the font that goes with that block. making translating it a tiresome process. As a new table needs to be made for every font just so that text can be dumped properly. where one font file and one table would have saved space and given the writers and programmers less of a headache.

(can you imagine one letters value meaning over 400 different letters in one game? that value staying in use through the entire game but getting a new graphical letter for it depending on the text...)

No disrespect to the programmers or owners of the copyright to this game was intended in this post.

This conversation is strictly for research study purposes.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
LifeSigns: Surgical Unit was the English sequel no?

Anyhow so the "character encoding" is in fact a bitmap image reworked using a tile map (SDK formats no less) to make text. Interesting- I have pondered such a thing in years past when trying to think up a way to explain some of the graphics concepts and font handling but never really expected to actually see an implementation. Would also go some way to explaining the difficulty in finding text in the rom when I had a quick snout around it years ago.

My favourite in recent times still has to be Wizard of Oz - Beyond the Yellow Brick Road http://gbatemp.net/topic/300953-pac-files-help/ (it gets a bit unreadable as things go on so apologies) which more or less has the script as a low rent scripting engine (I doubt it is Turing complete and certainly not in an obvious way but still fairly far reaching compared to your average text engine that might have placeholders if it is especially high end).

Equally http://gbatemp.net/topic/305167-the-various-audio-formats-of-the-ds/ has a couple of things, I also liked the zombie daisuki game if only because it had some odd ideas (actual text for one- no pointers or fun things like that).

I really should start pulling apart random roms again. Might even provide me with a bit of incentive to do something with my random roms hacking thread ( http://gbatemp.net/topic/282588-thread-of-a-thousand-rom-hacks/ ) I started and never did anything for.
 

Auryn

Well-Known Member
OP
Member
Joined
Jul 21, 2011
Messages
559
Trophies
1
Age
51
XP
706
Country
Swaziland
@rastasan: a pain in the ass to extract but you will probably overwrite all the fonts with the same one when you will reinsert the translation...no??

@[member='fast']: interesting topics


Some more from Ace Attorney Investigations 2
On AAI2 there are 3 fonts and all 3 have a tile width table at the beginning but for some reason, only 2 are used, the last one is just ignored and if you think that the one that are used are the one for the main text and the logic descriptions, and the one that is ignored is the one for the profiles/evidence descriptions, it's completely illogical.
By the way we are still searching for some good hacker to fix little problems as this one.

Other curious things is that AAI2 seems to like the bottom of every memory limits/bank and need to repoint almost everything that has to do with the text (even the text window) if expanded.

The next fact is probably done because of translation but there a character in the game with up to 4 different name codes that make appear the same name tab but actually are the same characters in different situations (present time or flashback or even different case).
Adding to this, maybe there are up to 2 more name codes for make appear the "???" before that the character is presented or he/she introduce herself O.o.

The last one is probably not so exciting because very common in many games: there are leftovers of the demo version of the game and naturally unused text as well.
 

rastsan

8 baller, Death Wizard,
Member
Joined
May 28, 2008
Messages
1,002
Trophies
1
Location
toronto
Website
rastsan.wordpress.com
XP
413
Country
Canada
@Auryn oh no I gave up on 7th dragon. I was on my x table file and going blind from identifying my 15 thousandth character.... Only to realize that I had three specific characters wrong throughout near every table and thus having to redump what I had dumped not quite re doing all the translation already inserted. that and the one person spamming my unlisted (unrelated to rom hacking in any way) email address with 7th dragon related "whens it gonna be done"... minimum 200 times a day.
If i do it again I am gonna watch one specific area in memory with an assortment of breakpoints before each and every font, thus saving time by letting the game make the table(s) for me. Or re-writing the main font file completely... I say this with a big IF.
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,824
Trophies
3
Location
Gaming Grotto
XP
29,821
Country
Poland
The largest "Japanese Programming Madness" instance I can think of is Sigma Harmonics by Square Enix for the DS.

The game's font is non-standard and encrypted to the point that it's physically impossible to translate it, not only for the fans but apparently for distributors aswell, since the game was never released abroad nor was it attempted by anyone in their right minds, all because the perspective is Portrait and the font goes from top to bottom vertically rather then horizontally (as it should in Japanese, but still).

[yt]GxxqtdRlzJI[/yt]

Check the ROM out - it's like it's black magic in .nds format.
 

Foxi4

Endless Trash
Global Moderator
Joined
Sep 13, 2009
Messages
30,824
Trophies
3
Location
Gaming Grotto
XP
29,821
Country
Poland
The largest "Japanese Programming Madness" instance I can think of is Sigma Harmonics by Square Enix for the DS.

The game's font is non-standard and encrypted to the point that it's physically impossible to translate it, not only for the fans but apparently for distributors aswell, since the game was never released abroad nor was it attempted by anyone in their right minds, all because the perspective is Portrait and the font goes from top to bottom vertically rather then horizontally (as it should in Japanese, but still).

Check the ROM out - it's like it's black magic in .nds format.
Sigma Harmonics really isn't that big of a clusterfuck. The font is in the pretty common NFTR format and there is no encryption. There are tools to extract the archives (including the official tool from the SDK) so unpacking and repacking isn't a problem either. Sigma Harmonics had *some* oddities but not any of the ones listed.

Time for a little rant since it gets me every time people claim how impossible some game engines are.

There is nothing that makes games played in portrait mode any harder to hack than normal games. People seem to jump to the font as being a big issue but it really isn't one. To understand that you must understand what a font really is. Speaking strictly in terms of what the NDS can do, a font is a collection of images for each character that will be displayed on screen. To display the sentence "Hello, world!" it will require an image for each unique character in the sentence ("Helo, wrd!"). A font file on the NDS is a collection of the character images and sometimes includes some extra data such as the width of the character depending on how complex the format is.

Here's the font I used when I was messing with Sigma Harmonics to give you an idea about how the font would work:
tiR6o.png

When turned the same way you would turn the DS to play Sigma Harmonics:
Oe7Km.png

No modifications needed to the font besides inserting rotated ASCII and/or remapping the characters to the normal ASCII range.

Next is the vertical text problem. Generally (I'm sure someone can find something that is weird) when you are displaying text on the screen you will have an X and a Y position. Those correspond go the coordinates on the screen. At some point in the game's code there will be a part that calculates the position of the next character to be displayed. Assuming the DS is being held in standard mode, a game with horizontal text it will be modifying the X position to move it left or right. A game that wants to write the text vertically will modify the Y position instead. Now if we want to think about this in portrait mode you just flip the axes. In portrait mode, if you want to display the text vertically you would modify the X position. To display the text horizontally you would modify the Y position. If the game is displaying text vertically in portrait mode then you just need to modify the code so it's modifying the Y position instead of the X position to display horizontal text in portrait mode.

The other problem is since the game displayed a border around all of the text, that must also be fixed. The frame itself is generated programmatically taking in the edge offsets and then filling in the rest. A pretty good rule to remember when dealing with games is "If it can be see it happening, it can be hacked". That includes things that you normally don't think of as seeing such as enemy AI. The difficulty involved ranges but if you see it happening, it can definitely be hacked. Everything the game uses to run must pass through somewhere at one point. All you need to do is find one of those places and trace it back far enough to find the code you want. Anything involving graphics is easier to find because you are guaranteed it will eventually end up in the VRAM.
I did not know that, thank you very much. I was convinced that it was quite the clusterf*ck, hence no translation surfaced.

I'm pretty sure you can't exactly edit the way the text window shows up though as it's not "a typical string" like it would be in the case of pre-set values for text but actual compiled code, so it would be more appropriet to "fool it" rather then change it. Example:

Letter1Line1 Letter1Line2 etc EOL
Letter2Line1 Letter2Line2 etc EOL

Effectively ending up with the letters displayed horizontally rather then vertically as in the original. It's alot of work though, but I'm sure you get the gist of what I'm saying. Thing is, with that sort of thing employed, we'd likely end up not having enough space in the String anyways, so... yeah. Shame.
 

Sora de Eclaune

All our splendor...
Member
Joined
Feb 15, 2011
Messages
2,850
Trophies
1
Location
Home
Website
www.youtube.com
XP
1,192
Country
United States
I did not know that, thank you very much. I was convinced that it was quite the clusterf*ck, hence no translation surfaced.

I'm pretty sure you can't exactly edit the way the text window shows up though as it's not "a typical string" like it would be in the case of pre-set values for text but actual compiled code, so it would be more appropriet to "fool it" rather then change it. Example:

Letter1Line1 Letter1Line2 etc EOL
Letter2Line1 Letter2Line2 etc EOL

Effectively ending up with the letters displayed horizontally rather then vertically as in the original. It's alot of work though, but I'm sure you get the gist of what I'm saying. Thing is, with that sort of thing employed, we'd likely end up not having enough space in the String anyways, so... yeah. Shame.
The strings in the game are just typical strings. There's nothing fancy going on. It stores "Hello, world!" just like that. You don't need to do any fooling besides changing it from moving on the X axis to moving on the Y axis. Doing it the way you showed is just overcomplicating it since it's a problem to be solved in the game's code, not in the data.
...Have I ever told you how much I love you?
 

Auryn

Well-Known Member
OP
Member
Joined
Jul 21, 2011
Messages
559
Trophies
1
Age
51
XP
706
Country
Swaziland
Well thanks Nagato for explaining that even if I kwew it :P

@[member='Foxi4']: I believe the % of games made by Square/Squaresoft/Square-enix that made it abroad was always less than 50% in any system but on the NDS I believe it's less than 30% or even 25%. Not because a game is difficult to translate that it doesn't get abroad (if so we would probably never got FF7 then :P).
That game is sure not easy to translate (none are) but it's sure possible to do even if the changes it needs make it a game of medium-high difficulty to hack.
As for the space, you see that the game doesn't use the whole height of the screen so not much different as the space you have horizontaly and if really needed, you can make the font a bit smaller as the original.
By the way, the script of the game will look the same (horizontaly with normal line breaks as we are writing here) in the original and the translated version, only the graphic rappresentation on screen will change.
I am sure that if somebody like Nagato would fix the text window and the text direction, somebody would sure pick it up very quickly.


 

Auryn

Well-Known Member
OP
Member
Joined
Jul 21, 2011
Messages
559
Trophies
1
Age
51
XP
706
Country
Swaziland
Interesting Nagato. Do you have the site/source of where you learned the ASM stuff for the NDS??
 

rastsan

8 baller, Death Wizard,
Member
Joined
May 28, 2008
Messages
1,002
Trophies
1
Location
toronto
Website
rastsan.wordpress.com
XP
413
Country
Canada
Interesting Nagato. Do you have the site/source of where you learned the ASM stuff for the NDS??
Unfortunately no. I wish I did since I've been asked that a few times. I've been reverse engineering games (almost exclusively x86 up until that point) since the mid 2000s so I had a lot of experience that I was able to apply to working with the NDS. The good thing about working with the NDS (and the GBA I suppose but I haven't messed with that) is that it uses the ARM architecture. ARM is a well documented architecture so I got a copy of no$gba debug version and, with the ARM documents in hand, whacked at it until I got it to work. I no longer work with no$gba since I find it doesn't meet my needs anymore but it worked well for what I needed back then. These days I use IDA Pro and Desmume with the GDB stub compiled since it's a much more powerful combination and I'm familiar with IDA Pro.

ARM Architecture Reference Manual: http://www.scss.tcd....3d1/arm_arm.pdf (Warning: huge PDF)
ARM Instruction Set Reference: http://infocenter.ar...QRC0001_UAL.pdf
GBATek (GBA/NDS-specific information): http://nocash.emubase.de/gbatek.htm
but well worth the read...
I got more from the arm architecture than any of the others... I can't remember if that one includes the arm7 too... which may seem pointless but there are games with arm7 programming.
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,321
Country
United Kingdom
One would think so greator but in practice they can often end up in a worse position than rom hackers do and end up doing many of the same tricks- http://www.loekalization.com/mistakes.html has a fair bit of insight.

Granted some of the highest end ones and top tier companies will have nice methods by which to effect a translation and/or full source code (source code is perhaps surprisingly not necessarily the most useful thing you can give your translation/localisation team) but not all.


As for assembly and related concepts I will also throw in http://www.coranac.com/tonc/text/toc.htm . It is for the GBA but most of it carries across.
 

pleonex

Well-Known Member
Member
Joined
Jan 16, 2009
Messages
204
Trophies
1
Location
Spain & Switzerland
Website
github.com
XP
523
Country
Switzerland
Interesting post... I have found a lot of forgotten files in NDS games. Some of then very funny

File name: "how_to_create_highlights.txt" in FIFA6, and many other gams of EASport
---------------------------/-------------------------------------------------------------------------------
To create/save highlights /
-------------------------/---------------------------------------------------------------------------------
* run a debug build
* put a breakpoint in game.c at the top of G_ReplayPlay where it says:
// to record replays, put a breakpoint here
* score a goal or miss
* press SELECT to replay at a good moment, the game should Break on your breakpoint before showing the replay
* Make a note of the address of G_tHighlight[0]
* Within Nitro Debugger, select File|Write
* Save As BIN with a filename of:
C:\work\FIFADS06\DATA\oot\miss0.bin OR C:\work\FIFADS06\DATA\oot\goal0.bin (as appropriate)
* set the Start Address of G_tHighlight e.g. 0x0220bc70, and the Length as 0x6760 (should be sizeof(THighlight))
* click OK to save
* increase the appropriate GOAL_LZ_COUNT or MISS_LZ_COUNT #define in gamesys.h (around line 21)
* check the bin files into sourcesafe
* any questions ask Charlie
-----------------------------------------------------------------------------------------------------------


Can anyone image what game has this image? :)
http://dl.dropbox.com/u/3981393/Tinke/image.bmp


Also, the game "Planet 51" has the images compressed in a common ZIP file (with folders too).

Maybe later I can add more files like code files, DLLs, batch or executables (they like to forget remove files) :P

NOTE: if this is against the rules, please tell me or/and remove it, I'm not very sure.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
    Xdqwerty @ Xdqwerty: roms wont boot with wood r4menu