Architecture
How Paleblood fits together: two tracks, decompilation and runtime, and how a function moves from original code to verified, readable C++.
At a glance
- Decompilation
- The game's code rewritten, function by function, as readable C++ proved to behave like the original.
- Runtime
- Paleblood's own loader and a growing set of PS4 system-call implementations.
- Game runs
- The game does not run on Paleblood's runtime yet; full runs still use an external host scaffold.
- Merge rule
- A function reaches main only when verified and readable, checked by an independent reviewer.
Paleblood is a decompilation with its own runtime.
- The decompilation rewrites the game's code, function by function, as readable C++ that is proved to behave like the original.
- The runtime is what that code, and the original executable while it is being replaced, runs on: Paleblood's own loader and a growing set of PS4 system-call implementations.
- The renderer draws the game's frames with Vulkan on Linux and Metal on macOS, by hooking the game's own drawing layer and translating its shaders, not by emulating the PS4's GPU. Its plan and progress are on the Runtime page.
The game does not run on Paleblood's runtime yet; the Runtime page has the roadmap, implemented calls, and the latest saved boot result.
What runs where today
Full game runs still use an external host scaffold while the project-owned runtime is completed.
The verification harness independently maps the executable and replays recorded inputs. A game
run can now record a hooked function's inputs as a case: with BB_CAPTURE_TRACE=1, the runtime
traces the original function once, instruction by instruction, before handing the call to the
replacement, and scripts any system call it makes on the way
(#133,
#134,
#135). Its tests use synthetic guest
functions; no recording from a real game run has verified a function yet. Paleblood also
has a project-owned implementation of the version-1 hook callback. A synthetic executable-memory
test verifies that its jump reaches a replacement, but the callback is not yet wired into the
full game-run scaffold and does not establish full-run equivalence.
What the executable is made of
Not all of the game's code is FromSoftware's own. Its assertion messages keep the source path of
each file they were compiled from, and since #480 Paleblood tags every function
with the file and library it most likely came from (symbols/source_files.csv, generated by
tools/source_files.py). The lead came from @sweetbbak in
issue #453: the engine is FromSoftware's Dantelion2, with Havok 2014.1 and
HavokScript, FMOD Ex 4.44.50, Silicon Studio's YEBIS and Sony's gnmx linked in.
| Library | Functions | Share of the 157,757 |
|---|---|---|
| Engine (Dantelion2 and the game's own code) | 84,215 | 53% |
| Havok | 21,098 | 13% |
| FMOD (sound) | 4,272 | 3% |
| YEBIS (post-processing) | 2,183 | 1% |
| HavokScript (scripting) | 1,278 | 1% |
| Sony gnmx (GPU helper library) | 113 | 0.1% |
| Not tagged | 44,598 | 28% |
Counts from Paleblood's docs/FUNCTION_CATALOG.md at the merge of #480.
Only about 1,700 functions are tagged directly, because they load a file's path; the rest are
filled in between two tags of the same file or library, so the split is an estimate, strongest
where tags are dense. The game was built with Sony's PS4 Clang, so this says which library a
function belongs to, not how to rebuild it byte for byte. It helps tell the engine's own code
from middleware when choosing what to study and decompile next.
The decompilation track
A replacement lives in the code repository's game/<system>/ and follows its style rules:
- the objects a function touches are structures with named fields;
- the original's other functions and globals are reached through named declarations, not addresses;
- constants are named;
- there is no test plumbing inside the game's code.
A function reaches the main branch only when it is both verified and readable, and an independent reviewer, not the author, has checked both.
How a replacement takes over. Replacements are registered in a hook table. When the runtime runs the game, each registered function's entry will jump to its replacement, so every caller lands in the new code. It is a 14-byte jump, which is why a function shorter than that cannot be hooked this way, except where the compiler's padding after it leaves room: that is how the tiny, repeated functions of a function family are hooked, many at once, with one replacement per family.
The runtime track
- Load. Paleblood's loader maps the game's executable, together with the game's own C library and file system modules.
- Link. It applies every relocation and binds every system import, to one of those modules or to the runtime's own implementation.
- Boot. The boot harness starts the guest startup sequence. It stops at the first system function the runtime does not implement yet, naming it, or runs until its time limit.
- Implement. The next piece of runtime work implements what the boot stopped at, written clean-room from public documentation and our own reverse engineering.
The latest saved trace (#536, 10 November 2026) reaches all eight boot milestones and runs until the time limit: no system call stops it, and all but three of the executable's system imports are bound (those three merged the next day, #555). With the display on, the maintainer's local runs draw the studio logos and the title screen, and with scripted input they get past the title, through the menus and the opening cinematic to character creation (Runtime).
The frame pipeline
The first system decompiled. Solid boxes are verified C++; dashed boxes are still original code.
Once per frame, the frame step:
- checks that the window is running;
- creates the
SprjFlipperon the first frame (its constructor readsGame.FlipMode); - lets the flipper's limiter wait out the frame;
- runs the game's task update.
The full walk-through is in How the Frame Limiter Works.
Verification
A replacement is checked against the original outside the game.
- Map. The harness maps the executable from your own dump with Paleblood's loader, and scripts every library call the function makes.
- Feed. The inputs are cases recorded in earlier game runs (the capture library) and edge cases generated for the corners.
- Run both. The original and the replacement run on the same inputs.
- Compare. ABI-selected return values, callee-saved registers, final bytes in declared memory regions, and scripted library calls must match.
- Break it on purpose. Deliberately wrong versions of the replacement must fail; if one passes, the cases are too weak and get fixed first.
| Status | Meaning |
|---|---|
| edge-verified | Passes, but no recording reaches the function's code yet. |
| verified | Recordings for it exist and pass, and the independent review has approved it. |
What the automated tools can establish
The merged differential engine adds deterministic fixture replay, bounded input exploration, mismatch minimization, and portable evidence reports. Its tests prove infrastructure behavior using synthetic instructions; they do not establish a new game function's semantics or promote a function automatically.
Instruction tracing (optional, Linux) watches supported guest memory reads and writes at byte granularity, including unaligned accesses, aliased pointers, and writes that leave the same value. For each access it records:
- the instruction;
- the access range;
- the bytes before and after;
- the register context.
Reading a difference. The first differing recorded memory event is a bounded diagnostic. Original and replacement code may take different instruction paths, so an internal trace difference with equal observable results is not treated as a behavior mismatch.
Limits of instruction tracing
The support matrix defines its limits: classified string/repeat, vector-memory, atomic, and system instructions fail closed; host code outside the instrumented ranges leaves an explicit gap. Capstone does not identify every architectural implicit-memory operation, so completeness applies only to the audited instruction families.
The tool does not claim an exact first divergence of every register at every instruction.
Coverage and the candidate pipeline
Supported instruction traces record executed basic blocks and outgoing edges per fixture. Complete traces can prioritize seeds that found new edges, or a conditional outcome whose other outcome is still unseen. Partial and unavailable coverage remain explicit and cannot feed that ranking. This describes observed fixture paths, not a complete static map of every possible path.
The opt-in automation prototype connects catalog qualification to an isolated worktree, local recorded fixtures, both compiler builds, differential tests, repository checks, and a reviewable draft pull request. It accepts a prewritten clean-room replacement patch; source generation is not automated. Each gate needs its evidence, and missing evidence rejects the run:
| Gate | Evidence required |
|---|---|
| Candidate | Fresh ownership checks, replacement-development qualification, exact executable identity, and documented ABI. |
| Fixtures | Recorded-game provenance and sufficient matching cases; generated boundary cases supplement those recordings. |
| Execution | Matching observable results, complete supported instruction traces, valid memory accesses, and eligible CFG coverage. |
| Delivery | Compiler and repository checks, a reproducible evidence report, then GitHub CI and human review. |
What the pipeline has not shown
Missing evidence rejects the run. Dry-run mode performs local work only, and a regression canary cannot open a function PR. No complete real-game candidate-to-PR run has been established by the merged evidence. Synthetic pipeline success does not change the verification counts.
Addresses
Every address in this wiki is a PS4 virtual address with the executable at 0x400000, the
convention of the community patches. See Ghidra & PS4 Quirks.
What comes next
The queues live in the code repository's NEXT.md: one for the decompilation track, one for the
runtime track.
Import-boundary observations
PR #85 takes bounded snapshots of registers and selected stack/fixture-buffer bytes when the harness enters and returns from a recognized import. They show the net change at that boundary, and nothing more.
What import-boundary snapshots do not show
Merged PR #85 adds bounded snapshots of registers and selected stack/fixture-buffer bytes at recognized harness import entry and return. They expose net changes at that boundary; they do not trace host instructions, establish argument types, observe every memory access, or prove host control-flow coverage. Comparison, automation acceptance and coverage feedback continue to reject external-execution evidence even if another label incorrectly calls the trace complete. These diagnostics cannot qualify a function for verification, and the import-dependent clock regression remains incomplete.