News:

11 March 2016 - Forum Rules

Main Menu

How to Properly Script Dump for DS ROM?

Started by LittleTeaFlower, November 28, 2018, 05:25:04 PM

Previous topic - Next topic

LittleTeaFlower

Hello!

I am trying to translate a game for the first time as practice. What I do know is that a Hex Editor is close to being absolutely useless when it comes to translating due to you literally have to replace each byte. Therefore, I have a couple of questions:

1. Script dumping will assist me being able to translate better than a Hex Editor, correct? What I am trying to accomplish is editing a game script without having to replace each byte. (For example, in a Hex Editor, if I want to edit a line that has 10 bytes, I need to replace if with another or different 10 bytes).
-If yes then please skip answering the question.
-If no then please inform me of what method would be best route to accomplish my goal.

2. If I assumed correctly about the script dumping, I will be trying to use Cartographer and Atlas to script dump. HOWEVER, I am having trouble in figuring out the correct codes to put in the "ff1_commands". Therefore, the only message that shows up on the Cartographer .bat file is:

cartographer ff1.nes ff1_commands.txt ff1_script -m
Failed to open file ff1.nes
Press any key to continue . . .


I know this is not going to be easy, and I have read the "readme" guide Cartographer has included. However, due to my lack of knowledge on the technical terms used in the .txt file, it is a bit difficult to understand how to properly fill in the command .txt


Jorpho

If you have a very long script, then it would probably make sense to write a script dumper – except then you would have to figure out how to write the script dumper, and then debug the script dumper, and so on.  It's the same question encountered in a lot of automation tasks.


Rather than sending me off to look at the readme myself, perhaps you can post an excerpt from the .txt file regarding the terms you have difficulty understanding?
This signature is an illusion and is a trap devisut by Satan. Go ahead dauntlessly! Make rapid progres!

mz

Quote from: LittleTeaFlower on November 28, 2018, 05:25:04 PM
cartographer ff1.nes ff1_commands.txt ff1_script -m
Failed to open file ff1.nes
Press any key to continue . . .
I know this is not going to be easy
I'm not an expert on Cartographer (in fact, I've never used it), but I think that error message means that it has failed to open the file "ff1.nes", so I'd start by making sure you have a file named "ff1.nes" that can be opened in the same folder as the ".bat" file.
There has to be a better life.

LittleTeaFlower

Quote from: Jorpho on November 29, 2018, 09:33:37 AM
If you have a very long script, then it would probably make sense to write a script dumper – except then you would have to figure out how to write the script dumper, and then debug the script dumper, and so on.  It's the same question encountered in a lot of automation tasks.


Rather than sending me off to look at the readme myself, perhaps you can post an excerpt from the .txt file regarding the terms you have difficulty understanding?

Of course! I would rather not waste your time (I thank you for trying to help). The 'readme' section that I have trouble with reads exactly this:



3. Commands

--------------------------------------

#GAME NAME: This specifies the name of the game text is being dumped from.
The name specifed here will be included in the output file. This
name is only output once, at the beginning of each file.

#BLOCK NAME: Each block of text is assigned the name specified. This name
is output at the beginning of each block. Multiple blocks can
share the same name, so it is the user's responsibility to keep
track of which block is which.

When multiple files are specified at the command line, each block
is dumped to a separate text file. The filename is created by combining
the output base filename given at the parameter in the command line
with a block number used by Cartographer internally to identify each
block.

#TYPE: This allows the user to specify one of three possible dump types:
NORMAL, FIXED_STRING, FIXED_STRING && FIXED_LINE

NORMAL:
The table entries control the output of text, i.e. line
breaks are only output where the table entries specify.

FIXED_STRING:
This is for games that use a fixed string length. Line
breaks will be output when the specified number of bytes
have been read.

See #STRING LENGTH below.

FIXED_STRING && FIXED_LINE:
This is for games that use a fixed string and a fixed line
length. Line breaks will be output when the specified
number of bytes have been read.

See #STRING LENGTH and #LINE LENGTH below.

#STRING LENGTH: This specifies the length of the string in bytes. Once the number
of bytes specified have been dumped, a line break will be output
to the script file.

Only include this command if TYPE has been specified to either
FIXED_STRING or FIXED_STRING && FIXED_LINE.

