commit 77c716c6a2509433eb129517d9f4cb646e5487e0
Author: Jon Bell <jondbell@protonmail.com>
AuthorDate: Sat May 30 09:45:57 2020 -0600
Commit: Jon Bell <jondbell@protonmail.com>
CommitDate: Sat May 30 09:45:57 2020 -0600
Move bios to compiled string instead of external file
---
fake08-nocart.p8 => source/FakoBios.h | 20 +++++++++++++++++---
source/cart.cpp | 12 +++++++++++-
source/vm.cpp | 10 ++--------
3 files changed, 30 insertions(+), 12 deletions(-)
diff --git a/fake08-nocart.p8 b/source/FakoBios.h
similarity index 88%
rename from fake08-nocart.p8
rename to source/FakoBios.h
index 1821ff8..c002c5b 100644
--- a/fake08-nocart.p8
+++ b/source/FakoBios.h
@@ -1,3 +1,11 @@
+#pragma once
+
+#include <string>
+
+
+//from PicoLove api.lua
+
+const char * fake08BiosP8 = R"#(
pico-8 cartridge // http://www.pico-8.com
version 27
__lua__
@@ -28,9 +36,13 @@ function _init()
print("currently in pre-alpha")
print("")
print("place p8 carts in sdmc:/p8carts/")
- print("⬅️➡️ to navigate carts")
- print("🅾️ (a) to load selected cart")
- print("start to close current cart")
+ if numcarts < 1 then
+ print("--no carts found--")
+ else
+ print("⬅️➡️ to navigate carts")
+ print("🅾️ (a) to load selected cart")
+ print("start to close current cart")
+ end
print("r to cycle screen sizes")
print("l + r to exit")
print("")
@@ -95,3 +107,5 @@ __gfx__
77777077777077770077770077777077077077777000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
77000077077077077077000000000077077077077000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
77000077077077007077777000000077770077770000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
+
+)#";
\ No newline at end of file
diff --git a/source/cart.cpp b/source/cart.cpp
index e644589..3e6c1c9 100644
--- a/source/cart.cpp
+++ b/source/cart.cpp
@@ -12,6 +12,8 @@
#include "cartPatcher.h"
#include "utf8-util.h"
+#include "FakoBios.h"
+
//#include "tests/test_base.h"
//#if _TEST
//#include "tests/cart_test.h"
@@ -88,7 +90,15 @@ std::string convert_emojis(const std::string& lua) {
Cart::Cart(std::string filename){
Filename = filename;\
Logger::Write("getting file contents\n");
- auto cartStr = get_file_contents(filename.c_str());
+
+ std::string cartStr;
+
+ if (filename == "__FAKE08-BIOS.p8") {
+ cartStr = fake08BiosP8;
+ }
+ else {
+ cartStr = get_file_contents(filename.c_str());
+ }
Logger::Write("Got file contents... parsing cart\n");
fullCartText = cartStr;
diff --git a/source/vm.cpp b/source/vm.cpp
index 879cfbd..132594d 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -209,7 +209,7 @@ bool Vm::loadCart(Cart* cart) {
void Vm::LoadBiosCart(){
CloseCart();
- Cart *cart = new Cart("fake08-nocart.p8");
+ Cart *cart = new Cart("__FAKE08-BIOS.p8");
bool success = loadCart(cart);
@@ -223,13 +223,7 @@ void Vm::LoadCart(std::string filename){
CloseCart();
Logger::Write("Calling Cart Constructor\n");
- Cart *cart;
- if (filename == "__FAKE08-BIOS.p8"){
- cart = new Cart("fake08-nocart.p8");
- }
- else{
- cart = new Cart(filename);
- }
+ Cart *cart = new Cart(filename);
bool success = loadCart(cart);