News

Patches

© 2018-2019 K1n9_Duk3

Note: If you decide to use any of these patches, you are doing so at your own risk. Always create a backup of your files before applying any paches. Always test modified executables in a safe environment like DOSBox or a virtual machine.

Here are a couple of patches that I've come up with in the past:

Unless stated otherwise, all of the patch scripts listed on this page are supposed to be used with K1n9_Duk3's Patching Utility.

If you find these patches useful and decide to use them in your own game mods, please give credit where credit is due.

Bio Menace (v1.1 freeware) - Mid-level saves and memory fix

This patch fixes a bug in Bio Menace that causes the game to "leak" memory when starting playback of a new music track, which could lead to "Out of memory" crashes. While this bug is not much of an issue when running the game in DOSBox, it might be useful for people who want to run the game on actual hardware or a different emulator.

Fixing said memory issue also allowed the re-introduction of mid-level saves. This allows the player to save the game at any point in the level and restore the game at the exact same position and state, just like in Commander Keen 4-6 and Keen Dreams.

Note: The saved games are compatible with the unpatched versions, so you won't lose any progress by applying the patch. However, trying to load a saved game that was written using a different version of the patch will cause severe problems and - if you're not running the game in DOSBox - could damage your system! If you have any saved games that were created using a different version of this patch, you need to resize the save file to 131 bytes (keep the first 131 bytes and remove the rest). If you don't have a utility that can truncate the file, load the saved games in the unpatched version of the game, delete the save file and then save again. This will cause you to lose any progress in the level as well as all the weapons and grenades, but it allows the patched executable to load the game without causing damage to your system.

There are also a couple of bonus patches in the scripts, allowing the player to carry weapons and grenades over into the next level.

The patch scripts are too big to list them here, but you can download them.

The scripts in the download are set up for use with BMxPATCH (part of the CKPATCH package) or K1n9_Duk3's Patching Utility (Version 2.0 or above). The scripts can also be modified for use with earlier versions of K1n9_Duk3's Patching Utility (Version 1.3 or above) if necessary. Using K1n9_Duk3's Patching Utility allows you to generate a fully patched standalone executable. The BMxPATCH utility usually takes up about 20k of conventional memory, so using the fully patched executables might be more useful on DOS configurations with little conventional memory to spare.

Commander Keen 4-6 (EGA) - Screen update fix

These patches fix a few minor graphical glitches when playing Commander Keen 4-6, such as:

  • jerky scrolling
  • sprites becoming invisible for one frame
  • sprites hidden behind foreground tiles becoming visible

Changing the "Fix Jerky Motion" option in the options menu will change the behavior of the screen update code. This option should be turned OFF (which is the default setting) when playing in DOSBox.

I also tested this code on various old PCs, using an MS-DOS 6.22 boot disk and running the game directly from DOS, and only one of them had problems with the default setting. That machine was a "Texas Instruments TravelMate 4000E 486 WinSX/25MHz Color" system. Enabling the "Fix Jerky Motion" option fixed the problems on that machine.

Note that this code has not been tested on an actual EGA card. The WaitVBL code was designed to stop waiting for a VBL when more than 1/70th of a second has passed since the code started to wait for a VBL. That's because the code can miss the VBL if the CPU was hadling an interrupt while the VBL signal was present and therefore the WaitVBL code didn't get to "see" the VBL signal. But EGA cards use a refresh rate of 60 Hz, not 70 Hz like the (S)VGA cards. That means it is possible for the WaitVBL code to exit a little too early on systems equipped with an EGA card, which means the issues listed above could still pop up.

Note: Each patch script only works on one specific version of the executables.

Commander Keen 4 (v1.4 EGA):

%exefile keen4e.exe 251712

%patch $1E7F9
	$55 $8B $EC $BA $03DAw $FA $EC $A8 $01 $74 $FB $EC $A8 $01 $75 $FB $8B
	$4E $06	$BA $03D4w $B0 $0C $EE $42 $8A $C5 $EE $4A $B0 $0D $EE $8A $C1
	$42 $EE $F7 $06 $7A14w $0001w $74 $03 $E8 $0053w $F7 $06 $7ADEw $0001w
	$75 $0C $BA $03C0w $B0 $33 $EE $EB $00 $8A $46 $08 $EE $F7 $06 $7A14w
	$0001w $75 $03 $E8 $0034w $FB $5D $CB

%patch $1E87A
	$E9 $FF7Cw $8B $1E $A53Dw $BA $03DAw $FB $EB $00 $FA $EC $A8 $08 $75
	$0A $A1 $A53Dw $2B $C3 $3D $0001w $76 $ED $C3

%end

Commander Keen 5 (v1.4 EGA):

%exefile keen5e.exe 254832

