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

Author Topic: I have a newbie doubt regarding Cartographer  (Read 760 times)

Firionel

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
I have a newbie doubt regarding Cartographer
« on: December 01, 2019, 05:19:52 pm »
Hi there! I recently got an idea for a translation hack of japanese Final Fantasy I, and after looking online for a bit I found that Cartographer and Atlas seem to be the most reccomended tools for script extraction and insertion.

When you download Cartographer it includes some example doccuments ready to be used for extraction on American Final Fantasy I. I had some trouble at first (if you're wondering how I had trouble when all I had to do was download the rom and click on the .bat, that's a great question), but after playing around with the commands I seemed to have the basics down. Feeling a bit emboldened, I decided to see if I could alter the example doccuments and use them to extract the text from the Japanese Final Fantasy, since that was one of the steps for my project. So I changed the tables and the commands doc, and it worked! Except... there's something odd.

I produced two dump files: a raw dump of the game's text, and a pointers dump to be used with Atlas. The pointers dump seems to be a perfect extraction with no issues, and the first lines, for the record, look like this:

Code: [Select]
//GAME NAME: Final Fantasy 1 (NES)

//BLOCK #001 NAME: Dialogue Block (POINTER_RELATIVE)

//POINTER #0 @ $28010 - STRING #0 @ $28210

#W16($28010)
//そこには なにも ありません。[END]


//POINTER #1 @ $28012 - STRING #1 @ $28220

#W16($28012)
//ひかりのせんしたち‥‥よげんしゃ ルカ―ンの[LINE]
//いったとおりだ。わしの たのみをきいてくれ。[LINE]
//おうじょが ガ―ランドに さらわれたのだ‥‥[LINE]
//たのむ たすけだしてくれ![END]


//POINTER #2 @ $28014 - STRING #2 @ $28273

#W16($28014)
//よくぞ おうじょを たすけだしてくれた。 さあ[LINE]
//この きたに はしを かけよう。わしにできるのは[LINE]
//これくらいのことしかない。 たいりくに わたり[LINE]
//クリスタルの かがやきを とりもどすのだ!![END]


//POINTER #3 @ $28016 - STRING #3 @ $282D3

#W16($28016)
//セ―ラは いつも そなたたちのことを[LINE]
//きにかけている。[END]


//POINTER #4 @ $28018 - STRING #4 @ $282EF

#W16($28018)
//おうじょは おれのものだ! だれにも わたさん![LINE]
//ひかりのせんしだと。こざかしいやつらよ![LINE]
//この ガ―ランドが けちらしてくれよう![END]

The raw dump, however, seems to be missing some random huge chunks of text and seems way messier:

Code: [Select]
//GAME NAME: Final Fantasy 1 (NES)

//BLOCK #000 NAME: Dialogue Block (RAW)
//Block Range: $28210 - $2B590

//そこには なにも ありません。[END]

と。こざかしいやつらよ![LINE]
//この ガ―ランドが けちらしてくれよう![END]

いどきょうしてるじゃねえか。[LINE]
//やろうども やっちまえ!![END]

めざめになったぞ!![END]

はてて[LINE]
//しまった。たのむ みなみにある ぬまの[LINE]
//どうくつ から クラウンを とってきてくれ。[LINE]
//そうすれば この しろも もとどおりになる‥‥[END]

かやく じゃ。[LINE]
//これで うんが が できるぞ。[LINE]
//さあ しごとに でかけるか![END]

![END]

とける!![LINE]
//さあ おまえたちにも おしえてやろう。[END]

だ![END]

‥‥[LINE]
//おれいに いずみの そこに わく[LINE]
//くうきのみずを くんできましょう![END]

んなの すがたは まぼろしのように きえさった[END]

あ このカヌ―をつかい グルグかざんにゆけ![END]

プさせ かこに よみがえったのだ![END]

このコ―ネリアじょうを[LINE]
//まもるという たいやくを おおせつかって[LINE]
//いますデスッ![END]

かりのせんし‥‥?[LINE]
//あの クリスタルのでんせつの?![END]

My doubt is: why does this happen? For the reccord, the commands file looks like this right now:

Code: [Select]
#GAME NAME: Final Fantasy 1 (NES)

#BLOCK NAME: Dialogue Block (RAW)
#TYPE: NORMAL
#METHOD: RAW
#SCRIPT START: $28210
#SCRIPT STOP: $2B590
#TABLE: ff1_raw.tbl
#COMMENTS: Yes //start first line with //
#END BLOCK //remainder of comment placement
//is handled by control codes

#BLOCK NAME: Dialogue Block (POINTER_RELATIVE)
#TYPE: NORMAL
#METHOD: POINTER_RELATIVE
#POINTER ENDIAN: LITTLE
#POINTER TABLE START: $28010
#POINTER TABLE STOP: $28210
#POINTER SIZE: $02
#POINTER SPACE: $00
#ATLAS PTRS: Yes
#BASE POINTER: $20010 //add $20010 to each pointer to get
#TABLE: ff1_ptr.tbl //the string address
#COMMENTS: Yes
#END BLOCK

