NetDeck M2: sub-net graph, link routing, ICE crack, red trace + feedback spike

Implements MVP.md §1-§3 (network half of the vertical slice) on the shared
coordinate space:
- 3-room floorplan (airlock/corridor/server room) with blast door + terminal
- 4 nodes: AIRLK root - JUNC - DOOR_CTRL (on the door tile) / HIVE (3s ICE)
- animated link builds (dotted->solid, 1.5s plain / 3.0s ICE), reachability
  tree from AIRLK; links offline until the build completes
- DOOR_CTRL toggles the blast door; X severs the hovered link (ICE progress
  resets, trace cut short resets safely)
- cracking HIVE spawns a 4s red trace to AIRLK; arrival = feedback spike:
  links drop + 3s OVERHEAT lockout (TEMP bar)
- FRENZY/BLIND daemon slots gated on HIVE link (effects land in M4)
- R instant reset via resetScenario() (also fixes root-online init bug)
- boot straight into the paused encounter
- emulator: --tap "x,y@frame" and repeatable --type "text@frame" for
  headless scenario testing

Verified headlessly: full trace->feedback run, safe sever, all gating
messages, reset; visual dumps inspected. Spec: src/netdeck/MVP.md.
This commit is contained in:
Dejvino
2026-11-14 11:23:37 +01:00
parent 3dcafa25e7
commit 6d2f593bc5
4 changed files with 670 additions and 230 deletions
+70 -20
View File
@@ -73,9 +73,16 @@ int main(int argc, char **argv)
{
long maxFrames = -1;
const char *dumpPath = nullptr;
const char *typeStr = nullptr;
int typeFromFrame = 30;
int dumpEvery = 0;
// scheduled screen taps: --tap "x,y[@frame]" (repeatable)
struct Tap { int x, y, at, hold; bool fired; };
static Tap taps[32];
int nTaps = 0;
// scheduled typing: --type "text[@frame]" (repeatable, chars ~40 ms apart)
struct TypeEvt { const char *s; int at; };
static TypeEvt typeEvts[16];
int nType = 0;
#ifdef EMU_APP_MISSILECOMMAND
bool autoplay = false;
#endif
@@ -83,8 +90,28 @@ int main(int argc, char **argv)
if (!strcmp(argv[i], "--frames") && i + 1 < argc) maxFrames = atol(argv[++i]);
else if (!strcmp(argv[i], "--dump") && i + 1 < argc) dumpPath = argv[++i];
else if (!strcmp(argv[i], "--dump-interval") && i + 1 < argc) dumpEvery = atoi(argv[++i]);
else if (!strcmp(argv[i], "--type") && i + 1 < argc) typeStr = argv[++i];
else if (!strcmp(argv[i], "--type") && i + 1 < argc && nType < 16) {
// "text[@frame]": queue another typing event (chars ~40 ms apart)
const char *s = argv[++i];
int at = typeFromFrame; // legacy default via --type-at
const char *atp = strchr(s, '@');
char *copy = strdup(s);
if (atp) {
at = atoi(atp + 1);
copy[atp - s] = '\0';
}
typeEvts[nType++] = { copy, at };
}
else if (!strcmp(argv[i], "--type-at") && i + 1 < argc) typeFromFrame = atoi(argv[++i]);
else if (!strcmp(argv[i], "--tap") && i + 1 < argc && nTaps < 32) {
Tap &t = taps[nTaps++];
t.x = t.y = t.at = 0; t.hold = 0; t.fired = false;
const char *s = argv[++i];
sscanf(s, "%d,%d@%d", &t.x, &t.y, &t.at);
if (t.at <= 0) t.at = 30; // "@frame" part optional
t.hold = t.at + 120; // hold long enough that a frame-paced
// pollTick (~34 ms apart) sees it
}
else if (!strcmp(argv[i], "--autoplay")) { emuAutoplay = true; }
#ifdef EMU_APP_MISSILECOMMAND
else if (!strcmp(argv[i], "--wave") && i + 1 < argc) emuStartWaveRequest = atoi(argv[++i]);
@@ -231,28 +258,35 @@ int main(int argc, char **argv)
}
}
// --type: queue the string on the keyboard device like a human typing
// (one char per --type-at start, ~40 ms apart in millis time, so the
// sketch processes each key before the next arrives).
// --type: queue the strings on the keyboard device like a human typing
// (chars ~40 ms apart in millis time, so the sketch processes each key
// before the next arrives; each event starts at its "@frame").
// '\n' emulates Enter: press the trackball pin for one iteration.
static const char *typeNext = nullptr;
static int typePressPin = -1;
static unsigned long lastTypeMs = 0;
if (typeStr && frame >= (uint32_t)typeFromFrame) {
if (typePressPin >= 0) {
emu::pinLevels[typePressPin] = 1; // release the Enter press
typePressPin = -1;
}
if (!typeNext) typeNext = typeStr;
const char *typeEnd = typeStr + strlen(typeStr);
if (typeNext < typeEnd && millis() - lastTypeMs >= 40) {
lastTypeMs = millis();
if (*typeNext == '\n' || *typeNext == '\r') {
typeNext++; // consume the Enter char
emu::pinLevels[BOARD_BOOT_PIN] = 0;
typePressPin = BOARD_BOOT_PIN;
} else {
emu::keyboard.push_back((uint8_t)*typeNext++);
static int curType = 0;
if (curType < nType) {
const TypeEvt &te = typeEvts[curType];
if (frame >= (uint32_t)te.at) {
if (typePressPin >= 0) {
emu::pinLevels[typePressPin] = 1; // release the Enter press
typePressPin = -1;
}
const char *typeEnd = te.s + strlen(te.s);
if (!typeNext) { typeNext = te.s; lastTypeMs = 0; }
if (typeNext >= typeEnd) {
curType++; // event finished
typeNext = nullptr;
} else if (millis() - lastTypeMs >= 40) {
lastTypeMs = millis();
if (*typeNext == '\n' || *typeNext == '\r') {
typeNext++; // consume the Enter char
emu::pinLevels[BOARD_BOOT_PIN] = 0;
typePressPin = BOARD_BOOT_PIN;
} else {
emu::keyboard.push_back((uint8_t)*typeNext++);
}
}
}
}
@@ -272,6 +306,22 @@ int main(int argc, char **argv)
}
#endif
// --tap: scheduled screen taps (left-button touch at x,y from frame N,
// held ~40 iterations so the sketch's frame-paced poll sees it)
for (int i = 0; i < nTaps; i++) {
Tap &t = taps[i];
if (!t.fired && frame >= (uint32_t)t.at) {
emu::touchX = t.x;
emu::touchY = t.y;
emu::touchDown = true;
t.fired = true;
std::printf("[emu] tap %d,%d at frame %u\n", t.x, t.y, frame);
} else if (t.fired && frame >= (uint32_t)t.hold) {
emu::touchDown = false;
t.hold = -1; // released; don't re-release
}
}
// fire any emulated interrupts triggered by the pin changes above
emu::dispatchIsrs();
File diff suppressed because it is too large Load Diff
+75
View File
@@ -0,0 +1,75 @@
To validate the core premise of **NetDeck: Breach & Board**—specifically whether *pausing time to manipulate a network graph while watching an autonomous squad survive a room breach* feels tense, readable, and fun on a 320x240 screen—you only need **one single room-breach encounter**.
Strip out sector maps, upgrades, multiple classes, oxygen systems, and procedural generation. Build a single, self-contained **Vertical Slice Sandbox** with these exact features:
---
### 1. Physical Deck Pane (184x192) — The Combat Arena
* **One Hardcoded 3-Room Floorplan:**
* *Room 1 (Airlock):* Where your squad spawns safely out of enemy line-of-sight.
* *Room 2 (Main Corridor):* Contains 2 low-cover crates and 2 patrolling/stationary security droids.
* *Room 3 (Server Room):* Guarded by 1 heavy droid + 1 automated ceiling turret, housing the objective terminal.
* **2 Identical Marines (No Classes Yet):**
* Represented by simple colored `8x8` or `12x12` sprites with a tiny overhead health bar.
* **Pathfinding:** Simple BFS/A* toward a single player-placed **Priority Beacon** (trackball click on any walkable floor tile).
* **Combat AI:** If an enemy is within range and line-of-sight (simple Bresenham tile raycast), stop and fire periodic hitscan/tracer lines. Standing adjacent to a cover crate cuts incoming hit chance by 50%.
* **2 Enemy Types:**
* *Security Droid:* Basic HP, shoots at marines.
* *Ceiling Turret:* Stationary, high rate of fire, shreds marines in seconds unless hacked or bypassed.
* **1 Interactive Blast Door:** Separates Room 2 and Room 3. Can be toggled open/closed via the network pane to trap droids or buy time.
### 2. Sub-Net Pane (136x192) — The Hacking Graph
* **4 Hardcoded Nodes:**
1. `[AIRLOCK]` (Your starting root node).
2. `[JUNCTION]` (Unprotected bridge node).
3. `[DOOR_CTRL]` (Connected to Junction — toggles the blast door between Rooms 2 and 3).
4. `[HIVE_CORE]` (Connected to Junction — protected by a 3-second ICE lock; controls the droids and turret).
* **Link Routing & Severing:**
* Clicking an adjacent node from an already-compromised node starts building a link (animated dotted line turning solid over 1.5s, or 3.0s if ICE-locked).
* Pressing **`X`** while hovering over a link immediately severs it.
* **Only 2 Exploit Daemons (Keys `1` and `2`):**
* You only need two contrasting verbs to test the tactical loop:
1. **`1: FRENZY` (Offensive Chaos):** Requires an active link to `[HIVE_CORE]`. For 5 seconds, droids and the turret target the closest entity (including each other).
2. **`2: BLIND` (Tactical Utility):** Requires an active link to `[HIVE_CORE]`. For 6 seconds, droids/turret cannot fire, giving your squad time to cross open floor into cover.
* **1 Enemy Counter-Measure (The Red Trace):**
* As soon as your link to `[HIVE_CORE]` finishes cracking, a red pulse spawns at `[HIVE_CORE]` and travels back toward `[AIRLOCK]` over **4 seconds**.
* If it hits `[AIRLOCK]`, your link drops, your deck locks out for 3 seconds ("OVERHEAT"), and a reinforcement droid spawns. Severing the link with `X` before it arrives resets the trace safely.
### 3. Minimal HUD & Flow Control (320x48)
* **`Space` (Tactical Pause):** Freezes the 20 Hz simulation tick instantly and draws a subtle `"PAUSED"` border/tint so you can calmly queue a link or move the squad beacon.
* **`Tab` (Pane Snap):** Warps the cursor between the center of the Left Pane and Right Pane so you never waste time scrolling the trackball across the whole screen.
* **HUD Readouts:** Just `[1:FRENZY] [2:BLIND]`, a `TEMP` bar (or cooldown timer), and a `RESET (R)` hotkey so you can replay the 60-second scenario instantly after winning or wiping.
---
### What to Intentionally Cut from the MVP
To keep this buildable in a few evenings, ruthlessly exclude:
* **RAM / Bandwidth math:** Use simple per-daemon cooldown timers instead of a resource pool.
* **Procedural map/graph generation:** Hand-tune the single 3-room layout until the timing between squad movement, ICE cracking, and the 4-second red trace feels razor-sharp.
* **Sound effects / SD card loading:** Compile your `8x8` sprites and map arrays directly into `const` headers in Flash.
* **Menus, title screens, and progression:** Boot straight into the paused encounter; on win/loss, show a 1-line banner (`BREACH SUCCESS` / `SQUAD KIA`) and let `R` reset the state struct.
### The Litmus Test for This MVP
Once this slice is running on the T-Deck, play it 5 times in a row. If you find yourself naturally hitting `Space` when the turret opens fire, slamming the blast door shut via `[DOOR_CTRL]`, cracking `[HIVE_CORE]` while your squad hugs cover, triggering `1: FRENZY` to watch the turret wipe out the droids, and hitting `X` right before the red trace reaches your airlock—you know the core game loop works and deserves a full sector generator around it.
+33 -1
View File
@@ -8,7 +8,7 @@ milestone lands.
| --- | --- | --- |
| **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 | Node graph in Network view (door nodes on bulkhead tiles), link routing, ICE crack, red trace + `X` sever | planned |
| 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 | 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) | planned |
@@ -56,3 +56,35 @@ milestone lands.
4. `Space` freezes (CRT scanlines, sim/packets halt); cursor stays live.
5. 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 terminal `T`.
- **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.
- **`X` severs 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
(`TEMP` bar). FRENZY/BLIND daemons are gated until a HIVE link is up
(effects land in M4).
- **`R` resets** 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 `r` reset; visual frame dumps inspected.