]> foleosoft.com Git - IdyllicBASIC.git/commitdiff
Wed Jan 22 11:03:34 PM EST 2025 master
authorserver <[email protected]>
Thu, 23 Jan 2025 04:03:34 +0000 (23:03 -0500)
committerserver <[email protected]>
Thu, 23 Jan 2025 04:03:34 +0000 (23:03 -0500)
Makefile
bin/idyll [new file with mode: 0755]
build.sh [new file with mode: 0644]
src/hardware/hardware.c
src/hardware/hardware.h
src/idyllic.c
src/main.c
src/parsing/evaluator.h

index 263f47d3fef09ae861fbe7e0b3743a6d9abf5504..048c49f81c79a3fb557015d4664198c113720483 100755 (executable)
--- a/Makefile
+++ b/Makefile
@@ -1,2 +1,17 @@
 make:
 make:
-       gcc src/main.c -o build/idyll -DDESKTOP
+       mkdir -p bin
+       gcc src/main.c -g -o bin/idyll -DDESKTOP -DWORD64
+
+install:
+       mkdir -p bin
+       gcc src/main.c -o bin/idyll -DDESKTOP -DWORD64
+       sudo cp bin/idyll /usr/local/bin/
+
+remove:
+       sudo rm /usr/local/bin/idyll
+
+uninstall:
+       sudo rm /usr/local/bin/idyll
+
+clean:
+       rm -r bin
diff --git a/bin/idyll b/bin/idyll
new file mode 100755 (executable)
index 0000000..af2fcc6
Binary files /dev/null and b/bin/idyll differ
diff --git a/build.sh b/build.sh
new file mode 100644 (file)
index 0000000..b763c2c
--- /dev/null
+++ b/build.sh
@@ -0,0 +1 @@
+make $@
index 37db3fa98d448d1c3c25227886b0aea7ccb52ef6..dcb759cfa857acdd59d8b9057ce148bc535d19e9 100755 (executable)
@@ -3,23 +3,43 @@
 #ifdef DESKTOP
 
 #include <stdio.h>
 #ifdef DESKTOP
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <sys/sysinfo.h>
 #define false 0
 #define true 1
 #define false 0
 #define true 1
-unsigned char RAM[125000];
+unsigned char* RAM;
+ibword RAM_SIZE;
 FILE *OPEN_FILE;
 
 FILE *OPEN_FILE;
 
+void initRAM() {
+       RAM = malloc(1000);
+       RAM_SIZE = 1000;
+}
+
+void freeRAM() {
+       RAM_SIZE = 0;
+       free(RAM);
+}
+
 //Get size of RAM.
 ibword sizeRAM() {
 //Get size of RAM.
 ibword sizeRAM() {
-       return 125000;
+       struct sysinfo info;
+       if (sysinfo(&info) == 0) {
+               unsigned long long available = (info.freeram * info.mem_unit) + (info.freeswap * info.mem_unit);
+               return (ibword)available;
+       }
+       return 32000;
 }
 
 //Read a byte from RAM.
 char readRAM(ibword pos) {
 }
 
 //Read a byte from RAM.
 char readRAM(ibword pos) {
+       if (pos >= RAM_SIZE) RAM = realloc(RAM, ++RAM_SIZE);
        return RAM[pos];
 }
 
        return RAM[pos];
 }
 
-//Write a byte to RAM. 
+//Write a byte to RAM.
 void writeRAM(ibword pos, char b) {
 void writeRAM(ibword pos, char b) {
+       if (pos >= RAM_SIZE) RAM = realloc(RAM, ++RAM_SIZE);
        RAM[pos] = b;
 }
 
        RAM[pos] = b;
 }
 
index 39ba0d52a4beae2b7783861f9f44ca70429b098e..af06f7b13ec84a36544ee3ad7cc6e6428ecccd35 100755 (executable)
@@ -6,8 +6,16 @@ typedef unsigned char bool;
 #endif
 #define undefined -1
 #ifdef DESKTOP
 #endif
 #define undefined -1
 #ifdef DESKTOP
