Ck456Tli » TileInfo resource editor for Keens 4,5,6
version 3.2 » released on May 6, 2007
research by adurdin » program by The CK Guy
This program allows the Keener to alter tile properties. This is most useful when the Keener is also a Modder, and wishes to create a few new tiles to use, or perhaps to create a whole new set of tiles.
This program does not alter the appearance of the tiles. (Use adurdin’s excellent ModKeen2 for that purpose.) It does not let you create new Keen levels. (Use TED5 or possibly Keen: Next for this.) And lastly, this program does not let you create completely new kinds of properties for tiles. (You’re on your own for this one.) This program only lets you change the tiles’ properties to those of existing tiles.
Three eventful years pass … (during which ModKeen2 is released, making this program actually useful)
Also — You may have noticed that the executable is now smaller and starts faster. This is because I am using a completely different build method: version 2.0 was built by translating the Euphoria 3.0.1 program into a tokenized version, and appending that to the interpreter. Version 2.1 was built by first translating the program into C, then compiling it with Open Watcom 1.5, then attaching the icon as a resource, then compressing it with UPX 2.01. The process takes much longer (several minutes instead of several seconds), but it does produce a smaller, faster executable.
Also — Sometime after this release and before the next one, a separate subforum on Keen: Modding was created for my program! Woohoo! That’s how I know it’s important!
First of all, these docs assume a good knowledge of CKPatch, Commander Keen built-in resources, and just modding in general. For a good introduction to these topics, check out the “Modding Tutorials” on Xtraverse’s “Beyond the Pogo” website at dosclassics.com/keen.
(Now that we’ve weeded out the riffraff, we may proceed unencumbered!)
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:
The flags for foreground tiles, listed in the order they appear in the TileInfo resource:
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.
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.
Before you even fun the program, you will need three things: a TileInfo resource dump, a standard bitmap of the background tiles (18 tiles per row), and a standard bitmap of the foreground tiles (also 18 tiles per row). For the TileInfo resource dump, you will probably be starting with one of the Keen?.tli included in Ck456Tli(v3.2).zip. For the two bitmaps, probably the easiest way to get these is to use ?TIL0000.BMP and ?TIL0001.BMP exported with ModKeen2.
Now you can start up the program. Click “OK” at the introductory welcome dialog. In the next dialog box that pops up, select the TileInfo resource file you want to edit, then click on “Open”. In the next window, open the background tile bitmap, and in the window after that, open the foreground tile bitmap. (For the last two windows, the default filename mask corresponds with the filenames used by ModKeen2.)
Now, the main program will start. The narrow section on the left has four buttons on top (“Save”, “Save As”, “About”, and “Help”, which have the obvious purposes), and below them various information about the loaded file. Now, especially if you’re working from one of the default TileInfo files that come with this program, I would recommend that you immediately click “Save As” and save to a new file.
To edit the properties of a tile, click on it in the pictures of the tiles. An enlarged version will appear in the top portion of the program. (For foreground tiles, an enlarged version of the mask will also appear.) Use the mouse wheel to scroll the tile pictures up and down. You can also control-click and drag with the left mouse button to scroll if your mouse doesn’t have a wheel.
For background tiles, you can edit the animation properties. To specify what tile this tile animates to, right-click it in the tile selection panel. If a tile animates, the target tile is outlined in a double red border. Note that tiles can only animate up to 128 tiles before them and up to 127 after them. By moving the scrollbar, you can change the amount of time spent on the tile while animating (0 to 255 time units).
For foreground tiles, you can also edit the animation properties (and they work the same way), but you can also edit several other properties. Above the enlarged pictures of the tile and its mask is a dropdown menu where you can select the properties of the top of the tile. Similarily, the dropdown menu below lets you select the properties of the bottom of the tile. Pushing in the buttons to either side signify that Keen (and other sprites) cannot enter the tile from that side. (Note that these are almost always set or cleared together. One-way tiles do not work as well in Keens 4,5,6 as they do in Keens 1,2,3.) Off to the right is another dropdown menu, which lets you change special properties of the tile. Lastly, when the “FRONT” button is pushed in, it means that the tile appears in front of Keen and other sprites rather than behind them.
And now, some keyboard shortcuts: For both background and foreground tiles, pressing escape resets the properties to their previous values. Pressing F1-F4 copies the current tile’s properties to internal clipboard 1-4, respectively. Pressing F5-F8 pastes the properties on clipboard 1-4 to the current tile. Pressing F9-F12 pops up a dialoge box displaying the contents of clipboard 1-4. You can even hold one of F5-F8 down as you drag the mouse around, applying the properties to many tiles quickly.
There is something important to note about the target tile for animation: this is stored as a relative offset to the target tile. This means that when you copy the properties from tile A and paste them to tile B, the target animation tile of tile B isn’t the same as that for tile A, but it is the same relative tile, which is usually what you’d want, anyway. Also note that there are not different kinds of clipboards for the background and foreground tiles—when you copy/paste a background tile, only the animation and timing properties are affected/used, the other properties of the clipboard are unchanged/ignored.
(You may be wondering how the program decides whether the ESC, F1-F8 keypresses apply to the background or foreground tiles. It’s actually quite simple: if your mouse is in the background group in the window, the command applies to the background tiles. If it’s in the foreground group, it applies to the foreground tiles. If the mouse isn’t in either group, nothing happens.)
To save the file click either “Save” to save to the current file, or “Save As” to save to another file. To use the TileInfo resource in you own Keen game, you can patch it into memory by putting one of these lines into your CKPatch script file:
%patchfile $249C2 <filename.tli> # for Keen 4
%patchfile $25B22 <filename.tli> # for Keen 5
%patchfile $25212 <filename.tli> # for Keen 6
Note that these are for Keens 4,5,6 version 1.4, not version 1.4 GT (distributed by Goodtimes Software), nor version 1.0 (nor any of the other myriad interim Keen 4 versions). This is the standard version for all modding in episodes 4,5,6, just as version 1.31 is the standard for Keens 1,2,3. If you must know, the offsets for Keens 4,5,6, version 1.0, are $23742, $24B12, and $23DE2, respectively. Modding from versions other than 1.4 is not recommended.
Here are the various flag values recognized by the program:
|
|
The program’s source code is now included in the distribution. This is provided for curious users, and will probably not be of interest to most people. The source is color-coded in the HTML file source.htm. I’m not releasing this out into the public domain—you need to ask me for permission before you distribute anything derived from it. (I’m allowed to say no!)
The program is written in Euphoria (version 3.0.2, to be precise), an obscure but amazing language I’ve grown to love over the years. [begin plug — The greatest thing about Euphoria is the flexible but simple data structures. The types of data are: atoms (these are numbers), and sequences (these are finite ordered collections of atoms and sequences). Sequences can contain any combination of other data, and are completely dynamic at runtime. With the one data structure of a sequence, you can implement arrays, multidimensional arrays, structures, trees, stacks, linked lists, and pretty much anything else you can think of. What about strings? These are just sequences of atoms, which are the ASCII codes. The string "ABC" is exactly the same as the sequence {65, 66, 67}. Anyway, this language is completely awesome and fully recommended. On October 17, 2006, it went completely open source (no more paying for advanced features!), so go get your copy today. — end plug] It uses Win32Lib (version 0.60.6), which is pretty much a gigantic set of wrapper routines for the Windows API. (To be honest, the library could be a lot nicer and more internally consistent.)
Special thanks to adurdin for doing the initial research on the TileInfo resource format a while back. He’s been the hub of the Commander Keen modding community for several years. Thanks to Xky Rauh for prodding me into completing version 2.0 of this program. Thanks to people who made suggestions on how to improve Ck456Tli over the past weeks. Thanks to various people for pressuring me into implementing a nice tile-selection interface. (Once I started trying to figure out how to do it, it wasn’t really that bad.) Ditto for the current-tile crosshairs. (And ditto for this part too.) And thanks to the entire K:M community for being awesome in general. (Notice that I’m pointedly not thanking the PCKF community. ;-P )
If you have any questions or comments, please post them on the “Ck456Tli” forum at Keen: Modding (www.keenmodding.org) or email them to me (theckguy@gmail.com). If you notice any bugs or inconveniencies (in·con·ve·nien·cy n, pl in·con·ve·nien·cies (21c): something that is inconvenient—from Webster’s 314th Well-it’s-a-Word-Now-and-I-Don’t-Care Dictionary) or discover flag values that do not work as expected, please tell me! I always want to hear suggestions about how to improve this program.
I need you guys to go bug-hunting and let me know what you find. And while you’re at it, make sure you add to the KeenWiki. (Do you know that that was where I first found out that people thought my program wasn’t easy to use? You’ve got to let me know this stuff in the forums!)
I hope this tool is useful! Now let’s have some more mods!
The CK Guy
May 6, 2007