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

Author Topic: Breath of Fire Text Extracting  (Read 7237 times)

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Breath of Fire Text Extracting
« on: October 19, 2011, 10:46:23 pm »
Okay, where to begin? So, I'm not sure where I need to place this since it doesn't fit the criteria for personal projects. What I want to do is simply extract the tables and script data from Breath of Fire 2 (both Japanese and English versions). The reason behind my wanting to do this is so I can get familiar with ROM hacking, as I just started just recently and have little knowledge/experience. What utilities do I use to extract the BOF scripts so I can edit them? While I don't expect to insert them into a ROM anytime soon, I just want something to tinker around with. I hope to someday retranslate the game as a project, but not right away obviously.

To sum up

- Retranslate BOF into a more grammatically, clear script (while it's better than BOF2, it could use some touching up).
- Learn how to properly extract the tables and scripts for easy (or at least something not confusing) editing.


Do you recommend any good tools that will actually work? The ones I tried either require tables and/or crash during extraction (the paradoxical part is the requirement for tables). How can I create tables or .txt files if they won't let me.

Again, I'm not asking to reinsert the edited script, I only wish dump for both Japanese and English. That is all.  ;D

Don't worry, I've had a nice discussion on GBATemp about this and I was referred to this website by Densetsu, a ROM hacker ( thread - http://gbatemp.net/topic/311523-densetsus-translation-toolbox/page__st__15 )

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 6907
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #1 on: October 19, 2011, 11:25:46 pm »
Breath of Fire 2 uses dictionary compression.

Not as simple as it seems.
Notes from my text dumper, haven't looked at the code in years.
01 : End of string
02 : Linebreak
03 xx : Dictionary table, pointers at 22DE00, resulting pointer relative to 22D000. First byte = string length.
04 : wait for keypress
05 : turn highlighting on/off
06 : print leader's name
07 xx : 4-character substrings at 282AC6
08 xx : question prompt with singature byte xx
09 xx : 8-character substrings at 55160
0A xx : 8-character substrings at 70000
0B xx : sound effect xx
0C : delay
0D : "hold". Can't remember what that means
0E-10 : unknown, unused?
11 xx : change pendant color xx?
12 xx : "pendant xx"?
The rest are text values.

Applies to English versions of BoF2 (well, both the US final and US proto. Don't know about the PAL version but probably.)
"My watch says 30 chickens" Google, 2018

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #2 on: October 19, 2011, 11:46:16 pm »
So Breath of Fire 1 would use a similar structure? Crap. That's exactly what I was afraid of. Are there any programs that could dump the necessary data? I did see one called Cartographer which extracts, but the the commands listed in the readme aren't clear. Am I SOL or what? I really need to find a GUI or CMD based program to dump/extract this. Again, I have no plans to insert the modified text into the ROM for quite a while, but just to put my Japanese expertise to the test (a re-translation of the first BOF).
« Last Edit: October 19, 2011, 11:53:19 pm by nintendo_nerd85 »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Breath of Fire Text Extracting
« Reply #3 on: October 20, 2011, 05:52:31 am »
Just find the DTE table and dump it with Cartographer. Then it's a cinch to just convert it into a table, or part of one, anyway.
In the event of a firestorm, the salad bar will remain open.

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #4 on: October 20, 2011, 11:39:19 am »
Just find the DTE table and dump it with Cartographer. Then it's a cinch to just convert it into a table, or part of one, anyway.

That's the problem, I suck at using hex to find these things. What does a table have to do with the actual dialogue/script? Heck, where can I find a list of commands for Cartographer? The ones included in the readme are not clear; they're just confusing.  Again, I am new at this (and I mean "new"), but I digress. This probably the only way (and best way) to learn how to hack ROMs, am I right?


A program like FF3usME would be ideal, or something close to it. I know that dumps the entire dialogue (formatted so it can be easily inserted).
« Last Edit: October 20, 2011, 11:51:23 am by nintendo_nerd85 »

Ryusui

  • Hero Member
  • *****
  • Posts: 4989
  • It's the greatest day.
    • View Profile
    • Tumblr
Re: Breath of Fire Text Extracting
« Reply #5 on: October 20, 2011, 03:13:38 pm »
What does a table have to do with the actual dialogue/script?

Everything, really. The script's not fully ASCII-coded; you'll need to create a table to fill in the gaps. These would include the DTE codes.
In the event of a firestorm, the salad bar will remain open.

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #6 on: October 20, 2011, 05:54:06 pm »
Everything, really. The script's not fully ASCII-coded; you'll need to create a table to fill in the gaps. These would include the DTE codes.

Ah, that would explain everything. Where do I begin (are there websites and/or resources that give hints as to where to find the DTE codes)? Heck, are there even list of Cartographer commands that do it? I  need to apologize once more as I'm new to the ROM hacking scene, but I am willing to learn, even if it drives me to tearing my hair out; this game could use a decent translation IMHO.

Auryn

  • Hero Member
  • *****
  • Posts: 650
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #7 on: October 20, 2011, 07:10:09 pm »
If in your dump you read "c09xxe" and in the game you see "castle" then you will know that in your table you need to write "09xx=astl".
If you mean how to find all DTE in the game, search for "astl" in the game, you will probably find the whole block of them.

You asking about a manual for Cartographer, why you not follow what is written inside the files you find inside Cartographer itself?? I admit it's a bit confusing at first but then you will need only one kind of block of those in the examples.

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #8 on: October 20, 2011, 07:43:45 pm »
Alright, I'll use WindHex and search for those offsets, as well as Cartographer. Thanks! :D

Now if I can figure out why it says "Usage: Cartographer ROM.ext Command.txt Output.txt -s/-m" when it tells me "Failed to open command.txt"...Where do I get that? It didn't come with the ZIP file.
« Last Edit: October 20, 2011, 08:04:53 pm by nintendo_nerd85 »

Klarth

  • Sr. Member
  • ****
  • Posts: 484
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #9 on: October 20, 2011, 08:21:25 pm »
Alright, I'll use WindHex and search for those offsets, as well as Cartographer. Thanks! :D
Here's how I'd personally go about solving the problem (without using assembly):

1. Build the normal entries of the table using relative search (Monkey Moore is a good util for relsearch).  You may have to search several strings before getting a valid result because of DTE/dictionary compression.
2. Using the table (and the dialogue location result from the relsearch) in Windhex, look for missing parts of words.  You'll be able to figure out whether the game uses DTE, dictionary (or both) and how it uses it.
3. Find a string that you know how to access in-game.  Say if you found F01D=that, then modify that string to be F01DF01EF01FF020 (example) and look at the text in-game.  Let's say the game showed, "thatwhowhichwhat<other texthere>"
4. Dictionary entries are usually (but not always) stored one entry after another with some null-byte in between (exception: fixed length strings).  So you can try text searching for the longest dictionary entry you found (here it's F01F=which), or you can text search/relsearch for "that?who?which?what" where ? is a wildcard.  If you have DTE (two characters per one script byte), then search without wildcards (like "thatwhowhichwhat").
5. Now you've hopefully found the table.  Dump the table from beginning to end and add it to your table (will take a few minutes of manual work).
6. Do a quick look over in Windhex for values you've missed.  Dump the text and confirm.

Once you've gotten this far...you need to identify pointers and that's generally enough info (script, pointer format, pointer locations) to get a complete script dump and to reinsert it.  Don't skip out on using Cartographer/Atlas because other ways are "easier", you'll pay for it in the end.

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #10 on: October 20, 2011, 08:53:00 pm »
To be honest, I don't need an easier method, as this alone will help me get better at ROM hacking. It'll be challenging, sure, but not impossible.

So, if I understand you correctly, I look up specific phrases/words using a wildcard, dump the tables with Monkey Moore, and then open up the tables with WindHex, right? And then from there, use WindHex to dump the script?

What did you mean by "normal entries"?
« Last Edit: October 21, 2011, 01:16:10 am by nintendo_nerd85 »

Klarth

  • Sr. Member
  • ****
  • Posts: 484
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #11 on: October 21, 2011, 04:25:08 pm »
To be honest, I don't need an easier method, as this alone will help me get better at ROM hacking. It'll be challenging, sure, but not impossible.

So, if I understand you correctly, I look up specific phrases/words using a wildcard, dump the tables with Monkey Moore, and then open up the tables with WindHex, right? And then from there, use WindHex to dump the script?

What did you mean by "normal entries"?
Normal (maybe basic entry is more appropriate) entries like: 10=a 11=b 12=c, etc.  DTE and dictionary entries like 80=de or 10F0=sword are not "basic" entries because they depend upon the 10=a 11=b, etc entries for their encoding.  So find the basic entries of your table first, then the DTE/dictionary entries.

You can dump partial tables with Monkey Moore...personally, I construct my tables by hand (except kanji tables).  Open up the table with Windhex (this allows you to see what's missing from your table).  You can use Windhex to dump the script for verification purposes.

But if you want to dump a script that you can insert, then find the pointers and use Cartographer.  It has more of a learning curve, but it'll save you much time in the end.

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #12 on: October 21, 2011, 06:30:25 pm »
Normal (maybe basic entry is more appropriate) entries like: 10=a 11=b 12=c, etc.  DTE and dictionary entries like 80=de or 10F0=sword are not "basic" entries because they depend upon the 10=a 11=b, etc entries for their encoding.  So find the basic entries of your table first, then the DTE/dictionary entries.

You can dump partial tables with Monkey Moore...personally, I construct my tables by hand (except kanji tables).  Open up the table with Windhex (this allows you to see what's missing from your table).  You can use Windhex to dump the script for verification purposes.

But if you want to dump a script that you can insert, then find the pointers and use Cartographer.  It has more of a learning curve, but it'll save you much time in the end.


Thanks! That cleared up a lot confusion. So when I search in Monkey Moore, I type something like "A through J*.." in the relative search bar, create the table (which is offset 0x1724A0 in this case), open it up in WindHex (after loading the ROM), then you find out the where the table and text begins/ends, then dump it with WindHex...?  Weird, because when I tried to dump the text yesterday, it told me it couldn't find the table in the ROM. *Sigh* Guess it's back to the drawing board. I know it's a learning process, and I'm sorry for being such a noob..  then again, I really shouldn't be so hard on myself.  :-[  And by pointer, do they look similar to offsets or is it just another word for offset?

Klarth

  • Sr. Member
  • ****
  • Posts: 484
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #13 on: October 21, 2011, 10:08:29 pm »
Ok, I'm going to give you a big hint in starting out.  I loaded up the ROM and looked for a word all lowercase (this is important) and several characters long.  I chose "perish" from the intro because it's not a common word (so it wouldn't be in a dictionary if there's dictionary compression...but even if it were, relsearch would find it in the dictionary, but not the script).  If you have a game with DTE, you often have to check many words before you get a correct result.

So I loaded up the ROM in Monkey Moore and searched for "perish" and came up with a good result (A=61 a=81 and "perish" at 0x60038 in the ROM).  I generated the table (keep in mind your A=61 will quite likely be wrong since we didn't relsearch for an upper case word...so 61 is just a guess by the program) and loaded the game+table into Windhex.  I went to 0x60038 in Windhex and you can see part of the text.  Try to complete the table on your own for practice.  You'll do most of this by hand (punctuation, identifying control codes, etc)...but for the dictionary entries, find where the dictionary is stored in-game and that'll make things much quicker.

nintendo_nerd85

  • Jr. Member
  • **
  • Posts: 65
    • View Profile
Re: Breath of Fire Text Extracting
« Reply #14 on: October 21, 2011, 10:23:27 pm »
Ok, I'm going to give you a big hint in starting out.  I loaded up the ROM and looked for a word all lowercase (this is important) and several characters long.  I chose "perish" from the intro because it's not a common word (so it wouldn't be in a dictionary if there's dictionary compression...but even if it were, relsearch would find it in the dictionary, but not the script).  If you have a game with DTE, you often have to check many words before you get a correct result.

So I loaded up the ROM in Monkey Moore and searched for "perish" and came up with a good result (A=61 a=81 and "perish" at 0x60038 in the ROM).  I generated the table (keep in mind your A=61 will quite likely be wrong since we didn't relsearch for an upper case word...so 61 is just a guess by the program) and loaded the game+table into Windhex.  I went to 0x60038 in Windhex and you can see part of the text.  Try to complete the table on your own for practice.  You'll do most of this by hand (punctuation, identifying control codes, etc)...but for the dictionary entries, find where the dictionary is stored in-game and that'll make things much quicker.

WHOA! That's what I'm talkin' about!  Thank you again!  ;D

Will update either later tonight or, well, after I get some more results.

For completing the table, I'll use something like WindHex (changing "Display Offset->SNES Lo-ROM") or Krupter. That should do the trick. I think.

Oh! Found something interesting - http://agtp.romhack.net/docs/tnrb/1-04.html

October 22, 2011, 12:43:38 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
Strange. WindHex doesn't let me enter the control commands (like <line break>) with the Table Editor, it doesn't do anything. Don't you load the ROM, then the table (the one using "perish"), then press CTRL+T? Yep. Doesn't let me insert the commands at all.
« Last Edit: October 22, 2011, 12:43:38 pm by nintendo_nerd85 »

DarknessSavior

  • Hero Member
  • *****
  • Posts: 5031
  • Darkness.
    • View Profile
    • DS: No, not the Nintendo one.
Re: Breath of Fire Text Extracting
« Reply #15 on: October 26, 2011, 11:21:37 pm »
If you're trying to enter linebreaks and stuff, you're going to have to enter it in hex. Hit tab to swap over to the hexadecimal portion of the editor, and simply enter the hex digit for the linebreak code.

Edit: Err, wait. You're trying to edit a table with WindHex? I recommend doing that in notepad (or JWPce if you're doing a game with Japanese characters).

~DS
Red Comet: :'( Poor DS. Nobody loves him like RC does. :'(
Sliver-X: LET ME INFRINGE UPON IT WITH MY MOUTH
DSRH - Currently working on: Demon's Blazon, Romancing SaGa, FFIV EasyType.
http://www.youtube.com/user/DarknessSavior