Difference between revisions of "Simcity 2000 Special Edition"

From XentaxWiki
Jump to: navigation, search
(SC2: Made description of segment header slightly less confusing (to me, at least))
(SC2: Conflicting with the IFF wiki page, but I'm pretty sure this file is in Little Endian. Adding notes from research on ALTM block.)
Line 34: Line 34:
 
== SC2 ==
 
== SC2 ==
 
* '''Format Type:''' [https://en.wikipedia.org/wiki/Interchange_File_Format Interchange File Format (IFF)]
 
* '''Format Type:''' [https://en.wikipedia.org/wiki/Interchange_File_Format Interchange File Format (IFF)]
* '''[http://en.wikipedia.org/wiki/Endianness Endian Order]''': Big Endian
+
* '''[http://en.wikipedia.org/wiki/Endianness Endian Order]''': Little Endian
  
 
=== Format Specifications ===
 
=== Format Specifications ===
Line 162: Line 162:
 
|CNAM
 
|CNAM
 
|The name of the city, uncompressed, and also optional it seems. When it's present, the length byte is a number 0 to 31, with that many bytes of city name. It's padded to 32 bytes with zeroes.
 
|The name of the city, uncompressed, and also optional it seems. When it's present, the length byte is a number 0 to 31, with that many bytes of city name. It's padded to 32 bytes with zeroes.
 +
|-
 +
|ALTM
 +
|<p>Altitude map, which is uncompressed. Each "square" is two bytes, with them being scanned in top to bottom, and from right to left in each row. In my testing, this seems to mean that the first square is at the northern-most corner of the screen. Following that, squares proceed to the south-west, or left in this case. Let every two bytes represent a [http://wiki.xentax.com/index.php?title=DGTEFF#-bit_.282-byte.29_numbers 16 bit integer], MSB first, such that bits 4-0 represent the altitude from 50 to 3150 feet. Bits 6-5 are unknown. Bit 7 seems to be set if a square is covered by water. Bits 15-8 are unknown. '''Notes from my own testing (in SCURK 1.0):''' By default, it seems that the default altitude of a square (starting in SCURK) is 4 "units" high, as is represented by a binary 00100. Raise that square by one, and it will become decimal 5, or binary 00101. At some point along a row of empty level squares, <code>hex 0x0084</code> squares show up in groups of 22 bytes, or 11 squares. This is <code>bin 10000100</code>, which is still the usual four squares high, although bit 7 is set despite the square not being under water.</p> Furthermore, in a totally unmodified city (with only the name/year/budget having been set), the first eight bytes of ALTM data (or four squares) have this <code>hex 0x0084</code> pattern, followed by 20 bytes (10 squares) with the <code>hex 0x0004</code> pattern. Eight more bytes follow that with <code>hex 0x0084</code>, and the alternation continues although the number of squares in each set does not seem to correlate with anything. Upon generating another city with a different name, but with all other parameters the same, the alternating pattern is also exactly the same. Starting with hex 84 then hex 4 and repeating, the number of squares is: 4, 10, 4, 13, 3, 3, 31, 25, 8, 27, 3, 11, ... Bit 7 apparently does not seem to indicate water coverage. Raising terrain as in the previous example does appear to disturb this pattern, with squares of hex 4 becoming more abundant.
 
|}
 
|}

Revision as of 22:55, 17 February 2016

Choose archive extension:

IDX + DAT


Format Specifications

// for each file

uint32 {4}   - ID
uint32 {4}   - File Offset


MultiEx BMS Script

Not written yet

Notes and Comments

  • The *.idx file contains the directory, the *.dat file contains the file data



Compatible Programs


SC2

Format Specifications

// HEADER

char {4} - Chunk Type ID ('FORM')
int32 {4} - Total count of bytes in file minus first 8 in the header
char {4} - File type (always 'SCDH' for SimCity 2000)

// Begin segments/nested chunks. For each nested chunk:

// Segment header

char {4} - Segment type
int32 {4} - Byte count of the data in this segment (excluding this header)

// Segment data, begin sub-segment bytes (let x = the byte's value)

byte {1}
// If 1 <= x <= 127:
byte {x} - Raw, uncompressed data
// If 129 <= x <= 255:
byte {1} - The following byte repeats x-127 times.
// Repeat for the rest of this segment's data length.

Notes and Comments

  • This is the file format in which cities are stored. See the IFF page on Wikipedia (linked above) for more information on the format, although it is essentially a generic container file format.
  • All of this information is thanks to the research done by David Moews, with a document here.
  • After the header, the rest of the file is made up of chunks containing an 8 byte header followed by its data. Almost all segment data is compressed using a run-length algorithm. Specifically:
    • The compressed data is a series of two kinds of chunks
    • In the first kind, the first byte equates to an integer 1 to 127. This means the byte is counting how many data bytes follow.
    • In the second kind, the first byte equates to an integer 129 to 255. If you subtract 127 from it, you end up with a count of how many times the following byte is repeated.
    • Chunks with a first byte of 0 or 128 never seem to occur.
    • Therefor, the maximum size of an uncompressed sub-chunk can be 127 bytes.

Segment Types

  • The following table is a list of segment types in the order they typically appear. Unless noted, they are compressed using the above algorithm. The lengths given are their uncompressed lengths.
Seg. type Length (bytes)
CNAM 32 (Uncompressed)
MISC 4800
ALTM 32768 (Uncompressed)
XTER 16384
XBLD 16384
XZON 16384
XUND 16384
XTXT 16384
XLAB 6400
XMIC 1200
XTHG 480
XBIT 16384
XTRF 4096
XPLT 4096
XVAL 4096
XCRM 4096
XPLC 1024
XFIR 1024
XPOP 1024
XROG 1024
XGRP 3328

Additional notes on segment types:

ID Comments
CNAM The name of the city, uncompressed, and also optional it seems. When it's present, the length byte is a number 0 to 31, with that many bytes of city name. It's padded to 32 bytes with zeroes.
ALTM

Altitude map, which is uncompressed. Each "square" is two bytes, with them being scanned in top to bottom, and from right to left in each row. In my testing, this seems to mean that the first square is at the northern-most corner of the screen. Following that, squares proceed to the south-west, or left in this case. Let every two bytes represent a 16 bit integer, MSB first, such that bits 4-0 represent the altitude from 50 to 3150 feet. Bits 6-5 are unknown. Bit 7 seems to be set if a square is covered by water. Bits 15-8 are unknown. Notes from my own testing (in SCURK 1.0): By default, it seems that the default altitude of a square (starting in SCURK) is 4 "units" high, as is represented by a binary 00100. Raise that square by one, and it will become decimal 5, or binary 00101. At some point along a row of empty level squares, hex 0x0084 squares show up in groups of 22 bytes, or 11 squares. This is bin 10000100, which is still the usual four squares high, although bit 7 is set despite the square not being under water.

Furthermore, in a totally unmodified city (with only the name/year/budget having been set), the first eight bytes of ALTM data (or four squares) have this hex 0x0084 pattern, followed by 20 bytes (10 squares) with the hex 0x0004 pattern. Eight more bytes follow that with hex 0x0084, and the alternation continues although the number of squares in each set does not seem to correlate with anything. Upon generating another city with a different name, but with all other parameters the same, the alternating pattern is also exactly the same. Starting with hex 84 then hex 4 and repeating, the number of squares is: 4, 10, 4, 13, 3, 3, 31, 25, 8, 27, 3, 11, ... Bit 7 apparently does not seem to indicate water coverage. Raising terrain as in the previous example does appear to disturb this pattern, with squares of hex 4 becoming more abundant.