<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en-GB">
	<id>https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Luis46coco</id>
	<title>ModdingWiki - User contributions [en-gb]</title>
	<link rel="self" type="application/atom+xml" href="https://moddingwiki.shikadi.net/w/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Luis46coco"/>
	<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/wiki/Special:Contributions/Luis46coco"/>
	<updated>2026-05-14T06:33:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.11</generator>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=DAT_Format_(God_of_Thunder)&amp;diff=5320</id>
		<title>DAT Format (God of Thunder)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=DAT_Format_(God_of_Thunder)&amp;diff=5320"/>
		<updated>2014-08-04T16:34:18Z</updated>

		<summary type="html">&lt;p&gt;Luis46coco: /* Compression */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archive Infobox&lt;br /&gt;
 | MaxFiles = 256&lt;br /&gt;
 | FAT = Beginning&lt;br /&gt;
 | Names = Yes, 8 chars&lt;br /&gt;
 | Metadata = None&lt;br /&gt;
 | Subdirectories = N&lt;br /&gt;
 | Compressed = Y&lt;br /&gt;
 | Encrypted = Y&lt;br /&gt;
 | Hidden = Y&lt;br /&gt;
 | Game1 = God of Thunder&lt;br /&gt;
}}&lt;br /&gt;
The &#039;&#039;&#039;DAT format&#039;&#039;&#039; is used by [[God of Thunder]] to store game data in &amp;lt;tt&amp;gt;GOTRES.DAT&amp;lt;/tt&amp;gt;.  Most files are compressed, and the header where the filenames are stored is encrypted with a simple [[XOR cipher]].&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature for this format, however reading in the entire FAT and checking that the filenames contain valid characters and that the offsets and file sizes are within range should correctly identify files.&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file begins with 256 file entries, in the format below.  All these file entries (i.e. the first 5888 bytes of the file) are encrypted with the [[XOR cipher|XOR algorithm]], at the byte level, starting with 128 and incrementing at each byte (so the first byte in the file is XOR&#039;d with 128, the second byte with 129, third byte with 130 and so on.  After XOR&#039;ing with 255 the value wraps and so the next byte is XOR&#039;d with 0.)&lt;br /&gt;
&lt;br /&gt;
The following Python 2.7 script will decrypt the header and output the result to a file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
# Setup our starting variables.&lt;br /&gt;
Cypher = 128                      # Cyper starts at 128.&lt;br /&gt;
Header = &amp;quot;&amp;quot;                       # Header will store the decrypted header.&lt;br /&gt;
HeaderSize = 5888                 # The header in GOTRES.DAT is 5888 bytes.&lt;br /&gt;
&lt;br /&gt;
# Open the God of Thunder data file.&lt;br /&gt;
with open(&amp;quot;GOTRES.DAT&amp;quot;, &amp;quot;rb&amp;quot;) as Input:&lt;br /&gt;
    # Loop through the header which consists of the first 5888 bytes.&lt;br /&gt;
    for x in range(0, HeaderSize):&lt;br /&gt;
        # Read a byte.&lt;br /&gt;
        Byte = Input.read(1)&lt;br /&gt;
        # XOR the byte with the current cypher.&lt;br /&gt;
        Header += chr(ord(Byte) ^ Cypher)&lt;br /&gt;
&lt;br /&gt;
        # Increment the cypher value, and set it back to 0 when it hits 256.&lt;br /&gt;
        Cypher += 1&lt;br /&gt;
        if Cypher == 256:&lt;br /&gt;
            Cypher = 0&lt;br /&gt;
&lt;br /&gt;
# Write the decrypted header to a file.&lt;br /&gt;
with open(&amp;quot;GOTHead.bin&amp;quot;, &amp;quot;w&amp;quot;) as Output:&lt;br /&gt;
    Output.write(Header)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After XOR decryption, each file entry is as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|[[char]] filename[9]||Filename (8 chars max), must be NULL-terminated&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] offset||File offset from start of file&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] size||Length of file stored here&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] decompressedSize||Length of file after decompression&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT16LE]] flags||Flags (1 if file is compressed, 0 otherwise)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The remaining unused file entries are all zeroes.  Since the FAT is fixed at 256 entries, the offset of the first file will always be 5888 (0x1700).&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
