SVE file format

darkpanda

Dark Prince
Joined
Oct 28, 2007
Messages
823
This thread is intended to store all available information about the format of Civ 1's SVE savegame files.

As time passes, I am now reposting latest findings as a SVE data reference table available here: http://forums.civfanatics.com/showthread.php?p=12422448#post12422448

The original first post of this thread is kept hereunder for reference.


--------

As a first post, I am attaching 2 text files used internally by JCivED (zipped in View attachment SVE_memory_map.zip because of .txt size limitations on this forum) that map every offset of the SVE byte data to the corresponding in-game data:
  • many data ranges or bytes are not identified yet, by lack of time or understanding, and always contain the tag word "unknown"
  • there 1 file per supported version:
    • Civ EN 475.01 (37856 bytes)
    • Civ FR 474.05 (37912 bytes)
  • the only difference between those 2 versions is the length of Unit Type names: 12 for english ones, and 14 for french ones; this makes up for the total SVE length difference between the 2 versions: 28 types * 2 chars = 56 bytes = 37912 - 37856;

The structure of the files follows a tab-separated table format, and contains 6 columns:

  • id: an arbitrary data element ID meant to uniquely identify the element
  • native_type: type of the data element, with possible values as below:
    • byte: a single, signed, 8-bit byte (value range: from -128[0x80] to 127[0x7F])
    • ubyte: a single, unsigned, 8-bit byte (value range: from 0[0x00] to 255[0xFF])
    • short: a 2-byte / 16-bit, signed, integer (value range: from -32768[0x8000] to 32767[0x7FFF])
    • ushort: a 2-byte / 16-bit, unsigned, integer (value range: from 0[0x0000] to 65535[0xFFFF])
    • string: a character string, usually terminated with a [0x0] char, but not always; for the French version, the exact used codepage looks like either IBM850 or IBM437, but for some reasons, some chars are still off
    • data: an otherwise untyped data block; used mainly to cover unknown data areas, or complex data parts (score graph, replay)
    • flagbyte: an 8-bit byte used as a set of 8 boolean flags by Civ: each bit is used to represent a TRUE or FALSE value
    • flagshort: same as flagbyte but with 16-bit; there is no difference between specifying 2 flgabytes or 1 flagshort, except to try keeping the memory map shorter :)
  • computed_offset: the decimal offset where the data element is located in the SVE
  • byte_length: the length, in bytes, of the data element: always 1 for *bytes and 2 for *shorts, can be any value for string or data
  • bit: just ignore this one at the moment
  • hex_offset: same as computed_offset, but expressed in hexadecimal code

The data IDs are completely arbitrary, and decided by me as I saw fit for usage in JCivED :)
However, there is some kind of naming standard, especially the usage of prefixes to highlight the data hierarchy, for example:
  • game: all IDs start with this prefix. Period.
  • game.civ<X>: replacing <X> by a value form 0 to 7, IDs starting with this prefix are specific to the related Civ; <X> then stands for:
    • <X> = 0: Barbarians
    • <X> = 1: white civ (Romans or Russians)
    • <X> = 2: green civ (Babylonians or Zulus)
    • <X> = 3: blue civ (German or French)
    • <X> = 4: yellow civ (Egyptians or Aztecs)
    • <X> = 5: cyan civ (Americans or Chinese)
    • <X> = 6: magenta civ (English or Greek)
    • <X> = 7: grey civ (Mongols or Indians)
  • game.civ<X>.unit<Y>: IDs starting with this prefix are specific to unit with ID <Y> of Civ with ID <X>; the range of <Y> is 0 to 127, i.e. 128 active units per Civ
  • game.unit_def<X>: replacing <X> by a value form 0 to 27, IDs starting with this prefix are specific to Unit Types
  • game.city<X>: replacing <X> by a value form 0 to 127, IDs starting with this prefix are specific to Cities; note the limitation of 128 total cities in the world
  • etc...

Also, some data ranges need more detailed description, such as the replay data... I hope to provide as much as possible through this thread, as time allows, and all contributions correct mistakes or enhance coverage are welcome ! :)

The picture below illustrates how much of SVE is already deciphered in blue (80.6%) compared with how much is still unknown, in red (21.4%):



Cheers
 

Attachments

  • unknown_map.png
    unknown_map.png
    894 bytes · Views: 2,349
Thanks for posting this. It's important because these data blocks are also present in the RAM when civ is running, so they show up in the assembler code. And since I've already identified some of the dynamic data, we can combine our results and close some gaps :)

Let's start with the city table:
game.city0.buildings_flag0 flagbyte 5384 1 0 1508
game.city0.buildings_flag1 flagbyte 5385 1 0 1509
game.city0.buildings_flag2 flagbyte 5386 1 0 150A
game.city0.unknown_cb4 byte 5387 1 0 150B
Confirmed.
Actually these are two flagshorts, so the unknown byte is also part of the bitfield.
Technically, civ is "wasting" space here, since 3 bytes would be enough for all buildings.
game.city0.position_x byte 5388 1 0 150C
game.city0.position_y byte 5389 1 0 150D
confirmed...
game.city0.unknown_cb7 byte 5390 1 0 150E
City Status flagbyte:
0x01 = Civil Disorder
0x02 = Coastal City (i.e. it is adjacent to an ocean square)
0x40 = Celebration a.k.a. Rapture
0x80 = sold an improvement during the current turn (cannot sell more than one per turn)
game.city0.population byte 5391 1 0 150F
confirmed...
But "population" is ambigous here. I prefer to call it "city size".
game.city0.unknown_cb9 byte 5392 1 0 1510
This is the displayed city size which is shown to the player. Can differ from the actual size if the player does not currently have vision of the city.
game.city0.current_prod_id ubyte 5393 1 0 1511
confirmed...
game.city0.unknown_cb11 byte 5394 1 0 1512
City Base Trade (trade routes not included), used for calculating the output of trade routes.
game.city0.owning_civ byte 5395 1 0 1513
confirmed...
game.city0.food_count short 5396 2 0 1514
game.city0.shields_count short 5398 2 0 1516
confirmed...
game.city0.workers_flag0 flagbyte 5400 1 0 1518
game.city0.workers_flag1 flagbyte 5401 1 0 1519
game.city0.workers_flag2 flagbyte 5402 1 0 151A
game.city0.workers_flag3 flagbyte 5403 1 0 151B
Interesting. How do these flags work?
game.city0.workers_flag4 flagbyte 5404 1 0 151C
game.city0.workers_flag5 flagbyte 5405 1 0 151D
These are the Specialist flags. It's actually a single flagshort, divided into eight 2-bit bitfields. Each bitfield represents one specialist slot and can assume 4 values:
0 = no specialist in this slot
1 = Taxman
2 = Scientist
3 = Entertainer
And yes, this means it's next to impossible to raise the limit of 8 specialists per city.
game.city0.city_name_id ubyte 5406 1 0 151E
confirmed...
game.city0.trade_city1 ubyte 5407 1 0 151F
game.city0.trade_city2 ubyte 5408 1 0 1520
game.city0.trade_city3 ubyte 5409 1 0 1521
confirmed...
game.city0.unknown_cflag27 flagbyte 5410 1 0 1522
game.city0.unknown_cb28 ubyte 5411 1 0 1523
I haven't identified these either, so far.
 
Moving on to the unit table...

game.civ0.unit0.status_flag flagbyte 9920 1 0 26C0
Confirmed. But so far I've only identified these flags:
0x01 = Sentry
0x02 = first terraforming order flag
0x04 = Fortifying
0x08 = Fortified
0x20 = Veteran
0x40 = second terraforming order flag
0x80 = third terraforming order flag

The terraforming flags seems to result in different terraforming orders depending on their combination. So unless 0x10 is also used for terraforming orders, this would allow for up to 7 different orders.
game.civ0.unit0.position_x ubyte 9921 1 0 26C1
game.civ0.unit0.position_y ubyte 9922 1 0 26C2
confirmed...
game.civ0.unit0.type ubyte 9923 1 0 26C3
confirmed...
game.civ0.unit0.remaining_moves ubyte 9924 1 0 26C4
Confirmed.
Movement points are multiplied by 3 here, so if this value is, for example, equal to 2, then the unit has 2/3 moves left.
game.civ0.unit0.unknown_unitbyte6 ubyte 9925 1 0 26C5
This is a shared value. It is used as "remaining fuel (counting turns)" for air units. If the air unit ends its turn outside of a city/carrier, then this value is decreased by 1. If it's negative after that, then the unit is removed and the "*FUEL" message from "error.txt" is displayed.
It also serves as a turn count accumulator for settlers which are currently assigned to a terraforming task. In this case, it's INcreased by 1 after each turn.
game.civ0.unit0.gotox ubyte 9926 1 0 26C6
game.civ0.unit0.gotoy ubyte 9927 1 0 26C7
Confirmed, at least for AI units. I guess it makes sense for player units, too.
game.civ0.unit0.unknown_unitbyte9 ubyte 9928 1 0 26C8
unknown to me, too...
game.civ0.unit0.unknown_unitbyte10 ubyte 9929 1 0 26C9
This is the vision flag byte, telling of a civ has vision of the unit. The unit's owner civ seems to be excluded, though (i.e. it can be 0 for the owner civ), but the owner civ still does have vision anyway.
game.civ0.unit0.unknown_unitbyte11 ubyte 9930 1 0 26CA
Unit ID of the next unit in this unit's stack (-1 if none). When going though a stack of units, the game will just search for the first unit and then use these values to find the others, one by one.
game.civ0.unit0.home_city_id ubyte 9931 1 0 26CB
confirmed...
 
Additional Status Bits not listed above posts.




Unit status bits &H10 appears to be unit on a ship*
cleaning pollution & building fortress use multiple bits


&#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9516;&#9472; cleaning pollution
&#9484;&#9516;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; building fortress
&#9474;&#9474;
7654 3210 &#9472;&#9472;&#9472;&#9472; Status bits
&#9474;&#9474;&#9474;&#9474; &#9474;&#9474;&#9474;&#9492; Sentinel
&#9474;&#9474;&#9474;&#9474; &#9474;&#9474;&#9492;&#9472; road / rail
&#9474;&#9474;&#9474;&#9474; &#9474;&#9492;&#9472;&#9472; Fortifying
&#9474;&#9474;&#9474;&#9474; &#9492;&#9472;&#9472;&#9472; Fortify
&#9474;&#9474;&#9474;&#9492;&#9472;&#9472;&#9472;&#9472;&#9472; On board vessel *
&#9474;&#9474;&#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; Veteran
&#9474;&#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; irrigation
&#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; mine / forest





See Building a Battleship in a Lake post 7 & 8 as the other civilizations don&#8217;t have this bit set for cities on inland seas (lakes).


game.city0.workers_flag0 flagbyte 5400 1 0 1518
game.city0.workers_flag1 flagbyte 5401 1 0 1519
game.city0.workers_flag2 flagbyte 5402 1 0 151A
game.city0.workers_flag3 flagbyte 5403 1 0 151B
Interesting. How do these flags work?
See Land use above the bits indicate which of the 21 city squares are in use by the city


Images produced by Civ$

* April 18, 2013 &#8211; I&#8217;m no longer convinced that &H10 bit is On board ship it is set at other times and I found an instance of it not being set for a unit on a ship
 

Attachments

  • vbdos_014.png
    vbdos_014.png
    6.2 KB · Views: 194
  • vbdos_015.png
    vbdos_015.png
    6.3 KB · Views: 2,351
  • vbdos_016.png
    vbdos_016.png
    7.5 KB · Views: 2,307
game.city0.workers_flag0 flagbyte 5400 1 0 1518
game.city0.workers_flag1 flagbyte 5401 1 0 1519
game.city0.workers_flag2 flagbyte 5402 1 0 151A
game.city0.workers_flag3 flagbyte 5403 1 0 151B
Interesting. How do these flags work?


See Land use above the bits indicate which of the 21 city squares are in use by the city

Indeed, the 32 bits of those 4 bytes must be re-split in different bit blocks:
  • the 20 first bits are flags indicating which city squares are exploited; they are ordered as shown on the screenshot below (taken from JCivED) and you can see there are indeed 20 exploitable squares surrounding a city (the city square itself is always exploited)
  • the next 6 bits are still unknown to me
  • the final 6 bits are used to code an integer value as a count of how many citizens are assigned as specialists instead of exploiting a city square

workers_allocation.png

To illustrate, I made 4 savegames where a city of size 18 has progressively 0, 1, 2 and 3 specialists. Hereunder is their 6 bytes starting at offset 0x15F8 (in green, I put the next 2 bytes, that code for the type of specialists):


0 specialist : {ef df} {1f 00} {00 00} - {1110:1111 1101:1111} {0001:1111 0000:0000} {0000:0000 0000:0000}
1 specialist : {ef 9f} {1f 04} {03 00} - {1110:1111 1001:1111} {0001:1111 0000:0100} {0000:0011 0000:0000}
2 specialists: {ef 9d} {1f 08} {0f 00} - {1110:1111 1001:1101} {0001:1111 0000:1000} {0000:1111 0000:0000}
3 specialists: {ef 1d} {1f 0c} {3f 00} - {1110:1111 0001:1101} {0001:1111 0000:1100} {0011:1111 0000:0000}


Note: the bytes above are extracted raw from the SVE, in little-endian arrangement, if ever you are surprised by their order; below is the same data re-arranged in bid-endian order:


0 specialist : {df ef} {00 1f} {00 00} - {1101:1111 1110:1111} {0000:0000 0001:1111} {0000:0000 0000:0000}
1 specialist : {9f ef} {04 1f} {00 03} - {1001:1111 1110:1111} {0000:0100 0001:1111} {0000:0000 0000:0011}
2 specialists: {9d ef} {08 1f} {00 0f} - {1001:1101 1110:1111} {0000:1000 0001:1111} {0000:0000 0000:1111}
3 specialists: {1d ef} {0c 1f} {00 3f} - {0001:1101 1110:1111} {0000:1100 0001:1111} {0000:0000 0011:1111}
 
Unit status bits &H10 appears to be unit on a ship
Thanks. With this hint I checked the references to this flag again and found some evidence implying that it's indeed "aboard a ship".

Indeed, the 32 bits of those 4 bytes must be re-split in different bit blocks:
  • the 20 first bits are flags indicating which city squares are exploited; they are ordered as shown on the screenshot below (taken from JCivED) and you can see there are indeed 20 exploitable squares surrounding a city (the city square itself is always exploited)
  • the next 6 bits are still unknown to me
  • the final 6 bits are used to code an integer value as a count of how many citizens are assigned as specialists instead of exploiting a city square
Thanks, now our list is almost complete :)
 
Thanks. With this hint I checked the references to this flag again and found some evidence implying that it's indeed "aboard a ship".
The funny thing is that I found it last night. I've looked at that bit for years wondering what it could be. In trying to prove your statement about offset 9 being visibility the &#8220;on board&#8221; bit somehow became apparent.
 
I’m no longer convinced that &H10 bit is On board ship it is set at other times and I found an instance of it not being set for a unit on a ship
 
Gowron and Dack, thanks for your inputs! I'll update the mapping files in a short while...

Meanwhile, hereunder is the structure of the replay data block, which is not otherwise detailed in the mapping files:

Code:
game.replay_data	data	30320	4100	0	7670

Replay

This encodes the data used to generate the REPLAY when finishing a Civ game:
  • At the beginning, it is "empty" (full of "0x00").
  • As Civ turns play out, replay entries are added to this data block
  • The 2 first bytes of game.replay are an unsigned short integer coding for the byte length of the replay data
  • Replay entries have variable sizes
  • The first byte of an entry is the entry type, which is enough to know the entry length:

    Entry type | Total bytes | Byte | Description [0x1*] City built or destroyed |6|0|Entry code: 0x1*
    ||1|Turn number(*)
    ||2|Owning Civ ID; if 0xFF, means the city is destroyed , not built
    ||3|City name ID
    ||4|City longitude (X position)
    ||5|City latitude (Y position)

    [0x2*] Declaration of war |3|0|Entry code: 0x2*
    ||1|Turn number(*)
    ||2|Civs at war: high-order 4 bits = attacking Civ ID; low-order 4 bits = attacked Civ ID

    [0x3*] Peace treaty |3|0|Entry code: 0x3*
    ||1|Turn number(*)
    ||2|Civs at peace: high-order 4 bits = proposing Civ ID; low-order 4 bits = agreeing Civ ID

    [0x5*] Scientific advance |4|0|Entry code: 0x5*
    ||1|Turn number(*)
    ||2|Civ ID
    ||3|Discovery ID

    [0x6*] Unit first-time built |4|0|Entry code: 0x6*
    ||1|Turn number(*)
    ||2|Civ ID
    ||3|Unit type ID

    [0x8*] Regime change / revolution |4|0|Entry code: 0x8*
    ||1|Turn number(*)
    ||2|Civ ID
    ||3|New government type

    [0x9*] City captured |6|0|Entry code: 0x9*
    ||1|Turn number(*)
    ||2|Civ ID who captured the city
    ||3|City name ID
    ||4|City longitude (X position)
    ||5|City latitude (Y position)

    [0xA*] Wonder built |4|0|Entry code: 0xA*
    ||1|Turn number(*)
    ||2|Civ ID
    ||3|Wonder ID
    |
    [0xB*] Replay summary |5|0|Entry code: 0xB*
    ||1|Turn number(*)
    ||2|City count
    ||3 and 4|Player civ population count (x 10,000)
    |
    [0xC*] Civ rankings |6|0|Entry code: 0xC*
    ||1|Turn number(*)
    ||2 to 5|4 bytes, to be read as 8 half-bytes, each half-byte codes for a Civ ID, the Civ with the highest ranking is the first half-byte, the Civ with lowest has the last half-byte

    [0xD*] Civ destroyed |3|0|Entry code: 0xD*
    ||1|Turn number(*)
    ||2|Civ that was destroyed
    ||3|Civ that destroyed them
  • (*) For Turn ID: because a single byte ranges from 0 to 255, it cannot account for the up to 650 possible turns in a game of Civilization, the low-order 4 bits of the replay entry code are used to encode additional turns:
    • "0x 10 34 ..." means "City built/destroyed at turn 52 (0x34)"
    • "0x 11 34 ..." means "City built/destroyed at turn 308 (0x134)"

Examples:

Description|Bytes
Turn 1 (3980 BC): Greeks build Athens|0x10 01 06 50 18 0F
Turn 8 (3840 BC): Russians build the first Phalanx|0x60 08 01 02
Turn 8 (3840 BC): Aztecs discover Pottery|0x50 08 04 2A
Turn 15 (3700 BC): Delhi destroyed|0x10 0F FF 60 1A 19
Turn 15 (3700 BC): Indians annihilated by Greeks|0xD0 0F 07 06
Turn 18 (3640 BC): Russians make peace with Americans|0x30 12 15
Turn 50 (3000 BC): BABYLONIANS: 3 CITIES; 70,000 POPULATION|0xB0 32 03 00 07
Turn 50 (3000 BC): *** 1:Babylonians 2:Americans 3:Greeks 4:Russians 5:Aztecs 6:French 7:Mongols|0xC0 32 25 61 43 70
Turn 96 (2080 BC): Babylonians declare war on Greeks|0x20 60 26
Turn 121 (1580 BC): BABYLONIANS BUILD COLOSSUS|0xA0 79 02 03
Turn 259 (1090 AD): Americans form Monarchy|0x81 03 05 02
Turn 269 (1190 AD): Americans capture Moscow|0x91 0D 05 70 34 17
 
The list reminds me of some of the remains of Great Library of Alexandra. Supposedly among the items that remain are list of books that no longer exists. Along with titles of data we need to flesh out the titles with information on the contents.
darkpanda and Gowron the two of you have certainly spark new interest in research into the inner recesses of CIV/dos. (If I were one to use emoticons I would insert a smiley face with clapping hands )

Good work guys!
 
Spoiler :

Code:
00
01	turn counter that changes +1 every turn
	4000bc turn 0 every turn 20 years
	1000ad turn FAx 250d
		10 years every turn
	1500ad turn 12Cx 300d
		5 years every turn
	1750ad turn 15Ex 350d
		2 years every turn
	1850ad turn 190x 400d
		1 year every turn
______
02	human player 0-7
03	
______
04	bit for human player !?
05	8421 8421
	7654 3210  --   ie 40 is for player 6 (english / greek)
______ 
06	Special Resources Master Word
07
        the low order byte (06) bits  8421 8421
                                           1111 - controls special Resources 
                                         1 1111 - controls huts
        both have separate formulas. The other 3 bits in the low order byte
        and the high order byte are unknown.
______
08
09	Date 2 bytes
______
0A	Difficulty level
0B
______	0-Cheftan 1-warlord 2-Prince 3-King 4-Emperor
0C	Civilizations ??? (active bit?)
0D
        addr  hex   dec  
        000C  00EF  00239  civ active

______
0E	researching Advance look a table(z%).rank (value here is +1 of rank)
0F	-1 (FFFF) is none
______
10	Attila_______0  Leader name 14 characters
1E	Caesar0______0		(13 max with trailing zero)
7F                              ( Underscore _ is a space , Zero is hex 0 )
______
80	Barbarians_0	Country name 13 characters
8C	Romans0		(12 max with trailing zero)
D4      Indians
DF
______

E0	Barbarian_0	Country name singular 13 bytes  
EC	Roman_____0	(12 max with trailing zero) 


12D     Mongol____0
137                     <- Last byte names
______
	Treasure Amount  (value 0 to 30000)
138	country 0 Barbarian (2 BYTES)
13A	country 1 Russian    / Roman
.
.
.
146	country 7 Indian     / Mongol

147
_____
	researching adavance (light bulbs)
148	country 0 Barbarian
14A	country 1 Russian    / Roman
14C             2 Babylonian / Zulu
14E             3 German     / French
150             4 Egyptian   / Aztec
152	country 5 American   / Chinese
154	        6 English    / Greek
156	        7 Indian     / Mongol
_____

Spoiler :
Code:
advance bits offset

4E8	0 Barbarians 
4F2	1 Russian    / Roman
4FC	2 Babylonian / Zulu
506	3 German     / French
510	4 Egyptian   / Aztec
51A	5 American   / Chinese
524	6 English    / Greek
52E	7 Indian     / Mongol