#STRING END: This allows the user to specify whether or not they want to
include an artificial control code at the end of the string.

Yes or No option only.

#END CTRL: If Yes was specified for #STRING END, this command allows the
user to specify the artificial control code they want output.
If Yes was specified for #STRING END and this command is omitted,
the default artificial control code (END) is used.

#LINE LENGTH: Similar to #STRING LENGTH, this command specifies the length of
a line in bytes. Once the number of bytes specifed have been
dumped, a line break will be output to the script file.

#LINE END: This allows the user to specify whether or not they want to
include an artificial control code at the end of the line.

Yes or No option only.

#LINE CTRL: If Yes was specified for #LINE END, this command allows the
user to specify the artificial control code they want output.
If Yes was specified for #LINE END and this command is omitted,
the default artificial control code (LINE) is used.

#METHOD: This allows the user to specify one of three ways to dump the text:
POINTER, POINTER_RELATIVE RAW

POINTER:
Dump the text based on a pointer table.

POINTER_RELATIVE:
Same as a pointer, but this allows the user to dump text
using a pointer table that contains relative pointers
instead of absolute pointers.

POINTER_RELATIVE_PC:
Similar to POINTER_RELATIVE, except the base value is a relative
value instead of an absolute value.

See #RELATIVE PC below.

RAW:
A simple start to stop dump, like romjuice.

#POINTER ENDIAN:
Specifies the endianess of the pointers: BIG or LITTLE

#POINTER TABLE START:
Specifies the beginning address of the pointer table.

#POINTER TABLE STOP:
Specifies the ending address of the pointer table.

#POINTER SIZE:
Specifies the size of the pointer in bytes, e.g. 16-bit pointers
have a size of 2, 32-bit pointers have a size of 4, etc.

#POINTER SPACE: Specifies the number of bytes between each pointer to ignore.
This is useful for games that embed additional information between
each pointer. If pointers occur one after the other, specify
a pointer space size of 0.

#ATLAS PTRS: SE allows the user the option of dumping an Atlas compatible
script. This option specifies whether to include Atlas style
pointer writes, e.g. #W16($12345), in the dump or not.

Yes or No option only.

#BASE POINTER: This specifies the value to add to every pointer when using
the POINTER_RELATIVE dump method.

#RELATIVE PC: This specifies whether to use the address of the pointer as the
base pointer address. I've only seen one game that does this so far,
but there are probably more.

Yes or No option only.

#SCRIPT START: Specifies the beginning address for a RAW dump.

#SCRIPT STOP: Specifies the ending address for a RAW dump.

#TABLE: The filename of the table to use for dumping the script. Each
block specifies its own table file, thus allowing the user to
dump multiple blocks that use different tables at once, e.g.
dialogue and menu options.

