Skip to content

Instantly share code, notes, and snippets.

@Najip
Forked from anpage/MW2_FUEL_PATCH.md
Last active April 14, 2025 04:17
Show Gist options
  • Save Najip/9be3ae18f91f7993042add19c5b5fd91 to your computer and use it in GitHub Desktop.
Save Najip/9be3ae18f91f7993042add19c5b5fd91 to your computer and use it in GitHub Desktop.
Patch to Fix Jet Fuel in MechWarrior 2 for DOS

Patch to Fix Jump Jet Fuel in MechWarrior 2: Ghost Bear's Legacy for DOS

Inspired by, adapted from, and forked from the original patch by anpage

I also created a companion patch for MechWarrior 2: Mercenaries for DOS, available here.


Overview

This patch addresses an issue in MechWarrior 2 where, at frame rates higher than 45.5 FPS, jump jet fuel does not recharge correctly. While this wasn’t a problem on hardware from the game's original release period, it becomes an issue on modern PCs when running at high CPU cycles in emulated DOS environments such as DOSBox. As a result, players must limit CPU cycles or constantly adjust them during gameplay to restore jump jet fuel properly—often at the cost of erratic frame rates and fluctuating game speed.


In the original patch for MechWarrior 2: 31st Century Combat v1.1, a custom subroutine intercepts the fuel-update logic to accumulate timer ticks properly—even when fewer than 4 ticks occur per frame.

I adapted that patch for MechWarrior 2: Ghost Bear's Legacy v1.0 for DOS because the DOS version offers a superior experience: it supports a native 1024×768 resolution, providing a sharper and more modern display. In contrast, the Windows 95 version of Ghost Bear's Legacy is locked at 640×480 in software-rendered mode, with no known way to upscale the resolution. The 3D-accelerated versions of MechWarrior 2: 31st Century Combat and Mercenaries (not to be confused with the Titanium Edition) can be upscaled via Glide or D3D wrappers and are playable on modern PCs at high resolutions. See version information for MechWarrior 2, Mercenaries, and GBL here.

Additionally, while there are Titanium versions of the MechWarrior 2 trilogy that feature 3D acceleration (via both D3D and 3dfx Glide), those versions modify much of the original engine and introduce various bugs that detract from the authentic experience. (See this FAQ, Answer XVIII and watch Kei-Nova’s explanation on YouTube here for more details.)

Given these differences, I believe Ghost Bear's Legacy benefits the most from this fix.


How the Patch Works

This patch preserves the original fuel-update mechanism with only minor modifications to support Ghost Bear's Legacy. The original developer’s logic remains unchanged—only the addresses of key external functions are updated.


Patch

Download .IPS Patch
Apply it using Lunar IPS

The patch works by intercepting the fuel logic at a specific hook offset, calling external routines to retrieve elapsed ticks and record refuel ticks, and then returning control to the normal fuel routine.

Checksum hashes are not necessary for MW2.EXE, since the DOS version of GBL had only one official release—unlike other MechWarrior 2 variants.


Assembly Code

Below is the assembly code and the locations where the bytecode should be inserted. I used Ghidra with LX Loader to adjust it manually.

; Write to 0x8384F in MW2.EXE
START:
    PUSH 0x82
    CALL 0xFFFFCDE4 ; Get elapsed ticks into EAX
    ADD ESP, 0x4
    CMP EAX, 182    ; Filter out huge values (hacky)
    JA TOO_BIG
    SHR EAX, 0x2    ; Divide by 4
    JZ RETURN       ; If it's 0, don't reset delta time
    PUSH EAX
    PUSH 0x82
    CALL 0xFFFFCE24 ; Record last refuel tick
    ADD ESP, 0x4
    POP EAX
RETURN:
    JMP 0xFFFC17A6  ; Return to increment fuel
TOO_BIG:
    PUSH 0x82
    CALL 0xFFFFCE24 ; Record last refuel tick
    ADD ESP, 0x4
    XOR EAX, EAX    ; Clear EAX
    JMP RETURN
; Overwrite at 0x44FE8 in MW2.EXE
    JMP 0x3E867

Note: The above assembly uses relative addressing. The hex diff shown below is the finalized result after hand-tweaking.


Diff Example

If you prefer to apply the patch manually using a hex editor like HxD, below is a diff between the original and patched executables:

$ diff <(xxd -g 1 MW2.EXE | sed 's/.\{18\}$//') <(xxd -g 1 MW2GBL_FUEL.EXE | sed 's/.\{18\}$//')
17663c17663
< 00044fe0: 00 7d 1a a1 48 5c 00 00 89 c2 c1 fa 1f c1 e2 02
---
> 00044fe0: 00 7d 1a a1 48 5c 00 00 e9 62 e8 03 00 c1 e2 02
33669,33673c33669,33673
< 00083840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
< 00083850: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
< 00083860: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
< 00083870: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
< 00083880: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
---
> 00083840: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 68
> 00083850: 82 00 00 00 e8 da cd ff ff 83 c4 04 3d b6 00 00
> 00083860: 00 77 19 c1 e8 02 74 0f 50 68 82 00 00 00 e8 00
> 00083870: ce ff ff 83 c4 04 58 e9 79 17 fc ff 68 82 00 00
> 00083880: 00 e8 ed cd ff ff 83 c4 04 31 c0 eb ea 00 00 00

In this diff:

  • At offset 0x44FE8, the original instruction is replaced with a jump to the custom subroutine.
  • At offset 0x83840–0x83880, an 80-byte block is inserted containing the subroutine that handles fuel logic correctly at high frame rates.

Conclusion

This patch preserves the original fuel-update logic with minor modifications tailored for Ghost Bear's Legacy. By updating the call addresses and intercepting the tick timing logic, the patch fixes the jump jet fuel issue that occurs at high frame rates while maintaining compatibility with the rest of the game.


Thanks


THIS DOCUMENT AND THE PATCH WITHIN ARE PROVIDED WITHOUT WARRANTY.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment