commit c939158ba011b805c587f42495fecfc1a282caae
Author: jtothebell <j.to.the.bell@gmail.com>
AuthorDate: Mon Mar 8 22:09:36 2021 -0700
Commit: jtothebell <j.to.the.bell@gmail.com>
CommitDate: Tue Mar 9 22:18:35 2021 -0700
Hack together POC for customizing bios
---
platform/SDL2/source/SDL2Host.cpp | 8 +++++++
source/FakoBios.h | 47 ++++++++++++++++++++-------------------
source/host.h | 2 ++
source/vm.cpp | 15 +++++++++++++
4 files changed, 49 insertions(+), 23 deletions(-)
diff --git a/platform/SDL2/source/SDL2Host.cpp b/platform/SDL2/source/SDL2Host.cpp
index 1bcc424..2d1ea00 100644
--- a/platform/SDL2/source/SDL2Host.cpp
+++ b/platform/SDL2/source/SDL2Host.cpp
@@ -304,3 +304,11 @@ vector<string> Host::listcarts(){
const char* Host::logFilePrefix() {
return "";
}
+
+std::string Host::customBiosLua() {
+ return "cartpath = \"~/p8carts/\"\n"
+ "selectbtn = \"z\"\n"
+ "pausebtn = \"esc\""
+ "exitbtn = \"close window\""
+ "sizebtn = \"\"";
+}
diff --git a/source/FakoBios.h b/source/FakoBios.h
index f166b75..9c18fec 100644
--- a/source/FakoBios.h
+++ b/source/FakoBios.h
@@ -38,29 +38,6 @@ function _init()
if __getbioserror then
linebuffer = __getbioserror()
end
-
- cls(bgcolor)
- spr(0, 1, 5, 6, 1)
- color(6)
- cursor(0, 6*3)
- print("welcome to fake-08")
- print("a homebrew pico-8 emulator")
- print("currently in alpha (" .. versionstr .. ")")
- print("")
- print("place p8 carts in " .. cartpath)
- if numcarts < 1 then
- print("--no carts found--")
- else
- print("⬅️➡️ to navigate carts")
- print("🅾️ (" .. selectbtn .. ") to load selected cart")
- print(pausebtn .. " to close current cart")
- end
- print(sizebtn)
- print(exitbtn .. " to exit")
- print("")
- -- 18 pixels from cursor() call, then
- -- 24 more from 4 print calls
- line=84
end
function _update60()
@@ -109,6 +86,30 @@ function _update60()
end
function _draw()
+ cls(bgcolor)
+ spr(0, 1, 5, 6, 1)
+ color(6)
+ cursor(0, 6*3)
+ print("welcome to fake-08")
+ print("a homebrew pico-8 emulator")
+ print("currently in alpha (" .. versionstr .. ")")
+ print("")
+ print("place p8 carts in " .. cartpath)
+ if numcarts < 1 then
+ print("--no carts found--")
+ else
+ print("⬅️➡️ to navigate carts")
+ print("🅾️ (" .. selectbtn .. ") to load selected cart")
+ print(pausebtn .. " to close current cart")
+ end
+ print(sizebtn)
+ print(exitbtn .. " to exit")
+ print("")
+ -- 18 pixels from cursor() call, then
+ -- 24 more from 4 print calls
+ line=84
+
+
rectfill(0, line, 128, line+5, bgcolor)
color(7)
print("> "..linebuffer, 0, line)
diff --git a/source/host.h b/source/host.h
index 2ef0664..2948643 100644
--- a/source/host.h
+++ b/source/host.h
@@ -44,4 +44,6 @@ class Host {
std::vector<std::string> listcarts();
const char* logFilePrefix();
+
+ std::string customBiosLua();
};
\ No newline at end of file
diff --git a/source/vm.cpp b/source/vm.cpp
index 209c379..0c40a17 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -301,6 +301,21 @@ bool Vm::loadCart(Cart* cart) {
}
lua_pop(_luaState, 0);
+ //customize bios per host's requirements
+ if (cart->Filename == "__FAKE08-BIOS.p8") {
+ std::string customBiosLua = _host->customBiosLua();
+
+ if (customBiosLua.length() > 0) {
+ int doStrRes = luaL_dostring(_luaState, customBiosLua.c_str());
+
+ if (! doStrRes == LUA_OK){
+ //bad lua passed
+ Logger_Write("Error: %s\n", lua_tostring(_luaState, -1));
+ lua_pop(_luaState, 1);
+ }
+ }
+ }
+
_cartLoadError = "";
return true;