velxio/test/pico_doom_demo/compile_check.sh

66 lines
2.4 KiB
Bash
Raw Normal View History

feat(examples): Pico Doom — Wolf3D-style raycaster on RP2040 + ILI9341 A new entry in the games category for the Raspberry Pi Pico. Renders a first-person 3D corridor à la Wolfenstein / early Doom using a column-wise DDA raycaster — 160 rays per frame drawn straight to a 320×240 ILI9341 TFT via drawFastVLine, no framebuffer. 16×16 tile map with 5 wall palettes (slate, blood, brown, toxic green, bronze door), darkened on NS faces so corners read in 3D. Forward / back move, two more buttons turn the player. 40-px HUD bar. Why a demo, not the canonical id Software Doom: Graham Sanderson's rp2040-doom port shoehorns DOOM1.WAD into 2 MB of flash with custom compression and pushes video out over PIO-driven DVI / VGA — none of that survives the rp2040js emulator (no PIO accuracy, no flash mapping for huge assets). A raycaster reproduces the *visual* of early Doom using only ~67 KB of flash and 9 KB of RAM, which the emulator runs perfectly. Pre-flight: arduino-cli compile against rp2040:rp2040:rpipico already verified inside the Velxio backend container — 3 % flash, 3 % RAM. The Adafruit_GFX + Adafruit_ILI9341 libs the example declares are already in the gallery's auto-install list. Bundled: test/pico_doom_demo/arduino_sketch.ino — source of truth sketch test/pico_doom_demo/README.md — what + why + pin map test/pico_doom_demo/compile_check.sh — operator script that runs arduino-cli against the same FQBN the prod backend uses frontend/src/data/examples.ts — gallery entry (boardType raspberry-pi-pico, category games, difficulty advanced, 5 components, 14 wires) frontend/src/__tests__/examples-pico-doom.test.ts — 10 vitest assertions: example is registered exactly once, target board / category / difficulty match, libraries declared, all four pushbuttons present, every wire endpoint references a real component id, SPI pin mapping matches the sketch's #define block, every button has a GND wire, the renderFrame loop is still present in the embedded code.
2026-05-14 03:54:35 +07:00
#!/usr/bin/env bash
# Pre-flight compile check for the Pico Doom raycaster example.
#
# Runs arduino-cli against the same FQBN the Velxio backend uses for the
# Raspberry Pi Pico and exits 0 only if the sketch builds cleanly with
# the gallery's auto-installed library set.
#
# Manual use:
# cd test/pico_doom_demo && ./compile_check.sh
#
# This file is wired into the test/ tree (not the vitest suite) because
# arduino-cli isn't available in the CI image we use for the JS tests;
# the operator runs it before merging the example, the in-repo unit
# test verifies the example data shape.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SKETCH_DIR="$SCRIPT_DIR"
BOARD_FQBN="rp2040:rp2040:rpipico"
BUILD_DIR="$SCRIPT_DIR/build"
echo "─── Pico Doom compile check ───────────────────────────────"
if ! command -v arduino-cli >/dev/null 2>&1; then
echo "ERROR: arduino-cli not on PATH. Install from https://arduino.github.io/arduino-cli/"
exit 1
fi
# Make sure the Pico core is installed. earlephilhower/arduino-pico is
# what the production Velxio backend pulls.
if ! arduino-cli core list 2>/dev/null | grep -q "rp2040:rp2040"; then
echo "[install] adding rp2040:rp2040 core index"
arduino-cli config add board_manager.additional_urls \
https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json \
|| true
arduino-cli core update-index
arduino-cli core install rp2040:rp2040
fi
# Confirm required libs exist; install if absent.
for lib in "Adafruit GFX Library" "Adafruit ILI9341"; do
if ! arduino-cli lib list 2>/dev/null | grep -q "$lib"; then
echo "[install] adding library: $lib"
arduino-cli lib install "$lib"
fi
done
rm -rf "$BUILD_DIR"
mkdir -p "$BUILD_DIR"
echo "[compile] $BOARD_FQBN"
arduino-cli compile \
--fqbn "$BOARD_FQBN" \
--output-dir "$BUILD_DIR" \
"$SKETCH_DIR"
uf2_path=$(find "$BUILD_DIR" -name '*.uf2' | head -n1 || true)
if [ -z "$uf2_path" ] || [ ! -s "$uf2_path" ]; then
echo "ERROR: no .uf2 produced — compile output above"
exit 1
fi
uf2_kb=$(($(stat -c%s "$uf2_path") / 1024))
echo "[ok] built $(basename "$uf2_path") (${uf2_kb} KB)"
echo "──────────────────────────────────────────────────────────"