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

Author Topic: The How's of Script Dumping  (Read 6814 times)

speaker

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
The How's of Script Dumping
« on: February 20, 2012, 11:53:46 am »
Hey there! I'm Speaker, and I began work on translating Rockman.EXE: Operate Shooting Star roughly two weeks ago.

This is my first time romhacking OR translating much of anything, but with the leftover materials and advice of the game's previous translator, I've been able to get off the ground and can now edit both the text and graphics of the game at a rather steady pace. xD

Editing text manually, however, is quickly becoming a massive chore. For all it's very much doable, the thought of being able to pull text out and put it back without running through text pointers in is very enticing! >>;

I'm not asking anyone to write a program for me, now! I know me some Javascript, so learning a new programming language won't be an ungodly hurdle of impossible proportions. xD

What I'd like is a push in the right direction-- to know what language I should be trying to pick up, to know of any pre-existing tutorials or the like that might be lying around (especially given my editing knowledge's limited to playing with hexadecimal in the Overlays, and I wouldn't know how to tell a program to look and edit accordingly without, uh, knowing how to tell it to look and edit accordingly), or anything off the top of anyone's head that might be of any help!

Thanks in advance for any and all help! ^_^

Pennywise

  • Hero Member
  • *****
  • Posts: 2363
  • I'm curious
    • View Profile
    • Yojimbo's Translations
Re: The How's of Script Dumping
« Reply #1 on: February 20, 2012, 02:22:38 pm »
You can probably use a program like Cartographer if the game doesn't do anything "special." What that'll do is dump the text and pointers from the table. From there you can use a program like Atlas to insert your script and update the pointers with just one click(Atlas is command line so a batch file is recommended).

speaker

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: The How's of Script Dumping
« Reply #2 on: February 22, 2012, 09:42:51 pm »
I'm grateful for how quickly you responded! However, I fear the learning curve might be a bit steep for me! XD

I've pulled out Cartographer and set it up to run off the .bin with the necessary table, and have it set to check for the pointer table only where it is (according to the "offset" in WindHex...?). All very well and good!

I recieve two errors when running Cartographer: the first, that it can't load the table. Second, "Hex token part of the string is already in the table. Multple tries causes dumping confliction."

At which point it stops.

*scratches head*

I'm moderately well assured I've gotten the commands file right, but still, here's how EXEOSS's pointers work:

The pointer tables are 16-bit and relative. For example, 000F would point out a string's starting point 15 places from the, uh, digit immediately before the pointer table in question. Strings have in-line ending markers, and the first strings starts immediately after the last pointer.

Knowing this, I told Cartographer the method was Pointer_relative, Little Endian (though I tried Big too, on a whim), and "normal" for type. Pointer size of 02, pointer space of 00... and I gave WindHex's appropriate "offset" for the table's start point and stopping point.

Have I done something outrageously wrong? xD And should I be doublechecking my table for anything unusual that's got Cartographer so unhappy? o_o;

KingMike

  • Forum Moderator
  • Hero Member
  • *****
  • Posts: 7102
  • *sigh* A changed avatar. Big deal.
    • View Profile
Re: The How's of Script Dumping
« Reply #3 on: February 22, 2012, 11:24:56 pm »
I recieve two errors when running Cartographer: the first, that it can't load the table. Second, "Hex token part of the string is already in the table. Multple tries causes dumping confliction."

At which point it stops.

*scratches head*

Did you give the same hex value two different values, something like
Code: [Select]
10=A
10=B
?
"My watch says 30 chickens" Google, 2018

speaker

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: The How's of Script Dumping
« Reply #4 on: February 23, 2012, 06:14:19 pm »
That was it exactly-- in two places, no less! XD Ah, kanji...

My next problem is one I hope will be just as easily resolved!

Cartographer is now giving me a .txt file with the appropriate text and locations (except how it continues to give me the one hex number into the very same table for the first pointer, but that's easily worked around!). However, I can't figure out how to tell it where the strings in question end!

They end in-line with a specific hex call. Cartographer's readme mentions the use of "#STRING END: Yes" resulting in (END) being taken as the end, right? I've adjusted my table accordingly, but Cartographer claims "STRING END" is an invalid command all the same.

I've fiddled, but I haven't gotten much of any other kind of response. I'm sorry for being high maintenence, but if anyone can tell me what I'm doing wrong, I'd be very appreciative! xD;

tashi

  • Jr. Member
  • **
  • Posts: 66
    • View Profile
Re: The How's of Script Dumping
« Reply #5 on: February 24, 2012, 09:25:10 pm »
In my personal, limited experience, I don't tell Cartographer anything about pointers. I just dump out the straight script by giving it blocks such as below.

Code: [Select]
#BLOCK NAME: Main Dialogue
#TYPE: NORMAL
#METHOD: RAW
#SCRIPT START: $7D0FD
#SCRIPT STOP: $7EC8C
#TABLE: caspertable.tbl
#COMMENTS: Yes
#END BLOCK

Then, when I insert with Atlas, I tell it where the pointer table is, the first pointer value, and for which <end> or [end] or whatever to write a new pointer.

Code: [Select]
#VAR(Ptr, CUSTOMPOINTER)
#CREATEPTR(Ptr, "HIROM", $0, 16)
#VAR(PtrTbl, POINTERTABLE)
#PTRTBL(PtrTbl, $7CF8B, 2, Ptr)
#JMP($67300,$6FFFF)
#AUTOWRITE(PtrTbl, "<end>")
#AUTOWRITE(PtrTbl, "<end1>")

FAST6191

  • Hero Member
  • *****
  • Posts: 3105
    • View Profile
Re: The How's of Script Dumping
« Reply #6 on: February 26, 2012, 01:45:32 pm »
The others are taking the proper way but I prefer to cheat.

It might not be that useful here but most text for DS games like this will end each section with a 00 or something easily searchable for (if not and in a pinch you usually will still have a fullstop)- generate a list of these for your edited text plus anything else pointers are there for (sometimes I see them for variables- "it costs ???? gold to stay the night in this inn" and such) or clean it up if you have to.
This is usually enough for most games but if you have relative pointers or something offset (or if the pointer technically points to 00+1) then I tend to cheat and bust out the spreadsheet- they might be relative but they should be equally spaced (better end to end) so you can just do something like take 4,8,12,16 from each in a list.

speaker

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: The How's of Script Dumping
« Reply #7 on: March 03, 2012, 01:06:53 pm »
I... what?

Ah, my head hurts! Fast, I REALLY don't follow. xD; I have used a spreadsheet to manually write down what each pointer should be in the order it should be in before, and then manually type it all in, but the pointer's aren't equally spaced. There is a set <END>, but... generate...? ><;;

Tashi! I am a miserable failure who would love some insight:




I have no idea where to go from here. XD

I'm struggling with understanding how Atlas works. In fact, I've gotten the same message I got from Cartographer, haven't I? Invalid command. Heh.

Throw me a bone, anyone?

EDIT: I should explain more. ^^;

Both Cartographer and Atlas are starting to come across as incredibly finicky. I wasn't able to copy/paste a command from either readme to where each program calls for it, and I don't understand why that's the case in both instances. While a blind solution would be welcome, as Tashi's offered, if I don't understand what's going on, then I worry I'll end up making a post here every time I run into an error message. XD

I'm asking for someone who'd be willing to sit down and give me a quick rundown, honestly. Readme instructions have been giving me errors, and I can't find any docs on them onsite. I'm in a position where I might be handing scripts over to someone for retranslation down the line, so being able to understand how to call on Cartographer's generated Atlas points would be a real treat, but I'll take whatever you have to offer.

I-I'm sorry about all the hassle. xD
« Last Edit: March 03, 2012, 05:33:20 pm by speaker »

Vehek

  • Full Member
  • ***
  • Posts: 207
    • View Profile
Re: The How's of Script Dumping
« Reply #8 on: March 03, 2012, 05:54:33 pm »
The quote marks in the ADDTBL command are the wrong type. While the Atlas readme may use curved quotes (those quotation marks where the opening and closing quotes are distinct), Atlas actually only supports straight quote marks in commands as far as I know. Change them to the type used in the other commands, and that error should be gone at least.

speaker

  • Jr. Member
  • **
  • Posts: 7
    • View Profile
Re: The How's of Script Dumping
« Reply #9 on: March 03, 2012, 06:09:25 pm »
Thank you. ^^

I wouldn't have thought there'd be a difference! Strange, eh?

I've adjusted the Atlas file accordingly. I'm getting a new error message now: that my table file is incorrectly formatted on line 7. *shakes head*

But there's no difference in formatting between line 7 and line 6.

Line 6: 05=4
Line 7: 06=5

...does Atlas not take Thingy tables? xD;;

FAST6191

  • Hero Member
  • *****
  • Posts: 3105
    • View Profile
Re: The How's of Script Dumping
« Reply #10 on: March 03, 2012, 07:48:37 pm »
I have not got the rom to hand but grabbing a random BMG file I had kicking around the general idea is as follows
One basic hex editor shot.

http://gbatemp.net/uploads/gallery/album_143/gallery_32303_143_148556.jpg
Look at 01b0 hex and you will see 0000
A bit of fiddling and one search for every 0000 brings a nice list. One short sample of the search results.

0168
01B0
024C
02F8
044E
0582
06B6
0788
082C
095E
0AA4
0BAC
0CC6
0DCA
0DCC
0EAE
0F54
1018
112E
1226


One nice sample of the pointer section

00000030 0002 0000 ....
00000034 004A 0000 .J..
00000038 00E6 0000 ....
0000003C 0192 0000 ....
00000040 02E8 0000 ....
00000044 041C 0000 ....
00000048 0550 0000 .P..
0000004C 0622 0000 ."..
00000050 06C6 0000 ....
00000054 07F8 0000 ....
00000058 093E 0000 .>..
0000005C 0A46 0000 .F..
00000060 0B60 0000 .`..
00000064 0C64 0000 .d..
00000068 0C66 0000 .f..
0000006C 0D48 0000 .H..
00000070 0DEE 0000 ....
00000074 0EB2 0000 ....
00000078 0FC8 0000 ....
0000007C 10C0 0000 ....
00000080 11F8 0000 ....
00000084 12C2 0000 ....
00000088 13E2 0000 ....

Now the text section starts at 0160 hex so add that to the basic values.

162
1AA
246
2F2
448
57C
6B0
782
826
958
A9E
BA6
CC0
DC4
DC6
EA8
F4E
1012
1128
1220
1358
1422
1542

Almost but looking at it and taking the new list from the 0000 location it appears my initial offset was out by 6. Anyhow one mathematical relation between the 0000 values and the pointers. Everything else is so much search, search again when string lengths have changed, hex to dec conversion, basic maths, use of the fill command and maybe a touch of gymnastics with a find and replace command (add a column of 0000 and wipe out all the tabs, spaces, line breaks and whatever else is in the way of a single length of hex).
If it was a relative pointer section (each pointer counting from its location) it will usually add at regular intervals as each pointer will usually have a given length/amount of padding so add in a times table (0,4,8,12,16....) give or take offsets at a good point and all is good once more.

One word of advice- some games are fans of having markup and placeholders so be aware of this and have a quick parse of your expected results (simple differences between the search and expected is usually enough) but skipping a few rows out is not a hard thing to do.

As previously mentioned the methods the others describe will work on anything you pull apart enough to figure out to built the extraction/calculation for but why mess around with such things when developers often provide a nice alternative like the above. If the developers were not nice enough to provide a 0000 to latch onto then kick it to language and do a search for full stops or something (even Japanese has a measure of it).

0155
0165
024A
02AA
02D4
02EE
02F6

(being wifi related I got tripped up by www"." but it makes a nice example of the sort of thing you might see when you have placeholders or markup).