Skip to content

Development guide

AcidBoy/
├── AcidBoy.slnx Solution
├── Directory.Build.props net10.0, C# latest, nullable and implicit usings for every project
├── dotnet-tools.json dotnet-ef (restore with `dotnet tool restore`)
│
├── src/
│ ├── AcidBoy.Core/ The emulator itself: no dependencies, platform independent
│ │ ├── Cpu.cs Bus.cs Ppu.cs CPU, memory bus (drives all timing), picture processor
│ │ ├── Timer.cs Joypad.cs Serial.cs Interrupts.cs
│ │ ├── GameBoy.cs Entry point: RunFrame() / RunDots()
│ │ ├── Audio/ APU and its four channels
│ │ ├── Cartridges/ Header, ROM only, MBC1, MBC3 (+ RealTimeClock), MBC5
│ │ ├── Hardware/ HardwareModel: DMG, MGB, CGB, AGB, SGB, SGB2
│ │ ├── Link/ ISerialLink and the in-process LocalLink
│ │ └── Sgb/ Super Game Boy packets, commands, colorization, border
│ │
│ ├── AcidBoy.Client/ Shared by the desktop and mobile apps (no packages)
│ │ ├── EmulatorSession.cs One loaded ROM and its .sav file
│ │ ├── GameLibrary.cs The mobile app's games: ROM copies, saves, library.json
│ │ ├── EmulatorHost.cs Runs a session on its own thread, paced by audio; links a second game or a NetworkLink
│ │ ├── Link/ NetworkLink (lockstep over any stream), LinkStepping, LinkDiscovery, PacketStream
│ │ └── AudioRingBuffer.cs FrameBlender.cs DmgPalettes.cs
│ │
│ ├── AcidBoy.Desktop/ The `acidboy` app (Raylib + SDL3)
│ │ ├── DesktopApp.cs Main loop, pacing, menus, hotkeys, link modes
│ │ ├── Program.cs Options.cs Command line and headless runner
│ │ ├── Settings.cs settings.json
│ │ ├── AudioOutput.cs Audio stream; paces the emulation
│ │ ├── Assets/ App icon
│ │ ├── Input/ SDL3 / Raylib backends, InputManager, controller mapping
│ │ ├── Online/ OnlineClient, OAuthLoopback, OnlineMenus, ChatOverlay
│ │ │ └── Games/ Win-detection trackers, Pokémon names, RAM dumps
│ │ ├── Ui/ Menu toolkit, file browser, controls and controller screens
│ │ └── Video/ Shader filters, GameView
│ │
│ ├── AcidBoy.Mobile/ The Android and iOS app (.NET MAUI + SkiaSharp)
│ │ ├── Pages/ Library, play, link and settings pages
│ │ ├── Game/ Touch controls, controller hub, audio sink interface, fullscreen
│ │ │ └── Link/ LinkManager, IBleLink (Bluetooth LE contract), multicast lock
│ │ └── Platforms/ Android (activity, AudioTrack, BLE) and iOS (AVAudioEngine, GameController, CoreBluetooth)
│ │
│ └── server/
│ ├── docker-compose.yml PostgreSQL for development
│ ├── AcidBoy.Online.Contracts/ DTOs, hub method names, GameKeys (shared with the emulator)
│ └── AcidBoy.Server/ ASP.NET Core
│ ├── Program.cs Startup and wiring
│ ├── ApiEndpoints.cs REST API
│ ├── Admin/ Staff dashboard (Blazor Server + Tailwind CSS)
│ ├── Auth/ OAuth, JWT and refresh tokens, moderation checks
│ ├── Data/ EF Core model and Migrations/
│ ├── Lobby/ SignalR hub, in-memory lobby state, friends
│ ├── Matches/ Match outcomes and leaderboards
│ ├── Relay/ WebSocket link relay and its tickets
│ └── wwwroot/ Dashboard CSS (generated), logo, favicon
│
├── tests/
│ ├── AcidBoy.Tests/ Core, desktop and shared client tests (xUnit), in Core/ and Desktop/
│ └── AcidBoy.Server.Tests/ Server integration tests (Testcontainers PostgreSQL)
│
├── docs/ This documentation
├── public/ Logo, README banners, screenshots, social preview
└── site/ Website: landing page + docs (Astro + Starlight)