%patch $1F795
	$55 $8B $EC $BA $03DAw $FA $EC $A8 $01 $74 $FB $EC $A8 $01 $75 $FB $8B
	$4E $06	$BA $03D4w $B0 $0C $EE $42 $8A $C5 $EE $4A $B0 $0D $EE $8A $C1
	$42 $EE $F7 $06 $6F12w $0001w $74 $03 $E8 $0053w $F7 $06 $6FDEw $0001w
	$75 $0C $BA $03C0w $B0 $33 $EE $EB $00 $8A $46 $08 $EE $F7 $06 $6F12w
	$0001w $75 $03 $E8 $0034w $FB $5D $CB

%patch $1F816
	$E9 $FF7Cw $8B $1E $9BA5w $BA $03DAw $FB $EB $00 $FA $EC $A8 $08 $75
	$0A $A1 $9BA5w $2B $C3 $3D $0001w $76 $ED $C3

%end

Commander Keen 6 (v1.4 EGA):

%exefile keen6.exe 260432

%patch $1E713
	$55 $8B $EC $BA $03DAw $FA $EC $A8 $01 $74 $FB $EC $A8 $01 $75 $FB $8B
	$4E $06	$BA $03D4w $B0 $0C $EE $42 $8A $C5 $EE $4A $B0 $0D $EE $8A $C1
	$42 $EE $F7 $06 $7018w $0001w $74 $03 $E8 $0053w $F7 $06 $761Aw $0001w
	$75 $0C $BA $03C0w $B0 $33 $EE $EB $00 $8A $46 $08 $EE $F7 $06 $7018w
	$0001w $75 $03 $E8 $0034w $FB $5D $CB

%patch $1E794
	$E9 $FF7Cw $8B $1E $A6CBw $BA $03DAw $FB $EB $00 $FA $EC $A8 $08 $75
	$0A $A1 $A6CBw $2B $C3 $3D $0001w $76 $ED $C3

%end

Commander Keen 6 (v1.5 EGA):

%exefile keen6.exe 259632

%patch $1E36B
	$55 $8B $EC $BA $03DAw $FA $EC $A8 $01 $74 $FB $EC $A8 $01 $75 $FB $8B
	$4E $06	$BA $03D4w $B0 $0C $EE $42 $8A $C5 $EE $4A $B0 $0D $EE $8A $C1
	$42 $EE $F7 $06 $6F12w $0001w $74 $03 $E8 $0053w $F7 $06 $E86Aw $0001w
	$75 $0C $BA $03C0w $B0 $33 $EE $EB $00 $8A $46 $08 $EE $F7 $06 $6F12w
	$0001w $75 $03 $E8 $0034w $FB $5D $CB

%patch $1E3EC
	$E9 $FF7Cw $8B $1E $E6C2w $BA $03DAw $FB $EB $00 $FA $EC $A8 $08 $75
	$0A $A1 $E6C2w $2B $C3 $3D $0001w $76 $ED $C3

%end

Duke Nukem II (registered) - God Mode

This patch allows you to toggle god mode (the game calls it "Tec mode") by holding down the G-O-D keys at the same time.

Note: This code only works on the executable from the registered version of the game.

%exefile NUKEM2.EXE $1C1AC

# make G-O-D keys toggle god mode ("Tec mode"):

%patch $1531A
	$6A 1 $9A $0741E352RL $90 $90 $90 $90 $90

%end

Duke Nukem II (registered) - Memory Fix

This fix replaces the subroutine for loading a raw screen with a shorter, more efficient subroutine that doesn't need a buffer for temporary storage. The original code used a buffer of 2000 bytes, which caused the game to run out of memory and exit to DOS when playing Episode 2 Level 2 on the hardest difficulty and bringing up the in-game help screens by pressing the H key.

Warning: Not all systems can handle loading data from a file directly into video memory. It does work fine in DOSBox, which I guess is how most people play the game these days. If you are experiencing any issues, delete the first part of the patch script and run it again on the original, unmodified executable.

As an added bonus, this also includes a patch that makes the game use all available memory instead of the fixed 390000 bytes, which might be useful for mods. Just keep in mind that this does not change the minimum memory requirements. If there are less than 390000 bytes of far memory available, the game will not start.

Note: This code only works on the executable from the registered version of the game.

%exefile NUKEM2.EXE $1C1AC

# load full-screen images directly into video memory without a buffer:

%patch $5AEE
	$C8 4w 0 $56 $57 $FF $76 $08 $FF $76 $06 $8D $46 $FE
	$50 $9A $03660423RL $BA $3CEw $B8 5w $EF $B8 $FF08w
	$EF $6A 0 $9A $000002FBRL $59 $BF 4w $BE $100w $BA
	$3C4w $8B $C6 $B0 2 $EF $8D $46 $FC $50 $68 8000w $68
	$A000w $6A 0 $FF $76 $FE $9A $00000E69RL $83 $C4 10
	$D1 $E6 $4F $75 $DC $8D $46 $FC $50 $6A 48 $1E $68
	$558w $FF $76 $FE $9A $00000E69RL $83 $C4 10 $FF $76
	$FE $9A $0366037ERL $6A 0 $9A $00000312RL $59 $5F $5E
	$C9 $CA 4w
