ROM Hack Few questions about programming.

WataruKun

Rom translator.
OP
Banned
Joined
Sep 12, 2009
Messages
616
Trophies
0
Website
Visit site
XP
130
Country
United States
Well, I've decided that I'm pretty much done relying on others for script programs and have realized the fact, that the only way I'm going to get what I want is to learn how to program them myself. I already know Japanese, but it seems I'll need to know more than that if I'm going to finish this translation alone. Also, if I learn how to make these, I wouldn't have to depend on anyone else who already knows how. So I have a few questions...

1. Writing a script extractor.

What would be the basic logic behind writing one of these? I'm asking because I've never written one. Could you basically tell the program the offset where the script ends and the offset where it begins? By 'it' I mean the script by the way. What would you NEED to know about the file structure to write a script extractor? Is the script extractable if the game has no pointers? I'd like to know the answer to this stuff.

2. A script inserter.

What's the basic logic behind a script inserter? What do you need to know about the file structure before you can make one? How should a script inserter work?

3. A script editor.

How would someone make a script editor, you know, a program that edits the script? How could you get the program to actually replace text? How could I figure where each text message is? I'd like to know that. And also, how do you make it so that the text editor automatically repoints a particular byte, after you've edited the text?
 

KingVamp

Haaah-hahahaha!
Member
Joined
Sep 13, 2009
Messages
13,472
Trophies
2
Location
Netherworld
XP
7,873
Country
United States
Can not answer your questions,but i have to say, should be mad at you right now because of the trick , but I lol and is not mad at all. Weird O.o
tongue.gif
 

kevan

Imagination rules the world
Member
Joined
Dec 4, 2009
Messages
1,378
Trophies
0
Age
29
Location
Place
Website
Visit site
XP
496
Country
Now you just deserve to be trolled

Im trolling
Im trolling
Im trolling
Im trolling
Im trolling
Im trolling
Im trolling
Im trolling
Im trolling
Im trolling
 

azerty1

Well-Known Member
Member
Joined
Mar 22, 2009
Messages
160
Trophies
0
Age
29
Website
Visit site
XP
99
Country
Canada
WataruKun said:
Kidding!




Now let's get on to the real topic.

Well, I've decided that I'm pretty much done relying on others for script programs and have realized the fact, that the only way I'm going to get what I want is to learn how to program them myself. I already know Japanese, but it seems I'll need to know more than that if I'm going to finish this translation alone. Also, if I learn how to make these, I wouldn't have to depend on anyone else who already knows how. So I have a few questions...

1. Writing a script extractor.

What would be the basic logic behind writing one of these? I'm asking because I've never written one. Could you basically tell the program the offset where the script ends and the offset where it begins? By 'it' I mean the script by the way. What would you NEED to know about the file structure to write a script extractor? Is the script extractable if the game has no pointers? I'd like to know the answer to this stuff.

2. A script inserter.

What's the basic logic behind a script inserter? What do you need to know about the file structure before you can make one? How should a script inserter work?

3. A script editor.

How would someone make a script editor, you know, a program that edits the script? How could you get the program to actually replace text? How could I figure where each text message is? I'd like to know that. And also, how do you make it so that the text editor automatically repoints a particular byte, after you've edited the text?
well...first off, what's your experience with programming and how comfortable are you with it? i would suggest using C# for these kinds of tools since it works on any microsoft computer with the .NET framework, it's faster than java and it's what everyone else is using...i'll post some form of a template in a minute or two...

here's a very, very simple extractor. it's the shell of what my StrikeWitchesExtractor was before i had to mess with pointers in the headers. it is really simple code. it looks for the text and then writes the text to file. this was the first version of the extractor and the final one ended up with another 50 or so lines in total to make it more accurate, but this is the essence of the kind of extractors I make...darthnemesis' are much better and i'm pretty sure he uploads his source on his mediafire channel.

CODEprivate Encoding encoding = new Encoding("SHIFT_JIS");

