How dgdiniz/bsnes-plus works
Project type and purpose
• bsnes-plus is an open-source SNES emulator fork (C++, Makefiles) with a heavy focus on debugging and extensibility.
• Core emulation (“bsnes/snes”), multiple frontend UIs (Qt-based “bsnes/ui-qt” and a simple launcher), and optional plugin binaries (snesfilter, snesreader, snesmusic, supergameboy).
High-level architecture derived from the file tree
• Top-level components:
• Core emulator engine (bsnes/snes)
• Frontend/UI (bsnes/ui-qt + launcher)
• Shared/common libraries (common/nall, common/zlib)
• Co-routine support (bsnes/libco)
• Plugins (snesfilter, snesreader, snesmusic, supergameboy)
• External dependencies (Qt5, SDL, OpenAL, zlib)
• Build system: platform-agnostic Makefiles (mingw, Linux, macOS) and per-component cc.bat/cc.sh scripts.
Core interactions and data flows
• UI layer (Qt) ←→ Core emulator API (“libsnes” interface in bsnes/snes/libsnes)
• Launcher / command-line parser initializes emulator, selects profile (accuracy/compatibility/performance), loads cartridges or satellite data.
• Core engine modules: CPU, SMP (audio CPU), PPU (graphics), DSP (audio DSP), scheduler, memory, cartridges, config & serialization.
• libco provides lightweight threading/co-routines used by the scheduler to interleave CPU, SMP, PPU, DSP execution.
• Common library (common/nall) provides platform abstraction (file I/O, threading, endian conversions, data structures) used across core, frontends, and plugins.
• Plugins interfaces: loaded at runtime alongside the core; each exposes a shared-library API to register filters (snesfilter), file extraction (snesreader), music playback (snesmusic), or alternate emulation core (supergameboy).
Architectural patterns & design principles
• Layered separation:
1. Platform/utility layer (common/nall, zlib)
2. Emulation core (bsnes/snes, libco)
3. Plugin layer (dynamically loaded .dll/.so/.dylib)
4. Frontend/UI (Qt UI controls, views, debugger panels)
• Modular plugin architecture for extensibility—each plugin resides in its own directory with a Makefile and hooks into a standard plugin loader in the core.
• MVC within the UI: UI-Qt components (views, controllers) call the “libsnes” API (the model) and update widgets (registers view, memory editors, PPU viewers).
• Single responsibility per component: audio, video, input, serialization, config are all distinct modules.