How has207/xenia-edge works
Purpose and entry points
Xenia Edge is a native C++ Xbox 360 emulator fork focused on compatibility, usability, iteration speed, and Windows/Linux/macOS support, with Android packaging present. The desktop launcher is src/xenia/app/xenia_main.cc, which hosts the emulator window and game library. Core orchestration is src/xenia/emulator.cc / src/xenia/emulator.h. Android enters through Java activities and native windowed-app support: android/android_studio_project/app/src/main/java/jp/xenia/emulator/LauncherActivity.java and src/xenia/ui/windowed_app_main_android.cc.
Host application, library, and content loading
The application layer scans configured host directories, maintains the game library, resolves titles/compatibility metadata, and launches selected content. Key boundaries are host UI/filesystem versus guest content and runtime:
• src/xenia/app/game_library.cc
• src/xenia/app/directory_scanner.cc
• src/xenia/app/game_compat_db.cc
Guest media, disc images, archives, host directories, and Xbox content containers are abstracted behind the VFS device/entry/file model:
• src/xenia/vfs/virtual_file_system.cc
• src/xenia/vfs/devices/disc_image_device.cc
• src/xenia/vfs/devices/xcontent_container_device.cc
Emulator composition and guest OS boundary
Emulator assembles memory, CPU, kernel, graphics, audio, HID, VFS, and patching into a game execution session. The kernel emulates Xbox system modules, exported APIs, guest objects, scheduling, threads, I/O, and XAM services; it is the principal boundary between guest calls and host implementations.
• src/xenia/emulator.cc
• src/xenia/kernel/kernel_state.cc
• src/xenia/kernel/guest_scheduler.cc
• src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc
• src/xenia/kernel/xam/xam_module.cc
CPU emulation and dynamic recompilation
Xbox 360 PowerPC code is loaded from XEX/ELF/raw modules, mapped into guest memory, and dispatched through the processor/thread model. The PPC frontend decodes guest instructions into HIR; compiler passes optimize/validate it; host-specific backends emit and cache native x64 or AArch64 code.
• src/xenia/cpu/processor.cc
• src/xenia/cpu/ppc/ppc_frontend.cc
• src/xenia/cpu/compiler/compiler.cc
• src/xenia/cpu/backend/x64/x64_backend.cc
• src/xenia/cpu/backend/a64/a64_backend.cc
Memory/MMIO plumbing is shared cross-subsystem infrastructure: src/xenia/memory.cc and src/xenia/cpu/mmio_handler.cc.
GPU command, shader, and presentation pipeline
Guest Xenos command streams and registers are interpreted by a command processor, accessing shared guest memory, textures, render targets, and translated shaders. Guest microcode is translated through SPIR-V/DXIL-oriented components, then submitted to a selected host graphics backend. This is the largest hardware-translation boundary.
• src/xenia/gpu/command_processor.cc
• src/xenia/gpu/graphics_system.cc
• src/xenia/gpu/shader_translator.cc
• src/xenia/gpu/spirv_shader_translator.cc
• src/xenia/gpu/shared_memory.cc
Backend implementations target Direct3D 12, Vulkan, and Metal:
• src/xenia/gpu/d3d12/d3d12_graphics_system.cc
• src/xenia/gpu/vulkan/vulkan_graphics_system.cc
• src/xenia/gpu/metal/metal_graphics_system.cc
Host UI, input, and audio
The UI layer owns native windows/surfaces, presenters, settings/dialogs, and overlay drawing; it interfaces with graphics providers rather than guest GPU logic directly. HID maps keyboard/SDL/portal devices into guest input, while APU emulates audio/XMA and outputs through SDL or XAudio2.
• src/xenia/ui/windowed_app.h
• src/xenia/ui/presenter.cc
• src/xenia/hid/input_system.cc
• src/xenia/apu/audio_system.cc
• src/xenia/apu/xma_decoder.cc
Runtime ecosystem and diagnostics
CMake is the main native build system (CMakeLists.txt, src/xenia/CMakeLists.txt); Android uses Gradle. Platform abstractions cover Windows, POSIX/Linux, macOS, and Android under src/xenia/base. Material dependencies include SDL3, FFmpeg, wxWidgets/ImGui, DirectX headers/compiler, Vulkan/MoltenVK, SPIR-V tooling, and Metal conversion libraries in third_party/. Optional integration includes Discord presence (src/xenia/app/discord/discord_presence.cc) and RenderDoc API access (src/xenia/ui/renderdoc_api.cc). GPU trace reader/writer/player/viewer paths support reproducible graphics debugging: src/xenia/gpu/trace_writer.cc, src/xenia/gpu/trace_player.cc, src/xenia/gpu/trace_viewer.cc.
Main entry points: emulator.cc Emulator session · kernel_state.cc Xbox kernel state · graphics_system.cc Graphics system · game_library.cc Game library
Components 26
Host Application
Desktop and Android entry points, library management, and presentation.
- Desktop launcher · Hosts the emulator window and game library.
src/xenia/app/xenia_main.cc - Android launcher · Starts Android emulator packaging.
android/android_studio_project/app/src/main/java/jp/xenia/emulator/LauncherActivity.java - Android native app
src/xenia/ui/windowed_app_main_android.cc - Game library · Maintains configured titles and compatibility metadata.
src/xenia/app/game_library.cc - Directory scanner
src/xenia/app/directory_scanner.cc - Compatibility DB
src/xenia/app/game_compat_db.cc - Window UI and presenter · Owns native windows, surfaces, overlays, and dialogs.
src/xenia/ui/presenter.cc
Emulator Runtime
Session orchestration and Xbox kernel boundary.
- Emulator session · Assembles guest execution subsystems for a launched title.
src/xenia/emulator.cc - Xbox kernel state · Implements guest objects, system APIs, I/O, and XAM services.
src/xenia/kernel/kernel_state.cc - Guest scheduler
src/xenia/kernel/guest_scheduler.cc - Xboxkrnl exports
src/xenia/kernel/xboxkrnl/xboxkrnl_module.cc - XAM services
src/xenia/kernel/xam/xam_module.cc
CPU Recompilation
Guest PPC execution translated to host-native code.
- PPC processor · Loads modules and dispatches guest threads.
src/xenia/cpu/processor.cc - PPC frontend · Lowers PowerPC instructions into HIR.
src/xenia/cpu/ppc/ppc_frontend.cc - HIR compiler · Optimizes and validates translated guest code.
src/xenia/cpu/compiler/compiler.cc - x64 / AArch64 backends · Emit and cache host-native code.
src/xenia/cpu/backend/x64/x64_backend.cc
Graphics Translation
Xenos command and shader translation pipeline.
- Graphics system · Selects and drives the host graphics backend.
src/xenia/gpu/graphics_system.cc - Xenos command processor · Interprets guest command streams and registers.
src/xenia/gpu/command_processor.cc - Shader translation · Translates guest microcode for host graphics APIs.
src/xenia/gpu/spirv_shader_translator.cc - D3D12 / Vulkan / Metal · Submit translated rendering to platform graphics APIs.
src/xenia/gpu/d3d12/d3d12_graphics_system.cc - GPU trace tooling · Records and replays reproducible graphics traces.
src/xenia/gpu/trace_player.cc
Guest I/O and Devices
Guest storage, input, audio, and shared memory services.
- Guest memory and MMIO · Shared guest address space and hardware register plumbing.
src/xenia/memory.cc - Virtual file system · Abstracts media, containers, archives, and host directories.
src/xenia/vfs/virtual_file_system.cc - XContent containers
src/xenia/vfs/devices/xcontent_container_device.cc - Input system · Maps host devices to guest input.
src/xenia/hid/input_system.cc - Audio system · Emulates audio and XMA output.
src/xenia/apu/audio_system.cc
Connections 30
- Desktop launcher → Game library: browses titles
- Android launcher → Android native app: starts
- Android native app → Emulator session: creates session
- Game library → Directory scanner: scans
- Game library → Compatibility DB: resolves metadata
- Game library → Emulator session: launches content
- Emulator session → Xbox kernel state: hosts guest OS
- Emulator session → PPC processor: runs guest code
- Emulator session → Graphics system: initializes GPU
- Emulator session → Virtual file system: mounts content
- Emulator session → Input system: initializes HID
- Emulator session → Audio system: initializes APU
- Xbox kernel state → Guest scheduler: schedules threads
- Xbox kernel state → Xboxkrnl exports: exports APIs
- Xbox kernel state → XAM services: provides services
- Xbox kernel state → Virtual file system: guest I/O
- Virtual file system → XContent containers: mounts
- PPC processor → PPC frontend: decodes PPC
- PPC frontend → HIR compiler: produces HIR
- HIR compiler → x64 / AArch64 backends: emits native code
- PPC processor → Guest memory and MMIO: accesses
- Xenos command processor → Shader translation: translates shaders
- Graphics system → Xenos command processor: drives commands
- Xenos command processor → Guest memory and MMIO: reads guest resources
- Shader translation → D3D12 / Vulkan / Metal: produces host shaders
- Graphics system → D3D12 / Vulkan / Metal: submits frames
- Graphics system → Window UI and presenter: presents frames
- Graphics system → GPU trace tooling: records / replays
- Input system → Xbox kernel state: guest input events
- Audio system → Xbox kernel state: guest audio services