The solution groups the projects in folders: src/infra (Core, Client), src/ui (Desktop, Mobile), src/server and tests. It includes the mobile app, so building all of it needs the maui-android workload (see Mobile app); without it, build or test the projects you need by path.

Terminal window
dotnet build AcidBoy.slnx # needs the maui-android workload
dotnet build src/AcidBoy.Desktop # without it
dotnet test tests/AcidBoy.Tests
dotnet test tests/AcidBoy.Tests --filter "FullyQualifiedName~NetworkLinkTests"
dotnet test tests/AcidBoy.Tests --filter "FullyQualifiedName~AcidBoy.Tests.Core." # or .Client. or .Desktop.
dotnet test tests/AcidBoy.Server.Tests
ACIDBOY_SERVER_URL=http://localhost:5280 dotnet test tests/AcidBoy.Server.Tests --filter "FullyQualifiedName~LiveServer"
Suite How it works
AcidBoy.Tests Synthetic ROMs from TestRoms.Create(...) with hand-assembled programs at 0x100. Fakes for input (FakeBackend/FakePad). Network links over loopback TCP or an in-memory DuplexStream; keep network tests on loopback so they don’t trigger firewall prompts
AcidBoy.Server.Tests One PostgreSQL container (Testcontainers) and an in-memory server (WebApplicationFactory) shared by the tests (ServerFixture). SignalR over long polling. [DockerFact] skips them without Docker. TestAdminHandler stands in for the GitHub sign-in to the dashboard
Live test LiveServerTests runs two real OnlineClients over real WebSockets against a running server

Test ROMs (Blargg, Mooneye, dmg-acid2, cgb-acid2) are not in the repository. Run them headless: acidboy rom.gb --headless. Note that dmg-acid2 matches its reference image only with --gray.

Running the desktop app, or tests that touch Settings, writes to the real settings folder.

.github/workflows/tests.yml runs on every pull request when it is opened or updated, on Linux. It runs only the tests for the code the pull request changes:

Changed Tests run
src/AcidBoy.Core Core, client and desktop (the shared client code and the desktop app are built on the core)
src/AcidBoy.Client Client and desktop (the desktop app runs on it); also server when Link/ changes (the server tests drive the relay link)
src/AcidBoy.Desktop Desktop; also server when Online/ changes
src/server/AcidBoy.Online.Contracts Desktop and server
Anything else in src/server Server (in Docker, like locally)
tests/... The group the test belongs to; the shared helpers run core, client and desktop
Build files or the workflow Everything

Docs and website changes run no tests. The Tests check sums up the result. Make that one required in branch protection, because the individual test jobs are skipped when they don’t apply. New test classes go in tests/AcidBoy.Tests/Core/, Client/ or Desktop/, because the workflow picks the groups by namespace. The mobile app has no tests of its own (its shared code is tested in Client/); mobile.yml builds it.

src/AcidBoy.Mobile is a .NET MAUI app for Android and iOS (see Mobile app for what it does). It is in AcidBoy.slnx (in the src/ui folder), so opening the solution in Visual Studio shows it. The CI jobs build each project by path, so the test jobs don’t need the MAUI workloads. To build the app alone:

Terminal window
dotnet workload install maui-android # once (plus maui-ios on a Mac)
dotnet build src/AcidBoy.Mobile -f net10.0-android
dotnet build src/AcidBoy.Mobile -f net10.0-android -c Release -t:Run # install and start on a phone (Debug is too slow to play)
dotnet publish src/AcidBoy.Mobile -f net10.0-android -c Release -o out # out/io.barrientos.acidboy-Signed.apk
dotnet build src/AcidBoy.Mobile -f net10.0-ios # macOS only, with Xcode; add -p:AcidBoyIosOnly=true without the Android workload
  • Android needs a JDK 17 or newer and the Android SDK (Visual Studio or Android Studio installs both). Run it on a phone with USB debugging, or on an emulator created with the SDK’s avdmanager. adb devices lists both.
  • iOS targets are added only on macOS. Running on an iPhone needs your Apple signing identity.
  • Shared code goes in AcidBoy.Client when it has no platform dependencies, so it is tested with the desktop tests (EmulatorSessionTests, GameLibraryTests, EmulatorHostTests). The app’s own code (pages, touch layout, platform audio and controllers) has no automated tests; try it on a device.
  • Platform code lives in Platforms/Android and Platforms/iOS, which only build for their platform. Their namespaces are AcidBoy.Mobile.Droid and AcidBoy.Mobile.Apple, because ...Platforms.Android would hide the Android.* namespaces.
  • CI: .github/workflows/mobile.yml runs when the app, AcidBoy.Client or AcidBoy.Core changes. It builds the Android APK on Linux and uploads it as the acidboy-android artifact, and builds the iOS app for the simulator on macOS. Neither is signed for a store.

site/ is the project website: a landing page (src/pages/index.astro) and these docs, built with Astro and Starlight. It needs Node.js 22 or newer.

Terminal window
cd site
npm install
npm run dev # http://localhost:4321
npm run build # static site in site/dist
  • These docs are the source. scripts/sync-docs.mjs runs before dev and build. It copies docs/ into src/content/docs/docs/, takes each page’s title from its first # heading, turns links between .md files into site links and renders ```mermaid blocks. It also copies the logo and screenshots from public/. The copies are gitignored, so edit docs/ and public/, never the copies. While npm run dev is running, run npm run sync again to pick up changes.
  • New pages need an entry in the sidebar in astro.config.mjs.
  • Hosting under a path (such as GitHub Pages at /AcidBoy/): set SITE_BASE=/AcidBoy and SITE_URL=https://<user>.github.io when building.
  • Publishing: every push to main that changes site/, docs/ or public/ builds the site and deploys it to GitHub Pages (.github/workflows/pages.yml, or run it by hand from the Actions tab). It needs Settings > Pages > Source: GitHub Actions once. The site is at https://barrientos.io/AcidBoy/ (the account’s custom domain; tavobarrientos.github.io/AcidBoy/ redirects there).
  • Custom domain: add the DNS record (a CNAME to tavobarrientos.github.io for a subdomain, or GitHub’s A/AAAA records for a root domain), then enter the domain under Settings > Pages > Custom domain and enable HTTPS. The workflow reads the address from GitHub on every run, so it needs no change and no CNAME file.
  • No console-type checks in the core. Every difference goes through HardwareModel capabilities.
  • Settings: new fields in Settings must be handled in Normalize() and RestoreDefaults().
  • Link protocol: bump NetworkLink.ProtocolVersion whenever the wire format changes.
  • Contracts: wire changes in AcidBoy.Online.Contracts affect both the server and the emulator; ship them together.
  • Packages stay on 10.x (the projects target net10.0; the newest releases target net11).
  • Docs: keep README.md and these docs in sync when adding user-visible features.
  • Secrets: never in appsettings.json. Use user-secrets or environment variables.
To add Do this
A cartridge mapper Subclass Cartridge, register its type codes in Cartridge.Load. Override RequiresTick/Tick for hardware with its own clock and ExportSaveData/ImportSaveData for battery state beyond plain RAM
A hardware model Derive from HardwareModel (or DmgModel/CgbModel); Validate() checks consistency
A game for win detection See Win detection › Adding a game
A REST endpoint ApiEndpoints.cs (or Auth/), DTOs in the contracts project, a test in AcidBoy.Server.Tests
A lobby feature A constant in LobbyServer/LobbyClient, a method on LobbyHub delegating to LobbyState, handling in OnlineClient
A database change Edit Data/Entities.cs and AcidBoyDb, then dotnet ef migrations add <Name> --project src/server/AcidBoy.Server --output-dir Data/Migrations
A dashboard page A Razor component in Admin/Components/Pages deriving from AdminPage, its queries in AdminService (call ActorAsync first), a link in AdminLayout. Use Tailwind classes; the CSS rebuilds on the next build
An online menu screen A LiveMenuScreen in OnlineMenus, fed by an OnlineClient call that posts its result through Poll()
  • Main-thread rule: the emulator’s OnlineClient and NetworkLink are used from one thread: the desktop’s main thread, or (for NetworkLink on mobile) EmulatorHost’s emulation thread, under the host’s lock. Background threads only post work (Poll()), except that NetworkLink’s read thread may apply link transfers under its _emulation lock.
  • Lobby state: the server’s LobbyState uses one lock and sends SignalR messages only after releasing it.
  • Dashboard database use: dashboard pages keep one DbContext for their lifetime, so AdminService clears the change tracker on every call (fresh roles, no stale entities). AdminPage serializes a page’s database work.
  • Results: result payloads are compared as stored (PostgreSQL normalizes jsonb), so both emulators must serialize the same values in the same order; the tracker base class takes care of that.