If a file&#039;s flag indicates it is compressed, then it should be decompressed with the LZSS algorithm below.  Each file&#039;s data begins with a [[UINT16LE]] value holding the decompressed size, in bytes. skip the next 2 bytes Other [[UINT16LE]] value(??). The rest of the data decompresses as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    If the amount of data decompressed matches the target size, finish.  Otherwise:&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Read a byte from the input data&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    For each bit in the previous byte, from the least significant to the most:&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        If the bit is 1, copy a byte unchanged from the input data to the output&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        Otherwise the bit is zero:&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Read a [[UINT16LE]]&lt;br /&gt;
            &amp;lt;ul&amp;gt;&lt;br /&gt;
              &amp;lt;li&amp;gt;&lt;br /&gt;
                Add two to the upper (most significant) four bits, and treat this value as the LZSS &amp;quot;count&amp;quot;&lt;br /&gt;
              &amp;lt;/li&amp;gt;&lt;br /&gt;
              &amp;lt;li&amp;gt;&lt;br /&gt;
                Take the lower 12 bits and treat the value as the LZSS &amp;quot;offset&amp;quot;&lt;br /&gt;
              &amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ul&amp;gt;&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Look back &amp;quot;offset&amp;quot; bytes into the newly decompressed data&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Copy &amp;quot;count&amp;quot; bytes from here to the end of the newly decompressed data&lt;br /&gt;
 (explanatory: &lt;br /&gt;
remember that each byte copied recently, extending the data and can be copied again, this occurs, for example, when the offset is 1, back one byte, and the counter is 15 + 2 = 17, this copy 17 times the last copied byte).&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Go back to step 1&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
{{BeginFileFormatTools|Type=group}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Camoto]]&lt;br /&gt;
| Platform = Linux/Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = No&lt;br /&gt;
| canCreate = Yes&lt;br /&gt;
| canModify = Yes&lt;br /&gt;
| canCompress = No&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Wombat]]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = Yes&lt;br /&gt;
| canCreate = No&lt;br /&gt;
| canModify = No&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{EndFileFormatTools}}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [http://grompe.org.ru/ Grom PE].  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;/div&gt;</summary>
		<author><name>Luis46coco</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=DAT_Format_(God_of_Thunder)&amp;diff=5319</id>
		<title>DAT Format (God of Thunder)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=DAT_Format_(God_of_Thunder)&amp;diff=5319"/>
		<updated>2014-08-04T16:33:23Z</updated>

		<summary type="html">&lt;p&gt;Luis46coco: /* Compression */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archive Infobox&lt;br /&gt;
 | MaxFiles = 256&lt;br /&gt;
 | FAT = Beginning&lt;br /&gt;
 | Names = Yes, 8 chars&lt;br /&gt;
 | Metadata = None&lt;br /&gt;
 | Subdirectories = N&lt;br /&gt;
 | Compressed = Y&lt;br /&gt;
 | Encrypted = Y&lt;br /&gt;
 | Hidden = Y&lt;br /&gt;
 | Game1 = God of Thunder&lt;br /&gt;
}}&lt;br /&gt;
The &#039;&#039;&#039;DAT format&#039;&#039;&#039; is used by [[God of Thunder]] to store game data in &amp;lt;tt&amp;gt;GOTRES.DAT&amp;lt;/tt&amp;gt;.  Most files are compressed, and the header where the filenames are stored is encrypted with a simple [[XOR cipher]].&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature for this format, however reading in the entire FAT and checking that the filenames contain valid characters and that the offsets and file sizes are within range should correctly identify files.&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file begins with 256 file entries, in the format below.  All these file entries (i.e. the first 5888 bytes of the file) are encrypted with the [[XOR cipher|XOR algorithm]], at the byte level, starting with 128 and incrementing at each byte (so the first byte in the file is XOR&#039;d with 128, the second byte with 129, third byte with 130 and so on.  After XOR&#039;ing with 255 the value wraps and so the next byte is XOR&#039;d with 0.)&lt;br /&gt;
&lt;br /&gt;
The following Python 2.7 script will decrypt the header and output the result to a file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
# Setup our starting variables.&lt;br /&gt;
Cypher = 128                      # Cyper starts at 128.&lt;br /&gt;
Header = &amp;quot;&amp;quot;                       # Header will store the decrypted header.&lt;br /&gt;
HeaderSize = 5888                 # The header in GOTRES.DAT is 5888 bytes.&lt;br /&gt;
&lt;br /&gt;
# Open the God of Thunder data file.&lt;br /&gt;
with open(&amp;quot;GOTRES.DAT&amp;quot;, &amp;quot;rb&amp;quot;) as Input:&lt;br /&gt;
    # Loop through the header which consists of the first 5888 bytes.&lt;br /&gt;
    for x in range(0, HeaderSize):&lt;br /&gt;
        # Read a byte.&lt;br /&gt;
        Byte = Input.read(1)&lt;br /&gt;
        # XOR the byte with the current cypher.&lt;br /&gt;
        Header += chr(ord(Byte) ^ Cypher)&lt;br /&gt;
