Add frame tick system for continuous animation

- Added INPUT_FRAME_TICK event type to input_event.h
- Added wants_frame_updates() virtual method to Game base class
- Implemented frame tick logic in main loop (basic1.cpp and emulator/main.cpp)
- Added Lua bindings: game.set_frame_updates(bool) and INPUT.FRAME_TICK
- Updated LuaGame to support frame updates via registry flag
- Updated ball.lua to use continuous frame updates for smooth animation
- Both hardware and emulator now support continuous animation for physics/games
This commit is contained in:
Adolfo Reyna
2026-02-07 13:20:10 -05:00
parent 8d176925f8
commit 2a472fc29f
10 changed files with 86 additions and 4 deletions

View File

@@ -186,6 +186,21 @@ static int lua_game_exit(lua_State* L) {
return 0;
}
// game.set_frame_updates(enabled) - enable/disable continuous frame tick events
static int lua_game_set_frame_updates(lua_State* L) {
LuaGame* game = get_game(L);
if (!game) return 0;
bool enabled = lua_toboolean(L, 1);
// Set frame updates flag (will be checked in wants_frame_updates())
lua_pushstring(L, "__wants_frame_updates");
lua_pushboolean(L, enabled);
lua_settable(L, LUA_REGISTRYINDEX);
return 0;
}
// ============================================================================
// INPUT TYPE CONSTANTS
// ============================================================================
@@ -283,6 +298,10 @@ void lua_bindings_register(lua_State* L, LuaGame* game) {
lua_pushcfunction(L, lua_game_exit);
lua_settable(L, -3);
lua_pushstring(L, "set_frame_updates");
lua_pushcfunction(L, lua_game_set_frame_updates);
lua_settable(L, -3);
// Create empty vars table for persistent state
lua_pushstring(L, "vars");
lua_newtable(L);