commit e2044fc762d7f6231fd3642a0fa50a5c08d5f0bb
Author: Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Sat Apr 16 07:58:21 2022 -0600
Commit: Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Mon Jun 27 18:56:15 2022 -0600
Add undocumented _set_fps function
---
source/picoluaapi.cpp | 6 ++++++
source/picoluaapi.h | 1 +
source/vm.cpp | 5 +++++
source/vm.h | 1 +
4 files changed, 13 insertions(+)
diff --git a/source/picoluaapi.cpp b/source/picoluaapi.cpp
index ad7e9df..2e1656e 100644
--- a/source/picoluaapi.cpp
+++ b/source/picoluaapi.cpp
@@ -1260,6 +1260,12 @@ int reset(lua_State *L) {
return 0;
}
+int setFps(lua_State *L){
+ _vmForLuaApi->setTargetFps(lua_tointeger(L, 1));
+
+ return 0;
+}
+
int listcarts(lua_State *L) {
//get cart list from VM (who should get it from host)
vector<string> carts = _vmForLuaApi->GetCartList();
diff --git a/source/picoluaapi.h b/source/picoluaapi.h
index 8209c32..48c3eb8 100644
--- a/source/picoluaapi.h
+++ b/source/picoluaapi.h
@@ -122,6 +122,7 @@ int run(lua_State *L);
int extcmd(lua_State *L);
int load(lua_State *L);
int reset(lua_State *L);
+int setFps(lua_State *L);
//api.tonum(val)
diff --git a/source/vm.cpp b/source/vm.cpp
index 57e538a..e4453fa 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -257,6 +257,7 @@ bool Vm::loadCart(Cart* cart) {
lua_register(_luaState, "_update_buttons", _update_buttons);
lua_register(_luaState, "run", run);
lua_register(_luaState, "extcmd", extcmd);
+ lua_register(_luaState, "_set_fps", setFps);
//rng
lua_register(_luaState, "rnd", rnd);
@@ -1007,6 +1008,10 @@ void Vm::vm_reset(){
_graphics->pal();
}
+void Vm::setTargetFps(int targetFps){
+ _targetFps = targetFps;
+}
+
int Vm::getFps(){
//TODO: return actual fps (as fix32?)
return _targetFps;
diff --git a/source/vm.h b/source/vm.h
index 3431f87..88a336c 100644
--- a/source/vm.h
+++ b/source/vm.h
@@ -136,6 +136,7 @@ class Vm {
void vm_reset();
+ void setTargetFps(int targetFps);
int getFps();
int getTargetFps();