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();