- 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