Skip to content
View in the app

A better way to browse. Learn more.

ResHax

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.
Help us keep the site running.

[SOLVED] Dragon Quest IV (PSX) Text-Block

Featured Replies

  • Author
  • Localization

markus-projects, posted Tue Nov 24, 2020 7:09 am (60563)


Hi,

I was sent from RomHacking to this forum. I try to translate Dragon Quest IV on PSX and found the textblocks.

This is an example textblock, the parsing result and the two interesting byte arrays (dataCE and dataED).
Image
The second byte array (dataED) seems to be a huffman tree?
I checked:
  • a japanese letter (leaf) occurs only once
  • the tree always starts with a node 0x8***
  • the node numbers always ranging from 0 to (number of nodes - 1)
  • the highest node number seems to be always on top
  • in the decoding routine in PSX-EXE it jumps from node to node until a leaf is found (see image)
  • the binary tree seems to be always full: n nodes and n 1 leafs (0x7f counts also as leafs, null are no leafs)

I tried the typical tree traversals and other binary tree representations, but it did not work out. Maybe I did something wrong? Some example trees are:
Image
The left number is just an index. The 0x7f seems also be leafs (but maybe I am wrong). The "null" is 0x0000 in the data (maybe a placeholder).
For example, what bothers me is that the second tree starts with 3 nodes but then 5 leafs follow or sometimes the node numbers are not sorted well (0 before 1).

The dataCE block has a length of a muliple of 4 (len mod 4 == 0). I think here are the bits to traverse the tree and find the leafs.

This is the related text decoding routine. r17 has the 0x8149 which is node '329' (because 0x149 = 329). The routine uses addresses to point to the parts of the tree, I assume.
Image

You can find more details in my blog post. I will update it, if I find something new.
  • Author
  • Localization

markus-projects, posted Fri Nov 27, 2020 7:07 am (60653)


Hi,

via a contact to a user who solved it in the past for DQVII I could understand it, too.
For those who are interested:
Yes, it is huffman coding and these are huffman trees. The node numbers are offsets to jump to the next node, that is why typical tree traversals and other binary tree representations did not work here. The 0x7f are leafs. Yes, dataCE has in fact the huffman code bits. Hence, I could decode it and got the japanese dialog.

Image
Image
Guest
This topic is now closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.