I assume there must be something wrong and I should be able to make it not look messy? Thanks so much in advance, and all help is appreciated.

abw

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
Re: I have a newbie doubt regarding Cartographer
« Reply #1 on: December 02, 2019, 08:13:48 pm »
That... looks bizarre. I actually tried this myself based on the table file on the wiki, but wasn't able to reproduce your results - my pointer and raw dumps came out with identical game text (after I realized the wiki had 00 and 01 backwards, that is :P), though of course the pointer dump also included all the extra pointer info. Would you be able to post links (not copy/paste, in case there's some kind of weird character encoding thing going on) to your table files?

As for cleaning up the raw dump (if you even have any use for the raw dump - the pointer dump is absolutely the one you want to use for insertion), I would do this outside of Cartographer. Assuming you have even a half-decent text editor, a couple of search-and-replace operations should be enough to reformat the raw dump in almost any way you would ever want to work with it.

Firionel

  • Jr. Member
  • **
  • Posts: 5
    • View Profile
Re: I have a newbie doubt regarding Cartographer
« Reply #2 on: December 03, 2019, 03:57:43 pm »
Huh... I figured it out.

These are the tables I used. Well, I've misplaced the exact table files I used cause I'm a mess, but these are identical.

https://drive.google.com/open?id=1Vz4rCXjAtQLKaD83Vm4XNEyHwrzzwj1g
https://drive.google.com/open?id=16ONtFOgtSZLZNlfT2SipynbV1bSZHhq6

Note that this is how they end:

Code: [Select]
01=[LINE]\¥
/00=[END]\¥\¥

The reason there's a slash (\) before the 00 is, plan and simple, because that's a format I'm used to seeing when it comes to letting software know about end of block codes, and it appears even in Data Crystal.

However, now that I check the original example files, it seems I was supposed to have the slash in the ptr table but not in the raw table. Doing so produces two perfect dumps: you can check this is true by editing those two files I shared.

Code: [Select]
//GAME NAME: Final Fantasy 1 (NES)

//BLOCK #000 NAME: Dialogue Block (RAW)
//Block Range: $28210 - $2B590

//そこには なにも ありません。[END]

ひかりのせんしたち‥‥よげんしゃ ルカ―ンの[LINE]
いったとおりだ。わしの たのみをきいてくれ。[LINE]
おうじょが ガ―ランドに さらわれたのだ‥‥[LINE]
たのむ たすけだしてくれ![END]

よくぞ おうじょを たすけだしてくれた。 さあ[LINE]
この きたに はしを かけよう。わしにできるのは[LINE]
これくらいのことしかない。 たいりくに わたり[LINE]
クリスタルの かがやきを とりもどすのだ!![END]

セ―ラは いつも そなたたちのことを[LINE]
きにかけている。[END]

おうじょは おれのものだ! だれにも わたさん![LINE]
ひかりのせんしだと。こざかしいやつらよ![LINE]
この ガ―ランドが けちらしてくれよう![END]

ああ あなたがたは ひかりのせんしたち‥‥[LINE]
たすけてくださって ありがとう!![END]

これは コ―ネリアのおうじょに だいだいつたわる[LINE]
リュ―トです。 ガ―ランドが わたしといっしょに[LINE]
しろから もちさったのです。 きっと なにかの[LINE]
やくにたつでしょう。 もっていってください。[END]

Code: [Select]
//GAME NAME: Final Fantasy 1 (NES)

//BLOCK #001 NAME: Dialogue Block (POINTER_RELATIVE)

//POINTER #0 @ $28010 - STRING #0 @ $28210

#W16($28010)
//そこには なにも ありません。[END]


//POINTER #1 @ $28012 - STRING #1 @ $28220

#W16($28012)
//ひかりのせんしたち‥‥よげんしゃ ルカ―ンの[LINE]
いったとおりだ。わしの たのみをきいてくれ。[LINE]
おうじょが ガ―ランドに さらわれたのだ‥‥[LINE]
たのむ たすけだしてくれ![END]


//POINTER #2 @ $28014 - STRING #2 @ $28273

#W16($28014)
//よくぞ おうじょを たすけだしてくれた。 さあ[LINE]
この きたに はしを かけよう。わしにできるのは[LINE]
これくらいのことしかない。 たいりくに わたり[LINE]
クリスタルの かがやきを とりもどすのだ!![END]


//POINTER #3 @ $28016 - STRING #3 @ $282D3

#W16($28016)
//セ―ラは いつも そなたたちのことを[LINE]
きにかけている。[END]


//POINTER #4 @ $28018 - STRING #4 @ $282EF

