Development guide
Repository layout
Section titled “Repository layout”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)Building and testing
Section titled “Building and testing”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.
dotnet build AcidBoy.slnx # needs the maui-android workloaddotnet build src/AcidBoy.Desktop # without itdotnet test tests/AcidBoy.Testsdotnet 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.TestsACIDBOY_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.
Tests on pull requests
Section titled “Tests on pull requests”.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.
Mobile app
Section titled “Mobile app”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:
dotnet workload install maui-android # once (plus maui-ios on a Mac)dotnet build src/AcidBoy.Mobile -f net10.0-androiddotnet 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.apkdotnet 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 deviceslists both. - iOS targets are added only on macOS. Running on an iPhone needs your Apple signing identity.
- Shared code goes in
AcidBoy.Clientwhen 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/AndroidandPlatforms/iOS, which only build for their platform. Their namespaces areAcidBoy.Mobile.DroidandAcidBoy.Mobile.Apple, because...Platforms.Androidwould hide theAndroid.*namespaces. - CI:
.github/workflows/mobile.ymlruns when the app,AcidBoy.ClientorAcidBoy.Corechanges. It builds the Android APK on Linux and uploads it as theacidboy-androidartifact, and builds the iOS app for the simulator on macOS. Neither is signed for a store.
Website
Section titled “Website”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.
cd sitenpm installnpm run dev # http://localhost:4321npm run build # static site in site/dist- These docs are the source.
scripts/sync-docs.mjsruns beforedevandbuild. It copiesdocs/intosrc/content/docs/docs/, takes each page’s title from its first# heading, turns links between.mdfiles into site links and renders```mermaidblocks. It also copies the logo and screenshots frompublic/. The copies are gitignored, so editdocs/andpublic/, never the copies. Whilenpm run devis running, runnpm run syncagain to pick up changes. - New pages need an entry in the
sidebarinastro.config.mjs. - Hosting under a path (such as GitHub Pages at
/AcidBoy/): setSITE_BASE=/AcidBoyandSITE_URL=https://<user>.github.iowhen building. - Publishing: every push to
mainthat changessite/,docs/orpublic/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 athttps://barrientos.io/AcidBoy/(the account’s custom domain;tavobarrientos.github.io/AcidBoy/redirects there). - Custom domain: add the DNS record (a
CNAMEtotavobarrientos.github.iofor a subdomain, or GitHub’sA/AAAArecords 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 noCNAMEfile.
Conventions
Section titled “Conventions”- No console-type checks in the core. Every difference goes through
HardwareModelcapabilities. - Settings: new fields in
Settingsmust be handled inNormalize()andRestoreDefaults(). - Link protocol: bump
NetworkLink.ProtocolVersionwhenever the wire format changes. - Contracts: wire changes in
AcidBoy.Online.Contractsaffect 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.mdand these docs in sync when adding user-visible features. - Secrets: never in
appsettings.json. Use user-secrets or environment variables.
Extending
Section titled “Extending”| 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() |
Architecture notes worth knowing
Section titled “Architecture notes worth knowing”- Main-thread rule: the emulator’s
OnlineClientandNetworkLinkare used from one thread: the desktop’s main thread, or (forNetworkLinkon mobile)EmulatorHost’s emulation thread, under the host’s lock. Background threads only post work (Poll()), except thatNetworkLink’s read thread may apply link transfers under its_emulationlock. - Lobby state: the server’s
LobbyStateuses one lock and sends SignalR messages only after releasing it. - Dashboard database use: dashboard pages keep one
DbContextfor their lifetime, soAdminServiceclears the change tracker on every call (fresh roles, no stale entities).AdminPageserializes 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.
