foxygit / fake-08-xbox360 Log in
commit 0b36761ca2d4c16a96fecdcde416bde9da4d5531
Author:     Jon Bell <j.to.the.bell@gmail.com>
AuthorDate: Fri Jan 2 10:11:04 2026 -0700
Commit:     Jon Bell <j.to.the.bell@gmail.com>
CommitDate: Fri Jan 2 10:11:04 2026 -0700

    Improve load to handle p8.pngs when only a filename is passed
---
 source/cart.cpp | 16 +++++++++++++++-
 source/vm.cpp   |  1 -
 2 files changed, 15 insertions(+), 2 deletions(-)

diff --git a/source/cart.cpp b/source/cart.cpp
index 3f9bdfb..f9899cb 100644
--- a/source/cart.cpp
+++ b/source/cart.cpp
@@ -442,7 +442,9 @@ Cart::Cart(std::string filename, std::string cartDirectory){
         filename = filename.substr(1);
     }

-    if (getFileExtension(filename) == "") {
+    std::string fileExtension = getFileExtension(filename);
+
+    if (fileExtension == "") {
         filename = filename + ".p8";
     }

@@ -467,6 +469,18 @@ Cart::Cart(std::string filename, std::string cartDirectory){

     std::string firstFourChars = get_first_four_chars(FullCartPath);

+    if (fileExtension == "" && firstFourChars.length() == 0) {
+        //fallback for cart loading by key - support .p8 and .p8.png
+        filename = filename + ".png";
+        // Rebuild full path with cart directory (same logic as initial path build)
+        if (cartDirectory.length() > 0 && !isAbsolutePath(filename)) {
+            FullCartPath = cartDirectory + "/" + filename;
+        } else {
+            FullCartPath = filename;
+        }
+        firstFourChars = get_first_four_chars(FullCartPath);
+    }
+
     // For non-built-in carts, check if file exists first
     if (!isDefaultCart && !isSettingsCart) {
         if (firstFourChars.length() == 0) {
diff --git a/source/vm.cpp b/source/vm.cpp
index 833e7ea..0a83afb 100644
--- a/source/vm.cpp
+++ b/source/vm.cpp
@@ -1333,7 +1333,6 @@ void Vm::vm_load(std::string filename, std::string breadcrumb, std::string param
     QueueCartChange(filename);
     LoadCart(_nextCartKey);

-
     //todo: don't call this here?  probably need to change load to not clear out some memory?
     vm_run();
 }