&lt;br /&gt;
        # Increment the cypher value, and set it back to 0 when it hits 256.&lt;br /&gt;
        Cypher += 1&lt;br /&gt;
        if Cypher == 256:&lt;br /&gt;
            Cypher = 0&lt;br /&gt;
&lt;br /&gt;
# Write the decrypted header to a file.&lt;br /&gt;
with open(&amp;quot;GOTHead.bin&amp;quot;, &amp;quot;w&amp;quot;) as Output:&lt;br /&gt;
    Output.write(Header)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After XOR decryption, each file entry is as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|[[char]] filename[9]||Filename (8 chars max), must be NULL-terminated&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] offset||File offset from start of file&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] size||Length of file stored here&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] decompressedSize||Length of file after decompression&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT16LE]] flags||Flags (1 if file is compressed, 0 otherwise)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The remaining unused file entries are all zeroes.  Since the FAT is fixed at 256 entries, the offset of the first file will always be 5888 (0x1700).&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
If a file&#039;s flag indicates it is compressed, then it should be decompressed with the LZSS algorithm below.  Each file&#039;s data begins with a [[UINT16LE]] value holding the decompressed size, in bytes. skip the next 2 bytes Other [[UINT16LE]] value(??). The rest of the data decompresses as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    If the amount of data decompressed matches the target size, finish.  Otherwise:&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Read a byte from the input data&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    For each bit in the previous byte, from the least significant to the most:&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        If the bit is 1, copy a byte unchanged from the input data to the output&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        Otherwise the bit is zero:&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Read a [[UINT16LE]]&lt;br /&gt;
            &amp;lt;ul&amp;gt;&lt;br /&gt;
              &amp;lt;li&amp;gt;&lt;br /&gt;
                Add two to the upper (most significant) four bits, and treat this value as the LZSS &amp;quot;count&amp;quot;&lt;br /&gt;
              &amp;lt;/li&amp;gt;&lt;br /&gt;
              &amp;lt;li&amp;gt;&lt;br /&gt;
                Take the lower 12 bits and treat the value as the LZSS &amp;quot;offset&amp;quot;&lt;br /&gt;
              &amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ul&amp;gt;&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Look back &amp;quot;offset&amp;quot; bytes into the newly decompressed data&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Copy &amp;quot;count&amp;quot; bytes from here to the end of the newly decompressed data&lt;br /&gt;
 (explanatory: &lt;br /&gt;
remember that each byte copied recently, extending the data and can be copied again, this occurs, for example, when the offset is 1 ,back one byte, and the counter is 15 + 2 = 17, this copy 17 times the last copied byte).&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Go back to step 1&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
{{BeginFileFormatTools|Type=group}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Camoto]]&lt;br /&gt;
| Platform = Linux/Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = No&lt;br /&gt;
| canCreate = Yes&lt;br /&gt;
| canModify = Yes&lt;br /&gt;
| canCompress = No&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Wombat]]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = Yes&lt;br /&gt;
| canCreate = No&lt;br /&gt;
| canModify = No&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{EndFileFormatTools}}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [http://grompe.org.ru/ Grom PE].  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;/div&gt;</summary>
		<author><name>Luis46coco</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=DAT_Format_(God_of_Thunder)&amp;diff=5318</id>
		<title>DAT Format (God of Thunder)</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=DAT_Format_(God_of_Thunder)&amp;diff=5318"/>
		<updated>2014-08-04T15:05:11Z</updated>

		<summary type="html">&lt;p&gt;Luis46coco: /* Compression */ error in header and error if offset+repeat &amp;gt; end the newly decompressed data&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Archive Infobox&lt;br /&gt;
 | MaxFiles = 256&lt;br /&gt;
 | FAT = Beginning&lt;br /&gt;
 | Names = Yes, 8 chars&lt;br /&gt;
 | Metadata = None&lt;br /&gt;
 | Subdirectories = N&lt;br /&gt;
 | Compressed = Y&lt;br /&gt;
 | Encrypted = Y&lt;br /&gt;
 | Hidden = Y&lt;br /&gt;
 | Game1 = God of Thunder&lt;br /&gt;
}}&lt;br /&gt;
The &#039;&#039;&#039;DAT format&#039;&#039;&#039; is used by [[God of Thunder]] to store game data in &amp;lt;tt&amp;gt;GOTRES.DAT&amp;lt;/tt&amp;gt;.  Most files are compressed, and the header where the filenames are stored is encrypted with a simple [[XOR cipher]].&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
&lt;br /&gt;
=== Signature ===&lt;br /&gt;
&lt;br /&gt;
There is no known signature for this format, however reading in the entire FAT and checking that the filenames contain valid characters and that the offsets and file sizes are within range should correctly identify files.&lt;br /&gt;
&lt;br /&gt;
=== File entry ===&lt;br /&gt;
&lt;br /&gt;
The file begins with 256 file entries, in the format below.  All these file entries (i.e. the first 5888 bytes of the file) are encrypted with the [[XOR cipher|XOR algorithm]], at the byte level, starting with 128 and incrementing at each byte (so the first byte in the file is XOR&#039;d with 128, the second byte with 129, third byte with 130 and so on.  After XOR&#039;ing with 255 the value wraps and so the next byte is XOR&#039;d with 0.)&lt;br /&gt;
&lt;br /&gt;
The following Python 2.7 script will decrypt the header and output the result to a file:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;Python&amp;quot;&amp;gt;&lt;br /&gt;
# Setup our starting variables.&lt;br /&gt;
Cypher = 128                      # Cyper starts at 128.&lt;br /&gt;
Header = &amp;quot;&amp;quot;                       # Header will store the decrypted header.&lt;br /&gt;
HeaderSize = 5888                 # The header in GOTRES.DAT is 5888 bytes.&lt;br /&gt;
&lt;br /&gt;
# Open the God of Thunder data file.&lt;br /&gt;
with open(&amp;quot;GOTRES.DAT&amp;quot;, &amp;quot;rb&amp;quot;) as Input:&lt;br /&gt;
    # Loop through the header which consists of the first 5888 bytes.&lt;br /&gt;
    for x in range(0, HeaderSize):&lt;br /&gt;
        # Read a byte.&lt;br /&gt;
        Byte = Input.read(1)&lt;br /&gt;
        # XOR the byte with the current cypher.&lt;br /&gt;
        Header += chr(ord(Byte) ^ Cypher)&lt;br /&gt;
&lt;br /&gt;
        # Increment the cypher value, and set it back to 0 when it hits 256.&lt;br /&gt;
        Cypher += 1&lt;br /&gt;
        if Cypher == 256:&lt;br /&gt;
            Cypher = 0&lt;br /&gt;
&lt;br /&gt;
# Write the decrypted header to a file.&lt;br /&gt;
with open(&amp;quot;GOTHead.bin&amp;quot;, &amp;quot;w&amp;quot;) as Output:&lt;br /&gt;
    Output.write(Header)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
After XOR decryption, each file entry is as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Data type!!Description&lt;br /&gt;
|-&lt;br /&gt;
|[[char]] filename[9]||Filename (8 chars max), must be NULL-terminated&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] offset||File offset from start of file&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] size||Length of file stored here&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT32LE]] decompressedSize||Length of file after decompression&lt;br /&gt;
|-&lt;br /&gt;
|[[UINT16LE]] flags||Flags (1 if file is compressed, 0 otherwise)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The remaining unused file entries are all zeroes.  Since the FAT is fixed at 256 entries, the offset of the first file will always be 5888 (0x1700).&lt;br /&gt;
&lt;br /&gt;
== Compression ==&lt;br /&gt;
&lt;br /&gt;
If a file&#039;s flag indicates it is compressed, then it should be decompressed with the LZSS algorithm below.  Each file&#039;s data begins with a [[UINT16LE]] value holding the decompressed size, in bytes. skip the next 2 bytes Other [[UINT16LE]] value(??). The rest of the data decompresses as follows:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;ol&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    If the amount of data decompressed matches the target size, finish.  Otherwise:&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Read a byte from the input data&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    For each bit in the previous byte, from the least significant to the most:&lt;br /&gt;
    &amp;lt;ul&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        If the bit is 1, copy a byte unchanged from the input data to the output&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
      &amp;lt;li&amp;gt;&lt;br /&gt;
        Otherwise the bit is zero:&lt;br /&gt;
        &amp;lt;ol style=&amp;quot;list-style-type: lower-alpha;&amp;quot;&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Read a [[UINT16LE]]&lt;br /&gt;
            &amp;lt;ul&amp;gt;&lt;br /&gt;
              &amp;lt;li&amp;gt;&lt;br /&gt;
                Add two to the upper (most significant) four bits, and treat this value as the LZSS &amp;quot;count&amp;quot;&lt;br /&gt;
              &amp;lt;/li&amp;gt;&lt;br /&gt;
              &amp;lt;li&amp;gt;&lt;br /&gt;
                Take the lower 12 bits and treat the value as the LZSS &amp;quot;offset&amp;quot;&lt;br /&gt;
              &amp;lt;/li&amp;gt;&lt;br /&gt;
            &amp;lt;/ul&amp;gt;&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Look back &amp;quot;offset&amp;quot; bytes into the newly decompressed data&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
          &amp;lt;li&amp;gt;&lt;br /&gt;
            Copy &amp;quot;count&amp;quot; bytes from here to the end of the newly decompressed data (if end the file repeat the same byte)&lt;br /&gt;
          &amp;lt;/li&amp;gt;&lt;br /&gt;
        &amp;lt;/ol&amp;gt;&lt;br /&gt;
      &amp;lt;/li&amp;gt;&lt;br /&gt;
    &amp;lt;/ul&amp;gt;&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
  &amp;lt;li&amp;gt;&lt;br /&gt;
    Go back to step 1&lt;br /&gt;
  &amp;lt;/li&amp;gt;&lt;br /&gt;
&amp;lt;/ol&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Tools ==&lt;br /&gt;
&lt;br /&gt;
{{BeginFileFormatTools|Type=group}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Camoto]]&lt;br /&gt;
| Platform = Linux/Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = No&lt;br /&gt;
| canCreate = Yes&lt;br /&gt;
| canModify = Yes&lt;br /&gt;
| canCompress = No&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{FileFormatTool&lt;br /&gt;
| Name = [[Wombat]]&lt;br /&gt;
| Platform = Windows&lt;br /&gt;
| canExtract = Yes&lt;br /&gt;
| canDecompress = Yes&lt;br /&gt;
| canCreate = No&lt;br /&gt;
| canModify = No&lt;br /&gt;
| canCompress = N/A&lt;br /&gt;
| editHidden = No&lt;br /&gt;
| editMetadata = N/A&lt;br /&gt;
}}&lt;br /&gt;
{{EndFileFormatTools}}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [http://grompe.org.ru/ Grom PE].  If you find this information helpful in a project you&#039;re working on, please give credit where credit is due.  (A link back to this wiki would be nice too!)&lt;/div&gt;</summary>
		<author><name>Luis46coco</name></author>
	</entry>
</feed>