public static void extract(byte[] bytes, string name)
{
ÂÂÂÂTextWriter writer = new StreamWriter(name.Replace("scd", "txt"));//writing stuff to text files.
ÂÂÂÂint length= 0;ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ//length of the line
ÂÂÂÂfor (int i = 0; i < bytes.Length; i++)
ÂÂÂÂ{
ÂÂÂÂÂÂÂÂif (((bytes == 0x34) && (bytes[i + 1] == 0x00)) && (bytes[i + 3] == 0x00))//3400xx00, where xx is the length of the string, is how a textbox was initialized
ÂÂÂÂÂÂÂÂ{
ÂÂÂÂÂÂÂÂÂÂÂÂlength = int.Parse(Convert.ToString(bytes[i + 2]));ÂÂÂÂÂÂÂÂÂÂÂÂ//in this case, the line length is 2 bytes before the text.
ÂÂÂÂÂÂÂÂÂÂÂÂwriter.WriteLine((int) (i + 2));ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ//write the index in the array to file
ÂÂÂÂÂÂÂÂÂÂÂÂwriter.WriteLine("Length=" + length)ÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂÂ//write the length to file
ÂÂÂÂÂÂÂÂÂÂÂÂwriter.WriteLine(encoding.GetString(bytes, i + 4, count));ÂÂÂÂÂÂÂÂ//write the line itself to file.
ÂÂÂÂÂÂÂÂ}
ÂÂÂÂ}
ÂÂÂÂwriter.Close();
}
 

Toni Plutonij

*has TrolleyDave & tiny p1ngy on moderating shelf!
Former Staff
Joined
Dec 22, 2007
Messages
8,149
Trophies
1
Age
36
Location
Depths of Nuclear powerplant
XP
700
Country
Croatia
Next time you do something like this, you'll get suspended from posting for few days and your thread will be closed.

Are you really so desperate for attention or what?

You do something like this, and wander why people post offtopic or flame..
 

FAST6191

Techromancer
Editorial Team
Joined
Nov 21, 2005
Messages
36,798
Trophies
3
XP
28,282
Country
United Kingdom
We had a big discussion on the various programming languages available on the last few pages of the rom hacking docs:
http://gbatemp.net/index.php?showtopic=733...60&start=60
I am sure if you poke around romhacking.net tools you can get some source code as well which will probably be far easier than this (although the DS file changes things a bit).

I will however say while these sorts of tools are useful if it is just you and obviously you know how to hack then you may not need these tools as for the most part they are intended for non programmers so as to not have to worry about text formatting.

You asked about the file structure, arguably you need to know
the text bit length (is it 8 or 16 bits per character and are there any exceptions: I have seen 8 bit formatting on 16 bit text, vice versa and other flags to increase bit length for text)
What are the wildcards; character names are often deferred to a string or something "you have [so much] gold remaining"
You need not know the entire text display routine but a good chunk is essential.
If it has pointers in the file (the DS has several examples end to end, fixed length, pointers in binary, pointers in another file) then know them but they are not essential to be able to program for. If it has no pointers it will likely still be bounded by a 00 (in fact I normally search for such things when trying to figure out pointers)

I am guessing you already understand tables; tables are a crude matrix (something every modern programming language adores whether it tells you about them or not)

Script extraction is easy enough, you have two main types:
Internal formats display: while you can do as below internally these take the binary files and have an inbuilt converter for display but edit using the internal formats. There are

Conversion extractor: this will convert to a text document (maybe with xml stylings rather than hex formatting; say bounding some text with 24 makes it bold, your app can then make it {b} {/b} or something) for editing with whatever editor you like.

Script insertion is the reverse of the extraction although while you can do things all at once most inserters are little more than a conversion from text mounted on top of a "copy /b" type command. Recalculation of the pointers is then kicked to another app or another side of the app.

"A script editor."
Binary to ascii is no harder than ascii to binary.

My suggestion, in addition to the source code from romhacking.net also try something truly trivial like making an app for NSMB (the text is unicode, simple pointers, (actually NSMB format text is used in several games but nowhere near as common as SDAT for sound or even the graphics formats).


Have fun.
 

WataruKun

Rom translator.
OP
Banned
Joined
Sep 12, 2009
Messages
616
Trophies
0
Website
Visit site
XP
130
Country
United States
QUOTE said:
well...first off, what's your experience with programming and how comfortable are you with it? i would suggest using C# for these kinds of tools since it works on any microsoft computer with the .NET framework, it's faster than java and it's what everyone else is using...i'll post some form of a template in a minute or two...
Pretty much a beginner in C#. Thanks for the example, that should help me.

FAST6191 said:
We had a big discussion on the various programming languages available on the last few pages of the rom hacking docs:
http://gbatemp.net/index.php?showtopic=733...60&start=60
I am sure if you poke around romhacking.net tools you can get some source code as well which will probably be far easier than this (although the DS file changes things a bit).

I will however say while these sorts of tools are useful if it is just you and obviously you know how to hack then you may not need these tools as for the most part they are intended for non programmers so as to not have to worry about text formatting.

You asked about the file structure, arguably you need to know
the text bit length (is it 8 or 16 bits per character and are there any exceptions: I have seen 8 bit formatting on 16 bit text, vice versa and other flags to increase bit length for text)
What are the wildcards; character names are often deferred to a string or something "you have [so much] gold remaining"
You need not know the entire text display routine but a good chunk is essential.
If it has pointers in the file (the DS has several examples end to end, fixed length, pointers in binary, pointers in another file) then know them but they are not essential to be able to program for. If it has no pointers it will likely still be bounded by a 00 (in fact I normally search for such things when trying to figure out pointers)

I am guessing you already understand tables; tables are a crude matrix (something every modern programming language adores whether it tells you about them or not)

Script extraction is easy enough, you have two main types:
Internal formats display: while you can do as below internally these take the binary files and have an inbuilt converter for display but edit using the internal formats. There are

Conversion extractor: this will convert to a text document (maybe with xml stylings rather than hex formatting; say bounding some text with 24 makes it bold, your app can then make it {b} {/b} or something) for editing with whatever editor you like.

Script insertion is the reverse of the extraction although while you can do things all at once most inserters are little more than a conversion from text mounted on top of a "copy /b" type command. Recalculation of the pointers is then kicked to another app or another side of the app.

"A script editor."
Binary to ascii is no harder than ascii to binary.

My suggestion, in addition to the source code from romhacking.net also try something truly trivial like making an app for NSMB (the text is unicode, simple pointers, (actually NSMB format text is used in several games but nowhere near as common as SDAT for sound or even the graphics formats).


Have fun.
Thanks for that information man. You've told me everything I needed to know. Now I should have no trouble writing one of these once I learn coding. Thanks!
 

rastsan

8 baller, Death Wizard,
Member
Joined
May 28, 2008
Messages
1,002
Trophies
1
Location
toronto
Website
rastsan.wordpress.com
XP
413
Country
Canada
go to microsoft download there software for beginner programmers visual basic visual c c++ whatever and practice with there begginer stuff (2 years later and it still makes no sense to me oh well)
you will need that stuff to compile the source code to something useful. you can get by with other stuff but at least microsofts free stuff comes with reasonable how to and help forums. ahem


at least someone answered, i'm kinda scared to post now if this is the response I'll get... geez thank you WataruKun for at least trying to ask. You didn't get the typical 'use the search function maybe you will find something that way' response

maybe like myself he literally has no programming experience and getting source code means nothing to him (like me) as I would heave no idea what to do with it.
Just being a little impatient, isn't a big thing.

Watarukun My 7thdragon translation is going real slow as I have to short form my insertions and my table files (yes there are two so far) are incomplete.
If the text doesn't fit big deal if it makes minimum sense then that is fine especially if this is your first translation anyone who wants to play it will have to deal with the shrtfrmtxt (short form text) if they don't like it ask a mod to close your forum after posting your patch and let the complainers be.... that is what I am going to do.
once i give up trying to dissassemble and reassemble an object or elf file for a game translation that I only took cause it looked easy (for a first project)

YOU DON"T NEED IT TO BE PERFECT JUST PLAYABLE
(p.s. take a look at the other patches okay you will see what I mean) shiren 2 being a prime example not that isn't a great translation
And yes doing it yourself means taking whatever time you need to do it yourself
flaming him for a serious question geez....
 

HernanZh

Well-Known Member
Member
Joined
Apr 6, 2008
Messages
178
Trophies
0
Age
36
Location
The Netherlands
Website
www.heigames.com
XP
165
Country
Netherlands
Hi. Go to romhacking.net. There are already general tools for script dumping and inserting.
Romjuice: Good tool for dumping scripts. Not many options, but gets the job done.
Atlas: Great tool for inserting scripts. Very flexible. Bad readme file, if you have questions about this one, I can probably answer them.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • No one is chatting at the moment.
    Sicklyboy @ Sicklyboy: *teleports behind you* "Nothing personnel, kiddo" +1