moving everything neatly into the assets directory
|
Before Width: | Height: | Size: 6.5 KiB After Width: | Height: | Size: 6.5 KiB |
|
Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB |
|
Before Width: | Height: | Size: 3.8 KiB After Width: | Height: | Size: 3.8 KiB |
39
assets/bios/tbasdist.js
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
|
||||||
|
var _BIOS = {};
|
||||||
|
|
||||||
|
// Syntax: [Port, Drive-number]
|
||||||
|
// Port #0-3: Serial port 1-4
|
||||||
|
// #4+ : Left for future extension
|
||||||
|
// Drive-number always starts at 1
|
||||||
|
_BIOS.FIRST_BOOTABLE_PORT = [0,1]; // ah screw it
|
||||||
|
|
||||||
|
Object.freeze(_BIOS);
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
// load basic.js
|
||||||
|
let p = _BIOS.FIRST_BOOTABLE_PORT;
|
||||||
|
com.sendMessage(0, "DEVRST\x17");
|
||||||
|
com.sendMessage(0, 'OPENR"tbas/basic.js",1');
|
||||||
|
let r = com.getStatusCode(0);
|
||||||
|
|
||||||
|
if (r == 0){
|
||||||
|
com.sendMessage(0, "READ");
|
||||||
|
r = com.getStatusCode(0);
|
||||||
|
if (r == 0) {
|
||||||
|
try {
|
||||||
|
let g=com.pullMessage(0);
|
||||||
|
let execAppPrg = eval("var _appStub=function(exec_args){"+g+"};_appStub;"); // making 'exec_args' a app-level global
|
||||||
|
execAppPrg();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
catch (e) {
|
||||||
|
printerrln("\n"+e.stack);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printerrln("I/O Error");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printerrln("No bootable medium found.");
|
||||||
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 13 KiB |
|
Before Width: | Height: | Size: 158 KiB After Width: | Height: | Size: 158 KiB |
@@ -11,6 +11,5 @@ for (i = indices.length - 1; i > 0; i--) {
|
|||||||
}
|
}
|
||||||
for (i = 0; i < 250880; i++) {
|
for (i = 0; i < 250880; i++) {
|
||||||
graphics.plotPixel(indices[i] % 560, (indices[i] / 560)|0, image[indices[i]]);
|
graphics.plotPixel(indices[i] % 560, (indices[i] / 560)|0, image[indices[i]]);
|
||||||
graphics.plotPixel(indices[i] % 560, (indices[i] / 560)|0, image[indices[i]]);
|
|
||||||
}
|
}
|
||||||
con.color_fore(0);
|
con.color_fore(0);
|
||||||
@@ -15,18 +15,19 @@ if (exec_args !== undefined && exec_args[1] !== undefined && exec_args[1].starts
|
|||||||
|
|
||||||
|
|
||||||
let INDEX_BASE = 0;
|
let INDEX_BASE = 0;
|
||||||
let TRACEON = true;
|
let TRACEON = false;
|
||||||
let DBGON = true;
|
let DBGON = false;
|
||||||
let DATA_CURSOR = 0;
|
let DATA_CURSOR = 0;
|
||||||
let DATA_CONSTS = [];
|
let DATA_CONSTS = [];
|
||||||
let DEFUNS_BUILD_DEFUNS = true;
|
const DEFUNS_BUILD_DEFUNS = true;
|
||||||
|
const BASIC_HOME_PATH = "/home/basic/"
|
||||||
|
|
||||||
if (system.maxmem() < 8192) {
|
if (system.maxmem() < 8192) {
|
||||||
println("Out of memory. BASIC requires 8K or more User RAM");
|
println("Out of memory. BASIC requires 8K or more User RAM");
|
||||||
throw Error("Out of memory");
|
throw Error("Out of memory");
|
||||||
}
|
}
|
||||||
|
|
||||||
let vmemsize = system.maxmem() - 5236;
|
let vmemsize = system.maxmem();
|
||||||
|
|
||||||
let cmdbuf = []; // index: line number
|
let cmdbuf = []; // index: line number
|
||||||
let gotoLabels = {};
|
let gotoLabels = {};
|
||||||
@@ -132,7 +133,7 @@ fs.open = function(path, operationMode) {
|
|||||||
throw Error("Unknown file opening mode: " + mode);
|
throw Error("Unknown file opening mode: " + mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
com.sendMessage(port[0], "OPEN"+mode+'"'+path+'",'+port[1]);
|
com.sendMessage(port[0], "OPEN"+mode+'"'+BASIC_HOME_PATH+path+'",'+port[1]);
|
||||||
let response = com.getStatusCode(port[0]);
|
let response = com.getStatusCode(port[0]);
|
||||||
return (response == 0);
|
return (response == 0);
|
||||||
};
|
};
|
||||||
@@ -196,8 +197,14 @@ let reNumber = /([0-9]*[.][0-9]+[eE]*[\-+0-9]*[fF]*|[0-9]+[.eEfF][0-9+\-]*[fF]?)
|
|||||||
|
|
||||||
let reNum = /[0-9]+/;
|
let reNum = /[0-9]+/;
|
||||||
let tbasexit = false;
|
let tbasexit = false;
|
||||||
|
const greetText = "Terran BASIC 1.0 "+String.fromCharCode(179)+" Scratchpad Memory: "+vmemsize+" bytes";
|
||||||
|
const greetLeftPad = (80 - greetText.length) >> 1;
|
||||||
|
const greetRightPad = 80 - greetLeftPad - greetText.length;
|
||||||
|
|
||||||
println("Terran BASIC 1.0 "+vmemsize+" bytes free");
|
con.color_pair(0,253);
|
||||||
|
print(" ".repeat(greetLeftPad)+greetText+" ".repeat(greetRightPad));
|
||||||
|
con.color_pair(239,255);
|
||||||
|
println();
|
||||||
println(prompt);
|
println(prompt);
|
||||||
|
|
||||||
// variable object constructor
|
// variable object constructor
|
||||||
@@ -1887,7 +1894,7 @@ bF.isSemanticLiteral = function(token, state) {
|
|||||||
return undefined == token || "]" == token || ")" == token ||
|
return undefined == token || "]" == token || ")" == token ||
|
||||||
"qot" == state || "num" == state || "bool" == state || "lit" == state;
|
"qot" == state || "num" == state || "bool" == state || "lit" == state;
|
||||||
}
|
}
|
||||||
bF.parserDoDebugPrint = true;
|
bF.parserDoDebugPrint = false;
|
||||||
bF.parserPrintdbg = any => { if (bF.parserDoDebugPrint) serial.println(any) };
|
bF.parserPrintdbg = any => { if (bF.parserDoDebugPrint) serial.println(any) };
|
||||||
bF.parserPrintdbg2 = function(icon, lnum, tokens, states, recDepth) {
|
bF.parserPrintdbg2 = function(icon, lnum, tokens, states, recDepth) {
|
||||||
if (bF.parserDoDebugPrint) {
|
if (bF.parserDoDebugPrint) {
|
||||||
@@ -2611,8 +2618,8 @@ bF._troNOP = function(lnum, stmtnum) { return new SyntaxTreeReturnObj("null", un
|
|||||||
bF._executeSyntaxTree = function(lnum, stmtnum, syntaxTree, recDepth) {
|
bF._executeSyntaxTree = function(lnum, stmtnum, syntaxTree, recDepth) {
|
||||||
if (lnum === undefined || stmtnum === undefined) throw Error(`Line or statement number is undefined: (${lnum},${stmtnum})`);
|
if (lnum === undefined || stmtnum === undefined) throw Error(`Line or statement number is undefined: (${lnum},${stmtnum})`);
|
||||||
|
|
||||||
let _debugExec = true;
|
let _debugExec = false;
|
||||||
let _debugPrintCurrentLine = true;
|
let _debugPrintCurrentLine = false;
|
||||||
let recWedge = ">".repeat(recDepth) + " ";
|
let recWedge = ">".repeat(recDepth) + " ";
|
||||||
|
|
||||||
if (_debugExec || _debugPrintCurrentLine) serial.println(recWedge+"@@ EXECUTE @@");
|
if (_debugExec || _debugPrintCurrentLine) serial.println(recWedge+"@@ EXECUTE @@");
|
||||||
@@ -3050,7 +3057,7 @@ bF.catalog = function(args) { // CATALOG function
|
|||||||
};
|
};
|
||||||
Object.freeze(bF);
|
Object.freeze(bF);
|
||||||
|
|
||||||
if (exec_args[1] !== undefined) {
|
if (exec_args !== undefined && exec_args[1] !== undefined) {
|
||||||
bF.load(["load", exec_args[1]]);
|
bF.load(["load", exec_args[1]]);
|
||||||
try {
|
try {
|
||||||
bF.run();
|
bF.run();
|
||||||
@@ -206,11 +206,11 @@ Functions are a form of expression that may taks input arguments surrounded by p
|
|||||||
|
|
||||||
\subsection{PEEK}
|
\subsection{PEEK}
|
||||||
\codeline{BYTE \textbf{= PEEK(}MEM\_ADDR\textbf{)}}\par
|
\codeline{BYTE \textbf{= PEEK(}MEM\_ADDR\textbf{)}}\par
|
||||||
Returns whatever the value stored in the \code{MEM\_ADDR} of the scratchpad-memory.\par
|
Returns whatever the value stored in the \code{MEM\_ADDR} of the Scratchpad Memory.\par
|
||||||
Address mirroring, illegal access, etc. are entirely up to the virtual machine which the BASIC interpreter is running on.
|
Address mirroring, illegal access, etc. are entirely up to the virtual machine which the BASIC interpreter is running on.
|
||||||
\subsection{POKE}
|
\subsection{POKE}
|
||||||
\codeline{\textbf{POKE(}MEM\_ADDR \textbf{,} BYTE\textbf{)}}\par
|
\codeline{\textbf{POKE(}MEM\_ADDR \textbf{,} BYTE\textbf{)}}\par
|
||||||
Puts a \code{BYTE} into the \code{MEM\_ADDR} of the scratchpad-memory.
|
Puts a \code{BYTE} into the \code{MEM\_ADDR} of the Scratchpad Memory.
|
||||||
|
|
||||||
\section{Higher-order Function}
|
\section{Higher-order Function}
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ _TVDOS.getPath = function() {
|
|||||||
_TVDOS.variables = {
|
_TVDOS.variables = {
|
||||||
DOSDIR: "\\tvdos",
|
DOSDIR: "\\tvdos",
|
||||||
LANG: "EN",
|
LANG: "EN",
|
||||||
PATH: "\\tvdos\\bin",
|
PATH: ";\\tvdos\\bin;\\tbas;\\home",
|
||||||
PATHEXT: ".com;.bat;.js",
|
PATHEXT: ".com;.bat;.js",
|
||||||
HELPPATH: "\\tvdos\\help",
|
HELPPATH: "\\tvdos\\help",
|
||||||
OS_NAME: "Terrarum Virtual DOS",
|
OS_NAME: "Terrarum Virtual DOS",
|
||||||
|
Before Width: | Height: | Size: 304 KiB After Width: | Height: | Size: 304 KiB |
|
Before Width: | Height: | Size: 1017 B After Width: | Height: | Size: 1017 B |
|
Before Width: | Height: | Size: 580 B After Width: | Height: | Size: 580 B |
|
Before Width: | Height: | Size: 589 B After Width: | Height: | Size: 589 B |
|
Before Width: | Height: | Size: 7.4 KiB After Width: | Height: | Size: 7.4 KiB |
|
Before Width: | Height: | Size: 3.7 KiB After Width: | Height: | Size: 3.7 KiB |
|
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
|
Before Width: | Height: | Size: 2.1 KiB After Width: | Height: | Size: 2.1 KiB |