# Remorse Patching and Mod-System Feasibility ## Conclusion A third path is feasible: keep the retail `CRUSADER.EXE` as the game runtime, distribute validated data replacements and narrowly scoped executable patches, and launch the resulting modded copy under DOSBox. This is materially less work than reconstructing the game as a modern source build, but it is not a general substitute for a source port. The practical ceiling depends on the change: | Change type | Feasibility | Current boundary | |---|---|---| | Replace map/archive content | High | Retail supports an alternate `STATIC\FIXED.DAT`, but evidence shows archive selection, not per-map merging or fallback. | | Change scripted interactions | Medium | Retail `-u` selects an alternate `EUSECODE.FLX` runtime root. Editing and rebuilding scripts is not yet a complete toolchain. | | Change native behavior | Medium for small hooks; low for broad additions | Existing tooling can patch NE bytes and relocation records. New code must fit a proven safe location or require more invasive executable-format work. | | Add large systems or replace platform/runtime behavior | Low | No general plugin ABI or native module loader is evidenced; this is where the source-port/rebuild tracks remain better suited. | **Recommendation:** add a Track C to the roadmap as a curated, version-specific patch and data-mod system. Start with resource replacement and a copy-first patch manager. Treat executable changes as explicit, individually tested patch profiles, not as arbitrary plugins. The path can coexist with Tracks A and B; it optimizes for changes to the original game, not portability or broad architectural replacement. ## Evidence ### The retail game already has data override points - Startup checks for `static\fixed.dat`; if present, it opens that archive and the fixed-map loader prefers its handle over the base archive. The recovered consumer selects one archive for a map read. It does not show per-entry merge or fallback to the base when an entry is missing. The base archive is opened first and remains required. See [startup-map-patch-file.md](startup-map-patch-file.md). - In retail No Remorse, `-u ` directs startup to an alternate `EUSECODE.FLX` root. The filename remains `eusecode.flx`; this replaces the active usecode runtime root rather than adding a second script layer. The path token has a small DOS-era buffer, and a failed existence check can fall through without a clear success/failure banner. See [usecode-startup-override.md](usecode-startup-override.md). - Fresh-game map selection is hardcoded in the executable; existing command-line warp options are a separate debug/startup path. This is evidence that behavior not covered by an external data lane may need an executable patch. See [first-mission-map-selection.md](first-mission-map-selection.md) and [command-line-parameters.md](command-line-parameters.md). These lanes make map and script mods plausible without recompiling the game, but they are replacement-oriented. A mod that changes a few maps or event bodies would currently need to build a compatible complete archive/root from the target game's baseline, not assume that the retail loader merges sparse additions. ### Script editing is promising, but the round-trip pipeline is unfinished The repository has local FLEX and class/event format evidence, byte-preserving extraction, and versioned USECODE source snapshots. The map-viewer path has an initial guarded fixed-width immediate-edit overlay. It does not yet have the complete edit, compile, class/archive rebuild, and in-game validation loop; unknown fields and opaque bytes must be preserved. See [usecode-roundtrip-ir.md](usecode-roundtrip-ir.md) and [usecode-tool-improvement-plan.md](usecode-tool-improvement-plan.md). USECODE can alter behavior through the executable's existing event dispatcher, VM, and intrinsic table. It cannot by itself add a new native intrinsic or platform service, and not every opcode/intrinsic contract is understood. Therefore script mods are a credible middle tier for existing game facilities, not an unrestricted scripting API. ### Native patching is technically demonstrated, but fragile The existing [patch_crusader_cheat_menu.ps1](../patch_crusader_cheat_menu.ps1) contains the beginnings of a reusable patcher: named patch sites, expected retail/patched patterns, unknown-state refusal, NE relocation lookup/retargeting, explicit restore targets, and post-write byte verification. The NE patch workflow documents why a relocated far call must be changed through its relocation record rather than by editing the on-disk placeholder bytes. See [raw-ne-patch-conversion.instructions.md](../.github/instructions/raw-ne-patch-conversion.instructions.md). There is also concrete evidence of the ceiling and risk. The debugger patch log records multiple candidates that applied and restored cleanly on retail copies but crashed at startup. The current O/P candidates embed a small stub in a replaced code window and retarget an existing far call; their runtime status is still pending. That proves mechanical patching and relocation work are practical, not that arbitrary injected code is safe. See [retail-debugger-patch-attempts.md](retail-debugger-patch-attempts.md). `CRUSADER.EXE` is a bound DOS MZ/NE executable with Phar Lap protected-mode loading and segmented far calls, not a normal Windows PE with a DLL/plugin interface. Adding a new native module or segment would involve loader-visible segment and relocation metadata, selector/address constraints, and matching calling conventions. That is a substantially riskier project than redirecting a verified existing call or replacing a bounded code window. See [phar-lap-extender.md](phar-lap-extender.md) and the NE workflow above. ## Proposed Track C ### Package model Use a manifest-driven package with distinct payload types: - `fixed_archive`: a complete alternate `STATIC\FIXED.DAT` for the supported target build. - `usecode_root`: a directory containing a compatible complete `EUSECODE.FLX` replacement and any required companion files. - `ne_patch`: a named set of byte-window and relocation-record edits, each with exact expected retail state, enabled state, and restore state. - `launcher_profile`: documented DOSBox arguments and mount/path setup needed to activate the selected payloads. Each package should declare its mod ID/version, exact supported game build(s), required files, patch dependencies/conflicts, and validation notes. Do not distribute retail game binaries or assets; require the user to provide a compatible installation and generate a separate modded copy. ### Installer and patcher behavior Build a copy-first manager rather than extending the current in-place research script directly: 1. Identify the executable build using a full-file fingerprint plus structural checks for the expected MZ/NE headers and segment layout. 2. Preflight every patch site and relocation before writing anything. Accept only the exact retail state or the exact already-enabled state; refuse unknown or partially conflicting states. 3. Apply the complete patch family to a staged copy, then re-read and verify every byte window and relocation target. Keep the original install untouched. 4. Record the applied package set and output fingerprint. Restore by recreating the clean staged copy or applying exact captured restore data; never infer restore bytes from an unknown binary. 5. Validate data archives with parsers and run a DOSBox smoke test for each supported build/profile. A successful byte comparison is a mechanical pass, not a runtime pass. The current PowerShell patcher is useful evidence and a source of site-definition patterns, but it writes to its selected EXE path. The new manager should not inherit that in-place behavior as its default. ### Safe expansion order 1. Support inspection and dry-run for the one documented non-Japanese No Remorse retail build. 2. Stage complete fixed-map and usecode replacements without editing the executable; test the existing loader paths independently. 3. Add one reversible, narrow NE patch family based on a behavior with a clear runtime test and known original bytes/fixups. 4. Add conflict detection, multi-patch composition, rollback, build fingerprints, and an automated apply/verify/restore test suite. 5. Add USECODE editing/rebuilding only after unchanged byte-identical round trips and supported edit cases pass in the map-viewer toolchain. 6. Consider native code injection or new NE segments only after a concrete mod requires it and a safe allocation/relocation strategy is proven. ## Acceptance Gates A first useful release should pass all of these: - It detects unsupported or modified retail executables before writing and leaves the source installation unchanged. - Repeated apply, inspect, and restore operations are deterministic; unknown bytes, stale fixups, and patch conflicts fail closed. - Data payloads reopen with independent format parsers, and the game demonstrably loads the intended alternate archive/root rather than silently using stock data. - Every executable patch passes exact raw-byte and NE-relocation checks, then boots and exercises the changed behavior in DOSBox on each declared build. - The package documents whether it replaces a whole archive, changes script behavior, or patches native code, plus known incompatibilities and recovery steps. Do not call the system a general mod SDK until users can author and validate supported packages without editing patcher source or manually calculating NE offsets. ## Risks and Open Questions - The exact supported retail executable variants and their fingerprints still need to be inventoried; addresses and relocation records must not be generalized across builds without verification. - The fixed-map lane's replacement behavior means even a small map mod may need a full compatible archive. Confirm the archive writer and variant-specific map coverage before promising convenient sparse map packs. - The `-u` path is constrained by DOS path rules and a short argument buffer; runtime confirmation and a clean activation diagnostic would reduce silent fallback risk. - USECODE tooling must preserve unknown class/event metadata and support offset changes before variable-length edits can be safe. - New native behavior may require a safe code cave, a reusable existing function, or NE segment-table changes. No general-purpose injected-code allocation area has been established. - Patch collisions, build differences, and interactions with other community patches are likely to dominate support cost once packages compose. - Mechanical apply/restore is not enough: the debugger experiments show that a patch can be byte-perfect and still corrupt startup or shared runtime behavior. ## Research Basis This assessment uses existing repository evidence, including live-Ghidra-derived startup, archive, USECODE, and NE patch notes. No additional live Ghidra operation was needed for the feasibility decision. Before implementing a specific native patch, re-check its target in the active `CRUSADER.EXE` database and verify the exact writable copy, bytes, and relocation records against the selected retail file. The source-port baseline and its remaining gaps are tracked in [remorse-windows-rebuild-roadmap.md](remorse-windows-rebuild-roadmap.md). Track C should be added there only when the user wants the roadmap itself revised; this note deliberately keeps the requested research separate.