User
Pass
Remember Me
Need an account? Register here!
Home/NewsForum/CommunityBeyond the PogoCosmic CavernsDuke Centralspatang.com
Menu
Forum Index
Member List
Articles
Downloads
Private Messages


Rate this Article
Rating:


Modding Applications Part 2: Patching
Author: xtraverseDate: February 1st, 2004
Views: 4885Rating:


CKPatch

CKPatch is an extremely useful tool that is an alternative to hex editing. If you’re making a mod of Keens 2 or 3 and want to hex edit, you’ll have to use CKPatch instead because it isn’t legal to release the executables of those games, even if they are hex edited. The Patchotron is an easy way to make patch files for CKPatch.

Now on to patching. When a Keen game loads it loads the executable into memory (using some DOS API function) before it executes the program. When setting a patch file, the program will load this after it writes the executable to memory and write over what you specified. You don’t have to worry about accidentally ruining an exe file or something like that.

Place the CKPatch exe that corresponds to the Keen you’re editing in the folder of the game.

Before you make any patches you have to take a dump (no, don’t go to the bathroom). Here’s the process:

1. Open up notepad and paste in the following (this assumes you’re using Keen 1):

%ext ck1

%dump dump.txt

%end


2. You’ll learn what all this means later. For now, just save this file as patch.pat.

3. Now paste this text into a new notepad file:

ck1patch patch.pat

4. Save this file as Keen1.bat.

5. Now run Keen1.bat. It should load the game. Just quit, you don’t need to do anything. There should now be a file called dump.txt in your game folder. This contains what is written to memory when the game loads.

When you need the address for a patch, find it in this file, not in the Keen executable.

The bat file you made will be what you always use to run the game from now on. Now it’s time to create a patch file.

