Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
b51a9d8
docs: simplify build steps
Grien25 Jun 23, 2025
4723f9c
Merge pull request #1 from EOT-RecompTest/codex/configure-and-build-p…
Grien25 Jun 23, 2025
1c8d4cf
Update README.md
Grien25 Jun 23, 2025
6e492d1
Working version
Grien25 Jun 25, 2025
84ea0c9
Update README.md
Grien25 Jul 2, 2025
bbb4487
Create .gitattributes
Grien25 Jul 2, 2025
4486fa4
Merge branch 'main' of https://github.com/EOT-RecompTest/XenonRecompU…
Grien25 Jul 2, 2025
3994343
Delete recomp_scheme.jpg
Grien25 Jul 2, 2025
d82b7d7
Update recompiler.cpp
Grien25 Jul 2, 2025
0f69944
Delete PPC_miss_list
Grien25 Jul 2, 2025
a69e0b5
replace
Grien25 Jul 2, 2025
cc0052c
CrackReference
Grien25 Jul 3, 2025
25e3604
Update README.md
Grien25 Jul 4, 2025
716296f
Update README.md
Grien25 Jul 4, 2025
a2f84ed
Update main.cpp
Grien25 Jul 4, 2025
40fcdee
Revert to old recompiler
Grien25 Jul 4, 2025
0f8f654
config tables
Grien25 Jul 4, 2025
1f15743
using other
Grien25 Jul 5, 2025
d994729
Added simde as a submodule
Grien25 Jul 5, 2025
2492e71
Fix lzxDecompress linkage
Grien25 Jul 5, 2025
b9746c6
Delete simde
Grien25 Jul 5, 2025
1fc9cf6
Merge pull request #2 from EOT-RecompTest/codex/fix-compilation-error…
Grien25 Jul 5, 2025
27bd438
Reference Files
Grien25 Jul 5, 2025
4b631a0
Update README with game preparation and macOS instructions
Grien25 Jul 5, 2025
af6ed6e
Merge pull request #3 from EOT-RecompTest/codex/update-readme-with-xe…
Grien25 Jul 5, 2025
1dec306
Add register save/restore search to XenonAnalyse
Grien25 Jul 5, 2025
7de84ac
Merge pull request #4 from EOT-RecompTest/codex/compare-main-xenonana…
Grien25 Jul 5, 2025
48fc677
Update README.md
Grien25 Jul 5, 2025
c88460d
xex
Grien25 Jul 5, 2025
1b8a1be
Encryption Compress
Grien25 Jul 5, 2025
7219426
Update README.md
Grien25 Jul 5, 2025
52b7b4e
Update README.md
Grien25 Jul 5, 2025
bb3b4df
Create Default_patched.xex
Grien25 Jul 5, 2025
994d8f4
Merge branch 'main' of https://github.com/EOT-RecompTest/XenonRecomp
Grien25 Jul 5, 2025
bf4aa71
Delete Default.xex
Grien25 Jul 5, 2025
6c296eb
Create Default_patched.xex.txt
Grien25 Jul 5, 2025
94736a7
Improve switch table detection
Grien25 Jul 5, 2025
8925f11
docs: explain switch pattern updates
Grien25 Jul 5, 2025
5f78685
Fix jump table offsets and update docs
Grien25 Jul 6, 2025
a34c217
Refine alternate switch patterns
Grien25 Jul 6, 2025
ebf3bba
Replace ORI with NOP in patterns
Grien25 Jul 6, 2025
23eecea
refine computed switch matching
Grien25 Jul 6, 2025
3a7704b
Document computed pattern update
Grien25 Jul 6, 2025
9d95f8e
Refine computed switch alt pattern
Grien25 Jul 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Auto detect text files and perform LF normalization
* text=auto
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ bld/
[Ll]og/
[Ll]ogs/
[Oo]ut/
/[Bb]uild/

# Visual Studio 2015/2017 cache/options directory
.vs/
Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,6 @@
[submodule "thirdparty/tiny-AES-c"]
path = thirdparty/tiny-AES-c
url = https://github.com/kokke/tiny-AES-c.git
[submodule "thirdparty/simde"]
path = thirdparty/simde
url = https://github.com/simd-everywhere/simde.git
35 changes: 0 additions & 35 deletions PPC_miss_list

