MAX DUO Pokémon Toolkit GitHub

Home / Library

How accurate is the simulated DUO?

Rendered from docs/SIMULATOR_ACCURACY.md in the repository.

The simulator (virtual/core/duocore.c, driven by tests/hwsim.py and the Virtual DUO) is only as good as the hardware facts behind it. This page keeps score: every behaviour, where the knowledge comes from, and whether the model has been compared with the real DUO. Made by tools/probes/behaviours.py --write.

47 behaviours: 31 checked against hardware, 10 modelled but not yet checked, 5 missing, 1 where hardware disagrees with the model.

Behaviour Source Status Settled by
A 32-bit read of open bus repeats the low halfword measured (session 33) disagrees s33_openbus
EEPROM saves - missing -
A DUO restart answers HELLO again after 0.50 s (ten of ten) measured (session 37) missing pc_soak
DS card save chip over SPI on LINK_OUT 10-12 / LINK_IN 12 datel-code missing a DS card
USB 1.1 'Datel' / 'GBA Link', bus-powered 100 mA, IN 10 ms / OUT 1 ms; string requests beyond the two it has can knock it off the bus measured (sessions 32, 36) missing usb, usb_deep
~8 ms per packet each way (~16 ms round trip, Reckless); Datel's HELLO answered in ~40 ms (its main loop); ~3 s fixed per lab run measured (sessions 32, 36) missing usb_deep, speed_*
AR button on LINK_IN bit 10 (clear = pressed) datel-code; idle state measured modelled p_switch (needs a hand)
AR switch on LINK_IN bits 13-14 (variant 0); OFF state datel-code modelled p_switch (needs a hand)
SST command set (program, sector/block/chip erase, ID) datasheet modelled -
After the image (0x0802EAC4-0x0802FFFF) the flash holds zeros; 0x0803C000-0x0803FFFF is 99% blank measured (session 32) modelled p_flash
SST 39VF400A answers ID BF/2780 in software-ID mode measured (October) modelled -
Mapping 0x0067 shows the AR block (DUO flash 0x08020000) at 0x09FE0000 from 0x0200 up, with LINK and 0x0180/0x01A0 still answering; switching 0x0007<->0x0067 keeps the save chip awake datel-code (Datel's engine runs on the model) modelled live view stage B/D
The header overlay shows the AR block's +0x20 (the trampoline) - zeros while no codes are set datel-code; consistent with sessions 32-34 modelled live view stage B
Six address/value ROM-patch slots (two for the hook's BL, four for ROM-patch codes), applied in mappings 0x0007/0x0067 datel-code (Datel's engine runs on the model) modelled live view stage B/D
The USB chip holds one packet with the GBA off measured (session 2b, session 32 start-up) modelled -
2-cycle first access flips a single bit (bit 1) in a few bytes of some pages; the same pages fail most passes with the same wrong result, others only sometimes; 3-cycle (0x4317) is clean measured (sessions 3, 32-37) modelled s35_waitfast, s37_faultrep
Nothing else mapped in the 32 MB cartridge space, DUO or game mapped measured (session 32) checked p_busmap
Only 0x09FE0000-0x09FE01FF is decoded; 0x09FE0200 up (the 'patch slots' too) reads as open bus, no mirrors measured (session 32) checked p_decode
With the game mapped (0x0101, 0x0007, 0x0001) the control registers and 0x09FE0400 read as open bus; the overlay and mapping register stay measured (session 34) checked s34_maps
The other decoded registers (0x09FE0000-0x01FF) read 0 at rest and stay still measured (sessions 32, 33) checked p_regs, s33_ctrlwatch
0x09FFE140 is not a readable register: it reads as open bus (0xF0A0); Datel writes 0x0FF0 to it measured (session 32) + datel-code checked p_decode
DUO flash is 512 KB, mirrored once below 1 MB (a full copy; only the mapping register differs), open bus above measured (sessions 1, 32, 37b) checked p_mirror, s37_fullmirror
First bytes after a start-up garbled twice in October (of 30+); none in November: 0 of 224 header reads after 24 restarts measured (sessions 6-7, 32, 33, 37) checked s37_garble
ID mode survives remapping; the chip still sleeps until a ROM read measured (session 33) checked s33_idpersist
ID mode survives a DUO restart (the cartridge isn't power-cycled) measured (session 35) checked s35_idon
LINK_IN/OUT: byte in bits 0-7, strobe bit 8, strict turn-taking measured + datel-code checked -
LINK_IN also reads at 0x09FE01C2 measured (session 32) checked p_decode
LINK_IN reads 0xF5xx at rest with the switch ON: bits 10 (button up), 12 (serial in), 13-14 (switch), 15 high measured (sessions 32, 33) checked p_regs, p_switch
LINK_IN doesn't flicker at rest (4,000 samples at full speed) measured (session 35) checked s35_linkfast
LINK_OUT reads 0x0002, not the GBA's last write measured (sessions 32, 33) checked p_regs, s33_ctrlwatch
0x0800009C reads F0 0F; its mirror 0x0808009C reads 00 00 measured (sessions 3, 33) checked s33_overlay
Mapping 0x0120 = DUO; 0x0101/0x0007/0x0001 = game measured checked -
Above the cartridge the GBA reads the address bits; 8- and 16-bit reads by halfword measured (sessions 3, 33) checked s33_openbus
Header 0x08000020-0x9F reads zero in every mapping and width measured (sessions 3, 3b) checked -
0x09FE0080 reads 0x0FF0 at rest measured (sessions 32, 33) checked p_regs
Game ROM: data, FF padding to 16 MB, open bus from 16 MB (Ruby also has small non-FF islands near 13-14 MB) measured (sessions 3, 4, 32) checked p_busmap
Sanyo ignores AA-55-F0 (seven waits up to 0x40000) and leaves ID mode on a lone F0 at any address measured (test 1, sessions 32, 33) checked p_idexit, s33_reset
Save area is an 8-bit bus: 16-bit reads give each byte twice, 32-bit four times measured (sessions 5, 37) checked s37_save8
128 KB Flash banks switched with AA-55-B0 then the bank number; the bank survives remapping and a DUO restart measured (sessions 34, 35) checked s34_banks, s35_bank1
Left mapped, the save chip stays awake (8 s idle); only remapping puts it to sleep measured (session 37) checked s37_sleep
In ID mode the chip reads ID, 00, 00 repeating (Sanyo 62 13 00 00) measured (sessions 32, 33) checked -
The save chip repeats every 64 KB through 0x0E000000-0x0FFFFFFF measured (session 37b) checked s37b_savemirror
Save chip sleeps after every swap-in; any ROM read wakes it measured (early, sessions 1, 33) checked -
The save chip answers straight after the wake read, no pause needed measured (session 34) checked s34_wake
1,000 version queries and 300 HELLOs with no errors; long streams repeat byte for byte measured (session 37) checked pc_soak, s37_stream_*
0x09FE0160 reads 0 on this DUO measured checked p_regs
The DUO's own flash reads correctly at every ROM wait state, prefetch on or off measured (sessions 32, 33) checked -

Replaying the real lab results

Made by tools/probes/sim_vs_hw.py: every recorded lab result replayed through the simulated DUO and compared by content-independent signature (see the tool's notes).

  • recorded script runs: 136; replayed: 136; skipped: 0; lab probe runs: 2
  • results compared: 1808; match: 1803; mismatch: 5
  • set aside as contents, not behaviour: 1783 (the real DUO's stored data and code database, the real game's ROM and the real firmware build differ from the simulator's synthetic ones; only open bus is compared there)
Area Match Mismatch Contents (not compared)
header overlay 10 0 0
control area 284 0 0
save chip 134 0 11
cartridge space 1359 5 1500
other 16 0 272

Mismatches

Script Result Read Hardware Simulator
s33_openbus.json #3 r32 0x08100000 +0x10 openbus32 openbus
s33_openbus.json #7 r32 0x09000000 +0x10 openbus32 openbus
s33_openbus.json #11 r32 0x09f00002 +0x10 openbus32 openbus

What the hardware runs will change

Session 32 (tools/probes/README.md) is aimed at every missing, modelled and disagrees line with a probe named above. Once it has run, sim_vs_hw.py replays its results too, the model is corrected where they differ, and the corrected lines move to checked.