Skip to content

Launcher and pause menu on emu-ui (shared with esp-box-emu) - #26

Merged
finger563 merged 12 commits into
mainfrom
feat/emu-ui
Nov 20, 2026
Merged

finger563 merged 12 commits into
mainfrom
feat/emu-ui

Conversation

@finger563

@finger563 finger563 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The launcher and pause menu now come from emu-ui, an LVGL component shared with esp-box-emu (added as the components/emu-ui submodule). components/gui and components/menu are now thin adapters that supply the games, boxart, settings and save slots. Their public APIs are unchanged, so main and the USB link's remote control work as before.

Launcher

  • Console tabs along the top, each console in its own colors and background.
  • The selected game's boxart, title and a Play button.
  • Each game shows its save count (emu_ui::count_saves over Cart::save_dir()), recounted when a game exits.
  • A console picker grid (X / F, or tap a tab).
  • A settings panel that slides in from the right (B, or the gear).
  • The dpad moves the selection; the list scrolls only once the selection reaches the top or bottom.

Pause menu

  • The paused frame and the slot's screenshot over the game's console background.
  • Resume / save / load / slot / reset / quit, plus the settings.
  • The game's title scrolls if it doesn't fit beside "Paused", the FPS and the battery.

Other

  • rom_info: the console color / shape fields are gone (emu-ui's ConsoleStyle has them).
  • console_art.{hpp,cpp} removed.
  • CONFIG_ESP_TIMER_TASK_STACK_SIZE raised from 6144 to 8192, as on the box: building the settings panel overflowed 6 KB.
  • CI initializes the new submodule.

The matching esp-box-emu PR: esp-cpp/esp-box-emu#141

Fixes for what the new UI caused (found in soak testing)

  • Plain malloc goes to PSRAM first at every size (CONFIG_SPIRAM_MALLOC_ALWAYSINTERNAL 256 -> 0, as on the box). At 256, small allocations went to internal RAM first (the config comment said the opposite). With the new launcher's game strings, that left MGS about 500 B of DMA-capable memory and a black screen. Launcher free internal RAM goes from 47 to 82 KB and DMA-capable from 8 to 43 KB.
  • The pause menu's two screenshot buffers (PSRAM) are allocated when the menu opens and freed when it closes, not held for the whole session.
  • emu-ui: the pattern tiles are a fixed table rather than a std::map (no heap node per console).

The other bugs the soak tests found are not about the UI and are in a separate PR, as is executing from flash.

Testing

  • Built and flashed to a Tab5 over emulink (v1.0.0-18-g53edf44; the soak tests below ran with the separate fix PR on top).
  • Launcher: navigation, console switching, picker, settings (value changes) and save counts checked on the device.
  • Pause menu: open (select+start), resume, quit. Its look was checked on the device by eye (USB screenshots don't work while it's open) and in emu-ui's desktop preview.
  • Soak over emulink: 19 launches across every core (NES, GB/GBC, SMS/GG, Genesis, MSX, SNES, GBA, PICO-8, Doom, Dark Forces, MGS, TPM, ScummVM) with free internal RAM flat to the byte from one launch to the next; 20 NES launches in a row; 3 Dark Forces launches; MGS plays.

🤖 Generated with Claude Code

https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY

finger563 and others added 5 commits November 18, 2026 22:59
The launcher and the pause menu are now emu-ui's (components/emu-ui, a
new submodule shared with esp-box-emu); gui/ and menu/ keep their APIs
and supply the games, the images and the settings:

- consoles as tabs along the top, the list with the console's name over
  each group, the selected game's cover, console, title and Play, over
  the console's background (an accent, colors and a pattern per console)
- settings in a panel from the right (B or the gear), the console picker
  as a grid of tiles (X), button hints along the bottom
- the pause menu: the paused frame, the slot with its screenshot, the
  actions and the settings in one list, over the game's console
- rom_info's ConsoleInfo keeps name, short name and key; the colors and
  the icon are emu-ui's (console_style)
- the keypad: an object flagged LV_OBJ_FLAG_USER_1 gets up / down as keys
  too (emu-ui's list, rows and picker), not only left / right

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…flowed 6 KB

Opening the settings panel builds its rows inside LVGL's key event, on
the Gui task's timer (the esp_timer task), and overflowed its 6 KB.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
The Gui counts the save states in Cart::save_dir() (emu_ui::count_saves)
on each reload and each return from a game, rebuilding the list when
the counts changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@github-actions

github-actions Bot commented Nov 19, 2026 •

Copy link
Copy Markdown

ESP-IDF Size Report for 'Tab5 Emu'

Metric Base PR Delta
FLASH 0 bytes (0.00%) 0 bytes (0.00%) 0 bytes (0.00%)
DRAM 269,596 bytes (61.09%) 269,724 bytes (61.12%) 🔺 +128 bytes (+0.03%)
IRAM 0 bytes 0 bytes 0 bytes
RAM (DRAM+IRAM) 269,596 bytes 269,724 bytes 🔺 +128 bytes (+0.03%)

FLASH uses app .bin size or json2 flash sum. RAM sums DRAM+IRAM via idf_size. Percentages shown when totals are available.
DRAM/IRAM usage does not include memory used by the heap allocator at runtime.
This report was generated by esp-idf-size-delta.

finger563 and others added 7 commits November 19, 2026 12:31
The pause menu held 1.2 MB of PSRAM for its two screenshots while the
game ran; Jedi Knight's level load needs every MB. They are allocated
(heap_caps_malloc: no throw, no screenshot if there is no room) when the
menu opens and freed when it closes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
ALWAYSINTERNAL=256 sent every allocation of 256 bytes or less to internal
RAM first (the comment said the opposite): the emu-ui launcher's game
titles, every small std::string and map node. With the new launcher that
left Metal Gear Solid ~500 bytes of DMA memory and a black screen, and
drifted internal RAM down per console shown. As on the box, code that
needs internal or DMA memory asks for it explicitly.

Launcher: internal free 47 -> 82 KB, DMA-capable 8 -> 43 KB; in MGS 53 /
14 KB (was 17.6 / 0.5 KB); a 19-game soak keeps internal RAM flat.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
A function-local static vector kept 112 KB (up to 478 KB in hi-res) in the
middle of the PSRAM heap after the game, cutting its largest free block
from 6.4 to 3.7 MB for good.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
nofrendo registered its pads again at every NES start and wrote past its
32-entry input table on the 17th game since boot (a load fault in
mmc_peek / retrieve_type).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…he status

Dark Forces' fallback allocations (and the std::string / map template
copies other code links from its library) asked for MALLOC_CAP_DEFAULT,
internal RAM first. After the fix three DF launches leave internal RAM
flat (only the first launch's two mutexes stay, as on the box).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
…keys

fmsx feat/start-key:
- Start was fMSX's own menu, which halts emulation. It is now the MSX's F1
  (pause in Konami's games), and Y opens fMSX's menu. Start + select (the
  pause-menu chord) no longer also toggles the on-screen keyboard.
- A frame is an emulated frame, not a drawn one (every other with -skip
  50): muted, MSX games ran at twice their speed, and the fps was per pair
  of frames.
- The on-screen keyboard's F1-F8, Insert, Delete and Stop indexed past
  fMSX's key table; they press the right keys now.

The README describes the MSX controls.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
The fixes the soak tests found that are not about the launcher and pause
menu (nofrendo's input table, SNES's screenshot buffer, Dark Forces'
allocator fallback, emulink's fps status, the MSX controls) go to a separate
PR. This one keeps the fixes for what the new UI itself caused: the pause
menu's screenshot buffers, plain malloc in PSRAM first (with the new
launcher, MGS had no DMA memory left) and emu-ui's tile table.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
@finger563
finger563 merged commit 92fb2db into main Nov 20, 2026
1 check passed
@finger563
finger563 deleted the feat/emu-ui branch November 20, 2026 18:54
finger563 added a commit that referenced this pull request Nov 20, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
finger563 added a commit that referenced this pull request Nov 20, 2026
main's tree is 91b1772's, which this branch already contains, so the
result is this branch's tree; the gui conflicts were the squashed copies
of #26's changes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
finger563 added a commit that referenced this pull request Nov 20, 2026
README conflicts: the layout block main edited now lives under
Development (its menu/ line updated there), and the MSX controls from #28
join the per-game controls after Star Trek.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SFCMzomCZ5wRHJN4sxwkvY
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant