Skip to content

Evoland: add epic games support#2380

Merged
kloptops merged 1 commit intoPortsMaster:mainfrom
bmdhacks:bmd-evoland
Apr 5, 2026
Merged

Evoland: add epic games support#2380
kloptops merged 1 commit intoPortsMaster:mainfrom
bmdhacks:bmd-evoland

Conversation

@bmdhacks
Copy link
Copy Markdown
Contributor

@bmdhacks bmdhacks commented Apr 5, 2026

Lotta people asked for this, so it now supports the epic games version.

@bmdhacks
Copy link
Copy Markdown
Contributor Author

bmdhacks commented Apr 5, 2026

BTW if anyone wanted the source code to this binary, here's the change I added:

use crate::find_function_by_name;
use hlbc::opcodes::Opcode;
use hlbc::Bytecode;
/// Patch MergeTitle.loadButtonImage to unconditionally use "xboxone" button images.
///
/// The GOG/Steam version has `if (name == "windows" || true)` which always takes
/// the branch (the `|| true` was a compiled-in steam controller check). The Epic
/// version has just `if (name == "windows")`, so on Linux the name stays "linux"
/// and the game tries to load `button_a_linux.png` which doesn't exist.
///
/// GOG bytecode pattern (ops 9-12):
///   9: GetGlobal   reg10 = "windows"
///  10: JEq         if reg5 == reg10 jump to 13     ← short-circuit to assignment
///  11: Bool        reg11 = true
///  12: JFalse      if reg11 == false jump to 15     ← NOP this (dead branch)
///  13: GetGlobal   reg9 = "xboxone"
///  14: Mov         reg5 = reg9
///
/// Epic bytecode pattern (ops 9-12):
///   9: GetGlobal   reg10 = "windows"
///  10: JNotEq      if reg5 != reg10 jump to 13     ← NOP this
///  11: GetGlobal   reg9 = "xboxone"
///  12: Mov         reg5 = reg9
///
/// We scan for Call0 (systemName) followed by a JNotEq or JFalse that skips the
/// "xboxone" assignment, and NOP the jump.
pub fn apply(code: &mut Bytecode) {
    let findex = find_function_by_name(code, "$MergeTitle", "loadButtonImage");
    let findex = match findex {
        Some(f) => f,
        None => {
            println!("  MergeTitle.loadButtonImage not found — skipping");
            return;
        }
    };
    println!("  Patching MergeTitle.loadButtonImage (findex {}) platform check", findex.0);
    for fun in code.functions.iter_mut() {
        if fun.findex != findex {
            continue;
        }
        // Find Call0 (systemName), then scan forward for the conditional jump to NOP.
        let mut found_system_name = false;
        for i in 0..fun.ops.len() {
            if let Opcode::Call0 { .. } = &fun.ops[i] {
                // Verify this is followed by toLowerCase pattern (NullCheck + Call1)
                if i + 3 < fun.ops.len()
                    && matches!(&fun.ops[i + 1], Opcode::NullCheck { .. })
                    && matches!(&fun.ops[i + 2], Opcode::Call1 { .. })
                {
                    found_system_name = true;
                }
            }
            if !found_system_name {
                continue;
            }
            // Epic pattern: JNotEq that skips the "xboxone" assignment
            if let Opcode::JNotEq { .. } = &fun.ops[i] {
                println!("    NOP op {} (JNotEq) — force xboxone button images", i);
                fun.ops[i] = Opcode::Nop;
                return;
            }
            // GOG pattern: JFalse after Bool true — already a no-op in practice,
            // but NOP it for cleanliness
            if let Opcode::JFalse { .. } = &fun.ops[i] {
                println!("    NOP op {} (JFalse) — force xboxone button images", i);
                fun.ops[i] = Opcode::Nop;
                return;
            }
        }
        println!("  Warning: platform check pattern not found in loadButtonImage");
        return;
    }
    println!("  Warning: loadButtonImage function body not found");
}

@kloptops kloptops merged commit b8eb86a into PortsMaster:main Apr 5, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants