Wednesday, 12 October 2016

TRLE File Formats savegame.*

Program: Original tomb4.exe (TR4/TRLE)
Description: Savegame file
Document: Version: 0.1
Note: This describes file format for original TRLE tomb4.exe.

TRNG (Tomb Raider Next Generation) tomb4.exe  savegame files have display section, a larger data section and an NG Header section at the end. Unknown whether TRNG uses same checksum procedure.

TRSaveGameFormat

After hex editing a savegame file, open and save it in Paul Walton’s TR Save Editor [link] to have the checksum performed.

The editor will write data to the last byte of the data section so the checksum passes when tomb4.exe checks the savegames.

Here is an *.xps document detailing as much as I know about the data section. (Sorry no info about finding Lara's position.)

 http://www.mediafire.com/file/k7wdrzva2g4r5vh/savegame.xps

A description of the fields can be found in Paolone's tutorial about variables and memory zones. See the section on Savegame memory.

http://www.mediafire.com/file/yrl5lhpnxhwj45p/PaoloneTutorial.zip

Here is the template file I created for HexEdit. [link]

http://www.mediafire.com/file/swjurtqvsx9tatc/TRSaveGame.xml

Updated 18Dec16

http://www.mediafire.com/file/vg8vfk8l14p4s3x/TRSaveGame.xml

Data Section
The data section appears to be composed of a fixed section followed by a section where the state of each game item that has changed state from an initial state is stored.

The address of each game item state seems not to be fixed and the order appears to be linked to their order in the Items array for the level.

There appears to be no identifier within each state such as the item’s index.

I created a TR4 level which contained only Lara and no other items and investigated the savegame file.

savegame2

In the picture above the highlighted bytes are Lara’s state showing that the items section appears to begin somewhere near 0x02D0.

The pattern of bytes 0x02 0x02 0x00 0x67 0x00 appears for Lara whenever the game is saved with Lara in her standing position.

This pattern of bytes is what Alain LeComte’s TR_Exe [link, scroll down to bottom]searches for to find the Lara item in the list and thus the address of the (x, y, z) position and room data.

The bytes meaning is as follows.
  • 0x02 (current state ID)
  • 0x02 (next state ID)
  • 0x00 (unknown)
  • 0x6700 (animation number = 103)
0x6206 is the absolute frame number (=1634).

x, y and z position data is world coordinates divided by 2.

If Lara has less than 100% health a uint16 is inserted after the frame number with her health value.

If Lara has horizontal speed a sint16 is inserted after the rotation (facing) value.

Paul Walton’s TRposEditor appears to search for the following six patterns.
  • 0x02 0x02 0x00 0x52
  • 0x02 0x02 0x00 0x67
  • 0x02 0x02 0x47 0x67
  • 0x50 0x50 0x00 0x07
  • 0x50 0x50 0x47 0x07
  • 0x47 0x47 0x00 0xDE
If it doesn’t find these patterns it then searches for 0xC0 and locates the position data directly after it.

TRposEditor

A study of the savegame for the TRLE Playable Tutorial level shows that the order of items seems dependent upon the order of items in the Item array for the level.

TuorialSavegame

At address 0x02CB is a bitfield where the status of the Shatter items in level is stored. Each bit represents one shatter object. 1 means not shattered.

When a pickup item is picked up 0x20 is stored for that item.

Unfortunately it appears that once you have the address of the position data for one savegame of a level you cannot be guaranteed that it is the same for another savegame for the same level. Most of the time it is the same but I have found one instance where the addresses were different.

To be continued…

No comments:

Post a Comment