Blame 0131-Made-the-program-chaining-exec-handle-the-X16-emulat.patch

a4f04fe
From f067c4530fb385137a7458011b082690ac1c705e Mon Sep 17 00:00:00 2001
a4f04fe
From: Greg King <gregdk@users.sf.net>
a4f04fe
Date: Wed, 25 Dec 2019 14:53:32 -0500
a4f04fe
Subject: [PATCH 131/170] Made the program-chaining exec() handle the X16
a4f04fe
 emulator's file-system.
a4f04fe
a4f04fe
---
a4f04fe
 libsrc/cx16/exec.c | 15 +++++++++------
a4f04fe
 1 file changed, 9 insertions(+), 6 deletions(-)
a4f04fe
a4f04fe
diff --git a/libsrc/cx16/exec.c b/libsrc/cx16/exec.c
a4f04fe
index 90af4e40..17a547e6 100644
a4f04fe
--- a/libsrc/cx16/exec.c
a4f04fe
+++ b/libsrc/cx16/exec.c
a4f04fe
@@ -1,7 +1,7 @@
a4f04fe
 /*
a4f04fe
 ** Program-chaining function for Commodore platforms.
a4f04fe
 **
a4f04fe
-** 2019-11-08, Greg King
a4f04fe
+** 2019-12-25, Greg King
a4f04fe
 **
a4f04fe
 ** This function exploits the program-chaining feature in Commander X16 BASIC's ROM.
a4f04fe
 **
a4f04fe
@@ -82,12 +82,15 @@ int __fastcall__ exec (const char* progname, const char* cmdline)
a4f04fe
     }
a4f04fe
     utoa (dv, basic.unit, 10);
a4f04fe
 
a4f04fe
-    /* Don't try to run a program that doesn't exist. */
a4f04fe
-    fd = open (progname, O_RDONLY);
a4f04fe
-    if (fd < 0) {
a4f04fe
-        return _mappederrno (4);        /* file not found */
a4f04fe
+    /* The emulator supports only loading and saving on its file-system. */
a4f04fe
+    if (dv != 1) {
a4f04fe
+        /* Don't try to run a program that doesn't exist. */
a4f04fe
+        fd = open (progname, O_RDONLY);
a4f04fe
+        if (fd < 0) {
a4f04fe
+            return _mappederrno (4);    /* file not found */
a4f04fe
+        }
a4f04fe
+        close (fd);
a4f04fe
     }
a4f04fe
-    close (fd);
a4f04fe
 
a4f04fe
     n = 0;
a4f04fe
     do {
a4f04fe
-- 
a4f04fe
2.26.0
a4f04fe