Quote from: Rai
- How exactly will pointers help me insert more text? WILL pointers help me insert more text? If not, I don't really care for them.
Before I go on to everything else, I have to understand these things.
Before I go on to everything else, I have to understand these things.
Here's a basic run down of pointers:
First, I assume you know what arrays are and how they work. Most game scripts are setup as a variable length data array (a block of text). It's an array with the data element (or strings) being variable in size.
There are two ways to access such an array.
1) is to parsed through the array until you've reached the desired string by counting the number of string terminators along the way.
2) is have another array with values that point into the variable length data array (I'm sure there is another name for this type array) for the starting position of the string of data. This type array is referred to as the table or pointer table.
Almost all games use the second method.
The reason why you want to rewrite the pointers in the Table (array) is because the replacement text your trying to insert is either longer or shorter than the original text. If you re-position a pointer after a shorter than original text insert, then you gain the additional space for use with larger replacement text/strings.
An very basic example:
Say you have a town with 3 people.
Old_man=0, young_kid=1, swordsman=2.
When you talk to the swordsman, the text routine uses the value associated with him as the index for the Table array.
unsigned short table_array[2]={ 0x9000, 0x9005, 0x900C };
The value pulled from the pointer table is now the index for the script array.
Let's say the script is 0x9000-0x900F in length.
Of the original text: Old_man's text is 5 bytes lone, young_kid's is 7 bytes long, and the swordsman's is 4 bytes.
And the replacement text is: Old_man's text is 4 bytes lone, young_kid's is 3 bytes long, and the swordsman's is 8 bytes.
The first two characters replacement text strings will fit no problem, but the last one won't. So we scan the replacement text and build new pointer locations for them.
The new pointers would be: 0x9000, 0x9004,0x9007. Now the swordsman's replacement text will fit. You don't need to know ASM to do this.
Hardcoded pointers are a different story. Unlike the above scenario, the actual pointers are attached to characters, elements, events, etc. If the script is stored in a block form(array), then you can extract it, translate it, and re-insert using an Overflow scheme. This does require ASM knowledge and writing the actual overflow routine. You can also use the overflow scheme in-conjunction with rewriting the pointers(above example) to avoid using compression schemes, but you'll probably need to expand the rom. I did this with BubbleGum Crash.
-Rich