Jump to content

Script directory: Difference between revisions

No edit summary
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
The script directory (contained in the [[master file table]]) contains both [[bytecode]] scripts and strings used in the game. It's layout is different than the other directories in the MFT:
The script directory (contained in the [[master file table]]) contains both [[bytecode]] scripts and strings used in the game. It's layout is different than the other directories in the MFT. The <code>build_date</code> is likely referring to Konami's authoring tools, and not to the game itself. The entire script directory and its contents may be aligned to a 1-byte boundary, as the game will only issue 1-byte reads to it. However, in practice it is still aligned to a 4-byte boundary.


<syntaxhighlight lang="c">
<syntaxhighlight lang="c">
struct script_directory {
struct script_directory {
   u32 unknown;                   // 0x3ea8eae6 in Boktai 1 (U)
   u32 build_date; // seconds since unix epoch
   script_entry script_entries[];
   script_entry script_entries[];


Line 15: Line 15:


   // NOTE: offsets.script_data points here
   // NOTE: offsets.script_data points here
   u32 special_script_offset; // unknown...
   u32 special_script_offset;


   // NOTE: script_entry.offset is relative to here
   // NOTE: script_entry.offset is relative to here
   u8 bytecode[];
   u8 bytecode[];


   // Unknown data, including the "special script"
   // NOTE: special_script_offset points here
   u8 unknown[?];
  u32 special_script_size;
   u8 special_script_data[];
};
};


Line 78: Line 79:


char* get_string(int id) {
char* get_string(int id) {
   // top bit is unknown, always seems to be 1?
   // Mask out the top bit, it's not part of the offset.
  // If the top bit = 1, then the string is text.
  // If the top bit = 0, then the string is other binary data.
   u32 offset = string_index[id] & 0x7fffffff;
   u32 offset = string_index[id] & 0x7fffffff;
   return string_data + offset;
   return string_data + offset;
Line 127: Line 130:


char* get_string(int id) {
char* get_string(int id) {
   // top bit is unknown, always seems to be 1?
   // Mask out the top bit, it's not part of the offset.
  // If the top bit = 1, then the string is text.
  // If the top bit = 0, then the string is other binary data.
   u32 offset = string_index[id] & 0x7fffffff;
   u32 offset = string_index[id] & 0x7fffffff;
   return string_data + offset;
   return string_data + offset;