Skip to content

Commit

Permalink
WIP- zepto 8 bios displaying
Browse files Browse the repository at this point in the history
  • Loading branch information
jtothebell committed Jan 15, 2024
1 parent 8a30268 commit 226dac5
Show file tree
Hide file tree
Showing 11 changed files with 234 additions and 41 deletions.
10 changes: 5 additions & 5 deletions platform/libretro/libretro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ EXPORT void retro_init()

_vm->SetCartList(_host->listcarts());

_vm->LoadBiosCart();
//_vm->LoadBiosCart();
}

EXPORT void retro_deinit()
Expand Down Expand Up @@ -615,10 +615,10 @@ EXPORT void retro_cheat_set(unsigned index, bool enabled, const char *code)

EXPORT bool retro_load_game(struct retro_game_info const *info)
{
if (!info) {
_vm->QueueCartChange("__FAKE08-BIOS.p8");
return true;
}
// if (!info) {
// _vm->QueueCartChange("__FAKE08-DEFAULT.p8");
// return true;
// }

auto containingDir = getDirectory(info->path);

Expand Down
2 changes: 1 addition & 1 deletion source/FakoBios.h → source/DefaultCart.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
//this shouldn't really count as the bios
//this is the cart loader cart

const char * fake08BiosP8 = R"#(
const char * fake08DefaultCart = R"#(
pico-8 cartridge // http://www.pico-8.com
version 35
__lua__
Expand Down
2 changes: 1 addition & 1 deletion source/FakoSettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ function updatecursor()
cursorpos = deli(path)
if not cursorpos then
--exit to bios
__loadbioscart()
__loaddefaultcart()
end
else
if inoption then
Expand Down
8 changes: 4 additions & 4 deletions source/cart.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#include "emojiconversion.h"

#include "FakoBios.h"
#include "DefaultCart.h"

#include "FakoSettings.h"

Expand Down Expand Up @@ -456,11 +456,11 @@ Cart::Cart(std::string filename, std::string cartDirectory){

std::string firstFourChars = get_first_four_chars(FullCartPath);

if (FullCartPath == "__FAKE08-BIOS.p8" || FullCartPath == "__FAKE08-SETTINGS.p8" || firstFourChars == "pico"){
if (FullCartPath == "__FAKE08-DEFAULT.p8" || FullCartPath == "__FAKE08-SETTINGS.p8" || firstFourChars == "pico"){
std::string cartStr;

if (FullCartPath == "__FAKE08-BIOS.p8") {
cartStr = fake08BiosP8;
if (FullCartPath == "__FAKE08-DEFAULT.p8") {
cartStr = fake08DefaultCart;
}
else if (FullCartPath == "__FAKE08-SETTINGS.p8") {
cartStr = fake08SettingsP8;
Expand Down
22 changes: 16 additions & 6 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,23 @@ int main(int argc, char* argv[])
Logger_Initialize(host->logFilePrefix());

Vm *vm = new Vm(host, memory, nullptr, nullptr, audio);

host->setUpPaletteColors();
host->oneTimeSetup(audio);

#if LOAD_PACK_INS

host->unpackCarts();
#endif

Logger_Write("initializing Vm\n");

bool vmInitResult = vm->Initialize();

if (!vmInitResult) {
Logger_Write("vm init failed\n");
return 1;
}

Logger_Write("initialized Vm and host\n");

Expand All @@ -59,14 +68,15 @@ int main(int argc, char* argv[])
}
#endif

Logger_Write("Loading Bios cart\n");

if (loadCart){
Logger_Write("Loading arg cart \n");
vm->LoadCart(cart);
}
else {
vm->LoadBiosCart();
}
Logger_Write("Bios Cart Loaded\n");
// else {
// vm->LoadBiosCart();
// }
//Logger_Write("Bios Cart Loaded\n");

// Main loop
Logger_Write("Starting main loop\n");
Expand Down
4 changes: 2 additions & 2 deletions source/p8GlobalLuaFunctions.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//from zepto 8 bios.p8
//this is the bios-- needs to get loaded first, and then will run every cart

const char * p8GlobalLuaFunctions = R"#(
const char * p8Bios = R"#(
-- The functions below are normally attached to the program code, but are here for simplicity
---------------------------------
--Table Helpers
Expand Down Expand Up @@ -182,7 +182,7 @@ __f08_menu_items = {
{nil, nil},
{nil, nil},
{"reset cart", __resetcart},
{"exit to menu", __loadbioscart},
{"exit to menu", __loaddefaultcart},
{"exit to settings", __loadsettingscart}
}
Expand Down
4 changes: 2 additions & 2 deletions source/picoluaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1321,8 +1321,8 @@ int getbioserror(lua_State *L) {
return 1;
}

int loadbioscart(lua_State *L) {
_vmForLuaApi->QueueCartChange("__FAKE08-BIOS.p8");
int loaddefaultcart(lua_State *L) {
_vmForLuaApi->QueueCartChange("__FAKE08-DEFAULT.p8");

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion source/picoluaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ int printh(lua_State *L);
int listcarts(lua_State *L);

int getbioserror(lua_State *L);
int loadbioscart(lua_State *L);
int loaddefaultcart(lua_State *L);
int loadsettingscart(lua_State *L);
int togglepausemenu(lua_State *L);
int resetcart(lua_State *L);
Expand Down
Loading

0 comments on commit 226dac5

Please sign in to comment.