MAX DUO Pokémon Toolkit GitHub

Home / Library

The DUO as a GameCube – the Colosseum Bonus Disc's Jirachi (hand-over plan, 21 November)

Rendered from docs/COLOSSEUM_BONUS_DISC.md in the repository.

The goal (Fred, 21 November): the DUO runs the exact multiboot program the Pokémon Colosseum Bonus Disc sends, delivering it just as the GameCube did, so the receiving game sees nothing different. This page is the plan for whoever picks it up: what we already know, what to find out, in what order, and how each step is proved. It continues path C of docs/MULTIBOOT.md.

Status: first look only (21 November). No DUO code has been written, nothing has been sent to any GBA, and no disc content has left Fred's PC apart from the file names and hashes below.

Status, 22 November (the other conversation, which worked from this plan's goal without having seen it). See GAMECUBE_MULTIBOOT.md and CISO_MULTIBOOT_PROGRESS.md.

  • Answered:
  • client.bin is the WISHMKR program, client.2003_1112.bin is METEOR, and sample0519.bin is the Japanese Negaiboshi sender.
  • After boot, client.bin needs only a fixed four-step JOY bus handshake ("PKEG"), then reports one result word.
  • The GameCube's whole side was read from main.dol and modelled against pret's libgcnmultiboot (phases 2-4).
  • Fred's choice on 22 November: to deliver the WISHMKR program now, without a GameCube, the handshake call is skipped (4 bytes), sent over the BIOS link-cable route. This is the opposite of "Not doing" below, so it's recorded here as his decision. Tested in emulation only.
  • Still open: this plan's path C (the DUO driving the JOY bus by hand) for the unchanged program, which needs phase 6's timing measurement.
  • Also found: coupon.bin is Japanese-only, unused by both Colosseum and XD, and a GameCube-driven server.

The ground rules that apply here

  • Multiboot: "100% reproduce ... no guessing" (Fred, 18 November). Every step of the protocol must come from a primary source: pret's decompilations (the games' receiving side), the Bonus Disc's own GameCube code (the sending side), GBATEK, or a measurement. Anything none of those settles is marked as needing a measurement, and nothing is built on a guess.
  • Nintendo data never goes in the repository. The disc images stay in C:\Users\<you>\ActionReplay\roms\Colosseum\, and anything taken from them (the GBA programs, the GameCube code) stays on Fred's PC or in the session's working area. Hashes and names, like those below, are fine to record.
  • Hardware safety. The Jirachi program writes the cartridge's save: that's what it was for. Our own code still never writes a save, and the DUO only passes on the original program. Sending it to a real cartridge is Fred's decision, made at the end of this plan, with the save backed up first (maxduo_saves.py). As in docs/MULTIBOOT.md, the tool must refuse without an explicit option.
  • Testing tiers and pushing as in docs/HANDOVER.md.