This file was deleted.

113 changes: 64 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,60 +1,71 @@
# XenonRecompUnlimited

<p align="center">
<img src="https://github.com/testdriveupgrade/XenonRecompUnlim/blob/main/recomp_scheme.jpg" width="1024"/>
</p>

XenonRecompUnlimited - it's special fork of XenonRecomp for TDU engine, like experimental fork-version with fresh updates
XenonRecompUnlimited - it's special fork of XenonRecomp for EOT, like experimental fork-version with fresh updates

(unfortunattely at this moment XenonRecomp updates long-term )

Some new commands of PowerPC CPU checked, but other experimental

### Simplified step-by-step Instructions
**I think default recompiler instruction too hard, because there a lot of text, that can be explained easier and a lot of not primary information, but less "obviously instructions(for some people it can be not obviously)" **
**Due to hard instructions a lot of enthusiasts can't GET TO THE MOST INTERESTING THINGS**

1)Install git
https://git-scm.com/downloads/win

2)open cmd(terminal) in directory and write: git clone --recursive https://github.com/testdriveupgrade/XenonRecompUnlimited.git


3)install clang-cl in Visual Studio installer (or install clang-llvm)
(install if you dont have VS https://visualstudio.microsoft.com/vs/ )

4)install CMAKE newer or 3.20
https://cmake.org/download/

(create folder build in output) directory

5)press "configure"

target Visual Studio 2022

(don't select x86, it should be x64(as default))
the parameter of CMAKE write: ClangCL

then "build"

and after "open"

6)After that in Visual Studio press "Run - green triangle"

Then you get exe files of Xenon Analyse and Recomp

7)file works

You should convert your .iso dump to .xex file (recomment to choose GUI)
https://github.com/wiredopposite/XGDTool/releases/tag/v1.0.0
(and there select input(folder with .iso)/output(target folder) and choose "Extract"), you will get semi-unpacked game with .xex

(I think integrated XenonR patcher works not good) use xextool to uncompress and unecrypt the .xex file
https://digiex.net/threads/xextool-6-3-download.9523/
(IT'S VERY IMPORTANT TO WRITE DIRECTORY PATH IN SPECIFIC WAY better to use these format example: )

### Quick Start
These instructions describe how to build XenonRecompUnlimited on Windows using Visual Studio 2022.

1. **Prepare your game files**
- Extract the game ISO using [Iso Extract](https://www.filehorse.com/download-xbox-360-iso-extract/?utm_source=chatgpt.com).
- Decrypt, uncompress and apply updates with [xextool](https://digiex.net/threads/xextool-6-3-download.9523/):
```cmd
xextool -eu -cu -p default.xexp -o default_patched.xex default.xex
```
- Keep `default_patched.xex` for analysis.

2. **Install dependencies**
- [Git](https://git-scm.com/downloads/win)
- [Visual Studio 2022](https://visualstudio.microsoft.com/vs/) with the "Desktop development with C++" workload and the `clang-cl` component
- [CMake 3.20 or later](https://cmake.org/download/)

3. **Clone the repository**

```cmd
git clone --recursive https://github.com/EOT-RecompTest/XenonRecomp.git
```

4. **Configure the project**
- Open the repository folder in CMake-GUI as a Source Repository
- Create a build folder in the repository, and select that as the build folder in CMake-GUI
- Click **Configure**
- Select `ClangCL` as the toolchain and `x64` as the target architecture
- Go through the configuration and once complete, Click **Build**

5. **Run Visual Studio**
- Open the generated sln file in your build folder
- Click **Build** >> **Build All** in Visual Studio
- This builds `XenonAnalyse` and `XenonRecomp` executables in the build directories

6. **Analyze and recompile**
```bash
./XenonAnalyse default_patched.xex switch_tables.toml
```
```bash
./XenonRecomp config.toml XenonUtils/ppc_context.h
```

### Quick Start on macOS

1. **Install dependencies**
- Install [Homebrew](https://brew.sh/) and then `brew install llvm cmake`.
- Install [CLion](https://www.jetbrains.com/clion/) or another CMake IDE.

2. **Clone the repository** (same as Windows).

3. **Open the project in CLion**
- Set the CMake profile to use `-DCMAKE_OSX_ARCHITECTURES=x86_64`.
- Configure and build the `XenonAnalyse` and `XenonRecomp` targets.

4. **Run the tools**
- Prefix all of your commands with `arch -x86_64` to run under Rosetta 2.
- Use `XenonAnalyse` on `default_patched.xex` to generate a switch table file.
- Run `XenonRecomp` with your configuration and `XenonUtils/ppc_context.h` to produce C++ code.
## About XenonAnalyser


Some games have different .xex properties, for example some games contain setjmp and longjmp (can be necessary offset), but other don't;

To find them use bin analysis programs, like Binary Ninja, etc.. (use instruction from Jump table)
Expand Down Expand Up @@ -177,6 +188,10 @@ Additionally, mid-asm hooks can be inserted directly into the translated C++ cod

## Usage

After building the tools you can follow this basic workflow:
1. Run `XenonAnalyse` on your patched XEX to create a jump table TOML file.
2. Edit or create a recompiler configuration referencing this file.
3. Run `XenonRecomp` with your configuration and `XenonUtils/ppc_context.h` to generate the C++ sources.
### XenonAnalyse

XenonAnalyse, when used as a command-line application, allows an XEX file to be passed as an input argument to output a TOML file containing all the detected jump tables in the executable:
Expand Down
37 changes: 37 additions & 0 deletions XenonAnalyse/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# XenonAnalyse

This folder contains the code for the jump table scanner. It was recently updated to support alternate instruction sequences that appear in some XEX files. In these binaries an `ori r0,r0,0` instruction behaves as a NOP and may appear between the real instructions that form a switch pattern. The code now treats this opcode as `NOP` when matching patterns.

## Issues Encountered

* **Switch table detection failures** – the original patterns only matched one strict order of instructions. A different game contained ORI padding instructions or reordered the RLWINM/ADDI operations, causing detection to fail.
* **Compilation problems** – building with a compiler older than C++17 or without the required third party libraries leads to errors such as `constructor not allowed in anonymous aggregate` or missing headers. The repository relies on submodules for `fmt`, `tomlplusplus` and `xxHash`.

## Fixes Made

* Added alternate pattern arrays in `main.cpp` (`absoluteSwitchAlt`, `computedSwitchAlt`, `offsetSwitchAlt`, `wordOffsetSwitchAlt`). These account for padding NOPs (`ori r0,r0,0`) and swapped instruction order so the scanner works across different disassemblies.
* Replaced all occurrences of `PPC_INST_ORI` with `PPC_INST_NOP` in the pattern definitions to explicitly match the disassembler's `NOP` opcode.
* Updated table reading logic to select instruction offsets for both patterns. The computed switch detector now accepts an alternate form with a NOP before the final `addi` and without the trailing `bctr`.

## Getting Your Build Working

1. **Update submodules**: run `git submodule update --init --recursive` so CMake can find the bundled libraries.
2. **Use a modern compiler**: the project expects at least C++17 support. Visual Studio 2022 with clang-cl or a recent clang/gcc build is recommended.
3. Configure with CMake 3.20+ and build normally (e.g. `cmake -S . -B build && cmake --build build`).

When analyzing a new XEX, run `XenonAnalyse <xex> <output.toml>` to produce a list of jump tables.

## Example patterns from `Default_patched.xex`

During validation we located representative tables for each switch type in the
reference disassembly:

* **Absolute** – e.g. at `0x8208f8f8` the instructions `lis`, `rlwinm`, `subi`,
`lwzx`, `mtspr`, `bctr` form the classic pattern.
* **Computed** – at `0x8222e9d8` a byte index is loaded via `lbzx`, shifted with
`rlwinm`, then combined with a base pointer before jumping.
* **WordOffset** – around `0x82245eac` a halfword table is indexed with
`lhzx` and combined with a base address using `add` before branching.

No byte‑offset tables were spotted in this particular binary, but the scanner
supports them if encountered.
Loading