How vita3k/vita3k-android works
Project type and purpose
• Vita3K is an emulator for the PlayStation Vita, targeting Windows, Linux, macOS, and Android.
• It loads Vita homebrew and commercial games by emulating the Vita’s hardware (CPU, GPU, audio, memory, I/O, kernel), and provides a host‐side frontend (GUI) for launching and controlling games.
File structure
• Top‐level directories
• vita3k/ – the emulator core, subdivided into dozens of modules (cpu, gpu, audio, net, io, kernel, modules implementations, etc.).
• android/ – the Android‐specific launcher, input overlay, SDL glue, and Gradle project.
• _readme/ – assets and screenshots for the repo.
• external/ – bundled third‐party libraries (SDL2, Vulkan headers, Dynarmic, Unicorn, ffmpeg, ImGui, etc.).
• cmake/, CMakeLists.txt, gradle/ – build and configuration scripts for desktop and Android.
• Patterns
• Core is organized by subsystems (cpu, mem, io, net, audio, gxm/gl/vk renderer, modules, gui).
• Uses layering:
– Emulation core (hardware abstraction)
– Vita modules implementations (Sce* services)
– Host environment abstraction (emuenv, compat, host/dialog)
– Frontend GUI (gui + SDL/ImGui)
• Deployment files
• Android Gradle build files, native AndroidManifest, ProGuard rules.
• AppImage scripts for Linux.
README for additional insights
• Emphasizes that the core is experimental, supports homebrew/commercial titles, and depends on many external libraries (Unicorn, Dynarmic, SDL2, Vulkan, ffmpeg).
Core components and relationships
a. Frontend Layers
• Desktop GUI: SDL2 + ImGui – user menu, settings, content manager.
• Android UI: SDL Activity + overlays (touch controls).
b. Host Abstraction Layer (emuenv, host/dialog, compat)
• Wraps OS file dialogs, window creation, threads, timers, and platform‐specific quirks.
c. Emulator Core Subsystems
• CPU: multiple implementations (Dynarmic JIT, Unicorn interpreter).
• Memory Management: allocator, mempool, VFS for Vita memory card and storage.
• I/O: controllers, touchscreen, HID, filesystem via Vita IoDevice and host FS.
• Kernel: threads, synchronization primitives, object store, load_self, callbacks.
• Modules Implementation: vita3k/modules/Sce* (system services reimplemented in C++).
• Codec & Audio: Atrac9, AAC, MP3, FFmpeg wrapper, cubeb/SDL audio backends.
• Graphics:
• GXM (native Vita GPU calls) recompiled to either OpenGL or Vulkan via renderer, glutil, vkutil.
• Shader Translator (shader/ – GXP→SPIRV or GLSL).
d. External Libraries – linked into core or build system (SDL2, Vulkan SDK, Dynarmic, Unicorn, ffmpeg, ImGui, spdlog, yaml‐cpp, etc.).
e. Storage & Packaging – local Vita “memory card” files, AppImage/uninstaller scripts, Android assets.
Architectural patterns and design principles
• Modularization: each Vita service lives in its own folder under vita3k/modules.
• Abstraction layers: separate host OS calls from emulated environment.
• Strategy pattern for CPU backends (select Unicorn vs Dynarmic).
• Factory/bridge for renderer backends (OpenGL vs Vulkan).
• Plugin‐style Vita module loader (scan library_init_list, instantiate modules at runtime).