N64 Japanese To English Translation Tutorial

Discuss miscellaneous N64-related matter here.
Post Reply
krom
Posts: 72
Joined: Sat Oct 05, 2013 2:19 am

N64 Japanese To English Translation Tutorial

Post by krom » Fri Sep 05, 2014 7:20 pm

Firstly I would like to say thanks to Zoinkity who we are lucky enough to have on this forum, for inspiring me to look at N64 translation with the great Sin and Punishment - Successor of the Earth translation.
Also Zoinkity has given loads of useful info regarding N64 translation on the http://romhacking.net forum, which was a great help in getting me started.

I thought I would write a step by step tutorial on how I am making my Kira to Kaiketsu! 64 Tanteidan Japanese to English translation as I feel it will help others try to translate other N64 games, & some of the tips might even help on other systems =D
You can find my translation here: https://github.com/PeterLemon/N64/tree/ ... 0Tanteidan

Tools Used:
bass assembler - Required for Big-Endian 16-bit text character remaping & ROM injection http://byuu.org/programming/bass
cen64 N64 emulator - Required for accurate N64 emulation testing http://cen64.com
nemu64 N64 emulator - Required for N64 memory dumping & analysis
HxD Hex Editor - Required for binary file Hex searching, & can search for differences between 2 binary files http://mh-nexus.de/en/hxd
Google Translate - Required for me to translate the Japanese to English!! https://translate.google.com/
Japanese character recognition - Required for me to find harder Japanese characters. http://appsv.ocrgrid.org/nhocr

1. Find the Character Encoding & make our Character Tables:
Every game stores the text somewhere in the game code, either compressed or uncompressed. If the text is stored uncompressed it is really easy to inject new text code directly into the ROM.
The hard part is finding how each game encodes its text. The N64 makes things harder by using 16-Bit encoding of text, I found a great tip that worked for this game, which is why I decided to start to translate it.

A) Run the game using NEMU, & get upto the Player Name selection screen in the game.
Do not write anything & take a dump of the memory: Plugins/Debug Dump memory... Start 0, End 400000, Filename: NEMURAMDUMPNONE.bin Format: RAW - Big endian (n64)
You should have a file called NEMURAMDUMPNONE.bin that is 4194304 bytes in length.

B) Run the game again using NEMU, & get upto the Player Name selection screen in the game.
Type "ABCDEF" using the English font & take a dump of the memory: Plugins/Debug Dump memory... Start 0, End 400000, Filename: NEMURAMDUMPABCDEF.bin Format: RAW - Big endian (n64)
You should have a file called NEMURAMDUMPABCDEF.bin that is 4194304 bytes in length.

C) Compare the files NEMURAMDUMPNONE.bin & NEMURAMDUMPABCDEF.bin using a Hex editor & the 1st difference you will see is the point at which the game writes the English characters "ABCDEF" into N64 memory.
NEMURAMDUMPABCDEF.bin Offset $E1AC0: A3 C1 A3 C2 A3 C3 A3 C4 A3 C5 A3 C6
From this I could see A = $A3C1, B = $A3C2, C = $A3C3, D = $A3C4, E = $A3C5, F = $A3C6

D) Using NEMU, if you go back to the Player Name selection screen and type any Japanese or Special characters. You will be able to see how all the characters are encoded: Plugins/Debug Memory... Address: E1AC0 (Remember to press Refresh!!)
You will also see that the 1st byte of the character encoding designates the Font e.g English uses $A3, Japanese uses $A4 & $A5, and Special characters are at $A1 etc...
You can now make font tables that match every character from these font screens, and represent the exact text encoding, I have done this here:
English characters ($A3): https://raw.githubusercontent.com/Peter ... ableA3.txt
Japanese Characters ($A4 & $A5): https://raw.githubusercontent.com/Peter ... ableA4.txt & https://raw.githubusercontent.com/Peter ... ableA5.txt
Special Characters ($A1): https://raw.githubusercontent.com/Peter ... ableA1.txt

2. Translation & English Text Injection:
Using the character tables we created, we can create new tables of any Japanese text that use the exact same font we could see in the Player Name selection screen, I used Google Translate todo my translations, I just copy and paste the Japanese text.
Once you have some text translated, you can do a Hex search on the Japanese text in the ROM, I'll use the "Yes", "No" option from the Boot Screen as an example:
The Japanese for "Yes" is 2 characters long "はい", & the text encoding in my new table looks like this:

Code: Select all

Yes
$0E1E20 (ROM Offset)
A4 CF   A4 A4   00 00   00 00 | Original Japanese Hex
 #  は   #  い    #       #    | Original Japanese Text
 #  Y    #  e    #  s    #    | New English Text
