Replacing text in a DS game - stuck on pointers

Started by Lyndis, February 20, 2017, 07:15:32 PM

Previous topic - Next topic

Lyndis

I'm trying my hand at this whole hacking thing and am a little lost. I've figured out how to dump this DS game (Angelique Duet) into individual files. I also downloaded a number of programs that I can view the file structure and/or the hex code with, like CrystalTile, WindHex, and NSMB Editor (lol). However, what I can't figure out is how to successfully overwrite the Japanese text with English. I've tried simply replacing the text in one of the files and importing it back into the game, but that results in a black screen when the text box would normally have appeared.

I was talking with a more experienced hacker and he was trying to explain that I need to find pointers that I could then import into Kruptar, where somehow the Japanese text will magically appear based on the pointers(?), and I can replace the text there, and then insert the text back into the game with new pointers. But I can't figure out how to locate said pointers. It seems like the method varies based on the system and maybe even based on the individual game. At the risk of sounding completely stupid and noobish, could anyone point (ha ha... ha) me in the right direction? And if pointers are not in fact the missing link here, what is?

mz

It's still too early to worry about pointers at this point.

How exactly are you editing the text?

Use a hex editor and change a single character (for example, change 0x5e to 0x2f) and see what happens. If you still get a black screen, the game may be using some kind of protection to prevent people from hacking it, which is *very* unlikely. I'd say you're not using the hex editor or file inserter correctly.
There has to be a better life.

FAST6191

Pointers are like the contents page of a book. Very useful to have and if you are going to do any real work you will want to have them and update them accordingly but not where most would start.

What you probably want is to figure out the encoding, and then make a table.
Short version is computers only know 1 and 0 at this present time. Stick 4 of them together and you have 256 characters possible, stick 8 and you have a lot more which also works for the likes of Japanese with its thousands of characters. DS games do often use common Japanese encodings rather than straight up custom like many older systems, however custom is certainly still a thing in many cases.

Looking at the file it appears that you might well have some flavour of shiftJIS (all the things starting with 8 and 9 is a bit of a telltale sign for me at this point). ShiftJIS table because why not
http://www.rikai.com/library/kanjitables/kanji_codes.sjis.shtml
crystaltile2 has one, and I think there is one somewhere in the downloads of this site. In what follows I did something with my browser but it is not a good tool for this sort of thing.
One spoiler full of not at all cleaned up text dump to see if it makes sense (I fed it to google translate and it came out with something other than complete gibberish so felt comfortable sharing it here).
Spoiler

時が来たのよ。
@R$�
�

$H
F2
確かに困難かもしれない。
@Rでも...。
@R$
$E
F1
大丈夫です、女王陛下。
@Rあの子たちなら、きっと
@R成しとげてくれますわ。
@R$
$H
F1
...そうね。
@Rあの2人に託しましょう。
@Rこの宇宙を、未来を、
@Rそして希望を...
@R$
$E
F0
女王候補よ、目覚めなさい。
@Rあなたはどちらの
@R女王候補ですか?
@R$
$E
F0
スモルニィ女学院の2年生。
@R明るく元気な
@Rごく普通の女の子ですね。
@R$
$
$E
F0
あなたは
@R金の髪の少女なのですね?
@Rはい
@Rいいえ
@R$
$E
F0
あなたは
@R青い瞳の少女なのですね?
@Rはい
@Rいいえ
@R$E
F0
では、どちらの少女なのですか?
@R$
$E
F0
スモルニィ女学院の2年生。
@R名門の家系に生まれ
@R女王としての資質も
@R十分に備えた女の子ですね。
@R$
$E
F0
星を導く使命を持つ子よ。
@R時が来ました。
@R扉を開けるのです。
@R$
[close]

There is a lot of odd stuff in that, so chances are there are also some extra bits of info for what character is talking, placeholder for money/character name/item required, maybe some font colour/formatting or something else to guide the text engine to do something.

