Patch:DICT files

From KeenWiki
Jump to: navigation, search

DICT files are 1'024-byte long files that contain the 'Huffman dictionary' used to decompress a game's data. They are used by Keen Dreams and Keen Galaxy and come in three kinds, depending on what data is being dealt with:

By default the dictionaries are internal, stored in the game executable. It is possible to modify the data without altering the method of its compression, in which case the dictionaries do not need to be patched. However some programs do alter the compression, in which case an external DICT file must be created. (E.g. EGADICT.CK4)

Location of dictionaries

Like most 'internal files' the location of the dictionaries depends on a pointer stored elsewhere in the executable. In the case of the dictionaries this is an offset from the start of the 'data segment'. Each dictionary cannot overlap with another (So the same dictionary cannot be used for two different types of data.)

Patch: Huffman dictionary calls
#Keen 4
%patchfile $354F6 AUDIODCT.CK4 %patchfile $358F6 EGADICT.CK4
#Keen 5
%patch $14314 $5B84W
%patch $14148 $5F84W
%patchfile $35EC4 AUDIODCT.CK5 %patchfile $362C4 EGADICT.CK5
#Keen 6
%patch $12EA8 $61BEW
%patch $12CDC $65BEW
%patchfile $36EEE AUDIODCT.CK6 %patchfile $372EE EGADICT.CK6
#Keen Dreams
%patchfile $2A046 AUDIODCT.CK7 %patchfile $29846 EGADICT.CK7 %patchfile $29C46 MAPDICT.CK7

Don't compress data\need dictionaries

Certain graphics and sound programs (Notably KeenWave and Keengraph) produce 'minimally compressed' data, that is, data that is essentially uncompressed but still adheres to the basic compression schematic. If all of a game's data is 'compressed' in this manner then all the compression does is slow loading times.

As such it is possible to remove the compression entirely, replacing it with code that simply copies the input to the output. Doing so greatly decreases loading times as well as freeing up code space. This does however require that all data is treated this way, which is only the case when certain specific programs are used.

Patch: Totally remove Huffman compression
#Keen Dreams - remove Huffman compression
%patch $B497 $55 $8B $EC $56 $57 $8C $DA $C4 $7E $0A $C5 $76 $06 $8B $4E $0E $D1 $E9 $FC $F3 $A5 $73 $01 $A4 $8E $DA $5F $5E $5D $CB
#Keen 4 - remove Huffman compression
%patch $12D2C $55 $8B $EC $56 $57 $8C $DA $C4 $7E $0A $C5 $76 $06 $8B $4E $0E $D1 $E9 $FC $F3 $A5 $73 $01 $A4 $8E $DA $5F $5E $5D $CB
#Keen 5 - remove Huffman compression
%patch $13CC9 $55 $8B $EC $56 $57 $8C $DA $C4 $7E $0A $C5 $76 $06 $8B $4E $0E $D1 $E9 $FC $F3 $A5 $73 $01 $A4 $8E $DA $5F $5E $5D $CB
#Keen 6 - remove Huffman compression
%patch $1285D $55 $8B $EC $56 $57 $8C $DA $C4 $7E $0A $C5 $76 $06 $8B $4E $0E $D1 $E9 $FC $F3 $A5 $73 $01 $A4 $8E $DA $5F $5E $5D $CB