Rendered from docs/LIVE_VIEW_PLAN.md in the repository.
Goal. With the DUO on top of the game cartridge in one GBA, see the game's live state on the PC while playing: party and hidden stats (IVs, nature), the RNG frame, and a backup the moment the game saves. Built on Datel's own in-game code engine (AR_ENGINE.md).
Stages
| Stage | What | Needs | Risk |
|---|---|---|---|
| A. Reconstruct (done) | How Datel hooks a game: master code, 8 KB block at 0x08020000, ROM patch to 0x08000020, mapping 0x0067, engine at 0x09FE0400 | Nothing | None |
| B. See Datel do it | Fred starts Ruby from Datel's own menu with one harmless code (e.g. from the built-in list), plays a minute, then restarts the DUO into USB SERVER MODE (hold L). Claude reads the 8 KB block back, read-only: trampoline at +0x20, engine at +0x400, codes at +0x9C0, and works out the hook address | Fred at the console, once | None beyond normal Action Replay use (Datel rewrites that block every time) |
| C. Simulate | duocore gains the patch slots, the overlay showing the block's +0x020 in mode 0x0007, and the 0x0067 window; the Virtual DUO runs Datel's real launch code and engine against real Ruby in mGBA, then a Reckless engine in place of Datel's: on each hook call, if the PC has sent a request (LINK_IN strobe), answer it with a few bytes of game RAM over LINK_OUT, else return at once | Nothing (all emulated) | None |
| D. First hardware run | Reckless writes its own 8 KB block (the same two flash sectors Datel rewrites, after backing them up and checking the sector boundaries), patches the hook and starts Ruby; duo_live.py asks for the party every half second and shows it |
Fred's explicit yes; Fred playing | Low: only the block Datel itself rewrites, with a backup; the firmware is untouched |
| E. Features | Live party/IVs, RNG frame counter, auto-backup on save, perhaps a live map | - | - |
Progress
- Stage C, part 1 (28 November): done in emulation.
tools/probes/ar_engine_sim.pyruns Datel's real trampoline and engine (from your own image) on a model of the game-time hardware: the game reaches the hook, the patched BL enters the trampoline at 0x08000020, mapping 0x0067 is written, Datel's engine at 0x09FE0400 applies a test code (an 8-bit write lands in EWRAM), mapping 0x0007 is written and the game carries on - five frames out of five. Datel's own code accepting the model is good evidence the reconstruction is right. - The Reckless live engine (
tools/probes/live_engine.py, 184 bytes) then took the engine's place, with the DUO's USB-chip model (duocore) behind LINK_IN/LINK_OUT: a simulated PC read 64 bytes of game RAM, 8 bytes per frame, all correct. Cost to the game: 18 instructions per frame when idle, up to 579 with a packet (well under 1% of a frame). Both are intests/test_probes.py. - The core models it too (
virtual/core/duocore.c,virtual/tests/test_ar.py): six patch slots, the block-backed overlay, the 0x0067 window with LINK and 0x0180/0x01A0, and the save chip staying awake across the trampoline's 0x0007/0x0067 switches. - The PC side,
duo_live.py, reads the party 8 bytes a frame and decodes species, level, HP, nature, IVs and EVs; in emulation a Ruby party came through in 153 frames (about 2.5 s). - The launcher (
tools/probes/live_launch.py, a 3 KB v4.2 RAM program) copies the live engine over Datel's IWRAM copy of its engine and calls Datel's own start-with-codes routine with just a master code. On the simulated DUO, Datel's routine then wrote the block (live engine at +0x400, master code at +0x9C0, trampoline at +0x20) with its own flash routine and patched the hook to BL 0x08000020. - Master codes, as Datel reads them (0x0800C548): address word 0xC4000000 | hook address; value word low byte = hook type (1-4 install a hook, 0 none), bits 8-14 = codes per call. Ruby's real master code (hook address and type) comes from stage B.
- Session 40 (28 November): Datel's start-with-codes routine, called from the PC (
duo_codes.py), started Ruby USA rev 2 with codes on hardware (hook 0x08000430, read from the cartridge in session 39). That covers most of stage B.duo_live.py launchnow sends the live engine the same way. - Stage D works on hardware (session 41, 28 November). The block read-back matched the reconstruction.
duo_live.py launchstarted Ruby with the live engine. A 90 s link test made 404 of 404 reads through the intro, the title screen and loading the save.duo_live.py partyread the real party (species, level, HP, nature, IVs, EVs) from the running game in 1.4 s. One earlier attempt stalled after a few reads; its cause is still open. - Next: stage E features (live IVs in battle, RNG frame, auto-backup on save), and a long soak to catch the stall.
The questions each stage answers
- B: the block's real layout and the hook address Datel uses for Ruby; whether the trampoline really sits at +0x20 and the codes at +0x9C0.
- C: whether a USB exchange fits in the time a hook call can take without the game noticing (a packet is ~8 ms each way on USB, but the engine only needs to pass bytes to the USB chip, which buffers them), and how to pace requests so the game never waits.
- D: whether LINK_IN/LINK_OUT answer in mode 0x0067 (the engine's use of 0x0180/0x01A0 says the control area is decoded there).
Safety rules for this project
- Nothing is written to the DUO's flash outside 0x08020000-0x08021FFF, and that block is read and kept on the PC before it is changed.
- No write to the game's save from the in-game engine; the live view only reads RAM.
- Every hardware step that writes waits for Fred's yes in chat.