Remember that patch.pat file you made to dump? This is your patch that you’re going to use. Here’s a brief explanation of how the patch file works. A pound (#) symbol starts a comment that CKPatch will skip over. I suggest you add comments to describe what different parts of your patch file do, so you don’t forget when you come back to it later.

A percent (%) symbol starts a macro command, which is what is used to patch the game. Here’s a brief rundown on the different commands:

CommandExampleUse
%ext (game)%ext ck1It isn’t necessary because there are individual CKPatch executables, but in future releases of CKPatch, it may be combined into one exe. It is recommended you use this anyway for future compatibility. This patch would go at the beginning of a patch file.
%end%endStops the reading and starts the game. Goes at the end of the patch file (duh…).
%patch (offset) (string)%patch 0x0AAAAA “This is a test”This is the most common command is this one, which allows you to write over any text in the entire game change filenames, etc… There are multiple ways of doing it, but I’ll tell you the one I find simplest. Open up your dump.txt file in a hex editor. Find the place where you want to write over some text. Get the hex address of that byte (if you don’t know how look in the help file of your hex editor). Now type in the macro %patch 0x0yourhexaddressYour patch text
It’s very important you put your patch text in quotes. That’s all you need to do.
%patchfile (offset) (string)%patch 0x0AAAAA file.extWorks the same way the %patch command except you’re loading a file into the memory instead of text.
%abort%abortStops the reading and closes the program.
%version (version #)%version 1.1
%version all
Only patches for the specified version. Used if the offset differs for different versions to make the patching more compatible. To go back to all versions use all after the %version command instead of a number.
%level.hint # (string)%level.hint 5 “This is a test”Used for Keens 1 (the yorp/garg statues) and 4 (Princess Lindsey hints). This could be done with the patch command but this command is a shortcut. The # represents the level number. See the level table near the bottom for specifications on what level numbers can be used and the number of allowed characters.
%level.DIR (dir)%level.DIR levelsUsed for Keens 1-3, changes the directory the levels are looked for in.
%level.name # (newname)
%level.entry # (newentry)
%level.name 5 “The Blue Place”
%level.entry 5 “Keen turns blue”
Level.name changes the name of a level in Keens 4-6. Level.entry changes the text it displays when you enter a level in Keens 4-6. The # represents the level number. See the level table near the bottom for specifications on what level numbers can be used and the number of allowed characters.
%gamemaps (file)
%egagraph (file)
%audio (file)
%gamemaps maps.ck4
%egagraph ega.ck4
%audio snd.ck4
Allows you to change the location of these files in Keens 4-6. It looks for the files relative to your patch file.
%audiohed (file)
%egahead (file)
%maphead (file)
%audiodct (file)
%egadict (file)
%audiohed sndh.ck4
%egahead egah.ck4
%maphead mapsh.ck4
%audiodct sndd.ck4
%egadict egad.ck4
Allows you to load the respective resource into the game executable at start for Keens 4-6. It looks for the files relative to your patch file.


The following info is unnecessary if you are using the Patchotron.

Keen 1 hints and char limits

Level(s)Char Limit
2, 6, 9, 10, 12   7 lines of 20 chars
114 lines of 20 chars
156 lines of 20 chars


Keen 4 hints and char limits (You may need to put carriage returns periodically)

Level(s)   Char Limit
573
776


Level Names (You may need to put carriage returns periodically)

Level(s) – Keen 4Char Limit
0-2, 5-10, 15-1715
3, 4, 11, 12, 14, 1831
1347
Level(s) – Keen 5Char Limit
0, 2, 13-1515
1, 3-1231
Level(s) – Keen 6Char Limit
0, 2, 5, 7, 9-11, 16, 18   15
1, 3, 4, 6, 8, 12-15, 1731


Level Entry Texts (You may need to put carriage returns periodically)

Level(s) – Keen 4Char Limit
0, 2, 7, 931
1, 3, 5, 6, 8, 10-12, 15-17   47
4, 13, 14, 1863
Level(s) – Keen 5Char Limit
0-10, 12-1447
11, 1563
Level(s) – Keen 6Char Limit
0, 731
1-6, 8-10, 12, 16-1847
13-1563
1179


The Patchotron

The Patchotron makes patch files read by CKPatch in an easy, user-friendly way, without the tedious work of finding offsets and such in a hex editor. This is Version 1.4..

Open up the Patchotron and select the Keen Game you want to start patching. You'll come to a screen with an array of buttons:


Here’s a brief rundown on the different buttons for Keens 1-3:

ButtonUse
MenuAllows you to change the text in the menu of a game (image).
Status ScreenAllows you to change the text in the status screen of a game.
About IDAllows you to change the text in the About ID.. screen of a game.
OrderInfoAllows you to change the text in the Ordering Info screen of a game.
FinaleAllows you to change the messages at the finale (end) of a game.
Mortimer ConversationAllows you to change the messages at the beginning of level 16 in Keen 3.
HintsAllows you to change the messages from the Yorp/Garg statues in Keen 1 and the frozen Vorticon Elders in Keen 2.
FilesAllows you to change the names of all the files for the game, including the extention.
High Score EntriesAllows you to change the default high score entries.
CheatsAllows you to change both the cheat codes themselves (image) and the messages displayed when you activate/deactivate a cheat.
BWB MessagesAllows you to change any of the four messages displayed when you try to go into your BWB in Keen 3.


Here’s a brief rundown on the different buttons for Keens 4-6:

ButtonUse
Level NamesAllows you to change the names of the levels in the game.
Level Entry TextsAllows you to change the text displayed when you enter a level.
HintsAllows you to change the messages from Princess Lindsay in Keen 4.
FilesAllows you to change the names of all the files for the game, including the extention.


Here’s a brief rundown on the different buttons that apply for all patching:

ButtonUse
Custom PatchIf you know an offset yourself, this lets you have some text patched there.
PatchfileIf you know an offset yourself, this lets you have a file patched there.
VersionAdds a header to define version-specific patches.
Abort/StopAdds the respective command.
DumpAdds a command that lets you choose a file to dump the memory into.
OtherPredefined patches that didn't fit into other categories.


You must be logged in to post a comment.
Copyright 2003-2010 xtraverse and spatang.com - All rights reserved