The Patching Process for Puyo Puyo Chronicle
Anonymous asked:I’m not sure how classified this is but what programs did you use when making the patch for Puyo Chronicle/3ds games in general? I know Puyo Nexus had a pretty flexible editor system but what do you guys use?
Special thanks to our coder MyLegGuy for this post.
Consider it officially declassified.
Here are the things we need to do in order to translate Puyo Puyo Chronicle:
- Extract the game
- Edit miscellaneous menu text
- Edit manzai text
- Edit NPC dialogue
- Edit hard coded text
- Create new fonts
- Edit images
- Test the patch
- Automate it
- Conclusion
This article will go over each of these one by one.
1. Extracting the Game
Before we can modify the game’s files, we actually need to get ahold of them.
Using ctrtool and 3dstool, we can extract the ROM.
This gives us the game’s files, but some are still not fully extracted.
The game uses NARC files, which are like ZIP files. They store many files inside of one.
To really get all of the files, we have to extract the NARC files using Narchive.
That gives us the rest of the files we need.
But they are all in non-standard, uneditable file formats.
The rest of the article details how we actually convert and edit these files.
2. Editing Miscellaneous Menu Text
The text is in the MTX format. It can be converted using Puyo Text Editor. Then we just edit it and the same tool is able to inject it back in. Nothing extra is needed here.
3. Editing Manzai Text
When we say “manzai,” we’re referring to the scenes in story mode.
These scenes are controlled by two parts:
- Text in the MTX format
- Script files that control how the characters move and determines when text from the text file shows up.
There are problems we need to solve.
- As you may remember from a recent post, there are hundreds of unused lines in the manzai. If we were to convert the text and try to edit it directly, as we did with menu text, we would get confused by all the unused lines cluttering up everything.
- There are thousands of actually used lines in the game. Adding line breaks to them manually is incredibly tedious.
- When the script file tells the game to display some text from the text file, it also tells the game how many lines the speech bubble should have. If we change the number of lines for a particular piece of dialogue, we’ll need to update this number.
A program called PuyoLines was created to fix these problems. Here is how each problem was fixed:
First, the unused text. After converting the text using Puyo Text Editor, PuyoLines scans the script files. It keeps track of which text the script file actually tells the game to display. Any text that the script file never instructs the game to use is marked as unused.
However, the unused text cluttering the text files actually didn’t end up being a problem. We did not translate the scenes by just looking at the text in the text files, that wouldn’t provide enough context.
Next, the line breaks. PuyoLines is able to scan a translated text file and automatically insert line breaks to keep the text inside the bubble. This requires accurate code to simulate Puyo Chronicle’s text drawing. After generating those line breaks, we are able to edit them manually to fix any problems.
Finally, fixing the bubble sizes that the script file requests. PuyoLines does it.
4. Editing NPC Dialogue
Similar to the manzai, NPC text is also controlled by a script file and a text file.
However, the script files are far more important in this case. NPCs can say different things depending on the status of a quest, how you respond to a question, how far you are through the game, and other variables. This is controlled by the script file.
As a result, converting the text file into a giant block of text and editing it would be impractical. There wouldn’t be enough context to tell when each message is displayed.
The solution is to combine the text file and script file into one.
That way, we follow the flow of the script while simultaneously being able to read the text.
The program to do this is called PuyoScriptEditor. It calls the combo files it creates “puyoScriptPack” files.
Here is an example of a simple puyoScriptPack file that responds to the player’s choice:
!unnamedScriptNo0 minitalk autoBreakOn (reserved) : main ; : phase_minitalk_main /// Wise Grandpa MiSetSpeaker 6 "Hohoho... Folks call me Wise Grandpa." "If ya got somethin' to ask, lemme hear it!" "Don't worry about talkin' my ear off!" "Now then... What kinda question you got?"int select RpSelectYesNo 10
if select = 1 int select_no 0 while int ret_no RpTalkTutorial select_no if ret_no = 6 break else RpSettingTutorial ret_no set select_no ret_no endif loop
"Hohoho... Come back anytime you got questions."
else “If you say so…”
endif ; |====
It’s also important to note that, because the NPCs don’t have any voice lines, we are able to add and remove messages at will.
If we tried to add another message to a manzai scene, the extra message would steal a voice line and incorrectly offset the ones that come after it.
5. Editing Hard Coded Text
Not all text is inside of text files. Some of it is just directly part of the game’s code. We can’t use PuyoTextEditor here.
A custom tool was used to insert our translated text directly. This article is just an overview, so the technical details will be skipped. Instead, take a look at a snippet of the file that tells the tool where to insert the text:
=== strswap === 1,0x4b46a4,Cinnarmor 1,0x4b4724,Aquarmor 1,0x4b47a4,Solarmor 1,0x4b4824,Verdarmor 1,0x4b48a4,Lavendarmor // 0x70877C,Gummy 0x708780,Aqua 0x708784,Fever 0x708788,Classic 0x70878C,Metallic
6. Creating New Fonts
If we run out of space, we sometimes use a smaller font. The game does not include any small fonts that have all English letters, therefore we need to make them ourselves.
A font is composed of two parts: an image with all the letters, and an info file that tells the game where the letters are in the image and how to display them.
First, we use a tool called fontbuilder to create the image for the font.
Second, we use a custom tool called PuyoFontConverter to create the info file. It actually converts the info file created by fontbuilder to Puyo Chronicle’s format.
That’s all about font creation for now.
Going into any more detail would be quite educational, but very boring.
7. Editing Images
There are two types of images we needed to handle. Ones that are in CTPK archives, and ones that are compressed with COMP.
You can think of CTPK like NARC, but it only includes images.
Kuriimu has code that can handle all the image formats we needed.
8. Testing the Patch
Citra now has LayerdFS. This allows us to just put the patch files in the correct location and have them automatically loaded.
Before that, we would have to rebuild the entire rom to test the patch with Citra. A modified version of 3DS-Builder was used.
9. Automation
With the tools and techniques described above, translating the game is possible. However, it is incredibly tedious and impractical.
Imagine doing these things:
- Going through and manually telling Narchive to extract each NARC.
- Manually finding and recreating the appropriate NARC every single time you edit something inside of it.
- Manually convert each image, and reconvert them after every single change. This includes recreating the NARC.
- Same manual work with images, but for text files instead.
- Manually adding the correct font to each text file.
You would go mad. Maybe not immediately, but certainly after two years.
Because we can’t have that happening to our precious group members, this all needs to be automated.
The custom automation program is called PuyoPatchCompiler.
To illustrate what it does, say that we have a file at the following location:/academy/academy.narc.narcFolder/academy_2.ctpkFolder/lesson_ingame2.png
When the patch compiler sees this file, this is what it does:
- Generates a CTPK file called
academy_2
that includes our modified version oflesson_ingame2.png
. - Generates a NARC file called
academy.narc
that includes our modified version ofacademy_2
. - Moves the modified
academy.narc
to the correct place.
To accomplish this manually, without the patch compiler, this is what you would have to do:
- First, realize that a CTPK file contains multiple images. To create a CTPK file that modifies one image inside of it, we need to create a new CTPK file that contains all of the unmodified files in addition to our modified one.
- Make a copy of the unmodified, extracted version of
academy_2
that contains the other images. - Copy your modified
lesson_ingame2.png
into the extractedacademy_2
folder with the other images. - Create a new CTPK archive using that
academy_2
folder. - Realize that NARC files have the same problem. To make a NARC that only modifies one file, you need to merge our modified file with the unmodified files.
- Get an unmodified, extracted version of
academy.narc
. - Copy our version of
academy_2
into that folder. - Recreate the NARC using that folder.
- Move the NARC to the correct place, depending on how you’ll test the patch.
- Repeat from step 1 when you realize that you actually want to move the image one pixel to the side.
Hopefully that shows the patch compiler’s importance.
It’s also worth noting that most of the tools mentioned above had to be modified to integrate with the patch compiler because they were designed to be used manually.
Take Narchive, for example. In order to create an NARC with five files, you must create a folder, copy those files into it, and then tell Narchive to make a NARC from that folder. The version of Narchive that the patch compiler uses is modified, allowing it to directly specify which files it wants to use to create a NARC. This saves a lot of file copying.
The patch compiler also has the hard coded text injecting integrated into it, which is why a name wasn’t initially attached to the program that injects hard coded text.
10. Conclusion
Each section here could be extended into its own article, but this was just an overview.
The original question asked about other 3DS games too. The only other one we’ve touched is Puyo 20th, and we’re still working on its tools.