Open main menu

GrimE/Patching

< GrimE
Revision as of 20:33, 19 October 2024 by Lephilousophe (talk | contribs) (Explain the tools for patching Grim games)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

ScummVM provides several patches to workaround original bugs in Grim Fandango and Escape of Monkey Island Lua scripts.

These patches are located in dists/engine-data/patches.

They are then packed in two files:

To add new patches or modify them there are several steps which can be fulfilled using scummvm-tools.

Build the needed tools

scummvm-tools needs to be checked out and configured. wx-widgets is not needed so it can be disabled with --disable-wxwidgets.

Then, the tools can be built with the following command: make -j grim_delua grim_diffr grim_luac grim_mklab grim_patchr grim_unlab

Unpack the game files and the ScummVM patch package

Each LAB file can be extracted using the command grim_unlab DATA000.LAB.

WARNING: The official patch overrides some Lua scripts. It must be extracted as well to make sure the correct file is patched.

Apply the ScummVM patches

Once the files are extracted, the ScummVM patches can be applied with the following command grim_patchr ORIGINAL.lua NEW.lua PATCH.lua.patchr.

Convert Lua bytecode to source code

The Lua files contained in the archives are in a bytecode form. They need to be converted to a text form before edition. The command grim_delua NEW.lua > FILE.luas will make it readable.

Edit the source code

Well... You know better!

Convert back the Lua source code to bytecode

To get back a Lua bytecode with minimal changes, the following command will be needed: grim_luac -o PATCHED.lua -b ORIGINAL.lua FILE.luas.

It builds a new Lua bytecode named PATCHED.lua using the file ORIGINAL.lua as a base and the FILE.luas as a source code.

Create a patch

Once the new Lua bytecode has been produced, a patch can be created using the following command: grim_diffr ORIGINAL.lua PATCHED.lua ORIGINAL.lua.patchr.

The file needs to be placed back in the dists/engine-data/patches directory.

WARNING: The .patchr file needs to have the same base name as he original file to be recognized by ScummVM.

Create the ScummVM patch package

Only the patch package is loaded by ScummVM. To refresh it, this command has to be used: grim_mklab --grim dists/engine-data/patches/grim dists/engine-data/grim-patch.lab.

For EMI, the argument --grim has to be replaced by --emi.