#W16($28018)
//おうじょは おれのものだ! だれにも わたさん![LINE]
ひかりのせんしだと。こざかしいやつらよ![LINE]
この ガ―ランドが けちらしてくれよう![END]


//POINTER #5 @ $2801A - STRING #5 @ $28332

#W16($2801A)
//ああ あなたがたは ひかりのせんしたち‥‥[LINE]
たすけてくださって ありがとう!![END]


//POINTER #6 @ $2801C - STRING #6 @ $2835A

#W16($2801C)
//これは コ―ネリアのおうじょに だいだいつたわる[LINE]
リュ―トです。 ガ―ランドが わたしといっしょに[LINE]
しろから もちさったのです。 きっと なにかの[LINE]
やくにたつでしょう。 もっていってください。[END]

...well, I fixed that. Now I'm not entirely sure how to use Atlas, so I would appreciate some guidance with that, but hey, one step at the time!


« Last Edit: December 04, 2019, 05:16:47 pm by Firionel »

abw

  • Sr. Member
  • ****
  • Posts: 329
    • View Profile
Re: I have a newbie doubt regarding Cartographer
« Reply #3 on: December 08, 2019, 09:38:29 pm »
Ah, yes, that'll do it. Cartographer's raw dump does some very weird things when your table file has end tokens. I had actually forgotten all about that :P.

The Cartographer pointer dump contains information about where each pointer is stored in the ROM and where it points to inside the script. To convert the Cartographer pointer dump into a working Atlas insert file, you'll need to add a few lines near the top of the file to tell Atlas what table file to use to convert the text back into binary, how to calculate the pointer values, and where to start inserting data. It's also a very good idea to set an upper bound on the address Atlas can write to so that you don't accidentally overwrite other code/data if your new script happens to take up more space than the old script.

For pointer calculations, the Atlas documentation seems to prefer setting up a custom pointer and using that for all the pointer writes, but it takes a couple of extra steps to convert Cartographer's output to use custom pointers, so I usually cheat a bit and just tell Atlas the ROM has a header whose size is the same as Cartographer's BASE POINTER value.

That should be enough to get Atlas working; if you uncomment all the script lines from the pointer dump, you should be able to insert the original script into (a copy of) the original ROM and end up with a file that is identical to the original ROM. After that, try changing some of the script text and do another insert - you should see your changes reflected in the ROM, and if you changed the length of any of the strings, you should see that all the subsequent pointers have had their values updated to match the new addresses of their corresponding string.

Code: [Select]
//GAME NAME: Final Fantasy 1 (NES)

// Define, load, and activate a TABLE.
#VAR(script_tbl, TABLE)
#ADDTBL("ff1_ptr.tbl", script_tbl)
#ACTIVETBL(script_tbl)

// Set a header of $20010 bytes, i.e. the difference between ROM and RAM addresses for pointer value calculations.
#HDR($20010)

// Jump to start of insertion point and set an upper bound on the address the inserted data is allowed to overwrite.
#JMP($28210, $2B58F)

//BLOCK #001 NAME: Dialogue Block (POINTER_RELATIVE)

//POINTER #0 @ $28010 - STRING #0 @ $28210
#W16($28010)
そこには なにも ありません。[END]

//POINTER #1 @ $28012 - STRING #1 @ $28220
#W16($28012)
ひかりのせんしたち‥‥よげんしゃ ルカ―ンの[LINE]
いったとおりだ。わしの たのみをきいてくれ。[LINE]
おうじょが ガ―ランドに さらわれたのだ‥‥[LINE]
たのむ たすけだしてくれ![END]

//POINTER #2 @ $28014 - STRING #2 @ $28273
#W16($28014)
よくぞ おうじょを たすけだしてくれた。 さあ[LINE]
この きたに はしを かけよう。わしにできるのは[LINE]
これくらいのことしかない。 たいりくに わたり[LINE]
クリスタルの かがやきを とりもどすのだ!![END]

//POINTER #3 @ $28016 - STRING #3 @ $282D3
#W16($28016)
セ―ラは いつも そなたたちのことを[LINE]
きにかけている。[END]

//POINTER #4 @ $28018 - STRING #4 @ $282EF
#W16($28018)
おうじょは おれのものだ! だれにも わたさん![LINE]
ひかりのせんしだと。こざかしいやつらよ![LINE]
この ガ―ランドが けちらしてくれよう![END]

//POINTER #5 @ $2801A - STRING #5 @ $28332
#W16($2801A)
ああ あなたがたは ひかりのせんしたち‥‥[LINE]
たすけてくださって ありがとう!![END]

//POINTER #6 @ $2801C - STRING #6 @ $2835A
#W16($2801C)
これは コ―ネリアのおうじょに だいだいつたわる[LINE]
リュ―トです。 ガ―ランドが わたしといっしょに[LINE]
しろから もちさったのです。 きっと なにかの[LINE]
やくにたつでしょう。 もっていってください。[END]