Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.
HTML apple-siliconbattle-netcrossover-alternatived3dmetaldiablo-ii-resurrecteddxmtea-appepic-gamesgame-porting-toolkitgogmac-gamingmacosmacos-gamingrockstar-gamessteamubisoft-connectwhisky-alternativewindows-gameswinewine-wrapper
soju xcl: Xbox Series X|S game code through XCL on Soju's engine (experimental) (#201)
Mikek6c3eda571d77
diff --git a/README.md b/README.mdindex abf16564ffe..86a3b9d55b9 100644--- a/README.md+++ b/README.md@@ -217,6 +217,9 @@ Games have not been broadly tested yet; anything that needs kernel anti-cheat (E## Xbox PC / Microsoft Store (Xodus backend, experimental)+Xbox Series X|S console games are a separate, earlier experiment: `soju xcl` runs [XCL](https://github.com/xcl-dev/xcl) on Soju's engine without CrossOver. Nothing is playable yet; see [docs/XCL.md](docs/XCL.md).++Soju can sign in to a Microsoft account, import owned and PC Game Pass games, search the Microsoft Store, download games and start them. **Starting games is experimental.** On an M4 Pro / macOS 26.5, Retro Classics reaches its main menu; other titles are untested. Per-game Wine settings live in `resources/xbox-compat.json`. The launch follows the path [MACxus](https://github.com/fladnaG86/MACxus) uses on macOS, where Vampire Survivors, TUNIC, Deep Rock Galactic and others reach gameplay on a CrossOver 26 based engine like Soju's.How a launch works: `xodus-cli run` gets the licence and decrypts the game into a temporary RAM-disk view; `scripts/xbox-wine.sh` starts it on the CX engine with D3DMetal in its own prefix (`xbox-bottle`). That prefix gets the Xbox game runtime DLLs (xgameruntime and friends, LGPL, from the Xodus Nexus runtime as MACxus rebuilt them for macOS; pinned in `resources/xbox-runtime.json`, about 600 MB downloaded once) and Microsoft's VC++ runtime. `xodus-service` runs during the session for sign-in, licences and cloud saves; the game reaches it through a keyed 127.0.0.1 bridge. Files the game writes are copied back into its folder when it exits. Playing needs the CX engine and Apple GPTK; setting up Xbox PC installs the engine, and GPTK is added in Platforms like for Battle.net, Epic and GOG.diff --git a/docs/XCL.md b/docs/XCL.mdnew file mode 100644index 00000000000..89ed336c16c--- /dev/null+++ b/docs/XCL.md@@ -0,0 +1,46 @@+# Xbox Series X|S games through XCL (experimental)++`soju xcl` runs [XCL](https://github.com/xcl-dev/xcl), a compatibility layer that loads unpacked Xbox Series X|S+executables and stands in for the console's system libraries, on Soju's own engine and Apple's D3DMetal, in a bottle+of its own (`~/.battlenet-macos/xcl`). The Apple Silicon port is [MacBox](https://github.com/aykhanium/MacBox), which+uses CrossOver; Soju runs the same build without CrossOver.++**No game is playable yet.** MacBox reports GTA VI reaching its terms screen on an M5 Max with macOS 27.2, then a+crash after loading. Soju includes no game files and cannot get them: XCL needs your own already-unpacked copy of a+game you own.++```sh+soju xcl setup # XCL (about 2 MB) and Microsoft's shader compiler (32 MB), then the bottle+soju xcl run "/Volumes/Games/My Game" # a game folder or its .exe; arguments for the game after --+soju xcl inspect "/Volumes/Games/My Game/game.exe" # XCL's own tools: inspect, disasm, shaders, rpf+soju xcl status+soju xcl remove --yes+```++Saves, settings and logs go to the bottle's `%LOCALAPPDATA%\XCL\<title>\` (`logs\xcl.log` and `logs\report.json`+when something fails); the game folder is only read.++## What was checked (2026-11-25, M4 Pro, macOS 26.5, D3DMetal 3.0)++| Check | Result |+|---|---|+| `xcl --version`, `--help` | runs |+| Shader disassembly and RPF archive tests | 3 of 3 pass |+| GPU compute with wave64 and mesh shaders | 3 of 3 pass |+| Graphics draw (`gpu_graphics_vs_ps_draw`) | crashes |++The graphics test compiles its shaders and creates its pipeline, then the process dies inside Apple's D3DMetal once+the draw is submitted (SIGSEGV on a Metal thread, not a Windows exception). D3DMetal 4.0 beta 3 crashes the same way.+MacBox reports this test passing on macOS 27.2, so the difference is most likely Apple's Metal compiler in macOS 26;+macOS 26 also logged MTLCompilerService crashes on an atomic built-in during XCL's broader test run. Games draw with+the same path, so on macOS 26 they are expected to stop at their first frame.++## Where the pieces come from++- `xcl.exe`: MacBox at the commit pinned in `resources/xcl.json`, built unchanged with `scripts/build-xcl.sh`+ (GPL-2.0-only; the bundle carries the license and a NOTICE naming the source).+- `libunwind.dll`: LLVM-MinGW 20261117.+- `dxcompiler.dll` / `dxil.dll`: downloaded at setup from Microsoft's DirectXShaderCompiler release v1.9.2609+ (not redistributed by Soju), with its licenses.++Every download is pinned by size and SHA-256.diff --git a/resources/xcl.json b/resources/xcl.jsonnew file mode 100644index 00000000000..aa0d1d258c7--- /dev/null+++ b/resources/xcl.json@@ -0,0 +1,21 @@+{+ "bundle": {+ "commit": "5e8c6c5215880731cc70effcac89ad5454d72da3",+ "source_url": "https://github.com/aykhanium/MacBox/tree/5e8c6c5215880731cc70effcac89ad5454d72da3",+ "url": "https://github.com/BCD1210/soju/releases/download/xcl-v1/soju-xcl-5e8c6c5.tar.xz",+ "size": 2140656,+ "sha256": "c6f8a9247ee2a437e7893d7a814d2440e06378cd9eb3ea75518dfd652ac5d556",+ "license": "GPL-2.0-only (XCL / MacBox); rebuild with scripts/build-xcl.sh"+ },+ "dxc": {+ "url": "https://github.com/microsoft/DirectXShaderCompiler/releases/download/v1.9.2609/dxc_2026_09_29.zip",+ "size": 32287592,+ "sha256": "ad31b1fc8443175d204f77a611fdb3ef2ec42759bdc2f1167368de24a4a7e7f1",+ "members": [+ "bin\\x64\\dxcompiler.dll",+ "bin\\x64\\dxil.dll",+ "LICENSE-MS.txt",+ "LICENSE-LLVM.txt"+ ]+ }+}diff --git a/scripts/build-xcl.sh b/scripts/build-xcl.shnew file mode 100755index 00000000000..39da4d3aa96--- /dev/null+++ b/scripts/build-xcl.sh@@ -0,0 +1,31 @@+#!/bin/bash+# build-xcl.sh <MacBox checkout>: build the XCL bundle `soju xcl setup` downloads.+#+# XCL (github.com/xcl-dev/xcl, GPL-2.0-only) runs Xbox Series X|S game code on Windows;+# MacBox (github.com/aykhanium/MacBox) is its Apple Silicon port, built here unchanged at the+# commit pinned in resources/xcl.json, with its own scripts/macos.sh (rustup, LLVM-MinGW and+# DXC, each pinned by SHA-256 there). The bundle holds xcl.exe, LLVM-MinGW's libunwind.dll,+# XCL's license and a NOTICE naming the exact source; Microsoft's DXC is not redistributed:+# setup downloads it from Microsoft's release (pinned in resources/xcl.json).+set -euo pipefail+ROOT=$(cd "$(dirname "$0")/.." && pwd)+SRC=$(cd "${1:?MacBox checkout}" && pwd)+COMMIT=$(python3 -c "import json;print(json.load(open('$ROOT/resources/xcl.json'))['bundle']['commit'])")+[ "$(git -C "$SRC" rev-parse HEAD)" = "$COMMIT" ] || { echo "MacBox must be at $COMMIT" >&2; exit 1; }+git -C "$SRC" diff --quiet HEAD -- || { echo "MacBox checkout has local changes" >&2; exit 1; }+(cd "$SRC" && bash scripts/macos.sh bootstrap && bash scripts/macos.sh build)+OUT="$SRC/target/x86_64-pc-windows-gnullvm/release"+STAGE=$(mktemp -d)/soju-xcl+mkdir -p "$STAGE"+cp "$OUT/xcl.exe" "$OUT/libunwind.dll" "$STAGE/"+cp "$SRC/LICENSE" "$STAGE/LICENSE"+cat > "$STAGE/NOTICE" <<NOTE+xcl.exe: XCL (https://github.com/xcl-dev/xcl) as ported to Apple Silicon by MacBox,+built unchanged from https://github.com/aykhanium/MacBox/tree/$COMMIT+(GPL-2.0-only, see LICENSE; the source is at that address).+libunwind.dll: LLVM-MinGW 20261117 (Apache-2.0 WITH LLVM-exception).+NOTE+mkdir -p "$ROOT/dist/xcl"+tar -C "$(dirname "$STAGE")" -cJf "$ROOT/dist/xcl/soju-xcl-${COMMIT:0:7}.tar.xz" soju-xcl+ls -l "$ROOT/dist/xcl/soju-xcl-${COMMIT:0:7}.tar.xz"+shasum -a 256 "$ROOT/dist/xcl/soju-xcl-${COMMIT:0:7}.tar.xz"diff --git a/scripts/soju b/scripts/sojuindex 19fecd975f4..b585f443f69 100755--- a/scripts/soju+++ b/scripts/soju@@ -36,6 +36,8 @@ Usage:soju vr play Play D2R in VR (OXRSys client on the headset; offline characters)soju vr play --flat Open the VR copy without VR to create offline characters with the mousesoju vr status|remove+ soju xcl setup Xbox Series X|S game code through XCL (experimental, nothing playable yet;+ needs your own unpacked game files): setup, run <folder>, status, removesoju epic-install Set up the Epic Games Launcher bottle (same engine)soju epic Launch the Epic Games Launcher@@ -103,6 +105,7 @@ case "${1:-}" inexec bash "$ROOT/scripts/create-launcher-bottle.sh" "${1%-install}" ;;steam-install) shift; export SOJU_PLATFORMS=steam; exec bash "$ROOT/install.sh" "$@" ;;vr) shift; exec python3 "$ROOT/scripts/d2r-vr.py" "$@" ;;+ xcl) shift; exec python3 "$ROOT/scripts/xcl.py" "$@" ;;xbox-install) exec bash "$ROOT/scripts/xbox.sh" install ;;xbox-login) exec bash "$ROOT/scripts/xbox.sh" login ;;xbox-logout) shift; exec bash "$ROOT/scripts/xbox.sh" logout "$@" ;;diff --git a/scripts/xcl.py b/scripts/xcl.pynew file mode 100644index 00000000000..cf23a35117b--- /dev/null+++ b/scripts/xcl.py@@ -0,0 +1,228 @@+#!/usr/bin/env python3+"""Xbox Series X|S game code on the Mac through XCL (experimental).++ soju xcl setup download XCL and Microsoft's shader compiler, make its bottle+ soju xcl run <game folder | .exe> [-- game arguments]+ soju xcl inspect|disasm|shaders|rpf ... XCL's own tools (see soju xcl --help)+ soju xcl status what is installed (JSON with --json)+ soju xcl remove delete XCL and its bottle (--yes)++XCL (github.com/xcl-dev/xcl) loads unpacked Xbox Series executables and stands in for the+console's system libraries; MacBox (github.com/aykhanium/MacBox) ports it to Apple Silicon+with CrossOver. Here it runs on Soju's own engine and D3DMetal instead, in a bottle of its own.++No game is playable yet. No game files are included: XCL needs your own unpacked copy.+Checked 2026-11-25 on an M4 Pro, macOS 26.5: XCL starts, and its shader, compute and mesh+tests pass; its graphics draw test crashes inside Apple's D3DMetal after the draw is+submitted, with D3DMetal 3.0 and 4.0 beta 3 alike (MacBox reports it passing on macOS 27.2).+"""+import hashlib+import json+import os+from pathlib import Path, PurePosixPath+import shutil+import subprocess+import sys+import tarfile+import zipfile++ROOT = Path(__file__).resolve().parents[1]+MANIFEST = ROOT / 'resources/xcl.json'+BASE = Path(os.environ.get('SOJU_BASE', Path.home() / '.battlenet-macos'))+ENGINE = Path(os.environ.get('XCL_ENGINE', os.environ.get('ENGINE', BASE / 'cx26-engine')))+XCL = BASE / 'xcl'+BOTTLE = XCL / 'bottle'+RUNTIME = XCL / 'runtime'+TOOLS = ('inspect', 'disasm', 'shaders', 'rpf', '--help', '-h', '--version')+++class XCLError(Exception):+ pass+++def say(text):+ print(text, flush=True)+++def digest(path):+ h = hashlib.sha256()+ with Path(path).open('rb') as f:+ for block in iter(lambda: f.read(1024 * 1024), b''):+ h.update(block)+ return h.hexdigest()+++def manifest():+ return json.loads(MANIFEST.read_text())+++def recipe(m):+ return hashlib.sha256(json.dumps(m, sort_keys=True).encode()).hexdigest()+++def fetch(entry, name, label):+ cache = XCL / 'downloads'+ cache.mkdir(parents=True, exist_ok=True)+ dest = cache / name+ if dest.is_file() and dest.stat().st_size == entry['size'] and digest(dest) == entry['sha256']:+ return dest+ say('Downloading ' + label + ' (' + str(max(1, entry['size'] // 1000000)) + ' MB)…')+ part = dest.with_suffix(dest.suffix + '.part')+ got = subprocess.run(['/usr/bin/curl', '--fail', '--silent', '--show-error', '--location', '--proto', '=https',+ '--proto-redir', '=https', '--retry', '3', '--connect-timeout', '20', '--max-time', '1800',+ entry['url'], '--output', str(part)], capture_output=True, text=True)+ if got.returncode:+ part.unlink(missing_ok=True)+ raise XCLError('Could not download ' + label + ': ' + (got.stderr.strip() or 'curl failed'))+ if part.stat().st_size != entry['size'] or digest(part) != entry['sha256']:+ part.unlink(missing_ok=True)+ raise XCLError(label + ' did not match its pinned checksum; nothing was installed.')+ part.replace(dest)+ return dest+++def extract_bundle(archive, target):+ with tarfile.open(archive) as t:+ for member in t.getmembers():+ parts = PurePosixPath(member.name).parts+ if (not parts or parts[0] != 'soju-xcl' or '..' in parts or member.name.startswith('/')+ or not (member.isfile() or member.isdir())):+ raise XCLError('Unexpected entry in the XCL bundle: ' + member.name)+ tmp = target.parent / (target.name + '.new')+ shutil.rmtree(tmp, ignore_errors=True)+ tmp.mkdir(parents=True)+ if hasattr(tarfile, 'data_filter'):+ t.extractall(tmp, filter='data')+ else: # macOS's /usr/bin/python3 3.9: members were checked above+ t.extractall(tmp)+ shutil.rmtree(target, ignore_errors=True)+ (tmp / 'soju-xcl').rename(target)+ shutil.rmtree(tmp, ignore_errors=True)+++def extract_dxc(archive, target, members):+ """The x64 DLLs and licenses of Microsoft's DXC release. Its zip names use backslashes."""+ with zipfile.ZipFile(archive) as z:+ for name in members:+ data = z.read(name)+ (target / name.replace('\\', '/').split('/')[-1]).write_bytes(data)+++def winpath(path):+ return 'Z:' + str(Path(path).resolve()).replace('/', '\\')+++def wine_env():+ env = dict(os.environ)+ env.update({+ 'WINEPREFIX': str(BOTTLE),+ 'WINEDEBUG': os.environ.get('SOJU_XCL_WINEDEBUG', '-all'),+ 'WINEMSYNC': '1',+ 'ROSETTA_ADVERTISE_AVX': '1',+ 'WINE_SIMULATE_WRITECOPY': '1',+ 'CX_ACTIVE_GRAPHICS_BACKEND': 'd3dmetal',+ 'CX_GRAPHICS_BACKEND': 'd3dmetal',+ 'CX_APPLEGPTK_LIBD3DSHARED_PATH': str(ENGINE / 'lib/external/libd3dshared.dylib'),+ 'DYLD_FALLBACK_LIBRARY_PATH': str(ENGINE / 'lib') + ':/usr/lib',+ 'XCL_DXC_DIR': winpath(RUNTIME),+ })+ return env+++def status():+ state = {}+ try:+ state = json.loads((XCL / 'state.json').read_text())+ except (OSError, ValueError):+ pass+ return {+ 'installed': (RUNTIME / 'xcl.exe').is_file() and (BOTTLE / 'system.reg').is_file(),+ 'current': state.get('recipe') == recipe(manifest()),+ 'engine_ready': (ENGINE / 'bin/wine').is_file() and (ENGINE / 'lib/external/libd3dshared.dylib').is_file(),+ 'source': manifest()['bundle']['source_url'],+ 'path': str(XCL),+ }+++def setup():+ m = manifest()+ if not (ENGINE / 'bin/wine').is_file():+ raise XCLError("Soju's engine is not installed. Run: soju install")+ if not (ENGINE / 'lib/external/libd3dshared.dylib').is_file():+ raise XCLError("XCL needs Apple's D3DMetal. Run: soju gptk")+ bundle = fetch(m['bundle'], PurePosixPath(m['bundle']['url']).name, 'XCL (GPL-2.0, built from MacBox)')+ dxc = fetch(m['dxc'], 'dxc.zip', "Microsoft's shader compiler (DXC)")+ extract_bundle(bundle, RUNTIME)+ extract_dxc(dxc, RUNTIME, m['dxc']['members'])+ if not (BOTTLE / 'system.reg').is_file():+ say('Making the XCL bottle…')+ env = wine_env()+ subprocess.run([str(ENGINE / 'bin/wine'), 'wineboot', '-u'], env=env, capture_output=True)+ subprocess.run([str(ENGINE / 'bin/wineserver'), '-w'], env=env, capture_output=True)+ (XCL / 'state.json').write_text(json.dumps({'recipe': recipe(m)}, indent=2) + '\n')+ say('XCL is set up (experimental: no game is playable yet). Run a game folder with: soju xcl run <folder>')+ return 0+++def xcl_args(args):+ """soju xcl run <path> [-- args] -> xcl.exe run Z:\\path [-- args]; the tools pass through,+ with existing Mac paths turned into Windows ones."""+ if not args:+ raise XCLError('Usage: soju xcl run <game folder | file.exe> [-- game arguments]')+ out, passthrough = [], False+ for a in args:+ if a == '--':+ passthrough = True+ elif not passthrough and a.startswith('/') and Path(a).exists():+ a = winpath(a)+ out.append(a)+ if out[0] == 'run' and len(out) < 2:+ raise XCLError('Choose a game folder or executable: soju xcl run <path>')+ return out+++def run(args):+ if not status()['installed']:+ raise XCLError('XCL is not set up. Run: soju xcl setup')+ if args and args[0] == 'run' and len(args) > 1 and not Path(args[1]).exists():+ raise XCLError('Not found: ' + args[1])+ cmd = [str(ENGINE / 'bin/wine'), str(RUNTIME / 'xcl.exe')] + xcl_args(args)+ os.execve(cmd[0], cmd, wine_env())+++def remove(yes):+ if not XCL.exists():+ say('XCL is not set up.')+ return 0+ if not yes:+ raise XCLError('This deletes ' + str(XCL) + ' (XCL saves in its bottle included). Run again with --yes.')+ subprocess.run([str(ENGINE / 'bin/wineserver'), '-k'], env=wine_env(), capture_output=True)+ shutil.rmtree(XCL)+ say('Removed ' + str(XCL) + '.')+ return 0+++def main(argv):+ try:+ if not argv or argv[0] in ('help',):+ say(__doc__.strip())+ return 0+ cmd = argv[0]+ if cmd == 'setup':+ return setup()+ if cmd == 'status':+ info = status()+ say(json.dumps(info) if '--json' in argv else '\n'.join(k + ': ' + str(v) for k, v in info.items()))+ return 0+ if cmd == 'remove':+ return remove('--yes' in argv)+ if cmd == 'run' or cmd in TOOLS:+ return run(argv)+ raise XCLError('Unknown command: ' + cmd + '. See: soju xcl help')+ except XCLError as e:+ print('soju xcl: ' + str(e), file=sys.stderr)+ return 1+++if __name__ == '__main__':+ sys.exit(main(sys.argv[1:]))diff --git a/tests/test_xcl.py b/tests/test_xcl.pynew file mode 100644index 00000000000..1e3c4df746e--- /dev/null+++ b/tests/test_xcl.py@@ -0,0 +1,75 @@+import importlib.util+import io+import json+from pathlib import Path+import tarfile+import tempfile+import unittest+from unittest import mock+import zipfile++ROOT = Path(__file__).resolve().parents[1]+spec = importlib.util.spec_from_file_location('xcl', ROOT / 'scripts/xcl.py')+xcl = importlib.util.module_from_spec(spec)+spec.loader.exec_module(xcl)+++class XCLTests(unittest.TestCase):+ def test_manifest_pins_every_download(self):+ m = json.loads((ROOT / 'resources/xcl.json').read_text())+ for key in ('bundle', 'dxc'):+ self.assertTrue(m[key]['url'].startswith('https://'))+ self.assertGreater(m[key]['size'], 0)+ self.assertEqual(len(m[key]['sha256']), 64)+ self.assertIn(m['bundle']['commit'], m['bundle']['source_url'])+ self.assertIn(m['bundle']['commit'][:7], m['bundle']['url'])++ def test_run_turns_mac_paths_into_windows_ones(self):+ with tempfile.TemporaryDirectory() as d:+ game = Path(d) / 'My Game'+ game.mkdir()+ out = xcl.xcl_args(['run', str(game), '--', '/not/a/windows/path', '-x'])+ self.assertEqual(out[0], 'run')+ self.assertTrue(out[1].startswith('Z:\\') and out[1].endswith('\\My Game'))+ self.assertEqual(out[2:], ['--', '/not/a/windows/path', '-x']) # game arguments untouched+ self.assertEqual(xcl.xcl_args(['--version']), ['--version'])+ with self.assertRaises(xcl.XCLError):+ xcl.xcl_args(['run'])++ def test_bundle_extraction_refuses_entries_outside_it(self):+ with tempfile.TemporaryDirectory() as d:+ bad = Path(d) / 'bad.tar.xz'+ with tarfile.open(bad, 'w:xz') as t:+ info = tarfile.TarInfo('../evil')+ info.size = 1+ t.addfile(info, io.BytesIO(b'x'))+ with self.assertRaises(xcl.XCLError):+ xcl.extract_bundle(bad, Path(d) / 'runtime')+ good = Path(d) / 'good.tar.xz'+ with tarfile.open(good, 'w:xz') as t:+ for name, data in (('soju-xcl/xcl.exe', b'MZ'), ('soju-xcl/LICENSE', b'GPL')):+ info = tarfile.TarInfo(name)+ info.size = len(data)+ t.addfile(info, io.BytesIO(data))+ xcl.extract_bundle(good, Path(d) / 'runtime')+ self.assertEqual((Path(d) / 'runtime/xcl.exe').read_bytes(), b'MZ')++ def test_dxc_dlls_come_out_of_backslashed_zip_names(self):+ with tempfile.TemporaryDirectory() as d:+ z = Path(d) / 'dxc.zip'+ with zipfile.ZipFile(z, 'w') as f:+ f.writestr('bin\\x64\\dxcompiler.dll', b'A')+ f.writestr('bin\\x64\\dxil.dll', b'B')+ xcl.extract_dxc(z, Path(d), ['bin\\x64\\dxcompiler.dll', 'bin\\x64\\dxil.dll'])+ self.assertEqual((Path(d) / 'dxcompiler.dll').read_bytes(), b'A')+ self.assertEqual((Path(d) / 'dxil.dll').read_bytes(), b'B')++ def test_run_needs_setup_first(self):+ with tempfile.TemporaryDirectory() as d:+ with mock.patch.multiple(xcl, XCL=Path(d), RUNTIME=Path(d) / 'runtime', BOTTLE=Path(d) / 'bottle'):+ self.assertEqual(xcl.main(['run', d]), 1)+ self.assertEqual(xcl.main(['nonsense']), 1)+++if __name__ == '__main__':+ unittest.main()