Romhacking.net

Romhacking => Personal Projects => Topic started by: Kunio on May 07, 2014, 07:36:33 am

Title: [NES] Word2Hex
Post by: Kunio on May 07, 2014, 07:36:33 am
What do you use to convert a word or text to its Hex value?
Well I always had hard time for doing this when translating a NES game!
So I decided to make this small program : Word2Hex
It is very easy to use but here is a brief instruction :
1. Complete the Hex Table according to your NES Pattern Table and save it
2. Type any word in the Text box
3. The program translates the word (or text) into the Hex values
4. Now you can copy and past the hex values into the Hex editor of the FCEUX to translate the game!

The program fully supports Persian language which is my native language and English Capital letters!
I also provide the source code in case of someone wants to develop it farther
I used Visual Basic 6 to write this program
Have Fun!  :P

(http://krauser.persiangig.com/Microbaz/post46/01.PNG)

Download Word2Hex version 1.2 (http://krauser.persiangig.com/Microbaz/post46/Word2HexV1.2.zip)
Title: Re: [NES] Word2Hex
Post by: Gideon Zhi on May 07, 2014, 12:07:52 pm
No disrespect, but isn't this pretty much exactly what script insertion utilities do, just on a much much smaller scale? Why would I use this instead of, say, Atlas?
Title: Re: [NES] Word2Hex
Post by: Kunio on May 07, 2014, 12:45:58 pm
Thanks for the comment.
I downloaded Atlas and read "Atlas.pdf" quickly but it seems very complicated!
I hate command line programs especially those that refuse to run directly on my windows XP, and it seems Atlas.exe is one of them!
Can you explain how does it work?
It seems it automatically can adjust the pointer!
But how can it judge about the fitting the text in a place?
Does it support Persian character and alphabet?
My program is good for beginners and manual translation.
But Atlas seems good for professional people
And after all I am still a beginner!  :-[

Do you think Atlas can handle such a translation :

(http://8pic.ir/images/03925830253074375235.png)

(http://8pic.ir/images/64310406468078022259.png)

I am translating every word manually by trial and error so that they can perfectly fit the space!
Title: Re: [NES] Word2Hex
Post by: Gideon Zhi on May 07, 2014, 01:26:01 pm
Atlas is pretty complicated to use, I agree, but it's also extraordinarily powerful. Maybe I'll write up a guide on how to use it at some point, but there are a few points I should make right now.

1) Learn how to use command-line apps. Atlas doesn't need a GUI, because all it does is take a text file (which the user provides) and shoves it into a ROM (which the user provides) then shows you some informational output about what it did. It can take a while to properly set up your text file, but once you're done, changing things around is as easy as running a simple command. You can even create a windows batch file to handle the command-line process, just redirect Atlas's output into, I dunno, _atlas.log or something.

2) Atlas can do all kinds of pointers so string length is generally much less of an issue than if you were inserting manually, but it relies on the user to set everything up properly in the text file.

3) I believe Atlas supports Unicode, so Persian characters should not be an issue.

4) If string lengths are really a concern, you can set a maximum insertion length for each segment in a #JMP command. It's #JMP(startoffset, endoffset); Atlas won't insert any text beyond endoffset.

I can't say for certain whether Atlas would be able to handle your game without getting my fingers into its guts myself, but my hunch is that it can. It can't handle every case but it was built to handle a lot of different and weird situations, and as such it's very, very powerful.
Title: Re: [NES] Word2Hex
Post by: BlackDog61 on May 07, 2014, 03:52:21 pm
Atlas is pretty complicated to use, I agree, but it's also extraordinarily powerful. Maybe I'll write up a guide on how to use it at some point.

My 3 cents: have a configuration (i.e. batch) set for most 2-3 common cases, per console. This would be ready-to-use = new user friendly. ;)
Title: Re: [NES] Word2Hex
Post by: Gideon Zhi on May 07, 2014, 06:16:48 pm
Batch wouldn't work; the only parameters Atlas takes are a rom name and a script name. Everything else is handled inside the script file. But yeah, that's sort of what I do. I have enough scripts that I, when needed, I can just copy the requisite setup information out of other files.

So for a LoROM SNES game, the top of my script file might look something like this:

Code: [Select]
#SMA("LOROM00")
#VAR(small,TABLE)
#VAR(large,TABLE)
#ADDTBL("8x8in.tbl",small)
#ADDTBL("8x16in.tbl",large)
#ACTIVETBL(large)
#EMBTYPE("LOROM00",16,$00)

#JMP($108000,$109E46)

SMA - Set machine addressing. There are a bunch of options but the easiest ones to use are the SNES ones. In this case, LoROM with bank numbers starting at 00 (instead of the 80 mirror addresses.)

VAR - create a variable. Takes a name and a type.
ADDTBL - adds a table file to a TABLE type variable.
ACTIVETBL - Specifies which TABLE variable to use for insertion. Really useful if you have multiple tables (like the italics in my SMT translation.)
EMBTYPE - Specifies a machine addressing, bit-size, and header/offset for embedded pointers. If you have something that looks like:

