EGAGRAPH.CKx is the file that contains all of the graphics in Keen Galaxy. The file is external and can be modified with two programs, ModKeen and keengraph. There are two other related files, EGAHEAD.CKx and EGADICT.CKx. In order to use altered graphics, one or both of these files must be patched.
EGAHEAD.CKx is the graphics 'header'; it is basically a list of locations of various graphics in the EGAGRAPH.CKx. EGADICT.CKx is the 'huffman dictionary' used to compress the graphics. The EGAGRAPH.CKx itself consists of a number of graphics 'blocks' or chunks; the game refers to all graphics by their chunk number. (Confusingly Modkeen does not number things by chunk number.)
Keen Dreams uses a different name for its graphics file.
The EGAHEAD.CKx and EGADICT.CKx files are internal and thus can be called anything, but the EGAGRAPH.CKx file's name can be patched. The file name is read once to open the file and read graphics from it. Keen 4 and 5 also check the existence of EGAGRAPH.CKx. (See below.)
|Patch: EGAGRAPH file name|
Patching new graphics
As mentioned above,using new graphics requires that the EGAHEAD.CKx and maybe EGADICT.CKx need to be patched (depending on whether Modkeen or Keengraph is being used, see their respective pages for details.) The patches used rely on a special command in CKPatch.
|Patch: Patch new graphics|
Don't scramble EGA dictionary
This patch prevents the graphics dictionary being 'scrambled' which occurs when the game runs. This patch can only be used if the graphics file is not compressed , otherwise the game will crash. This is useful since it frees up 1Kb of data segment space for patches and text.
This patch can also be used with an identical one for the AUDIODCT; this will increase the freed space to 2KB and also free up code space. ($12CE3-$12D2B in Keen 4, $13C80-$13CC8 in Keen 5 and $12814-$1285C in Keen 6).
|Patch: Don't scramble EGADICT|
EGAGRAPH file check & new patch space
In Keen 4 the game contains code both to check for EGAGRAPH and if it is not found to create it from two files, EGA1.CK4 and EGA2.CK4. Keen 5 has the code but it is defective, and Keen 6 does not have this ability at all.
If this check is disabled in Keen 4 then almost 400 bytes of space are freed up for patches. This check is separate from the EGAGRAPH.CKx filename which is only used if this check is passed. (See above.)
|Patch: Check for EGAGRAPH|
|Patch: Disable EGAGRAPH check|
Number of each graphic type
It is possible to alter the number of each of the different types of graphic (Converting, say, unmasked 16x16 tiles into masked 16x16 tiles.) This is best done before a project is started as it will drastically alter things such as the levels when implemented. The main way graphics chunks are differentiated and limited is the graphics decompression code. The first set of patches in this section deals with this code and a brief explanation of the patches on a kind-by-kind basis is as follows:
Masked and unmasked bitmaps: These are defined by the first sprite chunk; any graphic less than this is a bitmap of some kind. It is not currently known how masked and unmasked bitmaps are differentiated.
Sprites: Sprites are defined by one value giving the first chunk that is treated like a sprite and another that is the 8x8 unmasked chunk. The difference between these two values gives the total number of sprite chunks. Note that there are two matching entries for the 8x8 unmasked value for reasons.
Unmasked 8x8 tiles: Unmasked 8x8 tiles are defined by three sets of values. The first is the chunk used for the tiles. The second is the first 'non-8x8-unmasked' chunk which is the previous value plus one. It is the the masked 8x8 tiles chunk value. The third is the memory set aside for the tiles; each tile requires 32 or $20 bytes of memory, so this value divided by 32 gives the number of tiles the game can display. This is not the same as the number of tiles there actually are, it is usually slightly higher, possibly as a buffer of some sort. (In Keen 4 for example 4 extra tiles worth of memory is set aside.)
Unmasked 8x8 tiles: These are treated very similarly to the unmasked 8x8 tiles. They are defined by a value for the chunk they use and a value for the first 16x16 background tile, which is the first value plus one. They too have a value that gives how much memory is set aside. Masked tiles require 40 or $28 bytes of memory. The game usually sets aside massively more memory than is required, usually twice as much, again possibly as a buffer.
Unmasked 16x16 tiles: 'Background tiles' are defined by a value giving the first chunk that will be treated like a background tile as well as another value defining the fist chunk to be a foreground tile. The difference between these two values gives the total number of background tiles. The first value is also defined elsewhere in the code as mentioned below. 16x16 tiles have a memory value like 8x8 tiles but this is just the size of the individual tile and shouldn't be patched.
Masked 16x16 tiles: 'Foreground tiles' are defined by a value giving the first non-background chunk as well as several values that give the first 'non-tile' chunk. The difference between these values is the number of foreground tiles.
Misc: All remaining graphics are 'miscellaneous.' These include the first and last few graphics chunks. As such these are defined solely elsewhere in the code, often on a chunk-by-chunk basis.
Other chunk definitions: 16x16 tiles are also defined in the 'display level' code. There are two values for both masked and unmasked tiles, one for animating tiles and one for non-animating. The two values for each tile type should match and also match those in the graphics decompression code.
Things like the story texts or B800 screens are defined individually with each chunk having a single purpose and being capable of being placed anywhere in the EGAHEAD. The only exceptions are the demos; like tiles only a first value is given.
Note that Keen Dreams handles things slightly differently due to being an alpha of the Galaxy engine.
|Patch: Keen 4|
|Patch: Keen 5|
|Patch: Keen 6|
|Patch: Keen Dreams|