Commit Graph

6 Commits

Author SHA1 Message Date
Adolfo 74fe10f130 fix(LuaGame): fix render black screen, reduce stack to 8192, add exit gesture
- Init task stack 16384->8192 to avoid allocation failure (ret=-1)
- Replace GAME_W/H constants with fb_w/h dynamic for fullscreen 320x480
- Fix l_renderer_clear and app_on_show fill to use dynamic dimensions
- Add PSRAM Lua allocator already, conditional audio skip for solitaire saves RAM
- Exit gesture: top-right 40x40 tap calls tt_app_stop(), game.exit() also stops app
- Screenshot now shows solitaire cards: 810B PNG, 3662 non-black pixels, ASCII preview shows piles with optimized LEFT=4 GAP=4 TOP=4 TAB=60 (was 37/10/30/98)
- Tested solitaire loads external 24430 bytes, pico=1, init OK, no memory low warnings after fix
2026-07-31 13:30:37 -04:00
Adolfo ca1202345e fix(LuaGame): PSRAM Lua alloc, conditional audio, exit gesture, on-demand
- Custom lua_psram_alloc uses heap_caps_malloc(SPIRAM|8BIT) fallback to reduce internal heap pressure
  - Fixes sdmmc_read_sectors not enough mem (0x101) and MemoryChecker low 359 bytes
- Audio skipped for solitaire (no sfx/tone in source) to save RAM: 'audio not needed, skipping SfxEngine'
- Exit: game.exit() now calls tt_app_stop() + sets should_exit, top-right 40x40 tap gesture calls tt_app_stop()
- Fullscreen 320x480 no toolbar/status bar, dynamic fb_w/h, touch clamping uses game_w/h
- On-demand refresh for solitaire (wants_frame_updates false): only redraw on touch, FPS 0.1-1.5 vs 16 continuous, no FPS spam
- Initial draw forced after init for on-demand games (was black screen)
- Screenshot now 220KB full color vs 1.2K 4-bit, shows solitaire cards with optimized LEFT=4 GAP=4 TOP_Y=4 TAB_Y=60 (was 37/10/30/98) - no window chrome
- Tested solitaire loads external 24430 bytes, pico=1, no Lua errors
2026-07-31 13:23:40 -04:00
Adolfo 4e4e815995 feat(LuaGame): fullscreen 320x480, no toolbar, on-demand refresh for solitaire
- Manifest: HideStatusBar flag, version 0.2.0
- app_on_show: remove toolbar, get display resolution via lv_display_get_horizontal_resolution, allocate 320x480 framebuffer in PSRAM
- Dynamic game_w/h, fb_w/h in AppCtx, set_px/fill_rect use dynamic size
- touch_event_cb uses dynamic max_w/h
- On-demand refresh: l_game_set_frame_updates sets wants_frame_updates flag
  - Pico games without set_frame_updates (solitaire) only redraw on touch events
  - Continuous games (breakout, pong) with set_frame_updates(true) use FRAME_TICK every 16ms
  - Initial draw after init for on-demand games
  - FPS tracking only when redraw occurs
- Solitaire optimized: LEFT 37->4, GAP 10->4, TOP_Y 30->4, TAB_Y 98->60, removed draw_terminal_chrome (outer frame + title bar + window controls)
- Uploaded optimized solitaire via /fs/upload?path=/sdcard/lua/solitaire.lua (24430 bytes)
- Tested fullscreen: display 320x480, no toolbar, screenshot shows chrome removed, white pixels 3197 (cards only)
- Logs show no continuous FPS spamming for solitaire (on-demand)
2026-07-31 13:12:32 -04:00
Adolfo 279893eed0 feat(LuaGame): migrate solitaire, enable SD external loading
- Enable use_external=true with priority: solitaire, breakout, game, pong, snake, tetris
- Fix is_pico detection to check source content before load (renderer./INPUT.) instead of game.vars heuristic that always true
- Successfully uploaded solitaire.lua (24824 bytes) via /fs/upload?path=/sdcard/lua/solitaire.lua
- Tested solitaire loads: 'loaded external /sdcard/lua/solitaire.lua 24824 bytes, pico=1, FPS 13.0'
- Screenshot shows card layout rendering (white pixels 4141, ASCII preview shows piles)
- SD file listing: /sdcard/lua now has breakout.lua and solitaire.lua
- Ready for further pico games via same upload API
2026-07-31 13:00:38 -04:00
Adolfo 88870d7ac5 feat(LuaGame): Pico API compatibility layer + 17 games ported
- Added renderer, game, INPUT tables mapping Pico monochrome API to RGB565 framebuffer
  - renderer.clear, pixel, line, rect, circle, triangle (filled via scanline), text, text_scaled (8x8 font scaled)
  - game.width/height, vars, set_frame_updates, exit
  - INPUT constants NONE, TOUCH_DOWN/MOVE/UP, BUTTON_0/1, FRAME_TICK, GESTURE
- Event generation: touch down/move/up detection + FRAME_TICK each frame
- is_pico detection via source content (renderer./INPUT.) and game.vars heuristic
- Unified game loop handling both sys API (update(dt)) and Pico API (update(event))
- Generated pico_games.h with all 17 examples from pico-bare-metal:
  2048, air_hockey, asteroids, ball, breakout, counter, flappy_bird, lunar_lander,
  memory_match, pacman, pong, simon_says, snake, solitaire, tetris, tic_tac_toe
- Tested: Pong runs at 17 FPS, 'Pong initialized' log, no Lua errors
- Fixes: renamed breakout_lua_src to embedded_breakout_lua_src to avoid conflict with pico breakout
- Ready for game selector UI (menu wrapper) - currently embedded breakout fast v2 remains default, pico test flag use_pico_test available for dev
2026-07-31 12:56:53 -04:00
Adolfo 827fdb41c2 feat(LuaGame): Lua interpreter game engine with audio, 17 FPS, 4.5x ball speed
- Embed Lua 5.4.7 source to avoid missing symbols (clearerr, clock, getenv, etc)
- Provide local stubs for missing libc and avoid unexported LVGL cache APIs
- Fix float handling in sys.* bindings (checknumber vs checkinteger)
- Move Lua init and game loop to dedicated 16K FreeRTOS task to avoid GUI 4K stack overflow
- Implement sys API: clear, print (8x8 bitmap font direct FB), rect, circle, line, touch, sfx, tone
- Audio via SfxEngine (SfxId mapping, playNote for tone)
- Ball speed 2 -> 4.5, FPS counter (~17 FPS after direct FB text optimization)
- Supports loading from /sdcard/lua/breakout.lua and embedded fallback
- Verified symbols: 0 missing, builds esp32s3, installs on 192.168.68.107
2026-07-31 12:52:02 -04:00