$ show UnderminersTeam/UndertaleModTool
UndertaleModTool is a comprehensive, open-source modding and reverse-engineering tool for GameMaker games, specifically Undertale and Deltarune. It provides a full suite of functionality: reading/writing GameMaker data files (.win, .unx, etc.) with byte-for-byte accuracy, decompiling GML VM bytecode back into human-readable GameMaker Language (GML), compiling modified GML back into bytecode, and editing all game assets (sprites, sounds, rooms, code, textures, shaders, fonts, etc.) through a Windows-only WPF GUI or a cross-platform CLI. The tool also includes a project system for exporting/importing assets as JSON and PNG, a built-in C# scripting engine for automation, and game-specific definitions that tailor decompilation and modding to Undertale and Deltarune. The architecture is a classic library-plus-front-end pattern: the core library `UndertaleModLib` handles all binary serialization, decompilation, compilation, and project management. The GUI application `UndertaleModTool` and CLI `UndertaleModCli` are thin layers that use this library. The library itself is heavily version-aware, supporting multiple GameMaker versions (GMS1, GMS2, 2022-2024) with hundreds of conditional checks. The decompiler integrates with the external `Underanalyzer` submodule for advanced GML compilation and decompilation. A large collection of built-in C# scripts covers common modding tasks (resource export/import, technical utilities, game-specific modifications). While primarily an application, the repository also serves as a living document of GameMaker's internal data formatβa significant reverse-engineering effort. The code is rich with comments explaining undocumented structures, version differences, and workarounds for engine bugs. This hybrid nature makes it both a practical modding tool and a valuable research resource for understanding GameMaker internals.
The LLM identified 4 files worth highlighting for reuse:
Implements the BPS (Binary Patch System) format, a standalone patch application algorithm with CRC32 verification. The `ApplyPatch` method reads variable-length encoded integers, applies source/target copy operations, and validates output integrity. This component is entirely self-contained (no internal dependencies) and can be extracted for use in any project requiring binary patching.
A clean, self-contained implementation of the MurmurHash2 non-cryptographic hash function. Provides `Hash` and `HashBytes` static methods, uses unsafe code for performance, and includes a small helper to convert unsigned to signed bytes. Easily reusable in any C# project needing a fast, simple hash.
An immutable container for texture image data, supporting multiple GameMaker pixel formats (PNG, QOI, BGRA, DDS). It provides conversion to/from `MagickImage` (via ImageMagick) and raw byte arrays. The class is designed to be thread-safe and includes helpers for cropping and mask extraction. It demonstrates a clean abstraction over diverse image formats and can be reused in other projects dealing with game texture management.
Implements a rectangle packing algorithm for grouping multiple images into a single texture page. It handles cropping, border generation, and duplicate detection via 64-bit hash comparison. The `PackTextures` method returns an ordered list of placement results, optimizing for minimal texture page area. This utility is independent of the GameMaker context and can be extracted for any atlas-packing task (e.g., game engines, UI frameworks).