Mosaico Magic Tower for ESP32-S31
An ESP32 camera project for ESP-Mosaico (ESP32-S31) involving Speaker.
Parts and sourceBefore you start
Check the exact Speaker configuration against the upstream wiring or parts list.
Upstream README
Mosaico Magic Tower
An original fifty-floor Magic Tower for ESP-Mosaico (ESP32-S31, 480×480), built in C with the official Raylib Lite Engine / GSP stack. Author: Ponkan.
Current preview release: v1.8.0-rc.5. Play in English or Chinese, switchable in Settings. Battery initialization now runs after the first healthy frame and automatically retries failures, addressing the persistent -- reproduced after manually entering Vibe Mode and power cycling. Regular polling, maps, music and v8 checkpoints are preserved. One manual power-cycle route passed on the device; intermittent black-screen boots and long-term battery accuracy still require observation. See battery acquisition.
| Title | Chinese dialogue | Throne hall |
|---|---|---|
![]() |
![]() |
![]() |
Download RC5 firmware · Previous RC4 for Iris 0.2. RC5 uses schema esp-iris-system-update/0.2 and requires Vibe Mode 0.2 / Recovery ABI 2. First install the official v0.5.0 system through the official firmware updater if the device still has an old base; this application package does not upgrade it. See firmware downloads.
Campaign
- Fifty authored maps across Broken Gate, Sunken Hall, Ash Works, Silent Court and Star Crown. Resource thresholds, coloured doors, optional guards and return visits determine the route.
- Floors 1–10 are 11×11; later chapters use 13/15/17/19 tiles. 50F is an 11×11 symmetric throne hall, visible in one screen.
- An 11×11 viewport pages automatically when the hero enters a continuing edge. Open edges indicate more map; there are no camera buttons or manual panning.
- Eight hidden rooms: step into a darker wall block to reveal its chamber. The 8F NPC teaches this. Discovery persists in checkpoints.
- Three cross-floor errands, a reversible 14F sluice and three optional sigils. None is required by the ordinary winning routes. A distinct terminal robot waits in the optional 47F room.
- Chinese/English coordinate-specific NPC and event dialogue, with explicit pages, 24px Chinese and 16px English body text.
- Deterministic combat previews, confirmation/cancellation, coloured keys, guarded resource choices and shared shop prices of 15/25/35/... gold (+3 per purchase).
- Ten original music loops: title, five regions, final battle, exploration after victory, victory screen and death screen. Four integer voices, bounded echo and no rendering allocations or streamed samples.
- Volume zero fades/drains playback, closes the codec output and parks the audio task until a changed control arrives. Restoring volume primes silence and fades in; muted track time catches up without continuous PCM writes. The BSP's separate receive channel is unchanged; board power savings and speaker artifacts still need hardware measurement.
- A persistent upper-left battery percentage: white on battery power, green while charging (including full at 100%), with no lightning symbol. Checked gauge samples every five seconds; only changed values request a frame. Rejected samples retry once. Brief failures retain the last validated reading for less than 15 seconds; without one, or once it expires, the HUD shows
--. Valid SOC values are displayed directly, without percentage clamps or voltage-based guesses. - One settings button: language, volume, brightness and the readable GitHub address. Preferences are separate from journey data.
Checkpoints and controls
A new journey and every real stair/warp floor transition save automatically. Same-floor actions, menu visits and death do not overwrite the checkpoint. Failed saves report failure and preserve the previous record.
Footer Warp / Restart replaces manual save/load. Six anchors 1/10/20/30/40/50 unlock by chapter completion. Restart offers checkpoint retry, new game and cancel; new game requires another confirmation. Failed retry preserves the live run. After victory, continue exploring and use all six anchors.
Touch a neighbouring tile or swipe to move. Arrow keys/WASD move in Host; Start confirms, Left cancels. The gear has the previous language button's generous touch area.
Save version v8, 2632 bytes, includes checksum and semantic validation. v7 and older journeys are rejected, because their consumed-tile coordinates belong to different maps. Starting a new game replaces the journey only after confirmation; no NVS erasure is needed.
Validation
Use Python 3.10+, GCC and Pillow. Set CC to the compiler and MOSAICO_ENGINE_ROOT to the pinned official engine checkout, then:
python tools/verify_campaign_release.py
python tools/render_music.py
The suite retains logs in artifacts/campaign-validation/: five production routes with every-action save roundtrips; 2632 byte-corruption checks; semantic forgeries; actual input/dialogue/errand/checkpoint replay; restart, camera, settings, brightness and idle regressions; 112 real C bilingual page renders; all-track audio bounds; complete official Host ABI replay and screenshots. The four authored ordinary/alternative routes plus the secret/errand route prove specific winning paths, not every possible strategy or final balance. The attack-first witness ends with only 10 HP.
tests/run_tests.py runs the current portable model/campaign checks. Historical ten-floor test_tower.c, test_level_design.py, test_integration.py, test_guarded_forks.py, old strategy planners and capture_screens.py describe v1.6 and are not current acceptance commands. Use tools/capture_campaign_host.py for actual production gameplay screenshots; capture_campaign_design.py is a camera-only map QA facade.
Official build
This repository is a project inside the official ESP-Mosaico workspace, not a standalone ESP-IDF app. Put a real source copy under projects/magic_tower and preserve its relative component overrides. Verify ESP-IDF commit 7b9cc1ac79f865983f59bb8ff3ff43eb74ff1dbe and engine commit ca3200a6b7f63e2bdea07851e19fdbd3a42eb742.
For the current website, use the official utilities revision 73b4a37df6d7354cff339daf11b0aaa58ef582a2 with Recovery ABI 2. The older consumer-workspace tag alone does not ensure that version. See Iris 0.2 integration and offline export before building. Do not change an old bundle's schema string or install an ABI 2 application on an ABI 1 base.
A fresh engine needs tools/patches/raylib-lite-engine-settings-display.patch for existing display ownership integration. Inspect existing edits first; the development workspace already has it. Never reset or apply it twice.
From the official workspace, follow its build-doctor skill, then:
python mosaico.py game sim --project projects/magic_tower --headless --frames 120
python mosaico.py game build --project projects/magic_tower
Installation is a separate step through the official mosaico.py iris workflow after device identity, mode and layout compatibility checks. Preserve retained Vibe Mode firmware and the immutable partition prefix; do not use direct flash commands.
Sources
main/tower.c owns gameplay and save validation; tower_floors.c contains the exact approved maps. game.c owns input and screen state; game_view.c is shared Host/device drawing. campaign_dialogue.h and game_music_score.h are deterministic generated tables.
Design sources, maps, copy, music and route reports are under assets_src/level_design and docs/level-design. Reproduce generated tables with tools/gen_campaign_dialogue.py and tools/gen_campaign_music.py; regenerate CJK glyphs with tools/gen_ui_font.py (optional MOSAICO_UI_FONT override). Keep all three in sync.
Operation-driven drawing and the 15 Hz active cap remain in place. Host CPU timings do not establish device temperature, battery life, touch feel or speaker quality. This revision still needs hardware acceptance.
License
Project code, original maps, procedural art and scores use MIT; see LICENSE and NOTICE for retained upstream notices. No third-party map, sprite or music samples are bundled.