What we have (Fred's own discs)

Both are .ciso images (the Dolphin/WIT compact format, 2 MiB blocks). tools/gamecube_disc.py (21 November) reads them on Fred's PC: it lists files, opens the embedded .tgc disc and U8 archives, flags GBA programs, and copies files out to a folder outside the repository.

Disc Game ID File
Pokémon Colosseum Bonus Disc (USA) PC6E01 Pokemon Colosseum (USA) (Bonus Disc)\Pokemon Colosseum (USA) (Bonus Disc).ciso
Pokémon Colosseum (USA) GC6E01 Pokemon Colosseum (USA)\Pokemon Colosseum (USA).ciso

The Bonus Disc. The Jirachi download is its own little disc inside, tgc/pokedownload.tgc (a TGC: magic AE0F38A2, file offsets "virtual" as in Dolphin's TGCBlob). Inside it:

File Size What it looks like SHA-1
main.dol 792,736 The downloader's GameCube program (PowerPC); contains the text JIRACHI d9da26b12dfc3b6518c50f79988c41a864b227b7
client.bin 27,584 GBA program (multiboot header, game code AGBJ); contains JIRACHI. Most likely the WISHMKR program 39287eeba84ca1c4c4e4eeed36fcc36390364b99
client.2003_1112.bin 24,364 GBA program, game code AGBJ, dated in its name (12 Nov 2003); contains FLASH1M. A prototype; possibly the METEOR one 446b9a3d3abe45236ef4a378e6469496ae85aa5c
sample0519.bin 71,400 GBA program, empty game code. Project Pokémon found it waits for a "distribution server" handshake fe72fb983b623aa560df84e9d269e7a21db937e4
download.bin 6,716,648 U8 archive of .tm files (screens), no GBA code found -

Which of these is WISHMKR and which METEOR is a guess from their contents until phase 2 settles it. TCRF and Project Pokémon say the WISHMKR program's main code is compressed inside it and that it carries working FireRed/LeafGreen and Japanese support, two checks disabling the latter; Emerald isn't supported at all, so the target games are Ruby, Sapphire, FireRed and LeafGreen.

The main Colosseum disc has GBA programs of its own, for later:

File Size Note SHA-1
colbtl.bin 92,412 GBA program, game code TEST: Colosseum's link-battle program (pret's colosseum-mb is its decompilation; its hashes don't match this file as it stands, so compare after any padding or compression) 106b51c41138fd8103c7b5b300741f050e6299eb
coupon.bin 59,964 Starts with an ARM branch like a GBA program, but no logo: perhaps the Japanese Bonus Disc's Poké Coupon gifts (Pikachu) left in the game, as TCRF says some of its content was 9f170f72a7b06ee1e533f1e3c6812e810f772784
pkjb_test.bin 6,948 GBA program, empty game code: a test 215e873588838def7c52e118682a1b33c6d6eb6a
bg0..2thumbcode.bin ~43,000 Not GBA headers; unknown -

How the real thing works (what the sources already say)

  • The receiving end is in the game. Every Gen 3 game carries libgcnmultiboot (pret: pokeruby, pokefirered, pokeemerald src/libgcnmultiboot.s). During the intro, if a GameCube resets the link, the game hands over to it, takes a program over the JOY bus and runs it. So the player switches on as normal, with no START+SELECT; this is not the BIOS's own multiboot.
  • The GameCube is the master; the GBA is always the slave (GBATEK). The four JOY bus commands are FFh (reset), 00h (status: the GBA answers 00 04 and its JOYSTAT), 15h (write a word to the GBA) and 14h (read a word from it). The GameCube side is Nintendo's SDK GBA library (its "joy boot", then reads and writes), which should be findable in the Bonus Disc's main.dol.
  • What GBATEK doesn't give: the bit timing on the wire ("unknown"). The JOY bus is one data line with each bit a short low then high period, but the exact periods and the tolerance of the GBA's receiver are what phase 6 measures.
  • The DUO's GBA can't be a JOY bus master with its link hardware. It would drive the line itself in general-purpose mode (RCNT bit 15 set, bit 14 clear: SO as output, SI as input), from timed code in IWRAM with interrupts and DMA off. A JOY bus bit is a few microseconds; at 16.78 MHz a microsecond is about 17 cycles, which is tight but within reach.

The plan, phase by phase

Each phase ends with something checkable. Write findings into this page as they come.

Phase 1 - Inventory (started 21 November)

  • [x] Read both images, list files, find the GBA programs, record hashes (above).
  • [ ] Copy the GBA programs and the downloader's main.dol into a working folder outside the repository (gamecube_disc.py ... --extract ... --out), on Fred's PC; bring them across to the session only when needed (they're small).
  • [ ] Check the extraction against something independent: pret's colosseum-mb builds the colosseum program found compressed in FireRed/LeafGreen/Emerald; compare colbtl.bin with it (after decompression if need be) to prove the reader returns exact bytes.

Phase 2 - Understand the GBA program completely

For client.bin first, then the other two:

  • [ ] Header and entry point; how the main code is unpacked (TCRF: compressed) and where it runs.
  • [ ] Every hardware register it touches, especially the link port (RCNT 0x4000134, JOYCNT 0x4000140, JOY_RECV/JOY_TRANS 0x4000150-0x4000156, JOYSTAT 0x4000158). The key question: does it talk to the GameCube after it boots? If it reads or writes the JOY bus, the GameCube's side of that conversation is part of what the DUO must play.
  • [ ] Which games it accepts (game codes, languages; the two checks that turn Japanese support off).
  • [ ] What it writes to the save and how: the Flash commands it uses, which sector, which fields. It also repairs Ruby/Sapphire's berry clock, as the disc did.
  • [ ] How it makes Jirachi (PID, IVs, the Salac/Ganlon berry choice), against Project Pokémon's documented WISHMKR algorithm.
  • [ ] Settle which file is WISHMKR and which METEOR.

Tools: an ARM/Thumb disassembler in the session (capstone, or Ghidra headless if it can be installed), and the decompressor once identified. Keep annotated listings out of the repository; record only conclusions and addresses here.

Phase 3 - Understand the GameCube side completely

  • [ ] Find in the downloader's main.dol (PowerPC) the SDK's GBA routines and the code that calls them: which file it sends, the order of commands, every delay, and what it does with each answer. The XD decompilation (TeamOrre/xd-decomp) and Dolphin's SDK knowledge can help name functions.
  • [ ] Write the result as a sequence: "reset, status until 00 04, ... send these words, read until ..., wait N ms", each step with its address in main.dol. That sequence is what the DUO replays.

Phase 4 - The receiving side from pret

  • [ ] Read libgcnmultiboot.s (all three games) and write down what it expects: the boot handshake, the keys and checks, the frame-by-frame timing, when it gives up, and what it does after the program's header arrives (Emerald, for instance, swaps in its own copy if the game code is Colosseum's: pret:pokeemerald/src/intro.c, COLOSSEUM_GAME_CODE).
  • [ ] Phases 3 and 4 together are the protocol from both ends. Where they agree, it's settled; where they don't, find out why before going on.

Phase 5 - Simulate it, command by command, then bit by bit

  • [ ] A GameCube model at the command level. A small Python host that plays phase 3's sequence into mGBA's JOY bus support (mGBA can link to Dolphin, so it already handles commands FFh/00h/14h/15h on the GBA side), sending client.bin to a simulated Ruby at its intro. Success: the program runs, the game saves, and the save holds a Jirachi matching the algorithm, with the berry clock fixed. Run it on a copy of a test save only.
  • [ ] Optional but strong: the real disc as reference. Dolphin with its integrated mGBA can run the Bonus Disc itself; logging the JOY bus traffic there gives the real GameCube's sequence to compare with phase 3's reading. Dolphin may not run headless in the session; Fred's PC is an option.
  • [ ] The wire. A DUO firmware program (working name gcnhost) that drives the JOY bus by hand, and a matching part of the Virtual DUO (virtual/runner/vduo.c): it times the DUO's pin changes, decodes them into JOY bus bits and commands for the game's core, and encodes the game's answers back onto the DUO's SI with real timing. As with the normal-mode wire (21 November), the model must be exact enough that a timing mistake in the DUO's code fails in the simulator.

Phase 6 - Measure the wire timing (the rule's missing piece)

GBATEK doesn't give the JOY bus timing, so it has to be measured rather than assumed. Options, in order of preference:

  1. A tolerance sweep with only harmless commands. The DUO sends the status command (00h) to a GBA whose game is at its intro, stepping through bit periods and low/high ratios, and records which ones the GBA's JOY hardware answers with 00 04. Nothing is written anywhere; it's the same kind of lab run as the four-player sweep. The working window's centre becomes the DUO's timing, and the window's width says how much margin there is.
  2. A real GameCube, if Fred has one and a GameCube-GBA cable: the DUO's GBA in general-purpose mode sampling the line while the GameCube boots a GBA, as lab4p --scope did for the link cable. That would need a way to tap the line, so it's a second choice.

Also to settle here: the cable. In JOY bus mode the GBA takes data on SI and answers on SO (GBATEK). A cross-wired Game Boy Color cable (the CGB-003 Fred now has) joins each GBA's SO to the other's SI, which looks right, but check the GameCube-GBA cable's wiring (and whether SC and SD matter) from a reliable pin-out before relying on it.

Phase 7 - Hardware, step by step

  1. The status sweep (phase 6) - harmless.
  2. A boot of a harmless test program of our own through the identical protocol: it shows a screen and touches no save. Proves the DUO can boot a game's GBA exactly as a GameCube does.
  3. Decision point for Fred: client.bin to a Ruby or Sapphire with its save backed up, the tool naming the program and asking for the explicit option first. Then FireRed/LeafGreen.

Open questions to answer along the way

  • Is client.bin WISHMKR? (phase 2)
  • Does the program need the GameCube after it boots? (phase 2, then 3)
  • Exactly when in the intro the game listens, and how long it waits. (phase 4)
  • The JOY bus bit timing and the GBA receiver's tolerance. (phase 6)
  • The cable wiring. (phase 6)
  • Later, if wanted: the main disc's coupon.bin and the Japanese Bonus Disc's Celebi and Pikachu, which came through Colosseum itself rather than a standalone program, so they'd need Colosseum's trade link played instead.

Not doing

  • No editing of the programs (for instance re-enabling Japanese support): the point is the exact program. If that's ever wanted, it's a separate decision.
  • No leaked distribution ROMs or programs from elsewhere: only Fred's own discs.
  • Nothing sent to a real cartridge before phase 7's decision point.