Dialog Editing with Sukharah’s MES Unpacker

Introducing Sukharah’s MES Unpacker

After months of painstakingly editing dialog using a combination of Harrison’s MES Editor, Hex Editing, and Spreadsheets, I’m happy to say that we now have a much easier method for editing dialog (mes) files from Harvest Moon: A Wonderful Life and Another Wonderful Life.

Sukharah, the brilliant individual behind the CLZ Compression Tool, has created a new tool for manipulating MES files. This tool has been aptly named the MES Unpacker (although it can also repack).

Compiling the MES Unpacker

Prerequisites

The tool is released as source code, meaning you’ll need to have a C++ compiler such as g++ (included with MinGW, which can be installed using the mingw-get-setup.exe installer from the MinGW releases page.

Once you have MinGW/g++ installed, it’s just a matter of downloading the MES Unpacker repository, and building the program using your terminal of choice.

Compilation Options

There are 3 main modes you can use while compiling the MES unpacker.

The normal mode uses a fairly basic compilation command:

g++ -o mes.exe -std=c++11 -iquote header "source/main.cpp" "source/MES.cpp"

The next mode, known as ddupe, will allow the app to group sequential duplicate messages together in the final repacked .mes file. This is needed for certain dialog files (e.g. muumuu.mes) that approach the 73,376-byte file size limit. Attempting to load a .mes file larger than this in-game will result in a crash.

g++ -o mes_ddupe_seq.exe -DDUPE -std=c++11 -iquote header "source/main.cpp" "source/MES.cpp"

The final mode, known as ddupe2, will group together all duplicate messages from anywhere in the dialog file. This breaks compatibility with Harrison’s MES Editor, but should otherwise work in-game. It’s not advised to use this option unless you’re unable to get below the 73,376-byte limit after using ddupe.

g++ -o mes_ddupe2_nonseq.exe -DDUPE2 -std=c++11 -iquote header "source/main.cpp" "source/MES.cpp"

Precompiled MES Unpacker (Windows 10 only)

I have also created a compiled version. The limitation of this precompiled version is that it’s limited to Windows 10 systems, since that’s the type of system I compiled it on.

[Download]

mes.exe – Standard compilation

This version is recommended for almost all .mes editing use cases

mes_ddupe_seq.exe – Compiled with -DDUPE flag

This version is recommended for certain large .mes files that approach the 73,376-byte filesize limit.

e.g. muumuu.mes, son_talk.mes

It’ll group any sequential (appearing directly after one another) duplicate dialog messages together in the final output .mes file.

mes_ddupe2_nonseq.exe – Compiled with -DDUPE2 flag

This version is experimental. It’ll group any duplicate messages from anywhere in the dialog file.

This is only recommended if you’re having difficulty outputting a .mes file below the 73,376-byte file size after using mes_ddupe_seq.exe, which is possible if you plan on editing Muffy’s dialog (muumuu.mes).

Using Sukharah’s MES Unpacker

MES to TXT

Once you’ve compiled or downloaded the MES Unpacker, using it is fairly trivial.

Simply place your .mes file (e.g. badog.mes) in the same folder as your compiled program. Note this folder must also include the tool’s “data” folder and it’s contents.

Then, launch a command prompt in that folder. The simplest way to do this is by typing “cmd” in the navigation bar and pressing Enter.

From there, just type in the appropriate unpack command.

mes_program unpack file.mes file.txt

Where mes_program is either mes, mes_ddupe_seq, or mes_ddupe2_nonseq and file.mes is your dialog file.

Unpacking badog.mes and muumuu.mes using their respective builds.

Editing the TXT files

After you’ve run the commands, you should have some new text files in your folder.

You can edit these using any tool you like. Personally, I prefer Notepad++.

For this example, we’ll be replacing one of Dr. Hardy’s lines (badog.mes).

Simply locate your desired line in the appropriate text file, and edit it at will. Note that a single line (not counting actions like {PAUSE}, {WIPE}, {SOUND}, etc.) can only be 21 characters (letters) long. Anything beyond that will cause issues when displaying in-game.

TXT to MES

Once you’ve edited and saved the txt file, simply run the appropriate pack command.

mes_program pack file.txt file.mes

Where mes_program is your build of the tool, and file.txt is your edited dialog text file.

This will overwrite the mes file in your folder

You can then put the newly packed mes file back into your ISO or game folder, replacing the previous one.

From there, the game should load your new dialog in place of the old one.

And voila! You’ve successfully edited dialog.

CLZ Decompression / Recompression

Sukharah’s CLZ Compression Tool

Recently a wonderful soul who goes by Sukharah has managed to reverse-engineer the CLZ compression format used by AWL and AnWL.

They’ve used this knowledge to create a CLZ Compression Tool, which can be used to decompress clz files, as well as recompress them.

This is beyond amazing and opens up the project to begin work on models, animations, textures, and so much more.

Compiling / Downloading the Tool

The tool is meant to be compiled using a C++ compiler (e.g. g++). You can follow the instructions on Sukharah’s GitHub to compile it yourself.

Precompiled Version

For those not experienced in compiling programs, I’ve compiled a version that can be downloaded from [here]. I’ll be posting any newly compiled versions on the HMAPL Discord as Sukharah continues to develop the tool.

Note that this pre-compiled build will only work on Windows 10 and up, since that’s what I used to compile it.

Using the Tool

The utility is fairly straightforward.

I found the easiest method was to put your desired CLZ file in the same directory as CLZ.exe.

Then, open up a command prompt in that directory (e.g. type “cmd” in the Windows Explorer navigation bar).

Then, in the command prompt, execute the command:

 clz unpack input.file.clz output.file
clz unpack mainchapter0.arc.clz mainchapter0.arc

In the above example, I decompressed mainchapter0.arc.clz into it’s native arc format.

Quirks of Decompressed U8 Archives

The decompressed U8 archives (.arc files) seem to display improperly when viewed in BrawlBox (my former go-to arc tool).

Data sequence mismatching, resulting in seemingly duplicate data

As we can see from the above screenshot, the contents of boy_0.arc (embedded in mainchapter0.arc) are displayed before the actual boy_0.arc descriptor. This can cause mismatch/corruption issues when attempting to edit the files using BrawlBox.

After a bit of trial and error, I’ve found the best tool to work with these decompressed U8 archives is Wexos Toolbox

No more weird data sequence mismatches

Now that we’re able to decompress CLZ into ARC and modify these ARC files using the appropriate tools, we can play around with models, textures, and so much more.

Recompressing CLZ Files

While decompressing is one step, we need to recompress the files back into CLZ archives for any hope of the game reading them.

Fortunately, Sukharah built this functionality into their tool as well.

Unfortunately I had some issues using the “pack” function (output files would crash when loaded into AWL), although I believe this issue has been resolved in a recent revision of the tool.

So I ended up using the memory-optimized pack method.

clz pack2 input.file output.file.clz
clz pack2 mainchapter0.arc mainchapter0.arc.clz

Files compressed using the pack2 function worked perfectly, albeit with slightly longer load times than the original AWL files.