advance bits (10 bytes each)
	Made up of 5 words (16 bit)

 
    &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; Word 0 thru 4
    &#9474; &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; Bit within word
    &#9474; &#9474;      &#9484;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; rank
    &#9474; &#9474;      &#9474;  
    &#9474; &#9474;      &#9474;  
    &#9474; &#9474;      &#9474;   &#9484;&#9472;&#9472;&#9472;&#9472; Advance name     &#9484;&#9472;text for advance screen
    &#9474; &#9474;      &#9474;   &#9474;                      &#9474;
    0,&H0001,01  Alphabet
    0,&H0002,02  Code of Laws        ^Courthouse
    0,&H0004,03  Currency            ^Marketplace
    0,&H0008,04  Atomic Theory 
    0,&H0010,05  Democracy     
    0,&H0020,06  Monarchy
    0,&H0040,07  Astronomy           *Copernicus' Observatory
    0,&H0080,08  MapMaking           +Trireme   *Lighthouse
    0,&H0100,09  Navigation          +Sail *Magellan's Expedition
    0,&H0200,10  Mathematics         +Catapult
    0,&H0400,11  Medicine            *Shakespeare's Theatre
    0,&H0800,12  Physics 
    0,&H1000,13  Engineering   
    0,&H2000,14  University          ^University
    0,&H4000,15  Magnetism           +Frigate
    0,&H8000,16  Electronics         ^Hydro Plant   *Hoover Dam

    1,&H0001,17  Masonry             ^City Walls   ^Palace   *Great Wall   *Pyramids
    1,&H0002,18  Bronze Working      +Phalanx   *Colossus
    1,&H0004,19  Iron Working        +Legion
    1,&H0008,20  Bridge Building     
    1,&H0010,21  Invention     
    1,&H0020,22  Computers           *SETI Program
    1,&H0040,23  Writing             +Diplomat   ^Library
    1,&H0080,24  Steam Engine        +Ironclad
    1,&H0100,25  Trade               +Caravan
    1,&H0200,26  Ceremonial Burial   ^Temple
    1,&H0400,27  Mysticism           *Orical
    1,&H0800,28  Nuclear Fission     *Manhattan Project
    1,&H1000,29  Philosophy    
    1,&H2000,30  Religion            ^Cathedral *J.S.Bach's Cathedral *Michelangelo's Chapel
    1,&H4000,31  Literacy            *Great Library
    1,&H8000,32  Horseback Riding    +Cavalry

    2,&H0001,33  Feudalism     
    2,&H0002,34  The Wheel           +Chariot
    2,&H0004,35  Gunpowder           +Musketeers 
    2,&H0008,36  Industrialization   +Transport   ^Factory   *Women's Suffrage
    2,&H0010,37  Chemistry     
    2,&H0020,38  Combustion          +Cruiser
    2,&H0040,39  Flight              +Fighter
    2,&H0080,40  Advanced Flight     +Bomber  +Carrier
    2,&H0100,41  Space Flight        ^SS Structural   *Apollo Program
    2,&H0200,42  Mass Production     +Submarine   ^Mass Transit
    2,&H0400,43  Pottery             ^Granary    *Hanging Gardens
    2,&H0800,44  Communism           *United Nations
    2,&H1000,45  The Republic  
    2,&H2000,46  Construction        ^Aqueduct ^Colosseum
    2,&H4000,47  Rocketry            +Nuclear (with Manhattan Project)
    2,&H8000,48  The Corporation     

    3,&H0001,49  Metallurgy          +Cannon
    3,&H0002,50  RailRoad            *Darwin's Voyage
    3,&H0004,51  Nuclear Power       ^Nuclear Plant
    3,&H0008,52  Theory of Gravity   *Isaac Newton's Collage
    3,&H0010,53  Steel               +Battle Ship
    3,&H0020,54  Banking             ^Bank
    3,&H0040,55  Electricity   
    3,&H0080,56  Refining            ^Power Plant
    3,&H0100,57  Explosives    
    3,&H0200,58  SuperConductor      ^SDI Defense
    3,&H0400,59  Automobile          +Armor
    3,&H0800,60  Genetic Engineering *Cure for Cancer
    3,&H1000,61  Plastics            ^SS Component
    3,&H2000,62  Recycling           ^Recycling Center
    3,&H4000,63  Chivalry            +Knights
    3,&H8000,64  Robotics            +Artillery   ^SSmodule   ^Mfg. Plant

    4,&H0001,65  Conscription        +Riflemen
    4,&H0002,66  Labor Union         +Mechanized Infantry
    4,&H0004,67  Fusion Power  
    4,&H0008,68  Future Tech.        

___________
government 0-5	0-Anarchy   1-Despotism 2-Monarchy 
                3-Communist 4-Republic  5-Democratic

538     (2 bytes)    0 Barbarian
53A                  1 Russian    / Roman
53C                  2 Babylonian / Zulu
53E	             3 German     / French
540	             4 Egyptian   / Aztec
542	             5 American   / Chinese
544	             6 English    / Greek
546	             7 Indian     / Mongol
___________
 
