Skip to content

Win detection (result trackers)

While two players are linked online, the emulator watches the game’s memory and reports what happens to the server. Reported results are:

  • a round won, lost or drawn;
  • a set or match;
  • a trade.

Both emulators report independently, and a result only counts when both reports are identical (verified). The server then decides the match and updates records and leaderboards; see Data model › Match outcomes.

Game Key What is detected Memory addresses from
Tetris tetris Each 2-player round (win, loss, draw) and the set: first to 5 wins kaspermeerts/tetris
Dr. Mario dr-mario Each 2-player round and the match: first to 3 wins gbbolt/drmario-gbbolt
Pokémon Red, Blue, Yellow (English) pokemon-gen1 Link battle winners with both lead Pokémon; trades by name pret/pokered, pret/pokeyellow
Pokémon Gold, Silver, Crystal (English) pokemon-gen2 Link battle winners with both lead Pokémon; trades by name pret/pokegold, pret/pokecrystal

Trackers are picked by the cartridge title. Other languages and revisions may keep their data elsewhere, and each tracker sanity-checks memory so it stays silent rather than report nonsense.

Payloads use a neutral host/guest point of view, so both emulators produce byte-identical JSON:

{"game":"tetris","round":3,"winner":"host","score":{"host":2,"guest":1}}
Kind Meaning Payload
Battle One round or battle game, round, winner (host/guest/draw), score (rounds won so far), optional details
Set The end of a best-of series Same shape; the final score
Trade A finished Pokémon trade host and guest: what each side gave (species, name, level, otId)

Pokémon battles add "details":{"host":{"lead":"Pikachu"},"guest":{"lead":"Squirtle"}}.

Two-player state lives in high RAM:

Address Name Meaning
$FFE1 hGameState $1B game over → $1D/$1E init victory/defeat → $20/$21 victory/defeat screen
$FFD7 hOurWins Rounds won by this side
$FFD8 hTheirWins Rounds won by the other side

The init state’s handler increments a counter, or neither for a draw (flag $FFEF), before the result screen appears. The tracker:

  1. remembers the counters when the round ends ($1B-$1E);
  2. compares them when a result screen appears ($20/$21).

A counter reaching 5 ends the set.

Address Name Meaning
$FFB1 hTwoPlayer Non-zero in a link game
$FFE1 hGameState $17 RoundEndSync → $05 LevelCleared / $0F GameOver / $06 RoundDraw → $12 RoundOver
$D000 wWins1 Rounds won by this side
$D001 wWins2 Rounds won by the other side

LevelCleared increments wWins1, GameOver increments wWins2, and a draw increments neither. The counters are compared when RoundOver begins, and 3 wins end the match. Both counters reset in NextRound after the results screen.

PokemonLayout holds each game’s addresses (link state, battle flag and result, party, traded Pokémon, opponent’s party). Battles end when the battle flag drops in the colosseum, and the result byte says who won. A trade is detected when the party changes and its last member is the partner’s offered Pokémon. Species names come from PokemonNames, generated from pret’s name tables: Gen 1 by internal index, Gen 2 by Pokédex number.

Tetris and Dr. Mario rest on the disassemblies and on tests that replay their state sequences. Confirm a new tracker in real two-player play before relying on it.

flowchart LR
    A["Find the state<br/>(disassembly, or F9 dumps<br/>+ --ram-diff)"] --> B["Write a tracker<br/>(Online/Games/)"] --> C["Register it<br/>(GameResultTrackers.For,<br/>GameKeys)"] --> D["Test by replaying<br/>memory states"] --> E["Confirm in real<br/>two-player play"]
  1. Find where the game keeps the result. Prefer a public disassembly (search GitHub, Data Crystal, TCRF). Otherwise:
    • run a Debug build and press F9 at two moments, e.g. mid-round and on the “you win” screen. Each press writes ram-dumps/<title>-<time>.ram next to settings.json;
    • run acidboy --ram-diff a.ram b.ram to list the bytes that changed (C010: 01 -> 05; banked WRAM shows as D123/2, HRAM as FFxx);
    • repeat with a loss and a draw until the counters and state values are clear.
  2. Write a tracker in src/AcidBoy.Desktop/Online/Games/:
    • games with a win counter per side derive from RoundCounterTracker (see TetrisTracker and DrMarioTracker), which only needs the addresses and the state values;
    • anything else derives from GameResultTracker and calls ReportRound/ReportSet or Enqueue. The base class turns “I won” into host/guest.
    • read memory through Read/Read16BigEndian (Bus.Peek), never through the normal bus, which has side effects.
  3. Register it: add a key and display name to GameKeys (shared with the server), and a case to GameResultTrackers.For and Supported.
  4. Test it like VersusTrackerTests. Write the memory a round goes through on two consoles (host and guest) and assert identical payloads, the winner and the score, including draws and the end of a set.
  5. Play a real set over AcidBoy Online and compare the emulator’s history with the dashboard’s match page.

The admin dashboard’s Overview lists the most-played linked games that still have no tracker, which is the best guide. Well-known 2-player link games:

Kind Games
Puzzle Tetris DX, Yoshi, Yoshi’s Cookie, Kirby’s Star Stacker, Tetris Attack, Pokémon Puzzle Challenge, Puyo Puyo (Pocket Puyo Puyo)
Sports Tennis, Golf, Baseball, Mario Tennis, Mario Golf, F-1 Race
Battles Pokémon Trading Card Game, Dragon Warrior Monsters 1 and 2
Other Wario Blast, Super Mario Bros. Deluxe (VS race)

AcidBoy links two consoles; games for the 4-player adapter work in 2-player mode only.