#COMMENTS: Used to determine if the user wants each line of text in the
script to begin with Atlas style (//) comments or not.

Yes or No option only.

#END BLOCK: This specifies the end of the current block commands. This option
must be included, otherwise the commands for the next block will
overwrite the commands for the current block.

------------
Dependencies:
------------

Not every one of the above commands need be included. In fact, it's impossible to
include every command. Following is a list of commands that are dependent upon
certain options being specified in the previous command(s):

----- -----------------
#TYPE Required Commands
----- -----------------
FIXED_STRING #STRING LENGTH, #STRING END
FIXED_STRING && FIXED_LINE #STRING LENGTH, #STRING END, #LINE LENGTH, #LINE END

------- -----------------
#METHOD Required Commands
------- -----------------
POINTER #POINTER TABLE START, #POINTER TABLE STOP,
#POINTER SIZE, #POINTER SPACE, #POINTER ENDIAN,
#ATLAS PTRS

Note: These commands may be specified in any
order, but they are all required.


POINTER_RELATIVE #BASE POINTER plus the commands required for
POINTER method above.

POINTER_RELATIVE_PC #RELATIVE BASE plus the commands required for
POINTER method above.

RAW #SCRIPT START, #SCRIPT STOP

--------
Required:
--------

There are also certain commands which must be included:

GAME NAME, BLOCK NAME, TYPE, METHOD, TABLE, COMMENTS.

Additionally every block must end with an END BLOCK command.



What I have trouble with is understanding the "commands" section. I am supposed to use this for assistance in filling out the 'ff1_commands.txt' but it does very little to help me. If needed, I can send you the original 'ff1_commands'.txt and the 'ff1_commands.txt' I have modified to fit my game that I am trying to script dump.

LittleTeaFlower

@mz

Thank you for your response. Unfortunately, the Cartographer's zip does not include a ff1.nes as a visible file. (The .zip can be found here: https://www.romhacking.net/utilities/647/)
After doing some research about Cartographer and Atlas, I do believe I need to insert certain commands in the 'ff1_commands.txt' file to make a proper script extraction/dump. Which is where I mostly need assistance in. I wish there was more documentation about Cartographer; however, from what I have seen, it can be a bit tricky to use (especially for beginners such as myself).

KingMike

I presume that is a sample to show how to dump FF1. FF1.nes is not included because it's the ROM, which we expect the user to be able to obtain on their own.
I guess it is only an example of how to use Cartographer, not how to dump scripts in general.
Every game will be very different, especially between a NES and a DS game.
"My watch says 30 chickens" Google, 2018

LittleTeaFlower

#6
@KingMike

Oh my goodness thank you so much, I feel like such an idiot! FF1 stands for Final Fantasy 1, not some code. I see now. So in order for cartographer to work on my .nds ROM, I would need to program the Cartographer.bat file to open my ROM and not FF1's.
Okay, so that's a step in the right direction. Now my next question would be how on earth would I do that? Would I create another .txt file or just delete the old 'ff1_command.txt' file?

(EDIT): My biggest problem is the fact that when I press the Cartographer.exe, it pops up for a second and then automatically closes, so I assume this is a problem within the bat file that I need to fix and/or edit?

November 29, 2018, 04:33:13 PM - (Auto Merged - Double Posts are not allowed before 7 days.)

Alright, after doing some more research, I read this entire post at: https://www.romhacking.net/forum/index.php?topic=12837.0 which had practically the same question I did.
So I have figured out how to program the batch file to open my ROM, so now it looks like this whenever I open the batch file:

0230 - Bokujou Monogatari - Colobockle Station for Girl (Japan).nds Bokujou Monogatari_Commands.txt Bokujou Monogatari_Script -m
Usage: cartographer ROM.ext Command.txt Output.txt -s/-m
Cartographer was written by RedComet using Klarth's TableLib v1.0
Press any key to continue . . .


So now that I believe I have the batch file programmed correctly, I am onto the command file (which was my fearful main problem from the beginning). I'm trying to use the Final Fantasy's 1 command file as an example, but so far the only thing I have (embarrassingly so) is:

#GAME NAME: 0230 - Bokujou Monogatari - Colobockle Station for Girl (Japan)

I was wondering if I should just copy fully what Final Fantasy 1's command includes, regarding the #BLOCK NAME #TYPE and #METHOD. However, I am unsure of what the #SCRIPT START and #SCRIPT END means.

abw

Quote from: LittleTeaFlower on November 28, 2018, 05:25:04 PM
1. Script dumping will assist me being able to translate better than a Hex Editor, correct?
Yes. It takes some people a while to realize this, so you're already ahead of the game :D.

Quote from: LittleTeaFlower on November 29, 2018, 03:36:44 PM
Oh my goodness thank you so much, I feel like such an idiot! FF1 stands for Final Fantasy 1, not some code. I see now.
As somebody famous (Elon Musk, I believe) once said: Acronyms Seriously Suck :P.

Quote from: LittleTeaFlower on November 29, 2018, 03:36:44 PM
(EDIT): My biggest problem is the fact that when I press the Cartographer.exe, it pops up for a second and then automatically closes, so I assume this is a problem within the bat file that I need to fix and/or edit?
If you like, instead of running Cartographer.exe or Cartographer.bat directly from Windows, you can also open a command prompt first and then run Cartograper from there. It's basically the same thing, but you might find it fits your personal workflow better. Or not; it's just another option, so use whatever works best for you.

Quote from: LittleTeaFlower on November 29, 2018, 03:36:44 PM
So I have figured out how to program the batch file to open my ROM, so now it looks like this whenever I open the batch file:

0230 - Bokujou Monogatari - Colobockle Station for Girl (Japan).nds Bokujou Monogatari_Commands.txt Bokujou Monogatari_Script -m
Usage: cartographer ROM.ext Command.txt Output.txt -s/-m
Cartographer was written by RedComet using Klarth's TableLib v1.0
Press any key to continue . . .

It looks like your next obstacle has to do with command prompt (you might also see it referred to elsewhere as "shell") syntax. Basically, spaces separate the arguments that get passed to a program, so if the argument you want to pass contains a space itself, you'll need to wrap the argument in quotes, like so:

cartographer "0230 - Bokujou Monogatari - Colobockle Station for Girl (Japan).nds" "Bokujou Monogatari_Commands.txt" "Bokujou Monogatari_Script" -m


Quote from: LittleTeaFlower on November 29, 2018, 03:36:44 PM
So now that I believe I have the batch file programmed correctly, I am onto the command file (which was my fearful main problem from the beginning).
Cartographer is a general-purpose script extraction utility, so it provides a lot of different options for dealing with some of the very many different ways games use to store their scripts. In order to make the best use of it, you need to know a little bit about how your particular game stores its script. The sample ff1_commands.txt file gives examples of how you can deal with extracting two of those different ways, and the readme.txt file tries to explain what the commands mean. If you happen to have (or can find) a copy of the English NES Final Fantasy 1 ROM, you can rename it to ff1.nes, stick it in the same folder as Cartographer, run Cartographer.bat to see what it does, and play around with the commands and their values to see how that changes Cartographer's output. One of Cartographer's big selling points is that its output files require very little modification to become valid input files for Atlas, a general-purpose script insertion utility, so that when you use them together, extracting and re-inserting a script becomes much much less painful than it would otherwise probably be. There is a bit of a learning curve, and Cartographer does have a couple of quirky esoteric edge cases, but once you get the hang of it, it's generally pretty great.

Here's an alternate explanation of the commands you'll probably use most often, maybe it'll help:


#GAME NAME:The value you use here doesn't really matter; it just gets printed at the start of each output file so you can keep track of which game the output files are for.
#BLOCK NAME:This value also doesn't really matter; like GAME NAME, it's just there to help you keep track of what data the next chunk of output is for.
#TYPE:This one matters; "NORMAL" is almost always what you want to use here.
#METHOD:This controls how Cartographer goes about finding the text to dump, and your choice here determines what further commands are required. If you say RAW, Cartographer dumps everything between the file addresses given by SCRIPT START and SCRIPT STOP. If you say any of the POINTER options, then Cartographer reads a pointer table between the file addresses given by POINTER TABLE START and POINTER TABLE STOP and follows each of those pointers to find the text to extract. If you just say POINTER, then Cartographer assumes it doesn't need to do any math on the pointer values and just interprets them as file addresses. If you say POINTER_RELATIVE, then Cartographer will add the value of BASE POINTER to each of the pointer values it reads from the ROM and extract the text from the resulting file address. Technically there's also a POINTER_RELATIVE_PC option, but that's probably not what you want.
#POINTER ENDIAN:Different computer architectures interpret sequences of bytes in different orders, so this lets Cartographer know whether a pointer value of e.g. 0xAB 0xCD means 0xABCD (BIG) or 0XCDAB (LITTLE).
#ATLAS PTRS:If you plan on being able to insert your new script at some point, set this to "Yes"; even if you don't end up using Atlas, whatever you use instead is still going to need to know where the pointers are located and what text they point to, so having this available at the start will save you time later.
#TABLE:This is the name of the table file Cartographer will use to translate binary data into text. In general, games will encode their text however they want, so a table file provides a simple hex=text translation for a script extraction or insertion utility to use. Taking an example from ff1_ptr.tbl, in FF1's case, the byte 0x90 corresponds to the character "G", 0x60 corresponds to the pair of characters "we", and so forth. You'll need to figure out how your particular game translates binary data into text, but for an NDS game you might get lucky and have some standard character encoding like Shift JIS or UTF-8. Cartographer doesn't come with those built in, though, so you still need to provide a table file either way.
#COMMENTS:Whether you want each line of the script to start with "//", which Atlas interprets as a comment; it makes keeping the original text just above or below your new text easy.
#END BLOCK:This tells Cartographer the current block is done, so you can start a new block if you have more script to extract.

LittleTeaFlower

Wow! Thank you all so much! I finally got it to work! I appreciate your help!!