Code:
game.city0.unknown_cb7 byte 5390 1 0 150E
City Status flagbyte:
0x01 = Civil Disorder
0x02 = Coastal City (i.e. it is adjacent to an ocean square)
0x40 = Celebration a.k.a. Rapture
0x80 = sold an improvement during the current turn (cannot sell more than one per turn)

I am completing this list of city flags including the ones from Dack, and an additional one that we missed before (easy, though):

Code:
7654 3210
&#9474;&#9474;&#9474;&#9474; &#9474;&#9474;&#9474;&#9492; 0x01 = Civil disorder
&#9474;&#9474;&#9474;&#9474; &#9474;&#9474;&#9492;&#9472; 0x02 = Coastal city
&#9474;&#9474;&#9474;&#9474; &#9474;&#9492;&#9472;&#9472; 0x04 = ??
&#9474;&#9474;&#9474;&#9474; &#9492;&#9472;&#9472;&#9472; 0x08 = Hydro-powered
&#9474;&#9474;&#9474;&#9492;&#9472;&#9472;&#9472;&#9472;&#9472; [B][COLOR="Blue"]0x10 = Auto-build[/COLOR][/B]
&#9474;&#9474;&#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; 0x20 = Stole tech
&#9474;&#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; 0x40 = Celebration / rapture
&#9492;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472;&#9472; 0x80 = Sold improvement

Can't figure what 0x04 stands for... Some cities have it to 0, some have it to 1, I don't see what discriminates them...
 
My notes say 0x04 is to cancel "We love..."

Try fiddling with happy and unhappy people to test.
 
game.civ0.unit0.unknown_unitbyte9 ubyte 9928 1 0 26C8

Update about this value:
It's a map direction, coded as a value between 1 and 8. It's set to -1 when there's no direction to save.

However, I still don't know what this direction is used for. It seems to have something to do with the GoTo coordinates. Maybe it's just the current GoTo direction of the unit.

Edit: directions should be coded as follows (if y-coordinates are counted from top to bottom):
1 = down
2 = down right
3 = right
4 = up right
5 = up
6 = up left
7 = left
8 = down left

Alternatively, if y-coordinates are counted from bottom to top, it would be:
1 = up
2 = up right
3 = right
4 = down right
5 = down
6 = down left
7 = left
8 = up left
 
Alternatively, if y-coordinates are counted from bottom to top, it would be:
1 = up
2 = up right
3 = right
4 = down right
5 = down
6 = down left
7 = left
8 = up left

I think the latter is the correct one, it also matches the order in which roads and railroads sprites are stored in SP257.PIC:



Maybe it's a "cached" value for AI units in GoTo mode, for example "next move" ?

From my experience, Civ will determine that a unit is in GoTo mode if its "GoToX" attribute is not -1 (0xFF), in which case it uses GoToX and GoToY as the GoTo destination... Some trial and error needed here, I guess.
 

Attachments

  • SP257.PIC.X0+M0.gif
    SP257.PIC.X0+M0.gif
    30.3 KB · Views: 3,164
game.civ0.diplo_civ0 flagshort 1608 2 0 648
Diplomatic status flags which I've identified so far:

0x01 = War
0x02 = Peace
0x04 = Alliance
0x08 = Vendetta
0x40 = Embassy
 
Diplomatic status flags which I've identified so far:

0x01 = War
0x02 = Peace
0x04 = Alliance
0x08 = Vendetta
0x40 = Embassy

Has anyone actually experienced "Alliance" or "Vendetta" in a Civ game ?

I don't know if it's I only ever played the French version, but I don't recall ever seeing those diplomatic relations in action...
 
It's true that many cities that have the "Rapture" flag (0x40) also have the 0x04 flag turned on... But still, not always... I'll look into that in more details.

It's been years since I've made that note, but, from recollection, the flag would determine rapture behavior for the following turn. I think it's also possible for 0x40 to be off and 0x04 to be on for a net result of the city to begin celebrating the next turn.

But my testing was nowhere near exhaustive.
 
Top Bottom