Disassembly of K240 v1.886 using IRA reveals a data structure 400 bytes long, beginning at $1c338 in the main game executable. Analysis reveals that this stores data on the game's buildings, including all 40 Terran buildings but not alien buildings. Ten bytes are used to store each in the following format:
|WORD||Name||Index of the building name in the game's strings list|
|WORD||Description||Index of the building's description in the game's strings list|
|WORD||Cost||Build price of the building|
|BYTE||Hitpoints||Building hit points|
|BYTE||Build time||Build time in days|
|Name||Description||Cost||Hitpoints||Build time||Scaffold||Actual name|
|000e||002f||157c||14||24||00||Deep Bore Mine|
|0020||003f||1c20||14||30||03||Protected Solar Matrix|
|0022||003f||1d4c||20||30||02||Protected Storage Tower|
|00c4||00c5||2134||34||20||03||Protected Environment Control|
The C.P.U. is listed as costing 8000, although it cannot be built except automatically when a new colony is started.
The Decontamination Filter, Plasma Turret and Photon Turret have high numbers in the string list, appear out-of-order, and have their descriptions immediately following. This suggests they were added later in the game's development. They may have taken the place of three deleted buildings.
The Medical Centre, Environment Control, Protected Environment Control, Hydroponics, Hydration Plant and Security Centre all appear at the end of the list, have high numbers in the string list, and have their descriptions immediately follow in the string list. This suggests that they were added even later in the game's development. Early on, Life Support may have supplied all air, food and water.
Except for building hit points, all data in this table is visible in the game or in the game manual. Building hit points in decimal are as follows.
|20||Deep Bore Mine|
|20||Protected Solar Matrix|
|32||Protected Storage Tower|
|52||Protected Environment Control|
Interestingly, the "protected" buildings are actually tougher than their non-protected equivalents, except for the Protected Storage Tower.
This table does not store sprite reference or whether the building takes up 1 square or 2x2 squares.
Current building data
Disassembly using IRA reveals that nine areas of memory are written to disk in order to form the save game file, which suggests that these nine areas hold the entire game state. Analysis of PART4, which begins 93,658 bytes into the save game file and is 33,600 bytes long, reveals that the game stores building data for 24 asteroids, 100 buildings per asteroid, and 14 bytes per building. The hex editor HxD was useful for this analysis.
The limit of 100 buildings per asteroid explains why attempting to build too many buildings returns the message, "Asteroid structure too weak!" Tests reveal that the size of buildings (1 square or 2x2 squares) is irrelevant, only the number, which cannot exceed 100 due to a limitation of the data structure. Relatedly, it's possible that the reason why Landing Pads can't be built close to the edge of the asteroid is to prevent a ship taking off from a Landing Pad at the very top row of a large asteroid and rising above the top of the screen. Since an asteroid can be rotated, all edges are potentially "top".
The format is as follows:
|Byte||ID||The building's index in the buildings construction data, not necessarily its string index|
|Byte||Time to build?||Last 7 bits seems to be the number of days left to build.|
|6 bytes||Big coords||Additional coordinates for four-square buildings, also used by missile silos for animation frames while firing|
|Byte||Turret recharge||Seems to be an "initiative count" or time-to-fire for turrets|
Save state viewing with WinUAE reveals interesting features.
Building Armour doubles the hit points of new buildings, not existing ones. However, a Repair Facility will repair old buildings up to the Building Armour maximum. It seems as if Building Armour doubles the "maximum" hit points of all buildings, which allows existing buildings to be repaired to the new standard.
Watching the data of a colony under attack reveals that a Screen Generator halves all damage taken by buildings in its range, rounded down.
Destroying a building with the green bomb tool appears to deal that building 120 damage. This ensures destruction of any building, even (hypothetically) a 60HP building with Building Armour. The strongest Terran building is a Protected Environment Control with Building Armour at 104 hit points.
As building hit points is a signed integer, it's theoretically possible to have a building with 128 hit points which would survive this hit, but presumably no Terran or alien building can acquire this many hit points. This also implies that the Kll'Kp'Qua cannot acquire Building Armour, as their Queen's Chamber has 100 hit points, and Building Armour would raise this to 200, which the game would read as negative, thus destroying all new Queen's Chamber buildings one day after they are placed.
The following buildings require eight colonists each: Mine, Deep Bore Mine, Seismic Penetrator, Construction Yard, Command Centre and Missile Silo. No other buildings require workers. Ships do not require colonists for crew.
- Alien building data
- Information on the function of alien buildings
- Damage values / to-hit functions for Terran turrets and the turrets of Protected buildings
- Sprite rips
- How the game determines a building's type for the purpose of spy satellite reports
- What determines the order in which buildings disable in event of power loss