Code: [Select]
//[$08000]
Did you hear that the princess is sick?<$60><$51><$81><$93><$81>
//[$08151]
The best way to cure any sickness is beer!<end>
//[$08193]
Yeah, it's awful! She's been sick for a fortnight.<end>
(addresses completely made up, dialog loosely cribbed from Chaos World)

The idea here is that control 60 indicates a yes/no prompt, and each pair of bytes following it is a pointer to another string elsewhere in the file. In this case, a Yes choice points to 8151 ("The best way to cure any sickness is beer!") and a No choice points to 8193. The pointers here are embedded in the script - hence, "embedded" pointers. You'd set the block up to look something like...

Code: [Select]
//[$08000]
Did you hear that the princess is sick?<$60>
#EMBSET(0000)
#EMBSET(0001)

//[$08151]
#EMBWRITE(0000)
The best way to cure any sickness is beer!<end>

//[$08193]
#EMBWRITE(0001)
Yeah, it's awful! She's been sick for a fortnight.<end>

with the idea being that you have an #EMBTYPE(someaddressingmode, 16, 0) directive once before the EMBSET and EMBWRITE pairs. Then, when the game hits an EMBSET, it reserves 16 bits of space (two bytes) which it later fills in when it finds an EMBWRITE with the corresponding digit parameter (which, honestly, could be anything, so long as it's unique for each EMBSET and EMBWRITE pair.)

Beyond that you have basic writes: #W16(addr) - write 16 bit pointer to address addr, #W24(addr) - write 24 bit pointer, #WLB #WHB #WBB write low, high, bank bytes (of a potentially 24-bit pointer) to the corresponding address. You can also define custom pointers with bit-width, machine addressing type, and header/offset information. I'm pretty sure this is necessary for most NES games. These can be written with a #WRITE(pointertype, addr). I'll post some examples when I get home.

For whatever it's worth, Atlas is responsible for all of the following:
(http://agtp.romhack.net/images/projects/fmgh/33.png) (http://agtp.romhack.net/images/projects/darklaw/10.png)
(http://agtp.romhack.net/images/projects/srw2/16.png) (http://agtp.romhack.net/temp/lady020.png)
(http://agtp.romhack.net/images/projects/shodai/2.png) (http://agtp.romhack.net/images/projects/mysticark/6.png)
(http://agtp.romhack.net/extra/hourai/hourai008.png) (http://agtp.romhack.net/images/projects/madara/7.png)
So yeah, it can probably handle your stuff :) Though isn't Persian read right-to-left? I can't necessarily speak for something like that, but there's probably a way to get it working.
Title: Re: [NES] Word2Hex
Post by: Kunio on May 08, 2014, 03:59:09 am
@ Gideon Zhi
Would you accept this challenge :
In this game : Captain Tsubasa Vol. II - Super Striker (J) [!].nes
Translate the name of player number 10 (Tsubasa) with Atlas
つばさ --> سوبا

Here is the Persian characters for this word : (http://krauser.persiangig.com/image/PersianTsubasa.BMP)
I just want to make sure it can really handle it, if you can do it then I will learn to use Atlas for sure.
Title: Re: [NES] Word2Hex
Post by: Clippit on May 09, 2014, 05:16:30 pm
Hey, I think this is a great idea. It seems to be more "user-friendly" than the other program mentioned, which should be good enough for it to exist. Besides, Persian looks like a challenging language to translate to, so if this makes it easier... I guess it's alright.
Title: Re: [NES] Word2Hex
Post by: Airikita on May 12, 2014, 05:05:40 pm
This would be extremely useful for ROM translation projects... sometimes they take years because of how tricky it is to find all the text, time-consuming conversions just to find each string.
Title: Re: [NES] Word2Hex
Post by: Gideon Zhi on May 12, 2014, 05:48:14 pm
This would be extremely useful for ROM translation projects... sometimes they take years because of how tricky it is to find all the text, time-consuming conversions just to find each string.

No, not really. They do take years a lot of the time, but that isn't why.
Title: Re: [NES] Word2Hex
Post by: henke37 on May 12, 2014, 05:52:37 pm
This would be extremely useful for ROM translation projects... sometimes they take years because of how tricky it is to find all the text, time-consuming conversions just to find each string.
You imply that this tool would help with the string finding. It wont. In fact, it lacks all the important side features of such a tool.
Title: Re: [NES] Word2Hex
Post by: Kunio on August 07, 2015, 08:59:30 am
I know no one would care, but here is the new version :
Word2Hex v1.3 (2015/08/07) (http://s6.picofile.com/file/8204818034/Word2Hex_v1_3.zip.html)
Title: Re: [NES] Word2Hex
Post by: Zynk on August 07, 2015, 09:10:22 am
I know no one would care, but here is the new version :
Word2Hex v1.3 (2015/08/07) (http://s6.picofile.com/file/8204818034/Word2Hex_v1_3.zip.html)
Would you rather update that here on your utilitiy's page?  :huh:
http://www.romhacking.net/community/1260/