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)
- Map: 6 new wall pillars/stubs + 4 new cover crates; all load-bearing
fixtures (blast door, airlock, terminal, LOS/fog test lines) preserved
- Network: 4 -> 7 nodes, 3 -> 6 edges; new Camera node type (C_CAMERA)
sees farther (FOG_CAM_R=6 vs FOG_NODE_R=3) and draws a dotted sight
ring when online; fog radius is now a per-node sight field
- Garrison: 8 -> 12 units (room-1 patrol, server-room guard, corridor
patrol, turret on the door approach)
- Fix link slot/edge index conflation in linkOnEdge(): out-of-order
routes (e.g. JUNC-CAM1 in slot 1) shadowed JUNC-DOOR with a permanent
LINKING... refusal; NetLink now carries its edge id
- Tests: unit/fog_camera_sees_farther, unit/link_slots_dont_shadow_edges
(verified failing against the old code)
The legacy I2S driver buffers i2s_write() data in a TX DMA ring
(8x64 samples = 64 ms @ 8 kHz) and hands a buffer 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 zeroing
wiped it before the DMA reached a single sample: completely silent on
hardware. Longer tones force i2s_write() to block on a full ring,
pacing rendering to real-time playback — hence only long beeps were
audible, and the fade-envelope cap never moved the threshold. Every
game beep <= 80 ms (link-active 10, laser 30, sever 40, bleep/ICE 50,
feedback 80) sat in the dead zone. The emulator never showed it: its
i2s_write shim fed SDL directly and had no ring at all.
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(), reusing each DMA buffer only after the DMA played it. The
sound plays out fully and the ring then loops silence (still kills the
tail-replay bug the zeroing existed for). Keep the envelope cap at
total/4 so short tones keep a steady-state portion.
Emulator shim gains a TX DMA ring model (write/play cursors + bounded
DAC-emitted log) so the bug class reproduces headlessly: unit/
sound_short_tone_reaches_dac fails on the zero_dma code, passes on the
purge (A/B verified); shim_zero_dma_erases_unplayed pins model fidelity;
sound_long_tone_plays_out_fully guards against truncation. SoundEngine
gains a pumpOne() test seam and begin(spawnTask) for deterministic
driving. Full suite: 26 unit + 7 integration + 4 E2E, 0 failures.
Root cause (on device): 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. Verified on device with a diagnostic build: pin0 read
LOW at idle, exactly one latched FALLING edge, clicks never registered.
- sound_engine: set pins.mck_io_num = I2S_PIN_NO_CHANGE explicitly.
- NetDeck: register the trackball click on release with contact-bounce
collapse (the proven CrtTerminal pattern); pollTouch re-arms when
isPressed() stays true but getPoint() reports no points (stuck GT911
IRQ on some units).
- Emulator parity (so this class of bug dies before flashing):
GPIO-matrix pin-ownership model in the shim — i2s_set_pin() claims
its pins, claimed pins are dead inputs (digitalRead LOW, no edges,
loud WARNING on claim/ISR collisions); host pin writes go through
emu::setPin/togglePin with an edge-accurate ISR latch (a full
press+release pulse between dispatches no longer gets swallowed);
E2E inits SDL_INIT_AUDIO so the I2S path actually runs there.
Regression coverage: e2e/trackball_click (fails on the old engine),
unit/shim_claimed_pin_is_dead_input,
unit/shim_edge_survives_same_dispatch_pulse.
- Makefile: firmware step follows the sketch move (root platformio.ini,
src_dir = src/netdeck).
- HW.md: new notes file for emulator-vs-hardware quirks and the
on-device debugging recipe.
On-device verified: clicks register in both views (beacon drops, node
routing). Fast layer 23 unit + 7 integration green. Note: e2e
boot_and_controls + network_journey failures are pre-existing at HEAD
(reproduced on a clean stash before this change).
- Replace hardcoded with in NetDeck.ino (8 occurrences)
- Add to nd_layout.h
- Update test expectations in unit_tests.h and integration_tests.h from units[6] to units[7] to match the new reinforcement slot indexing
This enables supporting more than 7 units in the future.
Replace the fading visibility[] stub with two bitmaps over the tile grid:
fogNow (visible this tick) and fogSeen (persistent historical memory),
re-derived each sim tick via revealLos() Bresenham raycasts from:
- each living marine's 8-tile sight window (= marine fire range, so the
squad never shoots into darkness), and
- each online network node uncovering its connected tiles (3-tile window).
Rendering (renderMap): never-seen -> flat dark gray, historical ->
luma grayscale via gray565(), current -> full palette. Hostiles on
non-visible tiles are hidden in renderUnits. Ad-hoc revealTile() stamps
(marine step, door/HIVE links, hand-placed airlock tiles) removed; fog
refreshes on door toggle and scenario reset.
Tests: 5 new unit tests (initial reveal, wall blocking with face render,
historical persistence, node uncover/sever, gray565 channels) plus a
regression pinning fog sight >= marine fire range.
Port the shared emulator harness (all apps) to SDL 3.4 + SDL3_ttf 3.2:
- window creation without position args; renderer logical size via
SDL_SetRenderLogicalPresentation(LETTERBOX); SDL_RenderTexture;
SDL_SaveBMP_IO frame dumps
- SDL_EVENT_* event scheme, flattened SDL_KeyboardEvent, float mouse
coords; clicks mapped with SDL_ConvertEventToRenderCoordinates, keeping
the Xwayland global-state cross-check from 260a2b3
- audio shim on the stream API (SDL_OpenAudioDeviceStream +
SDL_PutAudioStreamData) since SDL_QueueAudio is gone
- TTF_RenderText_Blended (explicit length); SDL3_ttf header layout
handled via __has_include (Ubuntu installs under SDL3_ttf/)
- e2e freeze-tint pixel assertions updated to the committed
diagonal-stripe pattern (stale since the freeze rework; pre-existing
failures at HEAD under SDL2), sampled away from the freeze text
Full suite green: 14 unit + 7 integration + 3 E2E journeys, 0 failures.
MissileCommand, MiataDrive, NetDeck build; CrtTerminal (missing sndBlip
declaration) and Lotus3 (sketch not in repo) fail identically at HEAD -
pre-existing, out of scope.
The X server can deliver pointer event coords in a scaled space
(observed: exactly half the true window-relative position), so clicks
mapped to half the intended device coords (e.g. tile 19,11 instead of
39,23 at the map's bottom-right corner). Reconstruct the cursor position
from SDL_GetGlobalMouseState() - SDL_GetWindowPosition() (raw root
coords, unaffected by event scaling) when it lands inside the window,
falling back to the raw event coords otherwise. Also map clicks through
the SDL_RenderSetLogicalSize letterbox viewport instead of scaling
against the full window size.
- stampImage16_P(): PROGMEM 16bpp stamp with color-key transparency
(ND_TRANS16 pixels leave the destination untouched) — TFT_eSprite has
no transparent pushImage variant, so it composites via drawPixel on
both backends (sprite RAM on device, host framebuffer in the emulator)
- shim: pgm_read_byte/word/dword macros (flash is memory-mapped on
host and ESP32 alike)
- pattern: 2px checker of black dots + transparent cells — half-visible
dither, map/units stay readable underneath
- E2E now proves the transparency itself: wall pixels survive under
transparent cells, dots render black, key color never rendered
- replace the nonexistent draw16bppSprite_P(NULL,...) call with
pushImage(bx, by, 8, 8, checkered8x8): device = TFT_eSprite::pushImage
(blits into the fb sprite), emulator = new shim TFT_eSPI::pushImage
blit into the host framebuffer — same signature on both backends
- shim: define PROGMEM (no-op on host/ESP32, flash is memory-mapped)
- pattern data fixed into a real 2px checkerboard (black / 0x1F1F teal)
- E2E pixel assertions updated to the checker geometry
Verified: make netdeck (both targets) + full test suite, 0 failures
- src/netdeck/NetDeck.ino (git mv); the ../../src/netdeck include became
a plain "nd_layout.h"
- examples/NetDeck/platformio.ini: src_dir = ../../src/netdeck, -I . for
utilities.h (pio build green: RAM 8.6%, Flash 5.6%)
- emulator Makefile: NetDeck APP_DIR -> ../src/netdeck, extra -I for
utilities.h; make APP=NetDeck + smoke verified green
- STATUS.md: notes the new source layout
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.
- examples/Lotus3 -> examples/MiataDrive, sketch MiataDrive.ino,
emulator target APP=MiataDrive, platformio src_dir updated
- drop the borrowed photo title background (title_bg.h): the title
screen now renders the game's own start line under the arch with the
selected car parked on the road; color picker labels sit over the
horizon, showcase car doubles as the live preview
- add dedicated README (controls, features, sprite pipeline, gallery)
- commit in-progress work the game now depends on: sound engine events
(engine hum, crash noise) plus the 4-line SDL audio shim in the
emulator host
Segment-based pseudo-3D road (curves + hills, Jake Gordon technique):
perspective trapezoid rendering near->far with hill clipping, scrolling
rumble strips and lane dashes, depth fog, low camera for planted feel.
Sprites extracted from the provided spritesheet: red Miata player car,
blue/dark/yellow traffic with collision, palms/pines/bushes/billboards,
start-finish arch, tire stacks. Off-road excursions trigger a rollover
crash animation cycling the extra car views with dust, slide and camera
whiplash; rear-ending traffic jolts the camera.
Manual driving by default (arrows/WASD, P toggles demo AI); 3 laps with
checkpoint time, score, speed HUD. SDL emulator target added to the
emulator Makefile and platformio.ini src_dir switched to Lotus3.
The sound task used to zero the I2S TX DMA ring as soon as the event
queue drained. i2s_write() only queues samples, so anything shorter than
the ~64 ms ring was erased before it reached the speaker. Enable
tx_desc_auto_clear instead, which clears each descriptor after the DMA
has actually transmitted it.
Also add the NoiseSensor radar example and point the default PlatformIO
environment at it.
- Trackball edges are counted by IRAM_ATTR ISRs (4 quadrant pins + BOOT
click), so nothing is lost while loop() stalls in long TFT draws.
The old ~1 ms polling hot path is gone.
- Debounce is handled by the momentum model itself: edge counts are
impulses on a heavy ball, friction bleeds velocity off each frame.
Contact bounce decays into a sub-pixel nudge and never reverses
motion, so no time-gate is needed. Slow rolls glide in 1-px steps
via sub-pixel accumulators; hard flicks stay capped.
- Per-platform sensitivity: device gets 4x impulse per edge (its real
pulse rate is far lower than the emulator's synthetic streams) plus
lower friction; selected via the shim's EMULATOR define.
- Emulator shim: attachInterrupt/detachInterrupt emulation; handlers
are dispatched from the host loop when pin levels change.
- MissileCommand: extract arcade difficulty scaling into a tunables
block (wave quota, bomb speed, spawn pacing, smart-bomb chance,
craft speeds/drop rates, scoring, score multiplier, bonus-city
interval, mercy rules). Formulas unchanged, only symboled.
- Ignore all input for ~1.2 s after power-up/reset (INPUT_GRACE_MS):
the keyboard controller can emit stale bytes and pins can float,
which used to start a game right after a restart.
- High score + volume survive power cycles: Preferences (NVS, 'mc'
namespace) loaded in setup(), saved on game over and on every
volume key (U/V/M). arduino-esp32 commits NVS in end(), so
savePrefs() does putUInt x2 + end() + begin() reopen.
- SoundEngine::setVolume() restores a saved level (0 = stay muted,
lastVol_ keeps unmute working).
- Emulator: file-backed Preferences shim (mc-prefs.cfg, gitignored)
so persistence is testable on the desktop.
The crosshair crawled one 14px segment per tick because the ball pins
were sampled only once per game frame (33 ms) and just compared to the
previous level: a fast roll completed whole pulse cycles between reads,
so most edges were dropped and at most one step per frame was applied.
Now pollTrackball() runs in the loop() hot path (~1 ms apart) and counts
every edge into per-direction accumulators; applyTrackball() consumes
them once per frame, moving the cross steps * CROSS_STEP and capping at
CROSS_MAX_STEP (48 px/frame) — slow roll = fine steps, hard flick =
the cursor flies across the screen, arcade-style. Accumulation is
disabled outside PLAYING/BANNER and the first read is primed so the
power-up pin levels don't count as steps.
Emulator: mouse wheel now simulates ball pulses (6 edges per notch,
drained one toggle per iteration) for desktop testing.
Game (examples/MissileCommand):
- Trails rewritten as an analytic flight path (pos is a pure function of
distance travelled): paint and erase replay the exact same pixels, so
blinking trails leave zero residue. Smart bombs wiggle (S-curves) with
deterministic paths; erase band widened to a symmetric 7px so the ±1px
Bresenham slope jitter between paint/erase endpoints can never leak
paint ink (verified zero strays across dense frame captures).
- 2600 look: bright steady missile head dot with a flashing trail
(shared blink phase), trails vanish on death/impact; AA rockets stay
moving dots.
- Arcade rules: bomber planes (100x mult) and satellites (250x mult)
cross the sky dropping bombs; max 3 city kills per wave; bonus cities
at every 10k kept in reserve and deployed between waves; battery
silos rebuilt and replenished at each wave start (they no longer stay
dead across levels); center battery fires fast rockets, sides slow.
- Wave-start attack alarm (four falling tones, once); volume U/V/M with
OSD; sound task zeroes the I2S DMA ring when the queue drains so a
finished sound's tail no longer loops forever.
Emulator:
- --wave N flag to skip straight to a wave for quick testing
- --dump-interval N rolling frame captures (seq%05d.bmp)
- shim: uxQueueMessagesWaiting added