Construction data
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:
Datatype | Name | Description |
---|---|---|
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 |
BYTE | Scaffold | Scaffold height |
BYTE | Empty | Empty |
Name | Description | Cost | Hitpoints | Build time | Scaffold | Actual name |
---|---|---|---|---|---|---|
0001 | 0013 | 03e8 | 05 | 20 | 00 | Living Quarters |
0002 | 0023 | 05dc | 22 | 20 | 00 | Power Store |
0003 | 0024 | 05dc | 18 | 14 | 00 | Storage Facility |
0004 | 0025 | 1b58 | 10 | 24 | 00 | Anti-Missile Pod |
0005 | 0026 | 01f4 | 05 | 08 | 00 | Solar Panel |
00ba | 00bb | 1f40 | 18 | 20 | 02 | Decontamination Filter |
0007 | 0028 | 05dc | 0a | 0a | 00 | Solar Generator |
0008 | 0029 | 1130 | 18 | 20 | 00 | Weapons Factory |
0009 | 002a | 0fa0 | 14 | 20 | 00 | Mine |
000a | 002b | 1388 | 0a | 18 | 00 | Satellite Silo |
000b | 002c | 4e20 | 24 | 34 | 00 | Screen Generator |
000c | 002d | afc8 | 24 | 30 | 01 | Ore Teleporter |
000d | 002e | 88b8 | 18 | 34 | 01 | Gravity Nullifier |
000e | 002f | 157c | 14 | 24 | 00 | Deep Bore Mine |
000f | 0030 | 10cc | 0f | 20 | 00 | Missile Silo |
0010 | 0031 | 4e20 | 14 | 24 | 01 | Repair Facility |
0011 | 0032 | 0dac | 0f | 24 | 03 | Sensor Array |
00bc | 00bd | 157c | 14 | 1e | 00 | Plasma Turret |
00be | 00bf | 1d4c | 14 | 34 | 00 | Photon Turret |
0014 | 0033 | 32c8 | 18 | 30 | 02 | Life Support |
0015 | 0034 | 1f40 | 24 | 28 | 03 | C.P.U |
0016 | 0035 | 6784 | 18 | 2a | 02 | Seismic Penetrator |
0017 | 0036 | afc8 | 1c | 40 | 01 | Asteroid Engines |
0018 | 0037 | 2710 | 22 | 28 | 02 | Powerplant |
0019 | 0038 | 1f40 | 24 | 20 | 02 | Command Centre |
001a | 0039 | 1d4c | 14 | 20 | 02 | Construction Yard |
001b | 003a | 012c | 05 | 10 | 00 | Landing Pad |
001c | 003b | 0d48 | 10 | 18 | 00 | Laser Turret |
001d | 003c | 1388 | 0a | 20 | 03 | Solar Matrix |
001e | 003d | 0bb8 | 0a | 30 | 03 | Resiblock |
001f | 003e | 0bb8 | 20 | 28 | 02 | Storage Tower |
0020 | 003f | 1c20 | 14 | 30 | 03 | Protected Solar Matrix |
0021 | 003f | 2134 | 14 | 38 | 03 | Protected Resiblock |
0022 | 003f | 1d4c | 20 | 30 | 02 | Protected Storage Tower |
00c0 | 00c1 | 1388 | 0f | 1e | 03 | Medical Centre |
00c2 | 00c3 | 0c80 | 22 | 14 | 02 | Environment Control |
00c4 | 00c5 | 2134 | 34 | 20 | 03 | Protected Environment Control |
00c6 | 00c7 | 1b58 | 18 | 10 | 03 | Hydroponics |
00c8 | 00c9 | 1388 | 14 | 14 | 03 | Hydration Plant |
00ca | 00cb | 1194 | 0f | 18 | 02 | Security Centre |
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.
Hitpoints | Building name |
---|---|
5 | Landing Pad |
5 | Living Quarters |
5 | Solar Panel |
10 | Resiblock |
10 | Satellite Silo |
10 | Solar Generator |
10 | Solar Matrix |
15 | Medical Centre |
15 | Missile Silo |
15 | Security Centre |
15 | Sensor Array |
16 | Anti-Missile Pod |
16 | Laser Turret |
20 | Construction Yard |
20 | Deep Bore Mine |
20 | Hydration Plant |
20 | Mine |
20 | Photon Turret |
20 | Plasma Turret |
20 | Protected Resiblock |
20 | Protected Solar Matrix |
20 | Repair Facility |
24 | Decontamination Filter |
24 | Gravity Nullifier |
24 | Hydroponics |
24 | Life Support |
24 | Seismic Penetrator |
24 | Storage Facility |
24 | Weapons Factory |
28 | Asteroid Engines |
32 | Protected Storage Tower |
32 | Storage Tower |
34 | Environment Control |
34 | Power Store |
34 | Powerplant |
36 | C.P.U |
36 | Command Centre |
36 | Ore Teleporter |
36 | Screen Generator |
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:
Datatype | Name | Description |
---|---|---|
Byte | ID | The building's index in the buildings construction data, not necessarily its string index |
Byte | Hitpoints | Current hitpoints |
Byte | Time to build? | Last 7 bits seems to be the number of days left to build. |
Byte | BYTE03 | Empty? |
2 Bytes | Coords | Coordinates |
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 |
Byte | BYTE13 | ?? |
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.
Detonating buildings
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.
Observations
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.
Wanted
- 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