Commit Graph
20 Commits
Author SHA1 Message Date
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
Dejvino 0f85c75331 Missile Command: arcade rules, crafts, trail system v2, emulator wave skip
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
2026-11-10 23:42:01 +01:00
Dejvino 45ffa87425 Trails: match erase width to draw width, bright flashing missile head
- 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
2026-11-10 22:11:33 +01:00
Dejvino d4e6b4e6be Add Missile Command game for T-Deck + desktop emulator
Game (examples/MissileCommand):
- Classic Missile Command: 6 cities, 3 batteries x 10 missiles,
  escalating waves, smart bombs, score multiplier, session high score
- Trackball aims, press/tap fires, keyboard A/S/D selects battery,
  screen tap aims+fires
- Rendering: incremental TFT_eSPI drawing (persistent enemy trails that
  vanish on death, no AA-rocket trails, explosion circles that repair
  terrain, ghost-free crosshair)
- Sound (sound_engine.cpp): non-blocking I2S task on core 0; wave-start
  alarm of four falling tones (like the original), sweeps/noise effects,
  U/V/M keyboard volume control with OSD, master volume scaling

Emulator (emulator/):
- SDL2 host that compiles the unmodified sketch against shim headers
  (Arduino, TFT_eSPI->framebuffer, GT911 touch, I2C keyboard, I2S->SDL
  audio); arrow keys emulate the trackball, --autoplay/--frames/--dump
  flags for headless smoke tests
2026-11-10 22:06:41 +01:00