Commit Graph
223 Commits
Author SHA1 Message Date
Dejvino a243f303f6 emulator-template: Neutralize demo slot, add 10s auto-exit safety hatch
Make the template foolproof to copy-and-fill for a new demo:

- examples/Conway/ replaced by a neutral examples/Demo/Demo.cpp sample
  (bouncing box) documenting the full sketch contract (setup/loop,
  emuGfx::fb, emuGfx::dirty, emu::keyboard)
- Makefile passes the sketch path as -DAPP_SRC; main.cpp now includes
  APP_SRC instead of hardcoding Conway.cpp, window title uses APP_NAME
- Safety hatch: emulator auto-exits after 10 seconds by default so a
  runaway demo can't hang and eat resources; --user-run disables the
  cap, --timeout MS adjusts it (default 10000)
- README rewritten as a step-by-step recipe: replace the Demo sketch,
  run 'make run'; documents all CLI flags, drops the unimplemented
  --dump-interval flag

Verified: fresh copy + sketch swap builds and renders; hatch fires at
10s (and at --timeout 2000); --user-run runs until --frames cap.
2026-11-16 20:25:41 +01:00
Dejvino c331b55d82 emulator-template: Add full emulator-only template package, fix Conway starting paused
Complete self-contained SDL3 emulator-only template for prototyping
sketches without hardware:

- Makefile: single-TU build (host + sketch), run/smoke/clean targets
- shim.h: minimal Arduino API shim (millis, random, String, GPIO stubs)
- src/main.cpp: SDL3 host loop presenting emuGfx::fb, CLI frame dumps
- examples/Conway: Conway.cpp sketch + .ino reference copy
- .gitignore: exclude built binaries and captured BMP frames

The Conway sketch previously started with paused=true, which prevented
render() from being called each frame, leaving the framebuffer all-black
and resulting in a black SDL3 window. Changed to paused=false so the
simulation runs immediately.
2026-11-16 20:22:03 +01:00
Dejvino 303f17c2a6 Forbid airlock-hive connection 2026-11-15 21:54:09 +01:00
Dejvino b38d5d4b56 Extract map-specific data into a generic MapSource interface
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)
2026-11-15 18:21:35 +01:00
Dejvino 7b80854e1d Marines continue walking while firing 2026-11-15 15:41:50 +01:00
Dejvino 9c629b6561 All units have the same shooting distance to make it fair 2026-11-15 15:07:15 +01:00
Dejvino a6ea66d646 Denser encounter: camera nodes, wider garrison, thicker walls
- 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)
2026-11-15 14:56:55 +01:00
Dejvino 8534bdc0b2 Slow down game and make beeps shorter 2026-11-15 13:24:06 +01:00
Dejvino aa517e7a97 Extract playBleep usages into dedicated functions with unified positive/negative confirmation 2026-11-15 12:25:32 +01:00
Dejvino 7df1a2d785 Fix short beeps silent on HW: i2s_zero_dma_buffer erased the unplayed DMA ring
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.
2026-11-15 12:19:21 +01:00
Dejvino 8008b78db0 Fix reinforcement slot index after MAX_UNITS refactor; align E2E freeze-tint sampling 2026-11-15 11:06:33 +01:00
Dejvino 1dcc87d8d4 Fix trackball click: I2S MCLK was claiming GPIO0; emulator pin-ownership parity
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).
2026-11-15 10:24:30 +01:00
Dejvino 4645c7a1c6 Move utilities.h to src/netdeck and remove duplication from examples/NetDeck 2026-11-15 09:49:16 +01:00
Dejvino 01d3d192af current mode visualization 2026-11-15 09:45:28 +01:00
Dejvino ce668a8005 Refactor: replace hardcoded unit array size 7 with nd::MAX_UNITS
- 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.
2026-11-15 09:30:37 +01:00
Dejvino 6c7572bfae Fog of war: LOS-derived current/historical visibility bitmaps + rendering
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.
2026-11-14 23:26:04 +01:00
Dejvino 7ef629d5df Fix Frenzy.EXE: use tile coordinates instead of pixel positions for HIVE frenzy radius check 2026-11-14 23:11:36 +01:00
Dejvino 3cf17a9a5f Add basic sounds and bloops for NetDeck
- Add SoundEngine I2S audio renderer (TONE/SWEEP/NOISE)
- Add gameplay sounds: unit hit, unit death, door open/close, laser fire
- Add network sounds: ICE cracking, trace progress, link severed
- Add UI sounds: click confirm, key presses, view switch, FRENZY/BLIND
- Add network state sounds: node select, link build, ICE cracking
- Emulator: default to 960x720 window (3x scaling)
- Update STATUS.md with M4 done

All 21 tests pass (14 unit + 7 integration, 0 failures).
2026-11-14 19:01:50 +01:00
Dejvino 21d37486cf Emulator: migrate SDL2 -> SDL3
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.
2026-11-14 17:03:30 +01:00
Dejvino 260a2b3d0d Emulator: fix click->touch mapping under Xwayland
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.
2026-11-14 16:13:08 +01:00
Dejvino 396731da9b Freeze mode: diagonal-stripe tint with color-key transparency
- 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
2026-11-14 15:39:56 +01:00
Dejvino cd688b8abe NetDeck: transparent color-key dither for the freeze tint
- 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
2026-11-14 15:33:25 +01:00
Dejvino 83ec0217f4 NetDeck: freeze tint stamps a checkered 8x8 sprite pattern
- 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
2026-11-14 15:24:42 +01:00
Dejvino c80fcc609b Add pre-commit test gate + AGENTS.md
- .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
2026-11-14 15:07:47 +01:00
Dejvino a1d0730124 NetDeck: headless test runner — unit + integration suites, E2E as separate build
- emulator/tests/: harness.h (TEST/EXPECT framework, input + serial +
  framebuffer helpers), shim_globals.cpp (shim externs for test binaries,
  replacing main.cpp ownership)
