Quantcast

Page 2 of 2 FirstFirst 12
Results 16 to 19 of 19

Thread: Translating Saturn Grandia

  1. #16
    WCPO Agent
    Join Date
    Sep 2012
    Posts
    763
    Rep Power
    22

    Default

    Have you checked the file bounds, as in, what happens when the script file is larger than the old one, and what happens if one particular text is long enough to push another one down? Are the script start points hardcoded pointers or some other control values that indicate "text #001 starts here"?

    Those were the issues I came across in SOTN, text locations were fixed and all string values used hardcoded pointers (and the values pointing to them were also pointers). The whole script file was a compiled mess, somewhere in the middle of the game code so you couldn't even recompile and pad it out since it would get overwritten by other code, it had a fixed length.

  2. #17
    Hero of Algol TrekkiesUnite118's Avatar
    Join Date
    May 2010
    Age
    30
    Posts
    7,996
    Rep Power
    113

    Default

    Quote Originally Posted by zyrobs View Post
    Have you checked the file bounds, as in, what happens when the script file is larger than the old one, and what happens if one particular text is long enough to push another one down? Are the script start points hardcoded pointers or some other control values that indicate "text #001 starts here"?

    Those were the issues I came across in SOTN, text locations were fixed and all string values used hardcoded pointers (and the values pointing to them were also pointers). The whole script file was a compiled mess, somewhere in the middle of the game code so you couldn't even recompile and pad it out since it would get overwritten by other code, it had a fixed length.
    I haven't yet. Though if I were to take a guess I'd bet that the game will handle the expanded text fine as I'm not seeing anything in the text that looks like pointers, but something else will go wrong later on. The files that contain the script seem to contain more than just the script. Again taking a guess it seems that these files are for each specific area of the game, and contain the script for that area along with other data. So I'd imagine that if we expand text that bumps everything else in the file down, there is going to be a spectacular crash somewhere else down the line.

    I think this is where comparing the JP and EN PS1 files to figure out how they dealt with this issue will shed some light on what to do. Also comparing the JP Saturn MDT files to the JP PS1 MDP files would probably be beneficial as well as it can shed light on what is different between the formats.

    EDIT:

    So I think I might be figuring out how the script pointers work based on comparing the PS1 versions, and then spot checking with the Saturn version.

    So here is what I believe to be one complete text routine from the file BA38.MDT at x05B4:



    This highlighted portion I believe is a header of some kind. It seems to change from text sample to text sample, so there's probably optional values that are in some text boxes but not in others.


    Now this next highlighted portion is the important part. This value I believe represents how many bytes until the end of this text box. In this example it's 5A:


    If we then move forward 5A that will bring us to the end of this block of data. The end of a block of text data seems to be tagged with this possible footer:


    After this the next text box starts. I've been able to keep following this pattern and consistently keep finding what appears to be the correct number of bytes and the start of the next text box.

    I'm going to keep testing this but so far it's looking promising.

    Also, another interesting thing of note is that it seems that the English PS1 versions files seem to be close to if not the same size as the Japanese PS1 files. It looks like Sony removed unnecessary padding to keep the files close to the same size from what I can tell.
    Last edited by TrekkiesUnite118; 09-16-2018 at 02:46 AM.

  3. #18
    Hero of Algol TrekkiesUnite118's Avatar
    Join Date
    May 2010
    Age
    30
    Posts
    7,996
    Rep Power
    113

    Default

    Ok, so I think I've cracked the code of the MDT/MDP file headers. This information seems to hold true for both the Saturn and PS1 files, the only difference being that in the PS1 files pointers are Little Endian where as in the Saturn files they're Big Endian.

    • The header is 512 Bytes in size.
    • The header seems to consist of just a pointer table
    • Each entry is 8 bytes total in size
    • The first 4 bytes seem to be the place in the file where the data lives
    • The second 4 bytes seem to be the size of the data.
    • The entry that tells us where the text lives and how big it is seems to be at x60 every time.
    • There's an entry at x58 that seems to point to a 24 byte piece of data right before the text. Perhaps this is a header or something?
    • Consistently I'm seeing in the English PS1 version that any addresses that come after the address defined at x60 have their values increased by the increase in size of the text data, and any values that come before it are untouched.
    • I'm also seeing again padding being removed in the PS1 files of the exact amount added to the text.
    • Another oddity I'm seeing is that the last entry in the table at x1F8 seems to also have it's size increased by the increase in text size. But I'm not sure what that value represents or what data was added.

    Some other oddities I'm seeing is that some entries don't seem to make sense as the addresses are beyond the size of the file, but they're still updated in the English PS1 version.

    With this info I imagine I should be able to make a program that can do the following:
    • Parse the MDT files
    • Extract the script portions
    • Put the MDT file back together with a new script portion.
    • Recalculate the pointer table.

    The hard part to automate in code I'd imagine would be to find a portion of padding in the file that can be removed to keep the file size the same.

  4. #19
    Hero of Algol TrekkiesUnite118's Avatar
    Join Date
    May 2010
    Age
    30
    Posts
    7,996
    Rep Power
    113

    Default

    So I wrote a program that allows me to parse the MDT and MDP files from the Saturn and Playstation versions. This basically strips the first 512 bytes and reads them as a pointer table. This information is then used to parse the rest of the file. Knowing that 0x60 marks the table entry for the script, I wrote some code to copy the bytes defined in the table and write them to a file. This has essentially allowed me to dump the raw script for the game out of all the MDT/MDP files.

    I've made it so it also writes the pointer table to a file, as well as the pre-script and post-script sections to files. This way it should be easy to make some code to do the reverse and put all the pieces back together and recalculate the pointer table.

    On to the more interesting stuff though. After dumping the script for the Japanese Saturn, Japanese PS1, and English PS1 versions, I discovered that the Saturn and Japanese PS1 script data is identical. The initial cutscene I was looking at appears to be a special snowflake where they've added a bunch of additional control codes in the PS1 version. After that, things start lining up between the two. The only difference is the non-script parts of the data are byte swapped due to endian differences.

    This is making it really easy to start identifying pointer values and control codes by comparing the different versions. I'm still figuring things out in these files, but I'm starting to think it might be possible to write a program that could automatically convert the English PS1 script files into a format the Saturn is expecting.


    I've attempted to attach some samples for people to look at if they wish. The extension says .SCRIPT but that is just something I came up with to keep things organized. They're just raw data that you can look at in a hex editor.
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •