Repository navigation
platform/web: Game Boy-style WASM title screen and menus - #104
Conversation
Self-contained WASM menu/title renderer for the web emulator:
- Animated beach title baked from a source video into a 160x144,
8-shade flat (no-dither) palette-indexed image (landscape_bg.bin),
decoded in Rust. The sky/title region is frozen for a crisp,
shimmer-free look while the foreground (crabs/waves) animates.
- Crisp all-caps, cream-on-dark-green menus matching the title palette
(web_menu.rs), using a downscaled font8x8 face:
- main menu drawn over the title with an outlined font, centered;
- ROM list / pause / load-state menus with a horizontal name marquee
(1s pause before scrolling, re-anchored per selection), inter-row
spacing, vertical+horizontal centering for short menus, and
vertical scrolling with arrows.
- JS side (menu.js/app.js): all wasm menus render on a time-driven
animation loop so titles and long names scroll; touch hit-testing
follows the layout.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #104 +/- ##
=======================================
Coverage 93.21% 93.21%
=======================================
Files 82 82
Lines 14042 14055 +13
=======================================
+ Hits 13089 13102 +13
Misses 953 953 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
vbonduro
left a comment
There was a problem hiding this comment.
Go through the code and delete unused code after this change
| @@ -0,0 +1,24 @@ | |||
| // Animated title-screen background generated from gemini_generated_video_C5B695AC.mov. | |||
There was a problem hiding this comment.
What is the format of the binary? Add some comments with a description. Encapsulate the formats in structs and create unmarshalling functions for them. You can use pointers to avoid copies
There was a problem hiding this comment.
Refactor the changes in this file. Break large functions into smaller ones, create classes where it makes sense (eg marqueeStartAnimation -> marquee.start) favour return values over output parameters (assuming rvo will keep things efficient?) use functional programming paradigm, keep value boundaries to keep things testable
There was a problem hiding this comment.
Convert to typescript. Find other js and convert them too
There was a problem hiding this comment.
Refactor this file. Breakup large functions, prevent repetition, use classes (eg have a marquee with start function) use functional programming and value boundaries use solid design principles
…eview) - landscape_bg: document the binary format and re-encode it into a compact "RBG1" layout — 3-bit-packed palette indices plus the frozen sky/title region stored once (only the animated beach stored per frame). 2.64 MB -> 0.34 MB (-87%). Encapsulated in a zero-copy LandscapeBg<'a> (parse + render_frame(&mut [u8]); no per-frame Vec). Decoded pixels bit-identical. - web_menu: split the 914-line file into focused modules (marquee/layout/glyph/palette/mod), extract a Marquee type, dedup the two render paths, and delete dead code (quadrant/shade/braille drawers, collapsed draw_symbol, unused color arms). Public wasm API unchanged; 15 tests pass; wasm release build warning-free. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…#104 review) - Add a TypeScript + esbuild pipeline (package.json, tsconfig, build.mjs); convert app.js, menu.js, audio-processor.js to strict TS in src-ts/, emitting the same static/*.js outputs (esm / iife / worklet preserved). - Refactor while converting: a Marquee class (start/stop), pure paint and layout helpers, an AudioRingBuffer, and large functions broken up. - Dockerfile: add a node:20-slim ts-builder stage (npm ci && npm run build) overlaying the compiled JS; .dockerignore excludes node_modules. - wasm-bindgen API usage unchanged. typecheck + esbuild build pass; full cargo xtask deploy web verified end-to-end in a headless browser (title renders, no new console errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
static/app.js, menu.js and audio-processor.js are esbuild output compiled from src-ts/*.ts — they were accidentally committed. Untrack them (already covered by static/.gitignore); the Dockerfile ts-builder stage regenerates them at build time. Only the TS sources and hand-written assets (index.html, style.css) stay in source control. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
menu.ts carried a full second menu renderer (paint* canvas helpers, the #0F380F DMG palette, a JS Marquee, a JS selection mirror) used only when the WASM menu renderer was absent. But menus are only shown after the WASM module initialises, and that same module is the emulator itself — if it failed to load there'd be nothing to play — so the fallback never ran and merely duplicated (differently) what web_menu renders in Rust. Remove it. MenuRenderer is now a thin adapter: blit the wasm render_rgba() frame to the canvas, run the animation loop, and forward keyboard/touch input to the wasm renderer (the single source of truth for selection/scroll). If the wasm renderer is somehow unavailable it logs an error instead of silently drawing a different-looking menu. menu.ts: 662 -> 337 lines. Behavior verified unchanged via a headless-browser smoke test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The ratatui menus (SELECT GAME list, PAUSED, etc.) drew text with the downscaled font8x8 face, whose 2px-wide strokes read as bold. Replace it with a purpose-built 5x7 thin font (1px strokes, A–Z, 0–9 and the punctuation that appears in ROM names) rendered centered in each cell, so game titles render at a regular, lighter weight. The landscape title menu (CONTINUE/GAMES, outlined over the scene) is unchanged. Removes draw_basic_glyph_to_cell + MENU_GLYPH_H; build warning-free, 15 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The ratatui menu cell grid is 26×13 cells = 156×143 px, which doesn't tile the full 160×144 screen, so the 4px right and 1px bottom strips were left transparent and the light DMG screen background showed through as thin green bars. Pre-fill the rasterized buffer with the menu background (C0) so those leftover strips match the menu instead of showing through. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The pause-menu footer "▲▼ MOVE A SELECT B RESUME" (27 cols) and the load-state footer "▲▼ MOVE A LOAD SEL DEL B BACK" (32 cols) overflowed the 26-column menu and were clipped at the right edge (RESUME / B BACK cut off). Shorten both to fit: pause: "▲▼ MOVE A SELECT B RESUME" (25) load: "▲▼ A LOAD SEL DEL B BACK" (24) Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Workspace formatting only (re-indented attributes, multi-line call/macro reflows, trailing-newline trims) from an uncommitted `cargo fmt`. No logic changes. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Add a WasmMenuRenderer stub (show/render_rgba/item_at/move_selection/… — the full menu API) to the Playwright fixture so e2e tests run without the real wasm module. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Ignore .beads/ and .claude/ (local tool state) and the title-screen source media / experiment files (gemini_*, Madagascar*, ferris.png, 331269-*) plus stray index.html?* downloads. Also dropped the unreferenced 560KB landscape_bg.txt (superseded by landscape_bg.bin). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…eview) - landscape_bg: document the binary format and re-encode it into a compact "RBG1" layout — 3-bit-packed palette indices plus the frozen sky/title region stored once (only the animated beach stored per frame). 2.64 MB -> 0.34 MB (-87%). Encapsulated in a zero-copy LandscapeBg<'a> (parse + render_frame(&mut [u8]); no per-frame Vec). Decoded pixels bit-identical. - web_menu: split the 914-line file into focused modules (marquee/layout/glyph/palette/mod), extract a Marquee type, dedup the two render paths, and delete dead code (quadrant/shade/braille drawers, collapsed draw_symbol, unused color arms). Public wasm API unchanged; 15 tests pass; wasm release build warning-free. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
…#104 review) - Add a TypeScript + esbuild pipeline (package.json, tsconfig, build.mjs); convert app.js, menu.js, audio-processor.js to strict TS in src-ts/, emitting the same static/*.js outputs (esm / iife / worklet preserved). - Refactor while converting: a Marquee class (start/stop), pure paint and layout helpers, an AudioRingBuffer, and large functions broken up. - Dockerfile: add a node:20-slim ts-builder stage (npm ci && npm run build) overlaying the compiled JS; .dockerignore excludes node_modules. - wasm-bindgen API usage unchanged. typecheck + esbuild build pass; full cargo xtask deploy web verified end-to-end in a headless browser (title renders, no new console errors). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
static/app.js, menu.js and audio-processor.js are esbuild output compiled from src-ts/*.ts — they were accidentally committed. Untrack them (already covered by static/.gitignore); the Dockerfile ts-builder stage regenerates them at build time. Only the TS sources and hand-written assets (index.html, style.css) stay in source control. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
menu.ts carried a full second menu renderer (paint* canvas helpers, the #0F380F DMG palette, a JS Marquee, a JS selection mirror) used only when the WASM menu renderer was absent. But menus are only shown after the WASM module initialises, and that same module is the emulator itself — if it failed to load there'd be nothing to play — so the fallback never ran and merely duplicated (differently) what web_menu renders in Rust. Remove it. MenuRenderer is now a thin adapter: blit the wasm render_rgba() frame to the canvas, run the animation loop, and forward keyboard/touch input to the wasm renderer (the single source of truth for selection/scroll). If the wasm renderer is somehow unavailable it logs an error instead of silently drawing a different-looking menu. menu.ts: 662 -> 337 lines. Behavior verified unchanged via a headless-browser smoke test. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Self-contained WASM menu/title renderer for the web emulator.
Title screen
landscape_bg.bin), decoded in Rust.Menus (
web_menu.rs)font8x8face.JS (
menu.js/app.js)Build/serve:
cargo xtask deploy web --roms <dir>(Docker build recompiles the WASM and serves at :8080).🤖 Generated with Claude Code