Commit Graph

3 Commits

Author SHA1 Message Date
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