Patch:Tileinfo
The Tileinfo.CKx file is an external file that contains all of the game's tile properties. These include whether they block the player,if they are deadly or animate or are items. The file does not exist by default in any games, but is often employed when modders want to change the properties of tiles. There are two basic schemes, Vorticons and Galaxy\Dreams.
Although specific patches can be used to change specific tiles, this is cumbersome and it is far more common to employ a %patchfile command to patch the entire tile property block at once, with a utility like Galactile.
There is a patch that completely alters the tile properties function in Keen 1, the Vorticons 2 patch, which therefore requires its own special utility to create tilesets.
Patches that deal with what the tile properties do (As opposed to what tiles have those properties]] can be found on their own separate pages. A list of these pages can be found on the Patch:Tiles page, which also deals with patches involving how the game processes tiles.
Patches
Tile patches are quite simple, they involve replacing an entire section of the game executable with an external file. It is best to get the original, default files which are the right size and have many examples of existing tile properties. These can be extracted from the executable, but it is often easier simply to get them along with the tile editing utility of choice. The following patches are used for the most common version of various Keen games:
Tile info patches
%patchfile $130F8 Tileinfo.CK1 # for Keen 1
%patchfile $17828 Tileinfo.CK2 # for Keen 2
%patchfile $198C8 Tileinfo.CK3 # for Keen 3
%patchfile $249C2 Tileinfo.CK4 # for Keen 4
%patchfile $25B22 Tileinfo.CK5 # for Keen 5
%patchfile $25212 Tileinfo.CK6 # for Keen 6
%patchfile $1FC46 Tileinfo.KDR # for Keen D
How tiles work
The following descriptions of tile properties are based heavily on data from CK456DTli by The CKGuy and User:Levellass.
Vorticons
The properties of each tile are encoded in various “flags”. Tiles have six flags. The term flags here is rather misleading, because this seems to imply that each one is either on or off. This is far from true—each flag for each tile is represented as a word in the resource, so in theory a flag could have one of 65536 values, but this does not happen in practice.
The flags for tiles, listed in the order they appear in the TileInfo resource:
- AnimFlag
- MiscFlag
- TopFlag
- RightFlag
- BottomFlag
- LeftFlag
Altering the properties of a tile consists of changing the values of one or more flags for that tile. Now we’ll go into specifics on the various flags.
- AnimFlag — For tiles that do not animate, this is one. For animating tiles, it is two or four. It is the number of tiles in the 'animation loop' the tile is involved in. This means that for animating tiles a row of two or four tiles must have the same value or errors will occur. The tiles used in animation will depend on where in the loop a given tile is and this is hard-coded, meaning a given tile can only possibly animate to one other tile.
- TopFlag — This specifies what the top of the tile is like. It can have four values, zero is 'fall through', 1 is 'solid' 2 is 'slippery' and 3 is 'ice'.
- LeftFlag, BottomFlag and RightFlag — These are zero if you can enter from that side, and one if the tile is solid on that side.
- MiscFlag — This is the most complicated flag. It encodes many of the special properties that tiles can have (such as being deadly, being an item with a certain point value, etc.). The following values are used:
00: Nothing 17: Exit 01: Kills 18: Key 1 02: Door 1 19: Key 2 03: Door 2 20: Key 3 04: Door 3 21: Key 4 05: Door 4 22: Message box popup 06: 500 points 23: Lightswitch 07: 100 points 24: Teleporter 08: 200 points 25: Switch on 09: 1000 points 26: Swtich off 10: 5000 points 27: Ankh 11: Joystick 28: Single bullet 12: Battery 13: Vaccum 14: Whiskey 15: Raygun -1: Foreground 16: Pogo -2: Masked
Galaxy and Dreams
The properties of each tile are encoded in various “flags”. Background tiles have two flags and foreground tiles have seven. The term flags here is rather misleading, because this seems to imply that each one is either on or off. This is far from true—each flag for each tile is represented as a byte in the resource, so in theory a flag could have one of 256 values, but this does not happen in practice.
The flags for background tiles, listed in the order they appear in the TileInfo resource:
- TimeFlag
- AnimFlag
The flags for foreground tiles, listed in the order they appear in the TileInfo resource:
- TopFlag
- RightFlag
- BottomFlag
- LeftFlag
- AnimFlag
- MiscFlag (including the pseudo-flag ForegroundFlag)
- TimeFlag
Altering the properties of a tile consists of changing the values of one or more flags for that tile. Now we’ll go into specifics on the various flags.
- AnimFlag — (For foreground and background tiles) For tiles that do not animate, this is zero. For animating tiles, it is a relative offset to the next tile in the animation sequence. This is stored as a signed byte, so the offset can be from -128 to +127.
- TimeFlag — (For foreground and background tiles) For tiles that do not animate, this is zero. For animating tiles, it is the amount of time spent on this tile in the sequence. The time unit is not known. To quote from an old document of adurdin’s: “The time is specified in UNITS, from x00 to xFF. A value of x95 is approximately equal to 2 seconds. Values lower than x02 may animate only sporadically.”
- Also — These flags are not just used for tiles that animate “by themselves”. Most of the time when tiles turn into other tiles (on switch to off switch and back, empty keygem holder to keygem holder with key, bridge opening/closing, keygem door opening, Keen 5 keycard door opening, etc.), the situation is handled by animating tiles. The AnimFlag for one tile points to the other, but the TimeFlag is set to zero.
- TopFlag — This specifies what the top of the tile is like. It can be a flat solid top, an open top you can fall through, a particular slant, solid but has a pole going through, etc.
- LeftFlag and RightFlag — These are zero if you can enter from that side, and one if the tile is solid on that side.
- BottomFlag — This specifies what the bottom of the tile is like. If you specify the TopFlag to be solid, but specify the BottomFlag to be “jump through”, you will get a tile that you can jump up through and land on, and to get back down through, you look down and jump. Some examples of this kind of tile are the “narrow” floors in Keen 4, the holes in Keen 5, and the tree limbs in Keen 6.
- MiscFlag — This is the most complicated flag. It encodes many of the special properties that tiles can have (such as being deadly, being an item with a certain point value, etc.). All of these are actually encoded in the lower seven bits of the flag. The high bit specifies whether or not the tile is to appear in front of Keen and other sprites, as opposed to behind them as most foreground tiles do. In this program, this is implemented as a separate pseudo-flag, ForegroundFlag.
Tools
The following utilities can be used to edit tile properties. This is done by displaying the tileset bitmap(s) and showing the tile properties for each 'square' of bitmap involved.
- TileInfo Used to edit tile properties in Keen Vorticons
- Tileset-Tool Used to edit tile properties and make tilesets for the Vorticons 2 patch
- Ck456Tli For Keen Galaxy
- CK456DTli A version of Ck456Tli that also supports Keen Dreams
- Galactile The best Galaxy utility, also supports dreams. Currently has separate versions for ModKeen and keengraph graphics