+#ifdef WORD64
+typedef unsigned long long ibword;
+#endif
+#ifdef WORD32
 typedef unsigned int ibword;
 #endif
 typedef unsigned int ibword;
 #endif
+#ifdef WORD16
+typedef unsigned short ibword;
+#endif
+#endif
 #ifdef ARDUINO
 typedef unsigned short ibword;
 #endif
 #ifdef ARDUINO
 typedef unsigned short ibword;
 #endif
index 0c39476b514821c1f65c4155c0fef14f8a2a0a7e..2ad619adee071802c015744dea5dc2c25c6b4742 100755 (executable)
@@ -162,10 +162,12 @@ char evalAssignment(char *newstr) {
        //Check if key exists.
        ibword addr;
        if (newstr == NULL)
        //Check if key exists.
        ibword addr;
        if (newstr == NULL)
+       {
                addr = findNode(key);
                addr = findNode(key);
-       if (addr == (ibword)undefined && newstr == NULL)
-               return ERROR_KEY_NOT_FOUND;
-               
+               if (addr == (ibword)undefined && newstr == NULL)
+                       return ERROR_KEY_NOT_FOUND;
+       }
+
        //Skip to equal sign.
        char isArray = 0;
        while (c != '=' && !isEOL(c)) {
        //Skip to equal sign.
        char isArray = 0;
        while (c != '=' && !isEOL(c)) {
@@ -1159,4 +1161,4 @@ char eval(char *line) {
        if (!copyStringIntoLineBuff(line))
                return ERROR_SYNTAX;
        return evalLine(0, 0);
        if (!copyStringIntoLineBuff(line))
                return ERROR_SYNTAX;
        return evalLine(0, 0);
-}
\ No newline at end of file
+}
index 0a8091a55a74a6fe73cb3c7d871c46deef5e7180..98e241d1b9b44408371e6e30ab0dc89d2f82466b 100755 (executable)
@@ -1,6 +1,7 @@
 #include "idyllic.c"
 
 void main(int argc, char **args) {
 #include "idyllic.c"
 
 void main(int argc, char **args) {
+       initRAM();
        if (argc == 2) {
                if (!fileExistsOnDevice(args[1])) {
                        printf("File `%s` not found.\n", args[1]);
        if (argc == 2) {
                if (!fileExistsOnDevice(args[1])) {
                        printf("File `%s` not found.\n", args[1]);
@@ -38,4 +39,5 @@ void main(int argc, char **args) {
                        printString("Too long.\n");
                }
        }
                        printString("Too long.\n");
                }
        }
+       freeRAM();
 }
 }
index 0d9d49d3c25af9f281e856e69943dd6c94b21aeb..d4b2481ec89d4f1df1830d6dfe560b1961c08a68 100755 (executable)
@@ -57,11 +57,11 @@ void appendAdr(ibword num);
 
 //Copies a numeric formula to EVAL_BUFF for numeric processing.
 //     Returns false if a variable didn't exist.
 
 //Copies a numeric formula to EVAL_BUFF for numeric processing.
 //     Returns false if a variable didn't exist.
-char copyFormulaIntoEvalBuff();
+char copyFormulaIntoEvalBuff(ibword pos, ibword size);
 
 //Copies a string or string formula to EVAL_BUFF for string processing.
 //     Returns false if a variable didn't exist.
 
 //Copies a string or string formula to EVAL_BUFF for string processing.
 //     Returns false if a variable didn't exist.
-char copyStringIntoEvalBuff();
+char copyStringIntoEvalBuff(ibword pos, ibword size);
 
 //If EVAL_BUFF contains a string formula, use this to read
 //     a character from it. Characters are shifted out of it.
 
 //If EVAL_BUFF contains a string formula, use this to read
 //     a character from it. Characters are shifted out of it.