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.
- Replace static horizontal scanlines with diagonal-stripe 8x8 sprite pattern
- Color-key transparency (ND_TRANS16 = 0x1F1F) leaves frozen game view visible
- Lower triangle of each 8x8 cell dims (freeze dim), upper triangle shows game view
- Stamp pattern tiled across viewport in 8x8 grid for 50/50 dim/visible coverage
- renderFreezeTint() called only when paused, integrated into render() pipeline
- All 7 unit tests pass
- 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
- .githooks/pre-commit: runs 'make netdeck-test-unit' (fast layer:
unit + integration) before every commit; bypass with --no-verify
- make hooks: enables the hook for a clone (core.hooksPath .githooks)
- AGENTS.md: toolchain, one-command build/test entry points, hook
install instructions, commit discipline
Builds both targets of the app in one run (pio firmware, then the SDL2
emulator) so a change can never leave one of them silently broken.
Falls back to ~/.platformio/penv/bin/pio when pio is not on PATH.
- 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
Combat half of the MVP vertical slice on the shared coordinate space:
- 2 marines (BFS to the player beacon, stop-and-fire hitscan), cover
crates halve incoming hit chance, overhead + HUD HP meters
- patrol/stationary security droids, heavy droid + ceiling turret on the
objective terminal; feedback spike now spawns a reinforcement droid
- win: marine reaches the terminal (BREACH SUCCESS); loss: SQUAD KIA;
R resets either way; tracers dim in Network view
- firmware build fix: Arduino auto-prototypes break Unit& params
(planPath/unitMove/inCover/acquireTarget now take unit indices)
- HUD fix: R:RESET no longer overlaps RESUME/PAUSE; daemon slots and
SQUAD row spaced out
- STATUS.md: M3 section incl. scope note — BREACH SUCCESS is gated on
the M4 FRENZY/BLIND daemons; loss path + reset verified headlessly
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.
- render into a full-frame RAM second buffer (TFT_eSprite/PSRAM on device,
SDL shim framebuffer in the emulator) and push to the ST7789 as one
continuous SPI stream per frame (MiataDrive anti-tearing pattern)
- keyboard stale-byte flush at boot end; device-trackball constants branch
- examples/NetDeck/platformio.ini: self-contained firmware build
(pio run -d examples/NetDeck), ESP32-S3 compile verified
(RAM 6.7% / Flash 5.5%), binary at firmware/NetDeck_M1_261114.bin
- STATUS.md: M1 tracker + on-device flashing checklist
- IDEAS.md: capture map-scroll and companion-app ideas
Render every frame into a full-frame TFT_eSprite (16 bpp, PSRAM) and push
it to the panel in one continuous SPI stream — direct scattered draw calls
raced the panel scan-out and flickered. renderRoad split into projection
and draw passes: the sky now fills down to the topmost road row (fixes the
stale band at the horizon over crests) and the nearest segment is extended
to the screen bottom (fixes the wobbling stale strip). fillTrap uses
incremental edge interpolation. SPI raised to 80 MHz via build flag
(Setup210 define guarded) so the frame push fits the 33 ms budget.
sprite_tool.py gains a 'clean' subcommand that tidies the sheet in place:
drops specks (<=4px) and 1px sliver lines left over from the original
checker-keyed extractions, and re-centers every sprite in its cell
(bottom-anchored, 2px margin) so nothing touches the cell edges.
Tree trunks / palm fronds are protected from thin-line removal.
Run on the sheet: 489 junk pixels removed; re-import crops tightened
(e.g. car_white_turn 108x60 -> 92x54, car_yellow_turn 86x60 -> 80x56).
- 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
- sprite_tool.py: export renders sprites.h into sprites_sheet.png
(1120x560, 7x4 grid of 160x140 cells, 14px label strip, magenta bg);
import cuts the sheet back into sprites.h with fixed cell order,
magenta keying, halo cut (magenta excess > 35) and despill.
Round-trip is exact via bit-replicating 565->888 expansion; crops
re-trim tighter on each import.
- sprites_sheet.png: the editable asset sheet, tracked in git.
- sprites.h regenerated by the tool (canonical sprite names).
- Drop the original webp sprite sheets; the PNG sheet is the source now.
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 hardware log showed the live mic slots sitting at ~0.6 RMS in
ambient noise. At 37.5 dB the ES7210 was clipping, so the noise floor
slowly climbed to the saturated level and the gate never fired again:
the blip appeared once and then vanished forever.
Use 18 dB analog gain so ambient levels have headroom, lower the gate
to 1.5x the floor so real sounds stand out, and widen the loudness
window to -50..-6 dBFS. The debug line now also prints the
floor-relative signal levels.
The ES7210 power-up transient is loud enough to look like the first
sound. It placed one centred blip right after init and then pinned the
mic pair to whichever slots were loudest at that instant. If that was
the wrong pair, later claps were ignored forever.
Ignore the first 800 ms after starting the codec, and re-evaluate the
mic pair on every clear sound instead of locking once. The pair only
changes after repeating for a few blocks, or immediately when the
current pair is silent while another one is loud. Also enable the
per-second rms/pair debug line so the slot mapping can be verified on
hardware.
I2S_CHANNEL_FMT_ALL_LEFT copies a single channel into every slot, so
both microphones read the same signal and the balance stayed at zero.
Use I2S_CHANNEL_FMT_MULTIPLE (the real TDM mode) instead.
The board only fits two of the four ES7210 mic footprints, but the
schematic carries all four. Rather than hardcode MIC1/MIC3, the detector
now measures the TDM slots and locks onto the two that carry signal,
treating the lower slot as the left microphone. Equal maximum gain is
applied to all inputs so the pair amplifies consistently.
Also widen the balance range (claps produce only a few dB of difference
between the closely spaced mics) and recalibrate loudness to the dBFS
range seen with 37.5 dB analog gain.
Add a SoundDetector that reads the ES7210 as a 4-slot TDM stream
(slot 0 = MIC1/left, slot 2 = MIC3/right), tracks a per-channel RMS
envelope with an adaptive noise floor, and publishes a stereo balance
plus a dB-mapped loudness.
The radar sketch now slides a single reused blip left/right from the
balance and moves it nearer as the loudness rises, instead of firing a
hardcoded demo blip. The device's own ping/click mutes the detector for
200 ms so it cannot hear itself.
The trackball stays detached: GPIO0 is unavailable while the ES7210
microphones are running.
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
- Enemy missile trails now drawn 3px thick via drawThickLine() with a
bright head dot (white) that flashes against the trail color every
couple of frames, like the Atari 2600
- eraseBombTrail() uses a thicker erase band than the draw (5px, 7px for
wigging smart bombs) plus a 2px tip circle, so no trail residue is
left behind when a missile dies or impacts