- unit_tests.h (14): map/door/LOS/BFS/cover/link state machine/trace/
  spike/reinforcement/win/loss/reset — deterministic fixed-seed, sim
  stepped tick by tick
- integration_tests.h (7): keyboard->pollKeyboard->handleKey pipeline,
  beacon clicks -> squad movement, full network journey via clicks,
  hover-sever (incl. safe sever during trace), daemon gating
- e2e_tests.cpp (separate NetDeck-e2e build): real setup()/loop() journeys
  with device-pipeline input injection (boot grace, 0x55 keyboard, GT911
  tap, trackball ISRs), transcript + pixel assertions (HUD, freeze tint)
- shim SerialSim: opt-in transcript ring for test assertions (off by
  default, interactive emulator unchanged)
- make netdeck-test / -unit / -e2e (root) and make test / test-unit /
  test-e2e (emulator/); tests/README.md documents the structure
- STATUS.md: test-structure note

Verified: make netdeck-test -> 14 unit + 7 integration + 3 E2E, 0 failures
2026-11-14 13:02:41 +01:00
Dejvino 383bffc85a Add root 'make netdeck': one command builds firmware + emulator
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.
2026-11-14 12:51:18 +01:00
Dejvino b05d90bd12 NetDeck: move sketch to src/netdeck/ next to nd_layout.h
- 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
2026-11-14 12:15:02 +01:00
Dejvino 5571ec8399 NetDeck M3: squad vs. droids — BFS marines, droid/turret AI, cover, win/loss flow
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
2026-11-14 12:13:33 +01:00
Dejvino 6d2f593bc5 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.
2026-11-14 11:23:37 +01:00
Dejvino 3dcafa25e7 NetDeck M1: hardware sandbox — full-frame sprite rendering + firmware build
- 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
2026-11-14 11:04:24 +01:00
Dejvino 2bfd6c6428 NetDeck M0: emulator sandbox + design doc
- src/netdeck: DESIGN.md (RTwP cyber-tactical ship crawler for T-Deck),
  STATUS.md milestone tracker, nd_layout.h shared constants
- examples/NetDeck: M0 sandbox — 40x24 ship floorplan and 8-node sub-net
  in one shared coordinate space (door nodes pinned to bulkhead door
  tiles); Cameras/Network view modes via P (network overlaid as dotted
  outlines vs dimmed ship + full graph); trackball cursor (edge ISRs +
  momentum); Space tactical freeze with CRT scanlines; 20 Hz fixed-step
  sim (pause-verified frame-identical); keyboard @ I2C 0x55 groundwork
  for M2-M4
- emulator: APP=NetDeck support + Tab key host mapping
- platformio.ini: NetDeck src_dir ready for firmware build
2026-11-14 10:37:35 +01:00
Dejvino d542d6ffa7 MiataDrive: flicker-free framebuffer rendering + 80 MHz SPI
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.
2026-11-12 23:17:43 +01:00
Dejvino 9de07c46dd MiataDrive: fix title menu auto-starting (boot grace + click guard) 2026-11-12 22:42:12 +01:00
Dejvino 6eaac43050 MiataDrive: render optimizations (startWrite batching, fillRect grass/sky, DRAW_DIST 60) 2026-11-12 22:40:43 +01:00
Dejvino 008cfefc4d MiataDrive: unify A/D and arrow steering at 0.4 step 2026-11-12 22:39:34 +01:00
Dejvino 1a1ab8637e MiataDrive: sprite sheet cleanup pass
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).
2026-11-12 22:34:22 +01:00
Dejvino 2ac8706606 Rename Lotus3 to MiataDrive; original-graphics title screen
- 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
2026-11-12 22:29:37 +01:00
Dejvino 3c56f834c2 Lotus3: hand-editable sprite pipeline (sheet image + converter)
- 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.
2026-11-12 22:25:06 +01:00
Dejvino 84b8753150 Lotus3: pseudo-3D Miata racer for T-Deck
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.
2026-11-12 21:49:21 +01:00
Dejvino 25ad8aa17c M314-style radar: dual-mic blips, sweep reveal, fade lifecycle 2026-11-12 20:04:40 +01:00
Dejvino 315cdbd177 Learn the populated microphone slots and DMA packing at runtime 2026-11-12 14:54:47 +01:00
Dejvino 129c670ff4 Drop mic gain out of saturation and soften the noise gate
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.
2026-11-12 14:33:01 +01:00
Dejvino 72f80bfdd8 Make microphone slot discovery self-healing
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.
2026-11-12 14:10:17 +01:00
Dejvino b8de153e5a Fix microphone stereo detection on the T-Deck Plus
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.
2026-11-12 14:04:31 +01:00
Dejvino 2ba92a65d1 Drive radar blips from the T-Deck Plus dual microphones
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.
2026-11-12 08:20:38 +01:00
Dejvino 7dfdc06e6f Add NoiseSensor radar example and fix short sound playback
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.
2026-11-12 08:14:19 +01:00
Dejvino 951c56168c CRT Terminal app 2026-11-11 22:03:40 +01:00
Dejvino 1ef22cc832 Trackball: ISR edge capture + momentum model; extract difficulty tunables
- 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.
2026-11-11 07:32:12 +01:00
Dejvino 798f8600a0 Boot: input grace period; persist high score + volume via NVS
- 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.
2026-11-11 07:05:59 +01:00
Dejvino a5921032d7 Trackball: poll every iteration, count all pulses, accelerate
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.
2026-11-11 06:25:06 +01:00