# (this leaves 241 unused bytes at $5B6B)


# use all available memory, not just 390,000 bytes:

%patch $5956
	$90 $90 $90 $9A $000019C5RL $89 $16 $29B8w $A3 $29B6w
	$52 $50

%end

Test Drive 1 (EGA) - Keyboard Handler

This patch removes the code responsible for reading the joystick and replaces it with a custom keyboard handler. The custom keyboard handler allows you to hold down multiple keys, letting you steer while also accelerating or braking at the same time.

Note: This code only works on one specific version of the executable. You may have to unpack the executable with UNP before you can apply the patch.

%exefile TDEGA.EXE $13E10

# replace ReadJoystick routine with the new keyboard routines:

%patch $A12F
	$33 $C0 $2E $80 $3E $A1EAw 0 $74 44 $BB $A1AEw $2E $80 $3F 0 $74 2
	$0C 1 $83 $C3 3 $2E $80 $3F 0 $74 2 $0C 8 $83 $C3 2 $2E $80 $3F 0 $74
	2 $0C 4 $83 $C3 3 $2E $80 $3F 0 $74 2 $0C 2 $C3 0w 0w 0w 0w 0w 0w 0w
	0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w
	0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w
	0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0w 0 $50 $53 $33 $C0 $E4 $60 $8B
	$D8 $80 $E3 $7F $F6 $D0 $D1 $E0 $2E $88 $A7 $A166w $5B $58 $9C $2E $FF
	$1E $A1E6w $CF $2E $80 $3E $A1EAw 0 $75 54 $9C $FA $33 $C0 $8E $C0 $26
	$A1 $24w $2E $A3 $A1E6w $26 $A1 $26w $2E $A3 $A1E8w $B8 $A1EBw $26 $A3
	$24w $8C $C8 $26 $A3 $26w $8E $C0 $BF $A166w $B9 $40w $33 $C0 $F3 $AB
	$2E $C6 $06 $A1EAw 1 $9D $E9 $5DC7w $2E $80 $3E $A1EAw 0 $74 29 $9C
	$FA $33 $C0 $8E $C0 $2E $A1 $A1E6w $26 $A3 $24w $2E $A1 $A1E8w $26 $A3
	$26w $2E $C6 $06 $A1EAw 0 $9D $E9 $0FE6w

%patch $A5A2 $FC64w		# call kbstartup instead of main:
%patch $B24E $EFF9w		# call kbshutdown instead of sub_0_B257:

%patch $5C88 $E9 $FFA2w		# call ReadKeyboard when we've got a number key
%patch $5CB5 $E9 $FF75w		# call ReadKeyboard when we've got a cursor key


%end

Wolfenstein 3D - Use PC speaker for digitized sounds

This patch edits the config file for Wolfenstein 3D and changes the sound device for digitized sounds to the PC speaker option. There is no code to set this device to PC speaker in the game, editing the config file is the only way to use this setting.

This patch script should work for any DOS version of the game, including all versions of Spear of Destiny. All you need to change is the extension of the config file.

%file CONFIG.WL6 522

%patch $1D2 $01

%end

Various - Fix Divide Error in PCX Effects 1.04

This fixes a divide error that occurs when executing parts of the PCX Effects 1.04 code on systems using a Pentium 133 MHz or faster CPU. The fix prevents the games from crashing, but it does not fix any other speed-related issues in the PCX routines or the actual game. That means the patched game will start, but it might still run way too fast to actually be playable.

Note: These patches work on one specific version of the executable. If you want to try to fix this error in a version that is not listed here, search the uncompressed executable for the hexadecimal sequence 8B C6 F7 E1 B9 64 00 F7 F1 and replace it with the sequence B0 05 F7 E1 73 03 B8 FF FF.

Arctic Adventure (v2.0 freeware):

%exefile AA1.EXE $22800
%patch $163A4	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile AA2.EXE $22790
%patch $16334	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile AA3.EXE $22780
%patch $16324	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile AA4.EXE $227C0
%patch $16364	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%end

Dark Ages (freeware):

%exefile DA1.EXE $23406
%patch $11D2C	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile DA2.EXE $23276
%patch $11CD4	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile DA3.EXE $230C6
%patch $11C36	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%end

Pharaoh's Tomb (v3.0 freeware):

%exefile PTOMB1.EXE $1F730
%patch $122C4	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile PTOMB2.EXE $1F790
%patch $12324	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile PTOMB3.EXE $1F6E0
%patch $12274	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile PTOMB4.EXE $1F6E0
%patch $12274	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%end

The Monuments of Mars! (freeware):

%exefile MARS1.EXE $22A84
%patch $D176	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile MARS2.EXE $22F54
%patch $D32A	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile MARS3.EXE $22F54
%patch $D32A	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%exefile MARS4.EXE $23144
%patch $D3EC	$B0 $05 $F7 $E1 $73 $03 $B8 $FFFFw

%end

← Back | ↑ Top

© K1n9_Duk3, all rights reserved.