Noitora said:
guys a little change in plans I won't upload any text dumps because HernanZh is helping me out with the pointers and that means there soon will be no limit in how much text we can display.
I will post my explanation here instead of pm-ing you, so that everyone can see it and think about it.
Warning for massive post
Noitora sent me a file with text, I assume they all have the same stucture:
A file with the text goes like this
-Header (32 bytes)
-Text/Strings (I will refer to this as the string compartment)
-Pointer table
-Names of all strings (I will refer to this as the name compartment)
The header looks like this:
-4 bytes for the file size
-4 bytes for the size of the text/strings compartment (add 0x20 to it and you get the address of the pointertable)
-4 bytes of nothing (?)
-4 bytes for the number of pointers (number of strings to be exact)
-and finally another 16 bytes of nothing.
The pointer table goes like this:
-The pointer table is actually 2 pointer tables in 1. One pointer (4 bytes) first points to a string , then another pointer (4 bytes) points to the string names. Then another pointer for the string, then one for the string name etc. So the pointers are always grouped in 2, and for every string there is a string name.
-The pointers are always relative to the start of a compartment.
You'd think that the strings would all correspond to a string name in the same order. (aka the 1st string name in the name compartment is the name of the 1st string in the string compratment) Well guess again, the whole string compartment is messed up! The names are in order, but the string can be placed anywhere.
Example: In the file Noitora sent me, the first pointer points to the string 0x0D40 in the string compartment and the second points to 0x0000 in the name compartment.
This means:
string: ???????
name: MDRENTAL_DECIDE
The string is somewhere in the middle of the string compartment, and is not the first string in the string compartment!
This is obviously going to give some trouble, because everytime you want to edit a string, you will have trouble finding the corresponding pointer.
I propose the following:
Create a custom dumper for the text; one that reads the pointers in order, and so dumps the strings in the correct order. A correct dump for the text is very important! Creating a custom dumper should be very easy though
(Alternatively: you could also dump the strings in the order they are now. But then you must also dump a list of corresponding pointer addresses. I would recommend the other method though)
The second problem is inserting the text. If you want to use Atlas to insert the text, that's gonna give some trouble. As the pointer table is below the string compartment, that's a little icky, because Atlas will keep inserting text and if the text is longer than the original, it will overwrite the pointer table. (Perhaps Atlas can do something about that, but I wouldn't know)
Possible solution: Make a tool that edits the files into "Atlas-friendly" files, and turn them back into the original structure after inserting.
Instead of
- Header - Strings - Pointer table - Names
You turn it into
- Header - Pointer table - Names - Strings
Then use you can use Atlas, and then turn it back into the original form.
(Alternative solution: create a custom text inserter. One that lets you edit a string, moves the pointer table, and updates the pointer table as well. It's harder than making a dumper, but it would be very rewarding. This would also remove the need for a text dumper btw)