Skip to content

DS Netplay core: port GPL DetMP and deterministic mirrored melonDS to native Linux #163

Description

@EriArk

Parent: #162. Implement the emulator-side mechanism, not social/network UI.

Technical target

Port the useful ideas/source from GPL-licensed WatermelonDS Emufii Edition into a reproducible, TrainerOS-owned Linux melonDS build. Prefer a maintainable small patch set on a selected pinned upstream melonDS revision. Do not package the Android WatermelonDS APK, Kotlin UI, Android logging/properties/JNI or a parallel all-in-one launcher.

Start from exact inspected source

  • WatermelonDS Android netplay @ 9b603e53d4d098a0fcee3401ffa5e9c9992f01a3 — input frames, ENet handshake, per-peer mirrors, adaptive lag, hashes/checks.
  • Modified melonDS deterministic local wireless core @ 85fdb7596011a3d0e679a6f1f88c312e77ff4cc5 — emulated clock/time ordering and deterministic packet/command/reply exchange.
  • Check all related upstream core edits and patch ancestry: src/net/DetMP.*, MPInterface.*, NDS scheduling/frame hooks, Wi-Fi calls, deterministic serialization/savestate/JIT normalization, mirror lifecycle and renderer. One NetplayAndroid.cpp copy is insufficient.
  • Compare with current upstream melonDS and any upstreamed implementation before patching; prefer maintained upstream solution where demonstrably equivalent, without erasing provenance.

Implementation

  • Add a build target/profile and versioned patch in TrainerOS's managed emulator pipeline similar to the existing Dolphin netplay bridge; document reproducible source/toolchain/dependencies, hashes and ABI/platform support.
  • Use a narrow platform-neutral/netplay core API; replace Android __android_log_print, system properties, JNI/Kotlin, per-APK preferences and ad hoc user host/join dialog with Linux/core settings driven by trusted local TrainerOS integration.
  • Each physical client runs one local rendered DS plus one non-presented mirror for each other player. Local wireless interactions happen between co-located instances in emulated deterministic time; the network carries controlled inputs/synchronization, not raw timed DS Wi-Fi over a generic VPN.
  • Deterministically order wireless transmissions (frame/cycle timestamps, sender ID and sequence) and ensure JIT/core settings do not introduce divergence. Synchronize starting conditions and app state under DS Netplay security: lawful local BIOS, private saves and bounded mirror synchronization #164 before allowing a live lobby.
  • Adapt host-selected network lag to measured RTT/jitter rather than freeze a magic 4-frame default; track user-visible latency and failure modes.
  • Reuse diagnostic hash/checkpoint/desync comparison where appropriate, but never log raw memory, saves, BIOS, player identifiers or credentials.
  • Mirror-only rendering optimizations must be separately proven safe with GPU display captures (upstream Mario Kart issue is relevant), not blindly applied to Linux GPU paths.
  • Ensure ordinary single-player melonDS, local LAN mode and WFC game networking are unchanged when DS netplay is disabled.

Licensing

TrainerOS code is GPL-3.0-or-later (#115). Upstream melonDS/WatermelonDS changes are GPL-compatible. Preserve original copyright headers, exact source commit IDs, changed-file notices and corresponding GPL source/patch distribution. ENet MIT and zstd BSD-3-Clause notices/dependency versions must be retained. Keep Android-only code out of the native build.

Acceptance

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions