foxygit / fake-08-xbox360 Log in
commit 6e39029f3d2496e0afa8a968b1b0631cdf884fee
Author:     DPS2004 <dpsophinos@gmail.com>
AuthorDate: Wed Mar 9 10:35:01 2022 -0500
Commit:     DPS2004 <dpsophinos@gmail.com>
CommitDate: Wed Mar 9 10:35:01 2022 -0500

    fix starjump menuitem + cartdata behavior
---
 source/p8GlobalLuaFunctions.h | 22 +++++++++++++++++++---
 source/vm.cpp                 |  7 ++++---
 2 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/source/p8GlobalLuaFunctions.h b/source/p8GlobalLuaFunctions.h
index fc66ce6..4abd10d 100644
--- a/source/p8GlobalLuaFunctions.h
+++ b/source/p8GlobalLuaFunctions.h
@@ -180,11 +180,27 @@ function __f08_menu_update()
         until __f08_menu_items[__f08_menu_selected][1] ~= nil
     end

-    if btnp(4) or btnp(5) then
+    if btnp(0) or btnp(1) or btnp(4) or btnp(5) then
+		local bval = 0
+		local allowreturn = false
+
+		if btnp(4) or btnp(5) then
+			bval = 16+32+64
+			allowreturn = true
+		else
+			if btnp(0) then
+				bval = 1
+			elseif btnp(1) then
+				bval = 2
+			end
+
+		end
+
         toexec = __f08_menu_items[__f08_menu_selected]
         if toexec and toexec[2] then
-            toexec[2]()
-            if __f08_menu_selected > 0 and __f08_menu_selected < 6 then
+            local toexec_result = toexec[2](bval)
+
+            if __f08_menu_selected > 0 and __f08_menu_selected < 6 and allowreturn and not toexec_result then
                 __f08_menu_selected = 0
                 __togglepausemenu()
             end
diff --git a/source/vm.cpp b/source/vm.cpp
index d5589fd..a4f3f38 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -710,9 +710,10 @@ bool Vm::vm_cartdata(string key) {
     //todo: validate hex format
     if (cartDataStr.length() > 0) {
         deserializeCartDataToMemory(cartDataStr);
-    }
-
-    return true;
+		return true;
+    } else {
+		return false;
+	}

     //call host to get current cart data and init- set memory
     //file name should match pico 8: {key}.p8d.txt in the cdata directory