Save file: Difference between revisions

From Treasure Adventure Game Wiki
Jump to navigationJump to search
Marked this version for translation
No edit summary
Tag: Reverted
Line 1: Line 1:
<languages />


<translate>
<translate>

Revision as of 21:05, 21 July 2023

A save file is a game file that contains the current state of the game. The game creates or updates a save file after the player interacts with a Save Point. Treasure Adventure Game allows for 3 separate save files ("game_save_1.dat", "game_save_2.dat", and "game_save_3.dat"), which are stored in the "save_data" subdirectory in the game directory. If you want to, you can swap out or modify the files to load different save files (even when the game is running).

The save file stores various information about the game. These can be divided into:

Save file format

The save files are binary files that should not be opened with a text editor like Notepad. Instead you should use a hex editor or a dedicated tool for editing TAG save files.

The format is essentially a dictionary, or a list of key-value pairs. The keys are strings and the value is a pair consisting of a string and an integer. Entries are right next to each other, and each entry is structured like this:

  • A number in ASCII, terminated with a space (0x20) - the length of the entry,
  • A null-terminated string - the key of the key-value pair,
  • A null-terminated string - the first, string value,
  • A number in ASCII, without a terminator - the second, integer value. This number is read from the remaining bytes in the entry.

The entire entry takes up length + ascii_length + 3, where length is the value of the length (at the beginning of the entry), and ascii_length is the length of the length value, when represented with ASCII text. The + 3 comes from two null bytes at the end of the strings and the space (0x20) terminator.

Example

Here is a fragment of an example save file:

34 33 20 63  68 65 73 74  20 32 30 20  63 6F 69 6E  43 chest 20 coin

73 31 39 37  37 31 30 32  00 43 68 65  73 74 20 32  s1977102.Chest 2

30 20 43 6F  69 6E 73 31  39 37 37 31  30 32 00 31  0 Coins1977102.1

34 35 20 63  68 65 73 74  20 32 30 20  63 6F 69 6E  45 chest 20 coin

73 32 30 32  33 30 31 35  30 00 43 68  65 73 74 20  s20230150.Chest

On the left-hand side are bytes in hexadecimal, on the right-hand side is a text representation of those bytes; null bytes are represented as dots (.)

To read the values from the file you have to:

  1. Read the length of the entry - in this example it would be 43.
  2. Read the key of the entry until you encounter a null byte - in this example: chest 20 coins1977102
  3. Read the string value of the entry until you encounter a null byte - in this example: Chest 20 coins1977102
  4. Read the next x bytes, where x = entry_length - (key_length + string_value_length). key_length and string_value_length are lengths of the strings above, without counting the null byte. The string contains the integer value in ASCII form. In this example, x = 43 - (21 + 21) = 1, so we just read 1 character. This character is "1", so our number value is 1.
  5. Repeat the process from step 1 until the end of the file

So, the first entry would translate to:

Key String value Integer value
chest 20 coins1977102 Chest 20 coins1977102 1

The purpose of the string value is currently unknown, and it seems like if the string value is present, the key is always the string value, but lowercase.