As far as pointers go the start of the file looks like it has something. 4 byte sections, what might be a size value of some form and then you have things that, once flipped, count up in size by small, random and text like amounts before ending with a value somewhere around the end of the file. Nowhere near enough to be each individual line so maybe sections instead, and as this looks like a menu section of sorts it could well be that as the amount of sections above in that is about the same as the number of possible pointers. Indeed most sections there appear to start with 30 00 and the difference between some of those is the same (did not try it all).

Lyndis

@mz Yes, I can change text directly in the hex editor and it shows up just fine. The problem is that English takes up a whole lot more space than Japanese does, so if I just replace letter by letter there won't be nearly enough room to work with.

@FAST6191 I've actually already been working with the Shift-JIS table. I can view the Japanese characters in the hex editor and in the dumped file that I linked above. Seeing the text is not the problem at this point, it's how to replace it with English that's going to end up taking up significantly more room than the original Japanese. I'll take a look at the 4 byte sections you mentioned and see if I can make any sense of that.

mz

Quote from: Lyndis on February 20, 2017, 09:11:37 PM@mz Yes, I can change text directly in the hex editor and it shows up just fine. The problem is that English takes up a whole lot more space than Japanese does, so if I just replace letter by letter there won't be nearly enough room to work with.
I know, we all have the same problem in every game.

You still haven't answered my question, how exactly are you editing the text. Changing Japanese to English doesn't automatically triggers the black-screen routine, unless the game is programmed to detect the language you've inserted in and triggering the routine if it detects the text as English.

Besides corrupting the pointers and/or inserting back a file with a different size (and overwriting code), you may be trying to insert ASCII characters which the game may not be programmed to handle.
There has to be a better life.

Lyndis

Quote from: mz on February 20, 2017, 09:54:42 PM
You still haven't answered my question, how exactly are you editing the text. Changing Japanese to English doesn't automatically triggers the black-screen routine, unless the game is programmed to detect the language you've inserted in and triggering the routine if it detects the text as English.

I was using Notepad (don't laugh) to change the text in the dumped file, SELECT.MSG, and then using CrystalTile to import it to overwrite the same file. Saving it in Notepad probably changed it to ASCII, now that you mention it.

Still trying to wrap my head around this pointers thing.

mz

Quote from: Lyndis on February 20, 2017, 10:02:39 PMI was using Notepad (don't laugh) to change the text in the dumped file, SELECT.MSG, and then using CrystalTile to import it to overwrite the same file. Saving it in Notepad probably changed it to ASCII, now that you mention it.
Yes, you shouldn't use a text editor for these things, since there are many bytes that are not handled by them. (For example, those 4-byte things that FAST6191 mentioned are probably being ignored/overwritten with garbage.)
There has to be a better life.

NoOneee

FAST6191 is probably right with the sections idea.

(4 Bytes) Header Size in Bytes = 0x00000028
(4 Bytes) Offset Section 1 = 0x00000000
(4 Bytes) Offset Section 2 = 0x000000A7
(4 Bytes) Offset Section 3 = 0x00000154
...

Those section offsets are counted after the header (so add 0x28 to each number to find the start of the section).
You can see that all sections begin with a 0x24 byte.
If you increase the size of a section, you probably need to increase the offset of all the sections after that.

My suggestion is to code something dump/insert the text and adjust the offsets.

FAST6191

On English I should also say that while official shiftJIS supports some kind of unicode for the English side of things many, possibly most, DS games which use something similar to shiftJIS do not support that. In the Japanese side of things there is a run of Roman characters, however not all will have it. Beyond that plain text editors are a bad plan for editing most files, as was already mentioned. Generally when doing this sort of thing I will change a few characters in a hex editor in place and see if I get what I think I am getting. There are also certain games that don't like being rebuilt, and certain flash carts that also don't like certain methods.

You are going to want to look at the font (can be anything, however the Nintendo provided font format on the DS is nftr, if there are any files with the extension nftr then do have a look at that -- crystaltile2 has some limited abilities here, nftr editor is my favourite and you might also want to look at tinke.