Skip to content

Language script specification

ActiveMath edited this page Jul 14, 2015 · 2 revisions

Language Script Specification

(ENGLISH.DAT, ITALIAN.DAT, FRENCH.DAT, GERMAN.DAT etc.)


struct OffsetTable
{
	bitu16	Offset [NumGenericStrings + NumPSXStrings + NumPCStrings];
}

Header


bitu16	NumGenericStrings;
bitu16	NumPSXStrings;
bitu16	NumPCStrings;

bitu16	GenericStringsLen;	//	including the null-terminator bytes
bitu16	PSXStringsLen;	//	including the null-terminator bytes
bitu16	PCStringsLen;	//	including the null-terminator bytes

OffsetTable	stringsTable;	//	table holding offsets which point to corresponding strings

Note that the offsets in the offset table themselves are not relative to the file address 0; they are actually relative to the first Generic-string's starting byte address!

In order to get an absolute offset of a string whose relative offset you retrieved from the offset table, do the following: absoluteOffset = relativeOffset + sizeof(Header). sizeof(Header) depends, of course, on the number of strings in each group. Therefore, the header size is sizeof(bitu16)*6 + sizeof(OffsetTable). Finally: sizeof(Header) = 12 + NumTotalStrings*2.


Strings


In the usual TRLE situation, there are typically 359 strings (that is, usually NumTotalStrings = NumGenericStrings + NumPSXStrings + NumPCStrings = 359) defined. This, however, is not a limit nor rule of any kind!

All the strings defined within lang.dat files (where 'lang' is your language of choice) are ASCII null-terminated strings. Every character (byte) contained in such a string is XOR-ed with byte 0xa5 (regardless of what byte was specified in script.txt under the 'Security' option).
The null-termination byte is not being XOR-ed!
After the above defined header section goes an array of strings, in a predefined order: Generic-PSX-PC. The length of this array of total (NumTotalStrings) strings is therefore TotalStringsLen = GenericStringsLen + PSXStringsLen + PCStringsLen.

Hence the string array has the following format:

TRLEString	strings [NumTotalStrings];

where TRLEString is simply a char array, whose length depends on the corresponding string's length. That can be calculated by subtracting the next string's by the current string's offset.

Clone this wiki locally