How bluestormdna/kocoboy works
Main Components
• Core Emulator Module (kocoboy-core):
• Contains the emulator’s CPU, PPU, APU, Bus, Timer, Cartridge handling (MBC1, MBC2, etc.), and other core components.
• Represents the “backend” or business logic of the emulator.
• Compose Application Module (composeApp):
• Provides the UI built using Compose Multiplatform.
• Contains common UI code (commonMain) along with platform-specific implementations (androidMain, iosMain, desktopMain, wasmJsMain, nativeMain) for tasks like audio and image handling.
• Platform-Specific Wrappers/Applications:
• iOS App: The iosApp folder with Xcode project files handling iOS-specific configuration and integration.
• Android Manifest & resources under composeApp’s androidMain.
• Other platform setups (Desktop, WASM/JS) through dedicated source sets and resource folders.
• Supporting Build and Configuration Files:
• Gradle build scripts (build.gradle.kts, settings.gradle.kts, gradlew.*) managing builds, dependencies, and multiplatform configurations.
Relationships & Interactions
• The Compose UI (frontend) communicates with the emulator core (kocoboy-core) via clear APIs. For example:
• UI components (buttons, sidebars, previews) in composeApp access the emulator core logic (emulator main loop, CPU, PPU events) to run or control the emulation.
• Platform-specific implementations in composeApp (such as AudioPlayer.*.kt and ImageBitmap.*.kt files) serve as adapters bridging the common UI logic with native multimedia and system services.
• The IOS, Android, Desktop, and WASM/JS platforms each have their own entry points and resource bundles that feed into the Compose UI, but ultimately the common code and the core module drive emulator functionality.
Architectural Patterns & Technologies
• Kotlin Multiplatform Design:
• Separation between common code (shared among platforms) and platform-specific code (androidMain, iosMain, etc.).
• Compose Multiplatform for UI:
• Use of Compose-based UI components, including previews (with annotations provided in androidMain for compatibility).
• Modular Architecture:
• The division of the project into at least two modules: the core emulator logic (kocoboy-core) and the UI/app layer (composeApp), with external apps (iOS app backing project) that serve as wrappers.
• Adapter/Bridge Pattern:
• The per-platform implementations for multimedia (e.g., AudioPlayer and ImageBitmap), highlight how the project abstracts platform-specific functionality.