A3 D9   A3 E5   A3 F3   00 00 | New English Hex
** Note that the original ROM has padded zeros to the end of the Japanese text so I can extend this to 3 characters for "Yes"
Also we can see on every text string we search for it uses $00 as an end of string special character.
So to inject the English text into the ROM, we just need to use the Hex editor, and at that address write the characters for "Yes" shown above, and you should see it appear =D

Here is the full Text Table for that whole Boot Screen section: https://raw.githubusercontent.com/Peter ... Screen.txt
ImageImage

3. English Text Injection using bass assembler:
bass is really great for translation work as it allows you to easily remap the ASCII set to new Big-Endian 16-Bit encoded characters, allowing you to make simple text injection macros.
You can find the bass source of my latest translation patch using all these features here: https://raw.githubusercontent.com/Peter ... teidan.asm

4. Dealing with other Japanese Characters:
Sooner or later you will come across Japanese text characters that you do not recognize from the tables you have made, and when you search for the characters that you do recognize in a word that contains one of these, you will find that there are other new font tables we need to make.
Also to get the correct UTF-8 character for translation, can be hard... I recommend using a Japanese character recognition engine, where you can just send a square picture of the character, & it will give you the top 5 characters, with #1 being the most likely character.
Here is an example image I made from the game to use with the http://appsv.ocrgrid.org/nhocr website: Image
Sometimes the more complex characters are not recognised, so scale the image up using gimp, and use the brush blur to get it into a more recognisable form: Image
Make you new Character Tables accordingly: All the tables I have made are here https://github.com/PeterLemon/N64/tree/ ... CharTables

5. Changing the Default Player Name Selection Font:
I wanted to make the default font English on the Player Name selection screen, luckily I spotted that each font is $12C bytes of binary data in the ROM so I just swapped each one accordingly:
ImageImage

This is the end of Part 1 of this tutorial for Part 2 I will try to show GFX ROM Injection for all those pesky Japanese only GFX tiles =D
I hope this helps anyone who wants todo similar stuff here are some more before & after screenshots of my translation work:
ImageImage
ImageImage
Last edited by krom on Fri Sep 05, 2014 8:45 pm, edited 1 time in total.

User avatar
MarathonMan
Site Admin
Posts: 691
Joined: Fri Oct 04, 2013 4:49 pm

Re: N64 Japanese To English Translation Tutorial

Post by MarathonMan » Fri Sep 05, 2014 8:26 pm

This is why I love working on the scene... when somebody comes up with OC like this, it's so interesting to read about.

Good job. :)

krom
Posts: 72
Joined: Sat Oct 05, 2013 2:19 am

Re: N64 Japanese To English Translation Tutorial

Post by krom » Fri Sep 05, 2014 8:47 pm

Cheers MarathonMan this is a very exciting time for the N64 scene =D

User avatar
Snowstorm64
Posts: 303
Joined: Sun Oct 20, 2013 8:22 pm

Re: N64 Japanese To English Translation Tutorial

Post by Snowstorm64 » Mon Sep 08, 2014 12:24 pm

This is really cool! But I have two questions:

1) All the software needed seems be available for linux, except for nemu64. Is there an viable alternative for linux? Otherwise...someone should write something similar to nemu64's dumping and analysis tools...yes, I'm looking at you, MarathonMan! :P

2) How much well could one person do with very limited programming knowledges? For example knowing where to look at for translating text and such things.
OS: Debian GNU/Linux Jessie (8.0)
CPU: Intel i7 4770K @ 3.5 GHz
Build: AVX (compiled from git)

krom
Posts: 72
Joined: Sat Oct 05, 2013 2:19 am

Re: N64 Japanese To English Translation Tutorial

Post by krom » Mon Sep 08, 2014 3:50 pm

Snowstorm64 wrote:This is really cool! But I have two questions:

1) All the software needed seems be available for linux, except for nemu64. Is there an viable alternative for linux? Otherwise...someone should write something similar to nemu64's dumping and analysis tools...yes, I'm looking at you, MarathonMan!

2) How much well could one person do with very limited programming knowledges? For example knowing where to look at for translating text and such things.
Cheers Snowstorm64 these are good questions I'll try to answer them for you:

1) You could use the linux MESS emulator with the N64 Driver, and use the debug option -debug to be able to dump the N64 memory but I have not tried this out yet...
Here is a link that explains howto do this using MAME but is the same for MESS : http://www.dorkbotpdx.org/blog/skinny/u ... _old_games

2) I think anyone could do a translation with very limited programming knowledge depending on the game, so if all the text is uncompressed in the ROM, then it is easy to inject it etc. My above tutorial shows how easy this can be =D

