How givethesourceplox/bully-nx works
1. What this repository is
- This is a Nintendo Switch homebrew wrapper/port for the Android ARM64 release of *Bully: Anniversary Edition*.
- It does not reimplement the game logic. Instead, it loads the original native game library (libBully.so renamed from libGame.so) and runs it inside a Switch-side compatibility layer.
2. Top-level runtime boundary
- There are two major halves:
- the Switch host application built as bully_nx.nro
- the Android game binary loaded at runtime
- The host process is responsible for filesystem setup, config, patching, imports, and platform emulation; the game library remains the original proprietary code.
3. Startup and orchestration
- source/main.c and source/main.h appear to be the entry point and bootstrapping layer.
- This is where the wrapper likely:
- verifies the expected SD card layout
- creates missing config.txt / savegames/
- loads assets and shared libraries
- initializes platform hooks before transferring control to the game library
4. Game binary loading and ELF/so support
- source/so_util.c / so_util.h, source/cpplib_loader.c / cpplib_loader.h, and source/imports.c / imports.h form the dynamic-loading subsystem.
- Their role is to load an Android .so into the Switch process, resolve symbols, and satisfy runtime dependencies that the original binary expects from Android/Linux-style environments.
5. Android runtime patch layer
- source/jni_patch.c / jni_patch.h provide JNI/environment shims.
- source/movie_patch.c / movie_patch.h and likely parts of source/jni_patch.c adapt behavior that the Android game expects but the Switch port cannot provide directly.
- This layer is the key compatibility boundary between the original game library and the Switch host runtime.
6. Platform hooks
- The source/hooks/ directory contains subsystem-specific interception code:
- game.c for game-side behavioral hooks
- opengl.c for graphics API adaptation
- openal.c for audio API adaptation
- source/hooks.h likely coordinates registration of these hooks.
- These hooks redirect or replace native calls so the Android game can run against Switch-native services and libraries.
7. Graphics and audio adaptation
- OpenGL is handled as a compatibility surface rather than a direct Android graphics stack.
- OpenAL is likewise used as the audio abstraction layer.
- The repository expects Switch-side userspace graphics/audio support from the build environment, which is why the README calls out SDL2, OpenAL, and Switch Mesa/Nouveau userspace libraries as dependencies.
8. Asset and archive handling
- source/asset_archive.c / asset_archive.h and source/zip_fs.c / zip_fs.h implement the game-content filesystem layer.
- The README’s assets/data_0.zip, data_1.zip, etc. are the packaged game assets consumed by this subsystem.
- This is a major boundary: the wrapper provides a filesystem view over archive-based Android assets instead of a normal Android APK/runtime asset manager.
9. Configuration and persistence
- source/config.c / config.h manage sdmc:/switch/bully/config.txt.
- The config controls runtime behavior such as screen size, clarity, shadows, filtering, and timing workaround settings.
- savegames/ is runtime-generated persistent storage, separating user save data from the shipped game assets.
10. Stability, diagnostics, and error handling
- source/error.c / error.h, source/util.c / util.h, source/cxx_diag.cpp, and source/thread_guard.cpp support robustness and debugging.
- source/thread_guard.cpp suggests thread-safety or lifecycle enforcement around the loaded game/runtime.
- source/cxx_diag.cpp likely exists to surface C++ exceptions or diagnostics from the loaded library, which is important when hosting an Android C++ binary in a non-Android environment.
11. Game-specific compatibility work
- source/movie_patch.c indicates custom handling for video/movie playback, which is often a separate compatibility problem in game ports.
- source/hooks/game.c likely contains title-specific shims and workarounds for *Bully* rather than generic wrapper logic.
- The README’s mention of temporary hacks and timing workarounds suggests this layer contains some of the most game-specific adaptation logic.
12. Repository deployment model
- The expected on-device layout is simple but important to the architecture:
- bully_nx.nro = Switch launcher
- libc++_shared.so = Android C++ runtime dependency
- libBully.so = original game library
- assets/ = extracted game data archives
- config.txt and savegames/ = wrapper-managed state
- This makes the port a packaged runtime container around original game binaries and assets, not a conventional source-built game.
13. Build/tooling boundary
- The project is built with devkitA64/libnx and uses Switch homebrew tooling.
- The Docker-based build command in the README reinforces that the deliverable is a Switch NRO plus native runtime support libraries, not an Android APK replacement.
14. Architectural summary
- The clean architecture diagram should show:
- SD card content feeding config, archives, and original game binaries into
- a Switch wrapper runtime
- which applies JNI/ELF/import patches and OpenGL/OpenAL/game hooks
- then hands execution to the original Android ARM64 game library
- The wrapper owns platform adaptation and persistence; the game library owns gameplay logic.
Main entry points: main.c Startup · hooks.h Hooks · asset_archive.c Asset FS · so_util.c SO Loader
Components 18
Switch Host
Homebrew launcher, runtime glue, hooks, and compatibility layers on the Switch side.
- Startup · Entry point that prepares the wrapper runtime and transfers control to the loaded game library.
source/main.c - Config · Loads and saves wrapper options such as display, filtering, and timing behavior.
source/config.c - Asset FS · Presents packaged game archives as a filesystem view for the Android binary.
source/asset_archive.c - Zip FS · Low-level zip-backed storage used by the asset filesystem layer.
source/zip_fs.c - SO Loader · Loads the Android shared library and resolves its runtime symbols.
source/so_util.c - C++ Runtime · Provides support for the shared C++ runtime dependency expected by the game binary.
source/cpplib_loader.c - Imports · Supplies Android/Linux-style imported functions expected by the original binary.
source/imports.c - JNI Patch · Adapts JNI and Android runtime expectations to the Switch host process.
source/jni_patch.c - Movie Patch · Handles platform-specific movie and playback behavior.
source/movie_patch.c - Hooks · Coordinates hook registration for graphics, audio, and game-specific behavior.
source/hooks.h - Game Hooks · Bully-specific compatibility workarounds and runtime adjustments.
source/hooks/game.c - OpenGL Hooks · Redirects graphics calls toward the Switch rendering stack.
source/hooks/opengl.c - OpenAL Hooks · Redirects audio calls toward the Switch audio stack.
source/hooks/openal.c - Diagnostics · Error reporting, exception surfacing, utility helpers, and thread/lifecycle guards.
source/cxx_diag.cpp
Runtime Content
Original game binary, packaged assets, and SD-card persisted state consumed at runtime.
- Game Binary · Original proprietary Bully library loaded at runtime by the wrapper.
- Game Assets · Packaged game content archives consumed through the asset filesystem layer.
- Runtime State · Wrapper-managed config and save data stored on the SD card.
config.txt
Build Tooling
Project build and packaging boundary for the Switch target.
- Build · Switch homebrew build target and packaging boundary for the NRO deliverable.
Makefile
Connections 22
- Startup → Config: load/save · Startup reads settings and may create or update wrapper configuration.
- Startup → Asset FS: mount · Bootstraps the asset filesystem before game execution.
- Asset FS → Zip FS: backed by · Archive filesystem is implemented on top of zip mounting support.
- Startup → SO Loader: init · Entry point initializes the shared-library loader for the game binary.
- SO Loader → C++ Runtime: deps · C++ runtime support is prepared alongside the main shared-library loader.
- SO Loader → Imports: resolve · Loader binds the imported functions that the Android binary expects.
- Startup → JNI Patch: shim · Startup applies Android/JNI compatibility shims.
- Startup → Movie Patch: patch · Startup installs movie playback compatibility handling.
- Startup → Hooks: register · Registers hook subsystems before control transfers to the game.
- Hooks → Game Hooks: includes · Title-specific compatibility workarounds are part of the hook layer.
- Hooks → OpenGL Hooks: includes · Graphics adaptation is one of the hook domains.
- Hooks → OpenAL Hooks: includes · Audio adaptation is one of the hook domains.
- Startup → Diagnostics: protect · Diagnostics and guards support robust host-side execution.
- Startup → Game Binary: handoff · After setup, the wrapper transfers execution into the original game library.
- Asset FS → Game Assets: reads · Game content is consumed from packaged data archives.
- Config → Runtime State: persists · Settings and runtime state are stored on the SD card.
- Game Hooks → Game Binary: intercept · Title-specific hooks modify behavior observed by the game library.
- OpenGL Hooks → Game Binary: redirect · Graphics calls from the game are redirected through the hook layer.
- OpenAL Hooks → Game Binary: redirect · Audio calls from the game are redirected through the hook layer.
- JNI Patch → Game Binary: satisfy · JNI patching satisfies Android-side expectations of the binary.
- Imports → Game Binary: satisfy · Imported symbols are resolved so the game can run in the Switch process.
- Build → Startup: builds · The Makefile builds the Switch launcher and its wrapper runtime.