Tutorial: How to Manage Dialogue Indexes with Excel

Background Info

One issue with how A Wonderful Life manages it’s dialogue is that it sorts each dialogue entry by indexes.

Each index value is a 4-byte hex value (also known as a double-word) that shows the place of the message in the file.

As an example, here’s nami.mes (dialogue for Nami):

In this case, Message #1 would be located at 0x000008d8, Message #2 would be located at 0x0000091c, etc.

This means, when we modify a dialogue entry manually in hex (e.g. substituting a word for a longer or shorter word), we need to fix the index accordingly.

Using the nami.mes dialogue file as an example, lets try changing the word “Blue” (hex “800c 80e3 80ec 80dc”) to “Purple” (hex = “801a 80ec 80e9 80e7 80e3 80dc”)

This is what we’ll get if we don’t change any of the indexes. Note that the {EOM} portion of the message gets pushed over to the next message

This can lead to a lot of deformed dialogue later on in the file.

Adjusting Indexes (the long way)

My initial method of fixing indexes was to go and manually fix the index of each of the following entries in the dialogue file.

In the above case, I need to increase every single index by a hex value of 4 (e.g. 0000091c + 4 = 00000920)

This can become extremely tedious and time-consuming, considering that some dialogue files will have hundreds of indexes you’d need to fix in this manner. But it works, and doesn’t require anything except a hex editor.

Adjusting Indexes (the Excel way)

An easier method of fixing indexes is to use a spreadsheet.

Requirements

Instructions

1.Open your dialogue file (e.g. nami.mes) in your hex editor.

2. Set it to use “Big Endian” byte order and group by “Double Words”

3. Select all of the indexes (starting at 0x00000008) and Copy

4. Open Notepad++ and paste the copied values
5. Open the Replace window (Search -> Replace…”
6. Set it to find ” ” (without quotes) and replace it with “\n”
7. Set the Search Mode to “Extended”
8. Click on “Replace All”

Replace all spaces ” ” with newline “\n”

9. Select your nice new list and Copy

10. Open up a blank spreadsheet in Excel
11. Select a cell and click Paste -> Use Text Import Wizard

12. The first 2 windows don’t really matter, but on the 3rd window, you’l want to make sure you select “Text” formatting.

13. Feel free to adjust your spreadsheet at this point. I added a row so I could keep track of what each column is, as well as a “Message #” column.
14. In a new column (beside your column of pasted indexes), type the following formula: =DEC2HEX(HEX2DEC(B2)+HEX2DEC(0),8)
Note, B2 is my first index value in my spreadsheet.

15. Select the bottom-right corner of your new formula cell and click+drag down to copy the formula to all subsequent cells.

16. Next, find the cell you need to start adding to, in this case we need to change our Message #2 (and every subsequent cell) by adding 4 to them.
17. Select the cell, and in the formula bar, change the second Hex2Dec entry from 0 to whatever you need to add/subtract. In my example case, I need to change to add 4. Then press enter.
18. Select the bottom-right corner of your new “fixed cell” and drag it all the way down to apply the +4 addition formula. You should end up with a full list of corrected indexes.

19. Select all of the entries in your new list and hit Copy.

20. Go back into your hex editor. Go to the first index location.
21. Right-click and Paste your new index values, overwriting the old ones.

22. Save
23. Open up your newly edited file in Harrison’s MES Editor to verify that everything looks good.

No more pushing the {EOM} bits to the next message. Yay!

24. Repeat as necessary with any other dialogue edits.

Edit:Technically, we’re not done yet!

Upon review, I’ve found there are a few more unwritten technical rules on how mes files and their indexes are structured.

Each edited message needs to be padded out with one to four “00”, a.k.a. {EOM}, bytes so that the next dialog message starts at a double-word position.

Each file also needs to have an appropriate amount of {EOM} bytes at the very end of the file so that it ends at an odd “_f” position.

Example Spreadsheet (Download)

Here’s an example spreadsheet that I used while making some edits to dialogue in numerous .mes files.

The End

As always, feel free to reach out if you have any questions on how to edit dialogue indexes using the above method.

We also have a great Discord community who I’m sure would be happy to offer any help if needed.

2 thoughts on “Tutorial: How to Manage Dialogue Indexes with Excel

  1. Pingback: Dialog Editing with Sukharah’s MES Unpacker | Harvest Moon: A Proud Life

  2. Pingback: The Unwritten Rules of .mes Files | Harvest Moon: A Proud Life

Comments are closed.