I have nearly finished Part 2 of this tutorial where I will show howto inject new English GFX tile data into the game =D

krom
Posts: 72
Joined: Sat Oct 05, 2013 2:19 am

Re: N64 Japanese To English Translation Tutorial

Post by krom » Mon Sep 08, 2014 11:49 pm

N64 Japanese To English Translation Tutorial: Part 2

In this tutorial I will explain howto find Japanese Language GFX Data used in N64 games, I will then show howto create New English Language GFX & Inject the New GFX Data back into the ROM.
You can find the updated translation here: https://github.com/PeterLemon/N64/tree/ ... 0Tanteidan

Tools Used:
bass assembler - Required for GFX data palette remapping & ROM injection http://byuu.org/programming/bass
mosaic GFX explorer - Required for searching data visually to find correct offset of GFX data http://byuu.org/programming/mosaic/
cen64 N64 emulator - Required for accurate N64 emulation testing http://cen64.com
nemu64 N64 emulator - Required for N64 GFX data analysis
Google Translate - Required for me to translate the Japanese to English!! https://translate.google.com/
Japanese character recognition - Required for me to find harder Japanese characters. http://appsv.ocrgrid.org/nhocr

1. Find out the Format & Resolution of the GFX Data:
Every game stores the GFX data somewhere in the game code, either compressed or uncompressed. If the GFX is stored uncompressed it is really easy to inject new GFX data directly into the ROM.
The hard part is finding out what format & resolution the specific GFX data you want to edit is using, & the N64 has many formats...
Here is a simple way I have found to do it:
Run the game using NEMU, & get upto where the GFX data appears on the screen in the game.
We are using the game Kira to Kaiketsu! 64 Tanteidan, & the GFX I want to change are the Title Screen options which are in Japanese.
Using the Nemu64 Graphics (combine debug) <LemD3D8.dll> GFX plugin, you can browse every texture that has been loaded to the screen:
Plugins/Configure Video Plugin... Press Next & you will see each tile appear in the top left hand corner of the emulation window.
Keep clicking next until you see the texture you want to edit, for me it was the texture 57 of 66.
This also gives you useful information that you will need to help find the GFX data:
Texture Resolution = 64x32
Texture Format = Color Indexed (CI) 8 Bits Per Pixel, which uses a Texture Look-Up Table (TLUT) which is essentially a palette of 16-Bit RGBA colors
From using this I also knew that each of the 2 options on the title screen, were broken up into 3 64x32 textures, so I would need to replace 6 textures for both options to be in English.
I also knew that each texture would be 2048 Bytes of GFX data (64*32 8BPP).

2. Find out the exact Offset of the GFX Data in the ROM:
Using the tool mosaic I will show you howto make a profile suited to searching the game data for the exact format and dimensions of the GFX we want to find.
Here is a profile I made to search the ROM for the GFX N6464x32TLUTRGBA8B.mosaic:

Code: Select all

// N64 64x32 TLUT RGBA 8B

offset: 0x000000 * 8
depth: 8
palette: f(256) n * 0x010101

blockWidth: 64
blockHeight: 32
blockStride: 64 * 32 * 8
If you then load up the ROM using mosaic, & use this profile, you will see that it can search the whole ROM as if it is a giant set of concatenated textures matching the spec we are trying to find.
It was really fast for me to find the GFX data in the ROM, so I zeroed in on the exact Offset of the 1st texture by changing the Offset in the mosaic profile until the texture looked perfect in the top left hand corner of the mosaic window.
To test I had really found the correct Offset of the GFX Data in the ROM, I filled 2048 Bytes with zero starting from the Offset, & checked in an emulator & saw that there was a Black Square in the correct place on the screen:
ImageImage
Using this knowledge I was able to find the correct Offsets for all the 6 Textures that are used in the Title Screen, this is what the screen looked like after I finished:
Image

3. Make the new English GFX Data & Inject GFX Data back into the ROM:
I used bass to remap the TLUT or Palette to the ASCII table then built up the new GFX by hand in 4 Stages.
I Then used bass to inject the GFX data back into the ROM:

Stage 1) I did the Outline of each letter using the Black color from the Palette:
Image
Stage 2) It was hard to see, so I Filled each letter with a single Fill color:
Image
Stage 3) I wanted the letters to match the Gradient of the original Japanese characters, so I Filled each letter with the Gradient Palette Colors:
Image
Stage 4) Finally I touched up the Edges of the Outline of each letter, here it is alongside the old Japanese Title Screen:
ImageImage

I hope this helps people get to grips with GFX Data Injection, the next tutorial will probably be about dealing with data that is Compressed =D

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest