User:Pkmnfrk/Textbox.stb

From OHRRPGCE-Wiki
Jump to: navigation, search
Wip.png
This article discusses a brand new feature which is not included in the latest stable version, and may not even be in the next stable version. It can, however, be found in a nightly build, which can be found on the Downloads page. If you wish to discuss this feature, feel free to use the talk page.

This lump contains all the text for the text boxes. It is a variable width string table with a header. Text boxes should point to the header, which will then point you into the soup of text in the body.

Formal Specs[edit]

About Formal Specs - Note: This table uses byte-offsets, not word offsets

Offset Data Meaning
0-3 STR(4) ID code (should always be "OSTB")
4 INT Version (currently 1)
6 LONG Number of entries in the table
10 LONG Offset to beginning of string data (including this header, and the actual table)
Note that the offsets listed in the table are offset from the beginning of the string data, not the beginning of the file.

Next is the table portion of the header. It is 13 bytes long, and repeats for as many as there are entries.

Offset Data Meaning
0 BYTE Used or free (0 is free, 1 is used. Anything else is reserved, but should be interpreted as used)
1 LONG Pointer to string data
5 LONG Length of string data (actual usage)
9 LONG Allocated space (how much room the string data has to grow)

Finally, after the table, is the string data. A given string is padded out to its "Allocated" length with nulls. This does not mean that it is null terminated, however. When reading the string, always use the "Used" length to read the string. This is because if the string is exactly big enough to fill the space, it will not have any nulls at all. Further, if a string has an embedded null (i.e. 0x0 in the middle), you cannot assume it marks the end of the string.