One interface (nd_mapsource.h) now owns everything map-specific: tiles, rooms/doors/cameras, the network graph (nodes + edges with roles replacing the hardcoded N_AIRLK/N_DOOR/N_HIVE indices) and the entity spawn list. The scenario populates its structures once via selectMap() and never checks which map is active. - DemoMapSource: self-contained demo grid (moved out of the sketch), demo node/edge/spawn tables - GenMapSource: adapts the random MapGenerator — now with L-corridors for guaranteed connectivity, doors that lead somewhere, airlock pad, terminal and crates (never on corridor tiles); network graph derived from the room chain, marine-first spawn list with droid patrols - NetDeck.ino: all source branching removed; red trace follows the real active-link path (BFS HIVE->ROOT); reinforcement spawns near the blast door - Tests: MapTest validates 50 generated runs + demo via the interface with an airlock flood-fill; new generated-map integration journey; test node handles resolve through the source (no hardcoded indices)
18 KiB
NetDeck — Breach & Board: Milestone Status
Source of truth for gameplay/architecture: DESIGN.md. This file tracks milestone progress (DESIGN.md §7). Update it when a milestone lands.
| Milestone | Scope | Status |
|---|---|---|
| M0 — Emulator | SDL2 emulator support + M1 surface tested locally | done |
| M1 — Hardware Sandbox | Full-frame sprite rendering to ST7789, shared tactical view + HUD, cursor, Space freeze, P view switch |
compiled + emulator-verified; on-device check pending |
| M2 — Network Graph & Traces | 4-node sub-net in shared space (AIRLK→JUNC→DOOR/HIVE), animated link routing (1.5 s / 3.0 s ICE), door control, red trace → feedback spike + OVERHEAT, X sever, R reset |
done (emulator-verified) |
| M3 — Squad vs. Droids | 2 marines (BFS to the player beacon, continue walking while firing), patrol/stationary droids, heavy droid + ceiling turret on the terminal, cover crates, tracers/HP bars, win/loss banners, reinforcement on feedback spike | done (emulator-verified; firmware build fixed) |
| M3 — Squad vs. Droids | Ship floorplan in Cameras view, 3 marines → beacon, 4 droids, gunfire | planned |
| M4 — Cyber-Physical Bridge | Hive link + 1 FRENZY.EXE turns droids on each other (shared coordinate space) |
done |
M0 (done)
src/netdeck/nd_layout.h— shared constants: 320x192 tactical view + HUD bar (one coordinate space), palette, fixed-timestep timings.examples/NetDeck/NetDeck.ino— sandbox app: 40x24 demo floorplan and an 8-node sub-net graph in the same coordinate space (door nodes pinned to their bulkhead door tiles); two view modes — Cameras (full ship view, network as dotted outlines) and Network (ship dimmed ~35%, full graph with labels and packets), switched withP(Tab kept as legacy alias); trackball cursor (edge-ISRs + momentum, tile snap in Cameras / node target in Network); keyboard @ 0x55 (Spacefreeze,1-4/X/Rgroundwork); tap-to-cursor via GT911; 20 Hz sim accumulator (pause-verified frame-identical).- Emulator:
make APP=NetDeck run/smokefromemulator/; host gainedTabkey mapping (emulator/src/main.cpp).
M1 (this milestone)
- Flicker-free full-frame rendering (
examples/NetDeck/NetDeck.ino): all drawing goes into a RAM second buffer —TFT_eSprite fb(PSRAM, 320x240x16) on device, the SDL shim framebuffer in the emulator — and is pushed as one continuous SPI stream (present()→startWrite() / fb.pushSprite(0,0) / endWrite()), the proven MiataDrive anti-tearing pattern (commitd542d6f). - Firmware build: self-contained
examples/NetDeck/platformio.ini(pio run -d examples/NetDeck; board + libs resolved against the repo rootboards/andlib/). ESP32-S3 / arduino-esp32 2.0.9: RAM 6.7%, Flash 5.5%, binary atfirmware/NetDeck_M1_261114.bin. - Keyboard bring-up: stale-byte flush from the 0x55 controller at boot end (before the first frame), on top of the 1400 ms boot grace.
- Trackball device branch:
TB_IMPULSE/TB_FRICTIONconstants split for device vs emulator edge rates. - Emulator frames are pixel-identical to the M0 baseline (regression verified: cameras / network / freeze / beacon click).
Flashing + on-device checklist (needs the physical T-Deck)
pio run -d examples/NetDeck -t upload(or flashfirmware/NetDeck_M1_261114.bin).- Boot screen
M1 // SANDBOXshows for 1.4 s, then the Cameras view. Pflips to Network view (dimmed ship + labeled graph),Tabtoo.Spacefreezes (CRT scanlines, sim/packets halt); cursor stays live.- Trackball: smooth momentum cursor, tile snap in Cameras, node targeting in Network; Enter = beacon drop / node select; screen tap works too.
M2 (done — emulator-verified)
Implements the sub-net half of the MVP vertical slice (MVP.md §1–§3,
validation spec added in this commit) on the shared 320x192 coordinate space:
- 3-room floorplan (airlock / main corridor / server room) with the
Room2/Room3 blast door (
+) and the objective terminalT. - 4-node sub-net pinned to map tiles: AIRLK root (always online) — JUNC — DOOR_CTRL (on the blast door tile) / HIVE (3 s ICE). Click an adjacent offline node to route a link: animated dotted line turning solid over 1.5 s (3.0 s through ICE); offline until the build completes.
- DOOR_CTRL (once online) toggles the blast door open/closed — open doors also un-block LOS/movement for the combat milestone.
Xsevers the hovered link (distance cursor→segment): everything beyond it drops, ICE progress resets; severing during a trace resets the trace safely.- Red trace: cracking HIVE spawns a 4 s red pulse back to AIRLK;
arrival = feedback spike → all links drop + 3 s OVERHEAT lockout
(
TEMPbar). FRENZY/BLIND daemons are gated until a HIVE link is up (effects land in M4). Rresets the scenario instantly to the paused, re-armed state (resetScenario()), which also fixes the AIRLK-root-online bug.- Boot goes straight into the paused encounter; HUD shows daemon slots,
TEMP bar, and
R: RESET. - Emulator host (
emulator/src/main.cpp): headless testing support — repeatable--tap "x,y@frame"screen-tap injection and repeatable--type "text@frame"scheduled keyboard input. - Verified headlessly: full route→door→ICE→trace→feedback→cooldown run,
safe-sever run (trace reset, no spike), all gating messages
(NO HIVE LINK / NO UPLINK / OVERHEAT / LINK SEVERED / NO NODE),
and
rreset; visual frame dumps inspected.
M3 (done — emulator-verified)
Implements the combat half of the MVP vertical slice (MVP.md §1) on top of
the M2 sub-net, in the same 320x192 coordinate space:
- Squad: 2 identical marines spawning in the airlock; BFS pathfinding to the player-placed beacon (re-planned while blocked or every 8 ticks), continues walking while firing hitscan combat with inCover() cover rule (adjacent crate halves incoming hit chance), overhead HP bars + live SQUAD meters in the HUD.
- Enemies: 1 patrolling + 1 stationary security droid in the corridor; 1 heavy droid (2 dmg) + 1 stationary ceiling turret (high ROF) guarding the objective terminal at tile (34,7). Units may not share a tile; walls and the closed blast door block both movement (BFS) and sight (Bresenham).
- Feedback spike consequence: the M2 spike now queues a reinforcement droid spawning in the server room by the blast door.
- Flow: win = a marine reaches the terminal (
BREACH SUCCESS), loss = both marines down (SQUAD KIA); blinking 1-line banner,Rresets either way. Tracers (2-tick) render in Cameras view, dimmed in Network view. - Emulator verification (headless, scripted taps/keys): marines clear
both corridor droids; ICE→trace→feedback→reinforcement→cooldown still
works on top of combat; loss path +
rreset verified; frame dumps inspected (units, HP bars, tracers, banners). - Firmware build fix (this commit): the first M3 draft did not compile
on-device — the Arduino preprocessor injects auto-prototypes above the
Unitstruct, and functions takingUnit&/const Unit¶meters (planPath,unitMove,inCover,acquireTarget) broke the generated prototypes. The emulator (plain C++) never sees this. All four now take a unit index instead of a reference;pio run -d examples/NetDeckis green again. - HUD layout fix (this commit):
R: RESETno longer overlapsRESUME/PAUSE(right column re-spaced: SPACE/RESUME/R:RESET/VIEW), daemon slots and the SQUAD row got real gaps (frame-dump verified).
Known scope note: the win path is gated on M4
Scripted runs show the encounter plays out but BREACH SUCCESS is not
reachable yet: the marines reliably clear the corridor droids, then die at
the blast door to the heavy droid + turret. The intended counter — 1
FRENZY / 2 BLIND — lands in M4 (keys already arm and show the gating
message). The litmus-test loop (crack HIVE, FRENZY the turret, dash the
squad through) completes in M4; until then the loss path + reset are the
verifiable branches. On-device check still pending (inherits the M1
checklist in §M1 above).
M4 (done — Cyber-Physical Bridge)
Activating FRENZY.EXE via key 1 while a HIVE link is online corrupts droid IFF
targeting for 6 seconds. Infected droids turn red and shoot the nearest unit —
friend or foe — causing droids in the shared coordinate space to turn on each
other. This creates a tactical opening for the marines to cross open corridors
or press the advantage at the blast door. The frenzy timer decrements each
20 Hz tick and expires automatically.
260a2b3) is
kept alongside the official `SDL_ConvertEventToRenderCoordinates()` until
verified on this desktop. Ubuntu 24.04 → 26.04 note: SDL2 dev is now 2.24
(the floor for `SDL_GetWindowSizeInPixels`); SDL3 arrives from the repos.
E2E freeze-tint pixel assertions were stale since the diagonal-stripe
rework (pre-existing failures at HEAD under SDL2 too) — updated to the
committed pattern, sampled away from the freeze text. Full suite green:
14 unit + 7 integration + 3 E2E journeys, 0 failures.
### Hardware fix: trackball click dead on device (fixed this commit)
The sound engine zero-initialized `i2s_pin_config_t`, leaving
`mck_io_num == 0`; `i2s_set_pin()` then claimed **GPIO0** — an
MCLK-capable pin on the S3 and the trackball centre / BOOT line — as
its MCLK output, so clicks never registered on hardware (verified with
an on-device diagnostic build: `pin0=0` at idle, one latched FALLING
edge). Fix: `pins.mck_io_num = I2S_PIN_NO_CHANGE` in
`sound_engine.cpp`; the click now also registers on release with
contact-bounce collapse (the proven `CrtTerminal` pattern). The
emulator gained a GPIO-matrix pin-ownership model + edge-accurate ISR
latch so this class of bug reproduces there (`e2e/trackball_click`
fails on the old code, passes on the fix) — see [HW.md](HW.md).
### Sound fix: short beeps silent on hardware (fixed this commit)
Two stacked defects, and both only bite real hardware — the emulator's
`i2s_write` shim fed SDL directly and had no DMA ring, so neither ever
reproduced there:
1. **TX DMA ring zeroing erased short sounds entirely (the real killer).**
The legacy I2S driver copies `i2s_write()` data into a TX DMA ring
(8 × 64 samples = 512 samples = **64 ms** @ 8 kHz) and consumes it at the
sample rate; a buffer is handed back to `i2s_write()` only after the DMA
finished playing it. After the last queued event the sound task called
`i2s_zero_dma_buffer()`, which memsets the whole ring instantly — erasing
everything not yet played. Any sound ≤ 64 ms was written into free ring
space without ever blocking, so the render finished in microseconds and
the zeroing wiped it before the DMA reached a single sample:
**completely silent**. Sounds longer than the ring force `i2s_write()` to
block, pacing rendering to real-time playback, so their beginning had
already played — which is why only long beeps were audible and the
threshold never moved with the fade envelope. Every game beep ≤ 80 ms
(link-active 10 ms, laser 30 ms, sever 40 ms, bleep/ICE 50 ms, feedback
80 ms) sat in that dead zone. Fix: replace the instant zeroing with a
**paced silence purge** — once the queue drains, write one ring + one
chunk of zero samples through `i2s_write()`, which reuses each DMA buffer
only after the DMA finished playing it. The sound plays out fully, then
the ring loops silence (the zeroing existed to stop the tail replaying
forever; the purge still does that job, without the erase race).
2. **Fade envelope ate short tones.** `envelope()` capped the fade at
`total / 2`, so a 10 ms tone (80 samples) spent its whole duration in
fade-in + fade-out — zero steady-state samples even if the samples had
reached the DAC. Fix: cap at `total / 4` (10 ms tone now keeps ~41
steady-state samples; ≥ 50 ms tones unchanged).
The emulator shim gained a TX DMA ring model (write/play cursors + a bounded
"what the DAC emitted" log) so this class of bug reproduces headlessly:
`unit/sound_short_tone_reaches_dac` fails on the zero_dma code and passes on
the purge (A/B verified), `unit/sound_long_tone_plays_out_fully` guards the
purge against truncating long tones, and `unit/shim_zero_dma_erases_unplayed`
pins the model's fidelity to the legacy driver semantics. Reflash required:
`pio run -t upload`.