<?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=Vanshilar</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=Vanshilar"/>
	<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/wiki/Special:Contributions/Vanshilar"/>
	<updated>2026-06-28T03:57:25Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.11</generator>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=7013</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=7013"/>
		<updated>2016-12-21T11:30:44Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Territory data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of tasks (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of players (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of territories (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || [[INT16LE]] || 144 || Variables for plots&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Amount of Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Amount of Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Amount of Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Amount of Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Amount of Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Amount of Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Amount of Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Amount of Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Amount of Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Amount of Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Amount of Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Amount of Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Amount of Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Amount of Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Amount of Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Amount of Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Amount of Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Amount of Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Church standing (0 = excommunicated, 1 = not excommunicated)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 1 || [[UINT8]] || Unknown, but probably related to attack effectiveness (is based on Mil points, army size and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 35 || 1 || [[UINT8]] || Unknown, but probably related to defense effectiveness (is based on Mil points, army size and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 1 || [[UINT8]] || Rank (based on score), updated at beginning of each month&lt;br /&gt;
|-&lt;br /&gt;
| 37 || 1 || [[UINT8]] || If claimed the throne (0 = haven&#039;t claimed, 1 = have claimed the throne)&lt;br /&gt;
|-&lt;br /&gt;
| 38 || 1 || [[UINT8]] || Unknown (0 if computer, 1 if human)&lt;br /&gt;
|-&lt;br /&gt;
| 39 || 3 || Unknown || Unknown (seems to always be 0)&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown (seems to always be 0)&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 1 || [[UINT8]] || Number of possible concurrent tasks&lt;br /&gt;
|-&lt;br /&gt;
| 78 || 1 || [[UINT8]] || Unknown (0 if computer, 1 if human)&lt;br /&gt;
|-&lt;br /&gt;
| 79 || 1 || [[UINT8]] || Starting territory&lt;br /&gt;
|-&lt;br /&gt;
| 80 || 6 || [[UINT8]] || Opinion of each of the factions (Valois, Anjou, Albion, Burgundy, The Pope, Aragon), minimum of 1, maximum of 9&lt;br /&gt;
|-&lt;br /&gt;
| 86 || 6 || [[INT8]] || Months since was last attacked/saboteured by each faction (-1 means never)&lt;br /&gt;
|-&lt;br /&gt;
| 92 || 6 || [[INT8]] || Months since last successful diplomacy with each faction (-1 means never)&lt;br /&gt;
|-&lt;br /&gt;
| 98 || 1 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 99 || 1 || [[UINT8]] || Church standing message (if different from byte 31, give appropriate message)&lt;br /&gt;
|-&lt;br /&gt;
| 100 || 1 || [[UINT8]] || Resource type needed to pay troops (0 = food, 3 = gold)&lt;br /&gt;
|-&lt;br /&gt;
| 101 || 1 || [[UINT8]] || Amount of food/gold needed to pay troops&lt;br /&gt;
|-&lt;br /&gt;
| 102 || 1 || [[UINT8]] || If human player didn&#039;t pay troops&lt;br /&gt;
|-&lt;br /&gt;
| 103 || 1 || [[UINT8]] || Number of troop units&lt;br /&gt;
|-&lt;br /&gt;
| 104 || 1 || [[INT8]] || Days left before checking to pay troops (-1 = don&#039;t need to pay troops)&lt;br /&gt;
|-&lt;br /&gt;
| 105 || 1 || [[UINT8]] || If computer player didn&#039;t pay troops&lt;br /&gt;
|-&lt;br /&gt;
| 106 || 1 || [[UINT8]] || After claim, days left before Pope decides on claim&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Value || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Variables for plots ==&lt;br /&gt;
&lt;br /&gt;
These are mostly related to data used in the plots in a given game. They are used to store plot details such as the player&#039;s choices (plot progress -- such as where in the plotline the player is -- is stored elsewhere). Each variable is two bytes long, signed. They are referred to in lib.clu as variable 1000 to variable 1199, and thus will be referred to in the same way here; these are stored as variables 0 to 199 in this section, each two bytes long. Though they can be used to store different things, a number of these variables are used in the same way and stored across different plots. Known variables are below.&lt;br /&gt;
&lt;br /&gt;
For the fractional values, once they reach 100, they increment the related field. For example, if the fractional human player relations with The Pope reaches 106, then it will be changed to 6 and the human player&#039;s relations with The Pope will increase by 1.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Variable || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 1088 || 2 || [[INT16LE]] || Fractional human player relations with The Pope (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1089 || 2 || [[INT16LE]] || Fractional human player relations with Aragon (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1090 || 2 || [[INT16LE]] || Fractional human player relations with Anjou (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1091 || 2 || [[INT16LE]] || Fractional human player relations with Burgundy (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1092 || 2 || [[INT16LE]] || Fractional human player relations with Valois (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1093 || 2 || [[INT16LE]] || Fractional human player relations with Albion (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1099 || 2 || [[INT16LE]] || Fractional human player happiness (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1197 || 2 || [[INT16LE]] || Faction of human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=7011</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=7011"/>
		<updated>2016-12-10T07:01:09Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Player stats */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of tasks (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of players (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of territories (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || [[INT16LE]] || 144 || Variables for plots&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Amount of Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Amount of Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Amount of Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Amount of Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Amount of Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Amount of Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Amount of Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Amount of Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Amount of Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Amount of Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Amount of Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Amount of Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Amount of Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Amount of Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Amount of Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Amount of Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Amount of Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Amount of Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Church standing (0 = excommunicated, 1 = not excommunicated)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 1 || [[UINT8]] || Unknown, but probably related to attack effectiveness (is based on Mil points, army size and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 35 || 1 || [[UINT8]] || Unknown, but probably related to defense effectiveness (is based on Mil points, army size and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 1 || [[UINT8]] || Rank (based on score), updated at beginning of each month&lt;br /&gt;
|-&lt;br /&gt;
| 37 || 1 || [[UINT8]] || If claimed the throne (0 = haven&#039;t claimed, 1 = have claimed the throne)&lt;br /&gt;
|-&lt;br /&gt;
| 38 || 1 || [[UINT8]] || Unknown (0 if computer, 1 if human)&lt;br /&gt;
|-&lt;br /&gt;
| 39 || 3 || Unknown || Unknown (seems to always be 0)&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown (seems to always be 0)&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 1 || [[UINT8]] || Number of possible concurrent tasks&lt;br /&gt;
|-&lt;br /&gt;
| 78 || 1 || [[UINT8]] || Unknown (0 if computer, 1 if human)&lt;br /&gt;
|-&lt;br /&gt;
| 79 || 1 || [[UINT8]] || Starting territory&lt;br /&gt;
|-&lt;br /&gt;
| 80 || 6 || [[UINT8]] || Opinion of each of the factions (Valois, Anjou, Albion, Burgundy, The Pope, Aragon), minimum of 1, maximum of 9&lt;br /&gt;
|-&lt;br /&gt;
| 86 || 6 || [[INT8]] || Months since was last attacked/saboteured by each faction (-1 means never)&lt;br /&gt;
|-&lt;br /&gt;
| 92 || 6 || [[INT8]] || Months since last successful diplomacy with each faction (-1 means never)&lt;br /&gt;
|-&lt;br /&gt;
| 98 || 1 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 99 || 1 || [[UINT8]] || Church standing message (if different from byte 31, give appropriate message)&lt;br /&gt;
|-&lt;br /&gt;
| 100 || 1 || [[UINT8]] || Resource type needed to pay troops (0 = food, 3 = gold)&lt;br /&gt;
|-&lt;br /&gt;
| 101 || 1 || [[UINT8]] || Amount of food/gold needed to pay troops&lt;br /&gt;
|-&lt;br /&gt;
| 102 || 1 || [[UINT8]] || If human player didn&#039;t pay troops&lt;br /&gt;
|-&lt;br /&gt;
| 103 || 1 || [[UINT8]] || Number of troop units&lt;br /&gt;
|-&lt;br /&gt;
| 104 || 1 || [[INT8]] || Days left before checking to pay troops (-1 = don&#039;t need to pay troops)&lt;br /&gt;
|-&lt;br /&gt;
| 105 || 1 || [[UINT8]] || If computer player didn&#039;t pay troops&lt;br /&gt;
|-&lt;br /&gt;
| 106 || 1 || [[UINT8]] || After claim, days left before Pope decides on claim&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Variables for plots ==&lt;br /&gt;
&lt;br /&gt;
These are mostly related to data used in the plots in a given game. They are used to store plot details such as the player&#039;s choices (plot progress -- such as where in the plotline the player is -- is stored elsewhere). Each variable is two bytes long, signed. They are referred to in lib.clu as variable 1000 to variable 1199, and thus will be referred to in the same way here; these are stored as variables 0 to 199 in this section, each two bytes long. Though they can be used to store different things, a number of these variables are used in the same way and stored across different plots. Known variables are below.&lt;br /&gt;
&lt;br /&gt;
For the fractional values, once they reach 100, they increment the related field. For example, if the fractional human player relations with The Pope reaches 106, then it will be changed to 6 and the human player&#039;s relations with The Pope will increase by 1.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Variable || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 1088 || 2 || [[INT16LE]] || Fractional human player relations with The Pope (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1089 || 2 || [[INT16LE]] || Fractional human player relations with Aragon (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1090 || 2 || [[INT16LE]] || Fractional human player relations with Anjou (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1091 || 2 || [[INT16LE]] || Fractional human player relations with Burgundy (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1092 || 2 || [[INT16LE]] || Fractional human player relations with Valois (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1093 || 2 || [[INT16LE]] || Fractional human player relations with Albion (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1099 || 2 || [[INT16LE]] || Fractional human player happiness (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1197 || 2 || [[INT16LE]] || Faction of human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6835</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6835"/>
		<updated>2016-04-18T13:34:42Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Player stats */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of tasks (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of players (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of territories (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || [[INT16LE]] || 144 || Variables for plots&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Church standing (0 = excommunicated, 1 = not excommunicated)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 1 || [[UINT8]] || Unknown, but probably related to attack effectiveness (is based on Mil points, army size and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 35 || 1 || [[UINT8]] || Unknown, but probably related to defense effectiveness (is based on Mil points, army size and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 3 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 80 || 6 || [[UINT8]] || Unknown, but probably related to relations with other factions&lt;br /&gt;
|-&lt;br /&gt;
| 86 || 13 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 99 || 1 || [[UINT8]] || Church standing message (if different from byte 31, give appropriate message)&lt;br /&gt;
|-&lt;br /&gt;
| 100 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Variables for plots ==&lt;br /&gt;
&lt;br /&gt;
These are mostly related to data used in the plots in a given game. They are used to store plot details such as the player&#039;s choices (plot progress -- such as where in the plotline the player is -- is stored elsewhere). Each variable is two bytes long, signed. They are referred to in lib.clu as variable 1000 to variable 1199, and thus will be referred to in the same way here; these are stored as variables 0 to 199 in this section, each two bytes long. Though they can be used to store different things, a number of these variables are used in the same way and stored across different plots. Known variables are below.&lt;br /&gt;
&lt;br /&gt;
For the fractional values, once they reach 100, they increment the related field. For example, if the fractional human player relations with The Pope reaches 106, then it will be changed to 6 and the human player&#039;s relations with The Pope will increase by 1.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Variable || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 1088 || 2 || [[INT16LE]] || Fractional human player relations with The Pope (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1089 || 2 || [[INT16LE]] || Fractional human player relations with Aragon (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1090 || 2 || [[INT16LE]] || Fractional human player relations with Anjou (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1091 || 2 || [[INT16LE]] || Fractional human player relations with Burgundy (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1092 || 2 || [[INT16LE]] || Fractional human player relations with Valois (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1093 || 2 || [[INT16LE]] || Fractional human player relations with Albion (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1099 || 2 || [[INT16LE]] || Fractional human player happiness (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1197 || 2 || [[INT16LE]] || Faction of human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6834</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6834"/>
		<updated>2016-04-18T11:17:58Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Variables for plots */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of tasks (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of players (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of territories (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || [[INT16LE]] || 144 || Variables for plots&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Variables for plots ==&lt;br /&gt;
&lt;br /&gt;
These are mostly related to data used in the plots in a given game. They are used to store plot details such as the player&#039;s choices (plot progress -- such as where in the plotline the player is -- is stored elsewhere). Each variable is two bytes long, signed. They are referred to in lib.clu as variable 1000 to variable 1199, and thus will be referred to in the same way here; these are stored as variables 0 to 199 in this section, each two bytes long. Though they can be used to store different things, a number of these variables are used in the same way and stored across different plots. Known variables are below.&lt;br /&gt;
&lt;br /&gt;
For the fractional values, once they reach 100, they increment the related field. For example, if the fractional human player relations with The Pope reaches 106, then it will be changed to 6 and the human player&#039;s relations with The Pope will increase by 1.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Variable || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 1088 || 2 || [[INT16LE]] || Fractional human player relations with The Pope (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1089 || 2 || [[INT16LE]] || Fractional human player relations with Aragon (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1090 || 2 || [[INT16LE]] || Fractional human player relations with Anjou (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1091 || 2 || [[INT16LE]] || Fractional human player relations with Burgundy (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1092 || 2 || [[INT16LE]] || Fractional human player relations with Valois (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1093 || 2 || [[INT16LE]] || Fractional human player relations with Albion (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1099 || 2 || [[INT16LE]] || Fractional human player happiness (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1197 || 2 || [[INT16LE]] || Faction of human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6833</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6833"/>
		<updated>2016-04-18T11:17:24Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of tasks (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of players (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of territories (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || [[INT16LE]] || 144 || Variables for plots&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Variables for plots ==&lt;br /&gt;
&lt;br /&gt;
These are mostly related to data used in the plots in a given game. They are used to store plot details such as the player&#039;s choices (plot progress -- such as where in the plotline the player is -- is stored elsewhere). Each variable is two bytes long, signed. They are referred to in lib.clu as variable 1000 to variable 1199, and thus will be referred to in the same way here; these are stored as variables 0 to 199 in this section, each two bytes long. Though they can be used to store different things, a number of these variables are used in the same way and stored across different plots. Known variables are below.&lt;br /&gt;
&lt;br /&gt;
For the fractional values, once they reach 100, they increment the related field. For example, if the fractional human player relations with The Pope reaches 106, then it will be changed to 6 and the human player&#039;s relations with The Pope will increase by 1.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 1088 || 2 || [[INT16LE]] || Fractional human player relations with The Pope (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1089 || 2 || [[INT16LE]] || Fractional human player relations with Aragon (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1090 || 2 || [[INT16LE]] || Fractional human player relations with Anjou (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1091 || 2 || [[INT16LE]] || Fractional human player relations with Burgundy (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1092 || 2 || [[INT16LE]] || Fractional human player relations with Valois (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1093 || 2 || [[INT16LE]] || Fractional human player relations with Albion (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1099 || 2 || [[INT16LE]] || Fractional human player happiness (out of 100)&lt;br /&gt;
|-&lt;br /&gt;
| 1197 || 2 || [[INT16LE]] || Faction of human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6822</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6822"/>
		<updated>2016-04-08T03:22:08Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* File format */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of tasks (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of players (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown, likely number of territories (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || [[INT16LE]] || 144 || Variables for plots&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6819</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6819"/>
		<updated>2016-04-03T04:36:31Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || [[INT16LE]] || 72 || Months left before revolt for each of the 36 territories (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Months left before revolt ==&lt;br /&gt;
&lt;br /&gt;
This gives the months left before each territory will revolt, in 2-byte signed integers for each of the 36 territories (for a total of 72 bytes). It decreases by 1 on the 1st of each month. Once the territory is at 5 months or less, it&#039;ll start warning that a revolt is likely. Once the territory is at 1 month, on the 1st of the following month it will revolt. If the value is 0xFFFF then it is not counting down months to revolt (because it is neutral or because a Large Castle is nearby.)&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6818</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6818"/>
		<updated>2016-04-03T02:52:25Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Territory data */ corrected some incorrect byte values&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || Unknown || 72 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 242 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 244 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 246 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 248 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 250 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 252 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 254 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 256 || 1 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6815</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6815"/>
		<updated>2016-03-19T22:56:25Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Territory data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || Unknown || 72 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for all small pieces except the keep and is up to 31 for all tall pieces and the small keep. Note that this includes the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6814</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6814"/>
		<updated>2016-03-19T21:29:43Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: /* Territory data */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || Unknown || 72 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for small pieces and 31 for tall pieces. Note that this includes the keep and the door. The next bit (representing 64) is 1 if the piece has been modified since the last time it was viewed by the human player, 0 if no change since the last time. The practical use of this bit is unknown. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6813</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6813"/>
		<updated>2016-03-13T07:15:10Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || Unknown || 72 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for small pieces and 31 for tall pieces. Note that this includes the keep and the door. The next bit (representing 64) is 0 normally, but 1 if it&#039;s the keep. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that the castle file, *.LYT, is simply the first 246 bytes of this territory data, in unencrypted form.&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6812</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6812"/>
		<updated>2016-03-13T07:13:53Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || Unknown || 72 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 240 || [[UINT8]] || Data for each castle piece, in sets of 3 bytes for each of 80 allowed pieces&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces in data&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Number of castle pieces to be built (i.e. actual castle)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total built castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Total possible castle points, excluding moat (in tenths of a point)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Percentage completed (including moat if applicable)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Whether or not moat will be built (0 = no moat, 1 = moat)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 2 || [[UINT16LE]] || Moat points completed, max 500 (in tenths of a point, so value of 500 means 50 points)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT8]] || Castle build priority (0 = uniform, 1 = outward, 2 = inward, 3 = tower)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Each castle piece is composed of 3 bytes, in little endian form. The first 6 bits (the &amp;quot;small&amp;quot; 6 bits of the first byte) are the horizontal coordinate of the castle piece, with 0 being at the left. The next 6 bits (the &amp;quot;large&amp;quot; 2 bits of the first byte being the smaller bits, and the &amp;quot;small&amp;quot; 4 bits of the second byte being the large bits) are the vertical coordinate of the castle piece, with 0 being at the top. The next 4 bits (the &amp;quot;large&amp;quot; 4 bits of the second byte) are the type of castle piece. For the last byte, the first bit (the &amp;quot;small&amp;quot; bit) is if the piece is a small piece (0) or a tall piece (1). The next 5 bits are the points value of the piece, which is up to 19 for small pieces and 31 for tall pieces. Note that this includes the keep and the door. The next bit (representing 64) is 0 normally, but 1 if it&#039;s the keep. The last bit (representing 128) is unused.&lt;br /&gt;
&lt;br /&gt;
The pieces are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Square tower&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Round tower&lt;br /&gt;
|-&lt;br /&gt;
| 2 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Keep&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Low wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Low wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Low wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Low wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 8 || High wall (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 9 || High wall (northwest-southeast)&lt;br /&gt;
|-&lt;br /&gt;
| 10 || High wall (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 11 || High wall (northeast-southwest)&lt;br /&gt;
|-&lt;br /&gt;
| 12 || door (east-west)&lt;br /&gt;
|-&lt;br /&gt;
| 13 || door (north-south)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
| 15 || (Unused)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6811</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6811"/>
		<updated>2016-03-11T20:06:48Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes for the floppy version and 11733 bytes for the CD version. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted using bit-wise XOR, or bitxor. The second byte (byte 1) is the encryption bitxor value. The file is split into sections. From the 5th byte onward, the first byte of each section is bitxored with the encryption bitxor value, as well as with the length of that section (modulo 256). Every remaining byte in each section is bitxored with the immediately preceding (bitxored) byte. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. This is also further complicated by that many game fields take up 2 bytes (in little endian style), thus changing the value of a given byte will likely make that field&#039;s value too large or garbage. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
For example, the first section (tasks) has a length of 936 bytes. 936 modulo 256 is 168. Say the encryption bitxor value was 172, and the first 5 bytes of the tasks section from the save game file were 5, 4, 4, 136, and 171. To decrypt these values, bitxor the first value (5) with the encryption bitxor value (172), to get 169. Then bitxor this value with the length of section modulo 256 (168), to get 1. For subsequent bytes, take the bitxor with the immediately preceding byte value; 5 bitxored with 4 is 1, 4 bitxored with 4 is 0, 4 bitxored with 136 is 140, and 136 bitxored with 171 is 35. So the decrypted values are 1, 1, 0, 140, and 35. The 1st byte means the task is in progress, the 2nd and 3rd bytes (little endian) are the current progress of the task (value of 1, indicating a task which just begun), and the 4th and 5th bytes (little endian) are the total progress needed to complete the task, in this case 140 + 35*256 = 9100.&lt;br /&gt;
&lt;br /&gt;
In Excel, the bitxor of two values can be via the BITXOR command for newer versions, or by using the following formula for older versions (assuming the two values are in A1 and A2):&lt;br /&gt;
&lt;br /&gt;
=BIN2DEC(SUBSTITUTE(DEC2BIN(A1,8)+DEC2BIN(A2),2,0))&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || (none) || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || (none) || Encryption bitxor value for rest of save file (from byte 4 onward)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 2 || [[UINT16LE]] || (none) || Number of sections in save file (value is always 25 (0xA9) for floppy, 29 (0xAD) for CD)&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || 168 || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || 90 || Player stats; each set uses 143 bytes of data, for each the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 6 (0x06) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || 36 || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || 2 || Faction of the human player (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || 36 || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || 2 || Unknown (value is always 36 (0x24) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 400 || Unknown || 144 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11494 (0x2CE6) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11496 (0x2CE8) || 88 || Unknown || 88 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11584 (0x2D40) || 2 || [[UINT16LE]] || 2 || Days left until next plot event&lt;br /&gt;
|-&lt;br /&gt;
| 11586 (0x2D42) || 72 || Unknown || 72 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11658 (0x2D8A) || 2 || [[UINT16LE]] || 2 || Time of day (once it reaches 48 or 50 or so, advance to next day)&lt;br /&gt;
|-&lt;br /&gt;
| 11660 (0x2D8C) || 2 || [[UINT16LE]] || 2 || Current date (add 1, i.e. save file value of 6 is in-game date of 7)&lt;br /&gt;
|-&lt;br /&gt;
| 11662 (0x2D8E) || 2 || [[UINT16LE]] || 2 || Current month (0 = Jan, 1 = Feb, 2 = Mar, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11664 (0x2D90) || 2 || [[UINT16LE]] || 2 || Current year&lt;br /&gt;
|-&lt;br /&gt;
| 11666 (0x2D92) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11668 (0x2D94) || 2 || [[UINT16LE]] || 2 || Plots on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11670 (0x2D96) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11672 (0x2D98) || 2 || [[UINT16LE]] || 2 || Faction of human player (but not used? byte 1838 is what determines human player stats)&lt;br /&gt;
|-&lt;br /&gt;
| 11674 (0x2D9A) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11676 (0x2D9C) || 2 || [[UINT16LE]] || 2 || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
| 11678 (0x2D9E) || 2 || [[UINT16LE]] || 2 || Battles on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = easy, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
For the CD version of the game, the last few sections are instead:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || First byte bitxor || Description&lt;br /&gt;
|-&lt;br /&gt;
| 11680 (0x2DA0) || 2 || [[UINT16LE]] || 2 || Music level&lt;br /&gt;
|-&lt;br /&gt;
| 11682 (0x2DA2) || 2 || [[UINT16LE]] || 2 || Speech on or off (0 = off, 1 = on)&lt;br /&gt;
|-&lt;br /&gt;
| 11684 (0x2DA4) || 2 || [[UINT16LE]] || 2 || Difficulty (0 = easy, 1 = average, 2 = hard, 3 = impossible)&lt;br /&gt;
|-&lt;br /&gt;
| 11686 (0x2DA6) || 36 || [[UINT8]] || 36 || Territory&#039;s unique castle ID (0 = none, 1 = Beaumaris, 2 = Bodiam, etc.)&lt;br /&gt;
|-&lt;br /&gt;
| 11722 (0x2DCA) || 11 || [[UINT8]] || 11 || If human has built unique castle (1st byte always 0, 2nd byte is Beaumaris, 3rd byte is Bodiam, etc.; 0 = not built, 1 = built)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but probably related to battle effectiveness (is based on Mil points and happiness)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 255 || [[UINT8]] || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6810</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6810"/>
		<updated>2016-03-08T04:03:12Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines the meaning of the data stored at that location.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, the first byte in many sections has an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically, this assumption is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions; first byte is bitxored with 168 (0xA8), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || Player stats; each set uses 143 bytes of data, for each the 6 factions; first byte is bitxored with 90 (0x5A), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || Unknown (value is always 4 (0x04) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || Faction of the human player; first value is bitxored with 2 (0x02)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || Territory data; each set uses 257 bytes, for each of the 36 territories; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 588 || unknown || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but related to battle (decreases on a failed attack, but not on cancelled/successful attack)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 255 || [[UINT8]] || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6809</id>
		<title>Castles II: Siege and Conquest</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6809"/>
		<updated>2016-03-08T03:55:05Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
{{Game Infobox&lt;br /&gt;
 | Levels = No&lt;br /&gt;
 | Tiles = No&lt;br /&gt;
 | Sprites = No&lt;br /&gt;
 | Fullscreen = No&lt;br /&gt;
 | Sound = No&lt;br /&gt;
 | Music = No&lt;br /&gt;
 | Text = No&lt;br /&gt;
 | Story = No&lt;br /&gt;
 | Interface = No&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Castles II: Siege and Conquest&#039;&#039;&#039; is a real-time strategy game where the players vie to be the new king of Bretagne by conquering territory, making an army, and building castles.&lt;br /&gt;
&lt;br /&gt;
Unless otherwise noted, this page is for the floppy version of the game. The CD version may have somewhat different game mechanics and file formats than what is presented here.&lt;br /&gt;
&lt;br /&gt;
{{BeginGameFileList}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = lib.clu&lt;br /&gt;
 | Format = [[Castles II: Siege and Conquest Cluster Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Library cluster for plots&lt;br /&gt;
}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = *.gam&lt;br /&gt;
 | Format = [[Castles II: Siege and Conquest Save Game Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Save game&lt;br /&gt;
}}&lt;br /&gt;
{{EndGameFileList}}&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6808</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6808"/>
		<updated>2016-03-07T10:22:00Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines what field or data is stored.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, the first byte in many sections has an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically, this assumption is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 factions; first byte is bitxored with 168 (0xA8), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || Player stats; each set uses 143 bytes of data, for each the 6 factions; first byte is bitxored with 90 (0x5A), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || Unknown (value is always 4 (0x04) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || Relations between factions; each set uses 6 bytes of data, for each of the 6 factions; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || Faction of the human player; first value is bitxored with 2 (0x02)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || Territory data; each set uses 257 bytes, for each of the 36 territories; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 588 || unknown || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but related to battle (decreases on a failed attack, but not on cancelled/successful attack)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between factions ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each faction&#039;s relations with each of the 6 factions (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 255 || [[UINT8]] || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6807</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6807"/>
		<updated>2016-03-07T10:13:21Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines what field or data is stored.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, the first byte in many sections has an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically, this assumption is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that some (or many) of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 players; first byte is bitxored with 168 (0xA8), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || Player stats; each set uses 143 bytes of data, for each the 6 players; first byte is bitxored with 90 (0x5A), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || Unknown (value is always 4 (0x04) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || Relations between players; each set uses 6 bytes of data, for each of the 6 players; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || Faction of human player; first value is bitxored with 2 (0x02)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || Territory data; each set uses 257 bytes, for each of the 36 territories; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 588 || unknown || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task for each of the factions, in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for each faction in the order of Valois, Anjou, Albion, Burgundy, The Pope, and Aragon.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but related to battle (decreases on a failed attack, but not on cancelled/successful attack)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between players ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each player&#039;s relations with each of the 6 players (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 255 || [[UINT8]] || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6806</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6806"/>
		<updated>2016-03-06T18:39:55Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines what field or data is stored.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, the first byte in many sections has an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically, this assumption is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
Although the below tables gives data types as unsigned integers (UINTs), it is possible that a number of them are actually signed (INTs). However, generally speaking, most of the values should be from 0 to 127, so this does not make a difference. A notable exception is that the progress to the next Adm/Mil/Pol are signed integers, but for Adm, the player needs to reach a threshold of 125 for 8 Adm and 140 for 9 Adm, making it very difficult to reach 8 Adm and impossible to reach 9 Adm through task completions alone.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 players; first byte is bitxored with 168 (0xA8), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || Player stats; each set uses 143 bytes of data, for each the 6 players; first byte is bitxored with 90 (0x5A), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || Unknown (value is always 4 (0x04) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || Relations between players; each set uses 6 bytes of data, for each of the 6 players; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || Faction of human player; first value is bitxored with 2 (0x02)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || Territory data; each set uses 257 bytes, for each of the 36 territories; first byte is bitxored with 36 (0x24), rest are bitxored with previous byte&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 588 || unknown || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task, for player 1 (human) to player 6.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target faction (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for player 1 (human) to player 6.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Gold production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but related to battle (decreases on a failed attack, but not on cancelled/successful attack)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Relations between players ==&lt;br /&gt;
&lt;br /&gt;
Each set of relations is 6 bytes long, storing each player&#039;s relations with each of the 6 players (including themselves). The order is Valois, Anjou, Albion, Burgundy, The Pope, and Aragon, for both each set of 6 bytes and the 6 bytes within each set. The relations are as shown in the &amp;quot;relations&amp;quot; screens, with values from 1 to 9. Though probably not important, it should be noted that a player&#039;s relation with himself is 9 if he&#039;s a computer, and 8 if he&#039;s the human.&lt;br /&gt;
&lt;br /&gt;
== Territory data ==&lt;br /&gt;
&lt;br /&gt;
The data for each territory is 257 bytes long. After an initial set of data containing basic information about the territory, the rest pertains to the castle on the territory (if it exists), such as the ID, location, hitpoints, etc. of each piece.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Owner (0 = Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Resource (0 = Food, 1 = Timber, 2 = Iron, 3 = Gold)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 255 || [[UINT8]] || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The territories are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Territory ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || Brittany&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Normandy&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Rouen&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Amiens&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Calais&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Flanders&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Vannes&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Chartres&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Reims&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Nantes&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Maine&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Orleans&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Dijon&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Poitou&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Tours&lt;br /&gt;
|-&lt;br /&gt;
| 15 || La Marche&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Blois&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Nevers&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Bourbon&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Angouleme&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Limoges&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Rochefort&lt;br /&gt;
|-&lt;br /&gt;
| 22 || Bergerac&lt;br /&gt;
|-&lt;br /&gt;
| 23 || Auvergne&lt;br /&gt;
|-&lt;br /&gt;
| 24 || Bordeaux&lt;br /&gt;
|-&lt;br /&gt;
| 25 || La Tour&lt;br /&gt;
|-&lt;br /&gt;
| 26 || Quercy&lt;br /&gt;
|-&lt;br /&gt;
| 27 || Loire&lt;br /&gt;
|-&lt;br /&gt;
| 28 || Lyon&lt;br /&gt;
|-&lt;br /&gt;
| 29 || Valence&lt;br /&gt;
|-&lt;br /&gt;
| 30 || Gascony&lt;br /&gt;
|-&lt;br /&gt;
| 31 || Toulouse&lt;br /&gt;
|-&lt;br /&gt;
| 32 || Albi&lt;br /&gt;
|-&lt;br /&gt;
| 33 || Narbonne&lt;br /&gt;
|-&lt;br /&gt;
| 34 || Nimes&lt;br /&gt;
|-&lt;br /&gt;
| 35 || Provence&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6805</id>
		<title>Castles II: Siege and Conquest</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6805"/>
		<updated>2016-03-06T12:59:40Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
{{Game Infobox&lt;br /&gt;
 | Levels = No&lt;br /&gt;
 | Tiles = No&lt;br /&gt;
 | Sprites = No&lt;br /&gt;
 | Fullscreen = No&lt;br /&gt;
 | Sound = No&lt;br /&gt;
 | Music = No&lt;br /&gt;
 | Text = No&lt;br /&gt;
 | Story = No&lt;br /&gt;
 | Interface = No&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Castles II: Siege and Conquest&#039;&#039;&#039; is a real-time strategy game where the players vie to be the new king of Bretagne by conquering territory, making an army, and building castles.&lt;br /&gt;
&lt;br /&gt;
{{BeginGameFileList}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = *.clu&lt;br /&gt;
 | Format = [[Castles II: Siege and Conquest Cluster Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Library cluster for plots&lt;br /&gt;
}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = *.gam&lt;br /&gt;
 | Format = [[Castles II: Siege and Conquest Save Game Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Save game&lt;br /&gt;
}}&lt;br /&gt;
{{EndGameFileList}}&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6804</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6804"/>
		<updated>2016-03-06T12:56:32Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines what field or data is stored.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, the first byte in many sections has an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically, this assumption is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
| 4 (0x0004) || 936 || [[UINT8]] || Tasks; each task uses 26 bytes of data, tasks 1 to 6 for each of the 6 players; first value is bitxored with 168 (0xA8), rest are bitxored with previous value&lt;br /&gt;
|-&lt;br /&gt;
| 940 (0x03AC) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 942 (0x03AE) || 858 || [[UINT8]] || Player stats; each set uses 143 bytes of data, for each the 6 players; first value is bitxored with 90 (0x5A), rest are bitxored with previous value&lt;br /&gt;
|-&lt;br /&gt;
| 1800 (0x0708) || 2 || [[UINT16LE]] || Unknown (value is always 4 (0x04) )&lt;br /&gt;
|-&lt;br /&gt;
| 1802 (0x070A) || 36 || [[UINT8]] || Relations between players; each set uses 6 bytes of data, for each of the 6 players; first value is bitxored with 36 (0x24), rest are bitxored with previous value&lt;br /&gt;
|-&lt;br /&gt;
| 1838 (0x072E) || 2 || [[UINT16LE]] || Human player; first value is bitxored with 2 (0x02)&lt;br /&gt;
|-&lt;br /&gt;
| 1840 (0x0730) || 9252 || [[UINT8]] || Territory data; each set uses 257 bytes, for each of the 36 territories&lt;br /&gt;
|-&lt;br /&gt;
| 11092 (0x2B54) || 2 || [[UINT16LE]] || Unknown (value is always 38 (0x22) )&lt;br /&gt;
|-&lt;br /&gt;
| 11094 (0x2B56) || 588 || unknown || Unknown (to be determined)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Tasks ==&lt;br /&gt;
&lt;br /&gt;
Each task consists of 26 bytes of data. The tasks are stored from the first task to the sixth task, for player 1 (human) to player 6.&lt;br /&gt;
&lt;br /&gt;
The data for each task is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Status (1 = in progress, 3 = not active (completed or cancelled), 4 = unavailable)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 2 || [[UINT16LE]] || Current progress on task&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 2 || [[UINT16LE]] || Needed progress to complete task&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 2 || [[UINT16LE]] || Unknown (usually 0, but sometimes 1 for computer tasks)&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Task ID&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Number of Adm points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Number of Mil points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Number of Pol points used on task&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 7 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Target territory (0 if none, else 0 to 35 for the 36 possible territories)&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Target family (0 = none or Valois, 1 = Anjou, 2 = Albion, 3 = Burgundy, 4 = The Pope, 5 = Aragon, 7 = neutral)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 5 || Unknown || Task-dependent data&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || If task was cancelled (0 = not cancelled, 1 = cancelled)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The list of Task IDs are:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Task ID || Name&lt;br /&gt;
|-&lt;br /&gt;
| 0 || (blank)&lt;br /&gt;
|-&lt;br /&gt;
| 1 || Gather Food&lt;br /&gt;
|-&lt;br /&gt;
| 2 || Cut Timber&lt;br /&gt;
|-&lt;br /&gt;
| 3 || Mine Iron&lt;br /&gt;
|-&lt;br /&gt;
| 4 || Refine Gold&lt;br /&gt;
|-&lt;br /&gt;
| 5 || Build Castle&lt;br /&gt;
|-&lt;br /&gt;
| 6 || Police Realm&lt;br /&gt;
|-&lt;br /&gt;
| 7 || Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 8 || Archers&lt;br /&gt;
|-&lt;br /&gt;
| 9 || Knights&lt;br /&gt;
|-&lt;br /&gt;
| 10 || Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 11 || Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 12 || Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 13 || Trojan Rabbit (unavailable in game)&lt;br /&gt;
|-&lt;br /&gt;
| 14 || Attack&lt;br /&gt;
|-&lt;br /&gt;
| 15 || Saboteur&lt;br /&gt;
|-&lt;br /&gt;
| 16 || Scout&lt;br /&gt;
|-&lt;br /&gt;
| 17 || Spy&lt;br /&gt;
|-&lt;br /&gt;
| 18 || Diplomat&lt;br /&gt;
|-&lt;br /&gt;
| 19 || Merchant&lt;br /&gt;
|-&lt;br /&gt;
| 20 || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 21 || Council&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
Note that TASKS.BIN has more data on the characteristics of each task.&lt;br /&gt;
&lt;br /&gt;
== Player stats ==&lt;br /&gt;
&lt;br /&gt;
Each set of player stats consists of 143 bytes of data, for player 1 (human) to player 6.&lt;br /&gt;
&lt;br /&gt;
The data for each player is:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 || 1 || [[UINT8]] || Maximum Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 1 || 1 || [[UINT8]] || Maximum Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 2 || 1 || [[UINT8]] || Maximum Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 3 || 1 || [[UINT8]] || Available Adm points&lt;br /&gt;
|-&lt;br /&gt;
| 4 || 1 || [[UINT8]] || Available Mil points&lt;br /&gt;
|-&lt;br /&gt;
| 5 || 1 || [[UINT8]] || Available Pol points&lt;br /&gt;
|-&lt;br /&gt;
| 6 || 1 || [[UINT8]] || Happiness&lt;br /&gt;
|-&lt;br /&gt;
| 7 || 1 || [[UINT8]] || Number of territories&lt;br /&gt;
|-&lt;br /&gt;
| 8 || 1 || [[UINT8]] || Possible Food production&lt;br /&gt;
|-&lt;br /&gt;
| 9 || 1 || [[UINT8]] || Possible Timber production&lt;br /&gt;
|-&lt;br /&gt;
| 10 || 1 || [[UINT8]] || Possible Iron production&lt;br /&gt;
|-&lt;br /&gt;
| 11 || 1 || [[UINT8]] || Possible Good production&lt;br /&gt;
|-&lt;br /&gt;
| 12 || 1 || [[UINT8]] || Number of completed castles&lt;br /&gt;
|-&lt;br /&gt;
| 13 || 1 || [[UINT8]] || Current Food&lt;br /&gt;
|-&lt;br /&gt;
| 14 || 1 || [[UINT8]] || Current Timber&lt;br /&gt;
|-&lt;br /&gt;
| 15 || 1 || [[UINT8]] || Current Iron&lt;br /&gt;
|-&lt;br /&gt;
| 16 || 1 || [[UINT8]] || Current Gold&lt;br /&gt;
|-&lt;br /&gt;
| 17 || 1 || [[UINT8]] || Current Infantry&lt;br /&gt;
|-&lt;br /&gt;
| 18 || 1 || [[UINT8]] || Current Archers&lt;br /&gt;
|-&lt;br /&gt;
| 19 || 1 || [[UINT8]] || Current Knights&lt;br /&gt;
|-&lt;br /&gt;
| 20 || 1 || [[UINT8]] || Current Ballista&lt;br /&gt;
|-&lt;br /&gt;
| 21 || 1 || [[UINT8]] || Current Catapult&lt;br /&gt;
|-&lt;br /&gt;
| 22 || 1 || [[UINT8]] || Current Siege Tower&lt;br /&gt;
|-&lt;br /&gt;
| 23 || 1 || [[UINT8]] || Current Trojan Rabbit&lt;br /&gt;
|-&lt;br /&gt;
| 24 || 1 || [[UINT8]] || Current Infantry (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 25 || 1 || [[UINT8]] || Current Archers (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 26 || 1 || [[UINT8]] || Current Knights (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 27 || 1 || [[UINT8]] || Current Ballista (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 28 || 1 || [[UINT8]] || Current Catapult (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 29 || 1 || [[UINT8]] || Current Siege Tower (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 30 || 1 || [[UINT8]] || Current Trojan Rabbit (repeat, value used by game is above value not this one)&lt;br /&gt;
|-&lt;br /&gt;
| 31 || 1 || [[UINT8]] || Unknown (always 1?)&lt;br /&gt;
|-&lt;br /&gt;
| 32 || 1 || [[UINT8]] || Unknown (always 6?)&lt;br /&gt;
|-&lt;br /&gt;
| 33 || 1 || [[UINT8]] || Unknown (always 0?)&lt;br /&gt;
|-&lt;br /&gt;
| 34 || 2 || [[UINT16LE]] || Unknown, but related to battle (decreases on a failed attack, but not on cancelled/successful attack)&lt;br /&gt;
|-&lt;br /&gt;
| 36 || 6 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 42 || 8 || ASCII || Name (in ASCII)&lt;br /&gt;
|-&lt;br /&gt;
| 50 || 22 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 72 || 2 || [[UINT16LE]] || Current score&lt;br /&gt;
|-&lt;br /&gt;
| 74 || 1 || [[INT8]] || Progress toward next Adm point (since is signed, difficult to advance to 8 Adm, impossible to advance to 9 Adm)&lt;br /&gt;
|-&lt;br /&gt;
| 75 || 1 || [[INT8]] || Progress toward next Mil point&lt;br /&gt;
|-&lt;br /&gt;
| 76 || 1 || [[INT8]] || Progress toward next Pol point&lt;br /&gt;
|-&lt;br /&gt;
| 77 || 30 || Unknown || Unknown&lt;br /&gt;
|-&lt;br /&gt;
| 107 || 36 || [[UINT8]] || Apparent map to player for each of 36 territories (6 = unexplored, 8 = Valois, 9 = Anjou, 10 = Albion, 11 = Burgundy, 12 = The Pope, 13 = Aragon, 15 = neutral; add 16 if partial castle, 32 if small castle, 48 if large castle; add 64 if player owns territory; add 128 if player is computer)&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6803</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6803"/>
		<updated>2016-03-06T10:23:03Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines what field or data is stored.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, many sections start with an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically, this assumption is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6802</id>
		<title>Castles II: Siege and Conquest Save Game Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Save_Game_Format&amp;diff=6802"/>
		<updated>2016-03-06T10:22:03Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: Created page with &amp;quot;{{Playerdata Infobox  | Savegame = Yes  | Where = ?  | Elements = ?  | Games =     {{Game|Castles II: Siege and Conquest}} }}  The &amp;#039;&amp;#039;&amp;#039;Castles II: Siege and Conquest Save Game...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = Yes&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Save Game Format&#039;&#039;&#039; is used to store the game details of [[Castles II: Siege and Conquest]].&lt;br /&gt;
&lt;br /&gt;
The file is of fixed length, of 11682 bytes. As such, the location of each byte determines what field or data is stored.&lt;br /&gt;
&lt;br /&gt;
== File format ==&lt;br /&gt;
The file is encrypted by multiple layers of bit-wise XOR, or bitxor. Every byte except for the first 4 bytes (byte 0 to byte 3) is bitxored with the second byte (byte 1). Additionally, many sections start with an additional bitxor. Within each section, each value is then bitxored with the immediately preceding (bitxored) value. In this way, randomly changing the value of a given byte will likely change multiple values within the game, rendering the save game buggy or unusable. Thus, to correctly edit the same game file, the values need to be correctly re-encrypted.&lt;br /&gt;
&lt;br /&gt;
All values in the below table, from byte 4 onwards, are assumed to already have been bitxored with the second byte (byte 1). Mathematically this is redundant in some cases; for example, since byte 8 is bitxored immediately with the value before it (value in byte 7), it is unnecessary to bitxor byte 7 and byte 8 with the value in byte 1 before bitxoring them with each other to determine the un-encrypted value for byte 8. However, this assumption keeps the description cleaner, though more computationally expensive from an encryption/decryption standpoint.&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
!Start byte || Length || Data type || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 (0x0000) || 1 || [[UINT8]] || Unknown (value is always 16 (0xA0) )&lt;br /&gt;
|-&lt;br /&gt;
| 1 (0x0001) || 1 || [[UINT8]] || Bitxor value for rest of save file (from byte 4 to byte 11681)&lt;br /&gt;
|-&lt;br /&gt;
| 2 (0x0002) || 1 || [[UINT8]] || Unknown (value is always 25 (0xA9) )&lt;br /&gt;
|-&lt;br /&gt;
| 3 (0x0003) || 1 || [[UINT8]] || Unknown (value is always 0 (0x00) )&lt;br /&gt;
|-&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This format was reverse engineered by [[User:Vanshilar|Vanshilar]]. 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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Cluster_Format&amp;diff=6801</id>
		<title>Castles II: Siege and Conquest Cluster Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Cluster_Format&amp;diff=6801"/>
		<updated>2016-03-06T08:31:31Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Text Infobox&lt;br /&gt;
 | Type = Story&lt;br /&gt;
 | Lines =&lt;br /&gt;
 | Charset =&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Cluster Format&#039;&#039;&#039; is used to store the plotlines and plot text for [[Castles II: Siege and Conquest]]. This format describes the LIB.CLU file. The name stands for &amp;quot;cluster library&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Bytes 0 to 3999 (from 0x0000 to 0x0F9F) are all 0. Then bytes 4000 to 12803 (from 0x0FA0 to 0x3203) contain the byte location of each cluster entry, in 4-byte little endian format. However, each entry from 12064 to 12803 simply point to byte 1253323 (0x131FCB), which is the end of the file, so they are basically unused. Also, many entries point to the same location as the previous entry, so they basically point to &amp;quot;virtual&amp;quot; clusters of 0 bytes long, as a &amp;quot;null&amp;quot; entry. There are 359 non-&amp;quot;null&amp;quot; entries.&lt;br /&gt;
&lt;br /&gt;
Each cluster has some header information and can be divided 3 subclusters after the header information. The header information contains things like the location of each node within that cluster. Each cluster has up to 10 nodes, each node being a plot branch. The first subcluster is the plot instructions for that cluster&#039;s nodes. The second subcluster is the index for each line of text. The third subcluster is the text itself.&lt;br /&gt;
&lt;br /&gt;
The overall structure of LIB.CLU is as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Location || DataType || Description&lt;br /&gt;
|-&lt;br /&gt;
| 0 to 3999 (0x0000 to 0x0F9F) || [[UINT32LE]] || All values are 00&lt;br /&gt;
|-&lt;br /&gt;
| 4000 to 12803 (0x0FA0 to 0x3203) || [[UINT32LE]] || Byte location for the start of each cluster&lt;br /&gt;
|-&lt;br /&gt;
| 12804 to 1253322 (0x3204 to 0x131FCA) (rest of file) || variable || Cluster data&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The overall structure of each cluster is as follows:&lt;br /&gt;
&lt;br /&gt;
{|class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
! Length || DataType || Description&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Cluster ID&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Unknown (values vary from 0 to 9)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Starting byte location (within cluster) of first subcluster (all values are 40 because header is 40 bytes long)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Number of plot instructions in cluster (note each instruction is 6 bytes long)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Number of (non-virtual) nodes in cluster&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Starting byte location (within cluster) of second subcluster&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Number of plot text lines in cluster (note each plot text line index is 2 bytes long)&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Starting byte location (within cluster) of third subcluster&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Number of bytes of third subcluster&lt;br /&gt;
|-&lt;br /&gt;
| 2 || [[UINT16LE]] || Total length of cluster (or last byte of third subcluster)&lt;br /&gt;
|-&lt;br /&gt;
| 20 || [[UINT16LE]] || Byte locations of nodes 0 to 9 (2 bytes each)&lt;br /&gt;
|-&lt;br /&gt;
| variable * 6 || [[UINT16LE]] || Plot instructions (each is 6 bytes long, consisting of 3 little-endian 2-bytes)&lt;br /&gt;
|-&lt;br /&gt;
| variable * 2 || [[UINT16LE]] || Location of each plot text line (each location is 2 bytes long)&lt;br /&gt;
|-&lt;br /&gt;
| variable || ASCII (encrypted) || Plot text lines; plain ASCII text but encrypted by bit-wise XOR with the first byte of the header (i.e. the first byte of the cluster ID)&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
== Credits ==&lt;br /&gt;
&lt;br /&gt;
This file format was reverse engineered by [[User:Vanshilar|Vanshilar]].  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>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Cluster_Format&amp;diff=6796</id>
		<title>Castles II: Siege and Conquest Cluster Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Cluster_Format&amp;diff=6796"/>
		<updated>2016-03-05T11:27:48Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = No&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Cluster Format&#039;&#039;&#039; is used to store the plot instructions and plot text for [[Castles II: Siege and Conquest]]. This format describes the LIB.CLU file. The name stands for &amp;quot;cluster library&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Bytes 0 to 3999 (from 0x0000 to 0x0F9F) are all 0. Then bytes 4000 to 12803 (from 0x0FA0 to 0x3203) contain the byte location of each cluster entry, in 4-byte little endian format. However, each entry from 12064 to 12803 simply point to byte 1253323 (0x131FCB), which is the end of the file, so they are basically unused. Also, many entries point to the same location as the previous entry, so they basically point to unused clusters of 0 bytes long, as a &amp;quot;null&amp;quot; entry. There are 359 non-&amp;quot;null&amp;quot; entries.&lt;br /&gt;
&lt;br /&gt;
Each cluster is divided into up to 10 nodes.&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6795</id>
		<title>Castles II: Siege and Conquest</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6795"/>
		<updated>2016-03-05T10:38:53Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
{{Game Infobox&lt;br /&gt;
 | Levels = No&lt;br /&gt;
 | Tiles = No&lt;br /&gt;
 | Sprites = No&lt;br /&gt;
 | Fullscreen = No&lt;br /&gt;
 | Sound = No&lt;br /&gt;
 | Music = No&lt;br /&gt;
 | Text = No&lt;br /&gt;
 | Story = No&lt;br /&gt;
 | Interface = No&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Castles II: Siege and Conquest&#039;&#039;&#039; is a real-time strategy game where the players vie to be the new king of Bretagne by conquering territory, making an army, and building castles.&lt;br /&gt;
&lt;br /&gt;
{{BeginGameFileList}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = *.clu&lt;br /&gt;
 | Format = [[Castles II: Siege and Conquest Cluster Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Cluster format for plots&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{EndGameFileList}}&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Cluster_Format&amp;diff=6794</id>
		<title>Castles II: Siege and Conquest Cluster Format</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest_Cluster_Format&amp;diff=6794"/>
		<updated>2016-03-05T08:52:28Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: Some initial notes about the cluster format&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Playerdata Infobox&lt;br /&gt;
 | Savegame = No&lt;br /&gt;
 | Where = ?&lt;br /&gt;
 | Elements = ?&lt;br /&gt;
 | Games = &lt;br /&gt;
   {{Game|Castles II: Siege and Conquest}}&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;Castles II: Siege and Conquest Cluster Format&#039;&#039;&#039; is used to store the plot instructions and plot text for [[Castles II: Siege and Conquest]]. This format describes the LIB.CLU file. The name stands for &amp;quot;cluster library&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Bytes 0 to 3999 (from 0x0000 to 0x0F9F) are all 0. Then bytes 4000 to 12803 (from 0x0FA0 to 0x3203) contain the byte location of each cluster entry, in 4-byte little endian format. However, each entry from 12064 to 12803 simply point to byte 1253323 (0x131FCB), which is the end of the file, so they are basically unused. Also, many entries point to the same location as the previous entry, so they basically point to unused clusters of 0 bytes long.&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6786</id>
		<title>Castles II: Siege and Conquest</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6786"/>
		<updated>2016-03-05T07:28:54Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
{{Game Infobox&lt;br /&gt;
 | Levels = No&lt;br /&gt;
 | Tiles = No&lt;br /&gt;
 | Sprites = No&lt;br /&gt;
 | Fullscreen = No&lt;br /&gt;
 | Sound = No&lt;br /&gt;
 | Music = No&lt;br /&gt;
 | Text = No&lt;br /&gt;
 | Story = No&lt;br /&gt;
 | Interface = No&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Castles II: Siege and Conquest&#039;&#039;&#039; is a real-time strategy game where the players vie to be the new king of Bretagne by conquering territory, making an army, and building castles.&lt;br /&gt;
&lt;br /&gt;
{{BeginGameFileList}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = *.clu&lt;br /&gt;
 | Format = [[Castles II: Siege and Conquest cluster Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Cluster format for plots&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{EndGameFileList}}&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
	<entry>
		<id>https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6785</id>
		<title>Castles II: Siege and Conquest</title>
		<link rel="alternate" type="text/html" href="https://moddingwiki.shikadi.net/w/index.php?title=Castles_II:_Siege_and_Conquest&amp;diff=6785"/>
		<updated>2016-03-05T07:18:08Z</updated>

		<summary type="html">&lt;p&gt;Vanshilar: Creating page for Castles II: Siege and Conquest&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Stub}}&lt;br /&gt;
{{Game Infobox&lt;br /&gt;
 | Levels = No&lt;br /&gt;
 | Tiles = No&lt;br /&gt;
 | Sprites = No&lt;br /&gt;
 | Fullscreen = No&lt;br /&gt;
 | Sound = No&lt;br /&gt;
 | Music = No&lt;br /&gt;
 | Text = No&lt;br /&gt;
 | Story = No&lt;br /&gt;
 | Interface = No&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Castles II: Siege and Conquest&#039;&#039;&#039; is a real-time strategy game where the players vie to be the new king of Bretagne by conquering territory, making an army, and building castles.&lt;br /&gt;
&lt;br /&gt;
{{BeginGameFileList}}&lt;br /&gt;
{{GameFile&lt;br /&gt;
 | Name = *.clu&lt;br /&gt;
 | Format = [[CLU Format]]&lt;br /&gt;
 | KnownFormat = No&lt;br /&gt;
 | Desc = Cluster format for plots&lt;br /&gt;
}}&lt;br /&gt;
&lt;br /&gt;
{{EndGameFileList}}&lt;/div&gt;</summary>
		<author><name>Vanshilar</name></author>
	</entry>
</feed>