mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2026-10-24 08:02:27 +00:00
bataribasic: updated to latest WASM version
This commit is contained in:
1 parent
dea718b91a
commit
5ff7d0e4e7
21 files changed
+289
-4384
No files matched your search
@@ -97,7 +97,6 @@
|
||||
"test-web-all": "nightwatch -e chrome test/web",
|
||||
"fuzzbasic": "jsfuzz gen/common/basic/fuzz.js ~/basic/corpus/ --versifier false",
|
||||
"fuzzhdl": "jsfuzz -r binaryen gen/common/hdl/fuzz.js ~/verilator/corpus/ --versifier false",
|
||||
"machine": "node gen/tools/runmachine.js",
|
||||
"cli": "node gen/tools/8bws.js",
|
||||
"mkdoc": "typedoc --out web/jsdoc src/common/"
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
include fixed_point_math.asm
|
||||
rem Zombie Chase
|
||||
rem Zombie (Duck) Chase
|
||||
rem A fun game that may help you learn batari Basic!
|
||||
rem
|
||||
|
||||
@@ -320,7 +320,7 @@ wrap
|
||||
turndelay = turndelay + 1
|
||||
turndelay = turndelay & %11111011
|
||||
temp1=turndelay&3
|
||||
if temp1 <> 0 goto SameFrame
|
||||
if temp1 <> 0 then goto SameFrame
|
||||
|
||||
|
||||
if joy0left then carpos=carpos-1:gamebits{0}=1
|
||||
|
||||
@@ -440,6 +440,7 @@ export function getToolForFilename_6502(fn: string): string {
|
||||
if (fn.endsWith(".s")) return "ca65";
|
||||
if (fn.endsWith(".ca65")) return "ca65";
|
||||
if (fn.endsWith(".dasm")) return "dasm";
|
||||
if (fn.endsWith(".bb")) return "bataribasic";
|
||||
if (fn.endsWith(".acme")) return "acme";
|
||||
if (fn.endsWith(".xa")) return "xa";
|
||||
if (fn.endsWith(".wiz")) return "wiz";
|
||||
|
||||
@@ -481,8 +481,8 @@ export const TOOL_META: { [id: string]: ToolMeta } = {
|
||||
includeDirs: ['/includes'],
|
||||
editorStyle: 'bataribasic',
|
||||
helpURL: 'help/bataribasic/manual.html',
|
||||
wasmModule: 'bb2600basic',
|
||||
platforms: { default: { preloadFS: '2600basic' } },
|
||||
wasiFSZip: 'bb-fs.zip',
|
||||
platforms: { default: {} },
|
||||
includePatterns: SHARED_INCLUDE_PATTERNS,
|
||||
linkPatterns: SHARED_LINK_PATTERNS,
|
||||
},
|
||||
|
||||
@@ -292,6 +292,12 @@ export class WASIMemoryFilesystem implements WASIFilesystem {
|
||||
}
|
||||
getFile(name: string) {
|
||||
let file = this.files.get(name);
|
||||
// fallback: normalize leading './' so 'dir.name + "/" + path' joins still match
|
||||
if (!file && name.startsWith('./')) {
|
||||
const stripped = name.substring(2);
|
||||
file = this.files.get(stripped)
|
||||
?? this.parent?.getFile(stripped);
|
||||
}
|
||||
if (!file) {
|
||||
file = this.parent?.getFile(name);
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
|
||||
var bb2600basic = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
return (
|
||||
function(bb2600basic) {
|
||||
bb2600basic = bb2600basic || {};
|
||||
|
||||
var Module=typeof bb2600basic!=="undefined"?bb2600basic:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}else{return scriptDirectory+path}}if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",abort);Module["quit"]=(function(status){process["exit"](status)});Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}else{}var out=Module["print"]||(typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null);var err=Module["printErr"]||(typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||out);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.showLine truncated
|
||||
var asm=(/** @suppress {uselessCode} */ function(global,env,buffer) {
|
||||
"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.t|0;var j=env.u|0;var k=env.v|0;var l=env.w|0;var m=0;var n=0;var o=0;var p=0;var q=global.NaN,r=global.Infinity;var s=0,t=0,u=0,v=0,w=0.0;var x=0;var y=global.Math.floor;var z=global.Math.abs;var A=global.Math.sqrt;var B=global.Math.pow;var C=global.Math.cos;var D=global.Math.sin;var E=global.Math.tan;var F=global.Math.acos;var G=global.Math.asin;var H=global.Math.atan;var I=global.Math.atan2;var J=global.Math.exp;var K=global.Math.log;var L=global.Math.ceil;var M=global.Math.imul;var N=global.Math.min;var O=global.Math.max;var P=global.Math.clz32;var Q=env.a;var R=env.b;var S=env.c;var T=env.d;var U=env.e;var V=env.f;var W=env.g;var X=env.h;var Y=env.i;var Z=env.j;var _=env.k;var $=env.l;var aa=env.m;var ba=env.n;var ca=env.o;var da=env.p;var ea=env.q;var fa=env.r;var ga=env.s;var ha=0.0;
|
||||
// EMSCRIPTEN_START_FUNCS
|
||||
function ka(a){a=a|0;var b=0;b=k;k=k+a|0;k=k+15&-16;return b|0}function la(){return k|0}function ma(a){a=a|0;k=a}function na(a,b){a=a|0;b=b|0;k=a;l=b}function oa(a,b){a=a|0;b=b|0;if(!m){m=a;n=b}}function pa(a){a=a|0;x=a}function qa(){return x|0}function ra(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0;e=k;k=k+1200|0;f=e+1120|0;g=e+1112|0;h=e+1104|0;i=e+1096|0;j=e+1088|0;l=e+1080|0;m=e+1072|0;n=e+1064|0;o=e+1056|0;p=e+1048|0;q=e+1040|0;r=e+1032|0;s=e+1024|0;t=e+1016|0;u=e+1176|0;v=e+1172|0;w=e+1168|0;x=e+1164|0;y=e+1160|0;z=e+1156|0;A=e+1148|0;B=e+1144|0;C=e+1184|0;D=e+512|0;E=e;F=e+1140|0;G=e+1136|0;H=e+1132|0;I=e+1128|0;J=e+1124|0;c[e+1180>>2]=0;c[u>>2]=b;c[v>>2]=d;c[e+1152>>2]=0;c[A>>2]=0;c[G>>2]=0;c[H>>2]=3520;c[I>>2]=3532;c[J>>2]=0;a:while(1){d=sd(c[u>>2]|0,c[v>>2]|0,3560)|0;c[x>>2]=d;if((d|0)==-1)break;switch(c[x>>2]|0){case 63:{K=6;break a;break}case 105:{c[J>>2]=Zb(500)|0;bd(c[J>>2]|0,c[88538]|0)|0;break}case 114:{c[I>>2]=Zb(100)|0;bd(c[I>>2]|0,c[88538]|0)|0;break}default:{}}}if((K|0)==6){K=c[721]|0;c[t>>2]=c[c[v>>2]>>2];Od(K,3565,t)|0;ga(1)}c[88384]=0;Td(3621,s)|0;Wb(c[F>>2]|0);Va(c[J>>2]|0);c[w>>2]=Zb(200)|0;c[x>>2]=0;while(1){if((c[x>>2]|0)>=50)break;J=Zb(50)|0;c[(c[w>>2]|0)+(c[x>>2]<<2)>>2]=J;c[x>>2]=(c[x>>2]|0)+1}while(1){c[x>>2]=0;while(1){if((c[x>>2]|0)>=50)break;c[y>>2]=0;while(1){if((c[y>>2]|0)>=50)break;a[(c[(c[w>>2]|0)+(c[x>>2]<<2)>>2]|0)+(c[y>>2]|0)>>0]=0;c[y>>2]=(c[y>>2]|0)+1}c[x>>2]=(c[x>>2]|0)+1}c[B>>2]=Cd(D,500,c[689]|0)|0;cb();bd(E,D)|0;if(!(c[B>>2]|0))break;c[x>>2]=0;c[y>>2]=0;c[z>>2]=0;while(1){if(!(a[D+(c[x>>2]|0)>>0]|0))break;J=c[x>>2]|0;c[x>>2]=J+1;a[C>>0]=a[D+J>>0]|0;if((a[C>>0]|0)==32){if(!(c[G>>2]|0)){c[y>>2]=(c[y>>2]|0)+1;c[z>>2]=0}c[G>>2]=(c[G>>2]|0)+1}else{c[G>>2]=0;J=a[C>>0]|0;s=c[(c[w>>2]|0)+(c[y>>2]<<2)>>2]|0;t=c[z>>2]|0;c[z>>2]=t+1;a[s+t>>0]=J}}if((c[y>>2]|0)>40){J=c[721]|0;c[r>>2]=db()|0;Od(J,3627,r)|0}if(!(a[c[c[w>>2]>>2]>>0]|0)){J=c[c[w>>2]>>2]|0;t=c[A>>2]|0;c[A>>2]=t+1;c[q>>2]=t;lc(J,3652,q)|0}if(jc(c[c[w>>2]>>2]|0,12885,3)|0){c[p>>2]=c[c[w>>2]>>2];c[p+4>>2]=E;Td(3657,p)|0}Yb(c[w>>2]|0)}Ha()|0;c[88384]=Ia()|0;Wa();Td(3667,o)|0;if((c[88384]|0)==8)Td(3733,n)|0;if((c[88384]|0)==16)Td(3744,m)|0;if((c[88384]|0)!=32){Td(3766,j)|0;Td(3770,i)|0;Td(3770,h)|0;Td(3770,g)|0;L=c[F>>2]|0;M=c[I>>2]|0;Xb(L,M);N=c[H>>2]|0;Sa(N);O=c[721]|0;Od(O,3773,f)|0;k=e;return 0}Td(3755,l)|0;Td(3766,j)|0;Td(3770,i)|0;Td(3770,h)|0;Td(3770,g)|0;L=c[F>>2]|0;M=c[I>>2]|0;Xb(L,M);N=c[H>>2]|0;Sa(N);O=c[721]|0;Od(O,3773,f)|0;k=e;return 0}function sa(){var a=0;a=k;k=k+16|0;Td(3807,a)|0;k=a;return}function ta(){return c[88385]|0}function ua(){var a=0;a=k;k=k+16|0;Td(3821,a)|0;k=a;return}function va(b){b=b|0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0;d=k;k=k+80|0;e=d+64|0;f=d+56|0;g=d+72|0;h=d;i=d+68|0;c[g>>2]=b;c[i>>2]=0;wa();if(a[c[(c[g>>2]|0)+8>>2]>>0]|0?(a[c[(c[g>>2]|0)+8>>2]>>0]|0)!=58:0){c[i>>2]=xa(c[(c[g>>2]|0)+8>>2]|0,h)|0;if(c[i>>2]|0)ya(h);Td(3846,e)|0;za(c[(c[g>>2]|0)+8>>2]|0,c[i>>2]|0);j=c[g>>2]|0;l=j+4|0;m=c[l>>2]|0;Aa(m);n=c[g>>2]|0;o=n+4|0;p=c[o>>2]|0;Ba(p);k=d;return}Td(3837,f)|0;j=c[g>>2]|0;l=j+4|0;m=c[l>>2]|0;Aa(m);n=c[g>>2]|0;o=n+4|0;p=c[o>>2]|0;Ba(p);k=d;return}function wa(){bd(18400,4029)|0;return}function xa(b,d){b=b|0;d=d|0;var e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0;e=k;k=k+32|0;f=e+16|0;g=e+12|0;h=e+8|0;i=e+4|0;j=e;c[f>>2]=b;c[g>>2]=d;c[j>>2]=0;c[h>>2]=0;while(1){if((c[h>>2]|0)>=50)break;if(!(a[(c[f>>2]|0)+(c[h>>2]|0)>>0]|0)){l=4;break}if((a[(c[f>>2]|0)+(c[h>>2]|0)>>0]|0)==91){l=6;break}c[h>>2]=(c[h>>2]|0)+1}if((l|0)==4)c[h>>2]=50;else if((l|0)==6)c[j>>2]=1;if((c[h>>2]|0)>=50){m=c[j>>2]|0;k=e;return m|0}bd(c[g>>2]|0,(c[f>>2]|0)+(c[h>>2]|0)+1|0)|0;l=c[g>>2]|0;a[l+((Zc(c[g>>2]|0)|0)-1)>>0]=0;l=c[g>>2]|0;if((a[l+((Zc(c[g>>2]|0)|0)-2)>>0]|0)==93){l=c[g>>2]|0;a[l+((Zc(c[g>>2]|0)|0)-2)>>0]=0}l=c[g>>2]|0;if((a[l+((Zc(c[g>>2]|0)|0)-1)>>0]|0)==93){l=c[g>>2]|0;a[l+((Zc(c[g>>2]|0)|0)-1)>>0]=0}c[i>>2]=c[h>>2];while(1){if((c[i>>2]|0)>=50)break;a[(c[f>>2]|0)+(c[i>>2]|0)>>0]=0;c[i>>2]=(c[i>>2]|0)+1}m=c[j>>2]|0;k=e;return m|0}function ya(a){a=a|0;var b=0,d=0,e=0;b=k;k=k+16|0;d=b+8|0;e=b+12|0;c[e>>2]=a;Td(4023,b)|0;Ca(c[e>>2]|0)|0;c[d>>2]=c[e>>2];Td(4011,d)|0;k=b;return}function za(a,b){a=a|0;b=b|0;var d=0,e=0,f=0,g=0,h=0;d=k;k=k+32|0;e=d+8|0;f=d;g=d+16|0;h=d+12|0;c[g>>2]=a;c[h>>2]=b;b=c[g>>2]|0;if(c[h>>2]|0){c[e>>2]=b;Td(4015,e)|0;k=d;return}else{Ca(b)|0;c[f>>2]=c[g>>2];Td(4011,f)|0;k=d;return}}function Aa(b){b=b|0;var d=0,e=0;d=k;k=k+16|0;e=d;c[e>>2]=b;while(1){b=c[e>>2]|0;if((a[b+((Zc(c[e>>2]|0)|0)-1)>>0]|0)!=10?(b=c[e>>2]|0,(a[b+((Zc(c[e>>2]|0)|0)-1)>>0]|0)!=13):0)break;b=c[e>>2]|0;a[b+((Zc(c[e>>2]|0)|0)-1)>>0]=0}k=d;return}function Ba(a){a=a|0;var b=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0;b=k;k=k+144|0;d=b+128|0;e=b+120|0;f=b+112|0;g=b+104|0;h=b+96|0;i=b+88|0;j=b+80|0;l=b+72|0;m=b+64|0;n=b+56|0;o=b+48|0;p=b+40|0;q=b+32|0;r=b+24|0;s=b+16|0;tLine truncated
|
||||
function pc(d,e,f,g,i){d=d|0;e=e|0;f=f|0;g=g|0;i=i|0;var j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ba=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,na=0,oa=0,pa=0,qa=0,ra=0,sa=0,ta=0,ua=0,va=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0;j=k;k=k+64|0;l=j+56|0;m=j+40|0;n=j;o=j+48|0;p=j+60|0;c[l>>2]=e;e=(d|0)!=0;q=n+40|0;r=q;s=n+39|0;n=o+4|0;t=0;u=0;v=0;a:while(1){w=t;y=u;while(1){do if((y|0)>-1)if((w|0)>(2147483647-y|0)){c[(ec()|0)>>2]=75;z=-1;break}else{z=w+y|0;break}else z=y;while(0);A=c[l>>2]|0;B=a[A>>0]|0;if(!(B<<24>>24)){C=94;break a}D=B;B=A;b:while(1){switch(D<<24>>24){case 37:{C=10;break b;break}case 0:{E=B;break b;break}default:{}}F=B+1|0;c[l>>2]=F;D=a[F>>0]|0;B=F}c:do if((C|0)==10){C=0;D=B;F=B;while(1){if((a[F+1>>0]|0)!=37){E=D;break c}G=D+1|0;F=F+2|0;c[l>>2]=F;if((a[F>>0]|0)!=37){E=G;break}else D=G}}while(0);w=E-A|0;if(e)sc(d,A,w);if(!w)break;else y=z}y=(kc(a[(c[l>>2]|0)+1>>0]|0)|0)==0;w=c[l>>2]|0;if(!y?(a[w+2>>0]|0)==36:0){H=(a[w+1>>0]|0)+-48|0;I=1;J=3}else{H=-1;I=v;J=1}y=w+J|0;c[l>>2]=y;w=a[y>>0]|0;B=(w<<24>>24)+-32|0;if(B>>>0>31|(1<<B&75913|0)==0){K=0;L=w;M=y}else{w=0;D=B;B=y;while(1){y=1<<D|w;F=B+1|0;c[l>>2]=F;G=a[F>>0]|0;D=(G<<24>>24)+-32|0;if(D>>>0>31|(1<<D&75913|0)==0){K=y;L=G;M=F;break}else{w=y;B=F}}}if(L<<24>>24==42){if((kc(a[M+1>>0]|0)|0)!=0?(B=c[l>>2]|0,(a[B+2>>0]|0)==36):0){w=B+1|0;c[i+((a[w>>0]|0)+-48<<2)>>2]=10;N=c[g+((a[w>>0]|0)+-48<<3)>>2]|0;O=1;P=B+3|0}else{if(I|0){Q=-1;break}if(e){B=(c[f>>2]|0)+(4-1)&~(4-1);w=c[B>>2]|0;c[f>>2]=B+4;R=w}else R=0;N=R;O=0;P=(c[l>>2]|0)+1|0}c[l>>2]=P;w=(N|0)<0;S=w?0-N|0:N;T=w?K|8192:K;U=O;V=P}else{w=tc(l)|0;if((w|0)<0){Q=-1;break}S=w;T=K;U=I;V=c[l>>2]|0}do if((a[V>>0]|0)==46){w=V+1|0;if((a[w>>0]|0)!=42){c[l>>2]=w;w=tc(l)|0;W=w;X=c[l>>2]|0;break}if(kc(a[V+2>>0]|0)|0?(w=c[l>>2]|0,(a[w+3>>0]|0)==36):0){B=w+2|0;c[i+((a[B>>0]|0)+-48<<2)>>2]=10;D=c[g+((a[B>>0]|0)+-48<<3)>>2]|0;B=w+4|0;c[l>>2]=B;W=D;X=B;break}if(U|0){Q=-1;break a}if(e){B=(c[f>>2]|0)+(4-1)&~(4-1);D=c[B>>2]|0;c[f>>2]=B+4;Y=D}else Y=0;D=(c[l>>2]|0)+2|0;c[l>>2]=D;W=Y;X=D}else{W=-1;X=V}while(0);D=0;B=X;while(1){if(((a[B>>0]|0)+-65|0)>>>0>57){Q=-1;break a}w=B;B=B+1|0;c[l>>2]=B;Z=a[(a[w>>0]|0)+-65+(336+(D*58|0))>>0]|0;_=Z&255;if((_+-1|0)>>>0>=8)break;else D=_}if(!(Z<<24>>24)){Q=-1;break}w=(H|0)>-1;do if(Z<<24>>24==19)if(w){Q=-1;break a}else C=54;else{if(w){c[i+(H<<2)>>2]=_;F=g+(H<<3)|0;y=c[F+4>>2]|0;G=m;c[G>>2]=c[F>>2];c[G+4>>2]=y;C=54;break}if(!e){Q=0;break a}uc(m,_,f);$=c[l>>2]|0;C=55}while(0);if((C|0)==54){C=0;if(e){$=B;C=55}else aa=0}d:do if((C|0)==55){C=0;w=a[$+-1>>0]|0;y=(D|0)!=0&(w&15|0)==3?w&-33:w;w=T&-65537;G=(T&8192|0)==0?T:w;e:do switch(y|0){case 110:{switch((D&255)<<24>>24){case 0:{c[c[m>>2]>>2]=z;aa=0;break d;break}case 1:{c[c[m>>2]>>2]=z;aa=0;break d;break}case 2:{F=c[m>>2]|0;c[F>>2]=z;c[F+4>>2]=((z|0)<0)<<31>>31;aa=0;break d;break}case 3:{b[c[m>>2]>>1]=z;aa=0;break d;break}case 4:{a[c[m>>2]>>0]=z;aa=0;break d;break}case 6:{c[c[m>>2]>>2]=z;aa=0;break d;break}case 7:{F=c[m>>2]|0;c[F>>2]=z;c[F+4>>2]=((z|0)<0)<<31>>31;aa=0;break d;break}default:{aa=0;break d}}break}case 112:{ba=120;ca=W>>>0>8?W:8;da=G|8;C=67;break}case 88:case 120:{ba=y;ca=W;da=G;C=67;break}case 111:{F=m;ea=c[F>>2]|0;fa=c[F+4>>2]|0;F=wc(ea,fa,q)|0;ga=r-F|0;ha=F;ia=0;ja=13269;ka=(G&8|0)==0|(W|0)>(ga|0)?W:ga+1|0;la=G;ma=ea;na=fa;C=73;break}case 105:case 100:{fa=m;ea=c[fa>>2]|0;ga=c[fa+4>>2]|0;if((ga|0)<0){fa=ae(0,0,ea|0,ga|0)|0;F=x;oa=m;c[oa>>2]=fa;c[oa+4>>2]=F;pa=1;qa=13269;ra=fa;sa=F;C=72;break e}else{pa=(G&2049|0)!=0&1;qa=(G&2048|0)==0?((G&1|0)==0?13269:13271):13270;ra=ea;sa=ga;C=72;break e}break}case 117:{ga=m;pa=0;qa=13269;ra=c[ga>>2]|0;sa=c[ga+4>>2]|0;C=72;break}case 99:{a[s>>0]=c[m>>2];ta=s;ua=0;va=13269;wa=1;xa=w;ya=r;break}case 109:{za=yc(c[(ec()|0)>>2]|0)|0;C=77;break}case 115:{ga=c[m>>2]|0;za=(ga|0)==0?13279:ga;C=77;break}case 67:{c[o>>2]=c[m>>2];c[n>>2]=0;c[m>>2]=o;Aa=-1;C=81;break}case 83:{if(!W){Ac(d,32,S,0,G);Ba=0;C=91}else{Aa=W;C=81}break}case 65:case 71:case 70:case 69:case 97:case 103:case 102:case 101:{aa=Cc(d,+h[m>>3],S,W,G,y)|0;break d;break}default:{ta=A;ua=0;va=13269;wa=W;xa=G;ya=r}}while(0);f:do if((C|0)==67){C=0;y=m;ga=c[y>>2]|0;ea=c[y+4>>2]|0;y=vc(ga,ea,q,ba&32)|0;F=(da&8|0)==0|(ga|0)==0&(ea|0)==0;ha=y;ia=F?0:2;ja=F?13269:13269+(ba>>>4)|0;ka=ca;la=da;ma=ga;na=ea;C=73}else if((C|0)==72){C=0;ha=xc(ra,sa,q)|0;ia=pa;ja=qa;ka=W;la=G;ma=ra;na=sa;C=73}else if((C|0)==77){C=0;ea=zc(za,0,W)|0;ga=(ea|0)==0;ta=za;ua=0;va=13269;wa=ga?W:ea-za|0;xa=w;ya=ga?za+W|0:ea}else if((C|0)==81){C=0;ea=c[m>>2]|0;ga=0;while(1){F=c[ea>>2]|0;if(!F){Ca=ga;break}y=Bc(p,F)|0;Da=(y|0)<0;if(Da|y>>>0>(Aa-ga|0)>>>0){C=85;break}F=y+ga|0;if(Aa>>>0>F>>>0){ea=ea+4|0;ga=F}else{Ca=F;break}}if((C|0)==85){C=0;if(Da){Q=-1;break a}else Ca=ga}Ac(d,32,S,Ca,G);if(!Ca){Ba=0;C=91}else{ea=c[m>>2]|0;F=0;while(1){y=c[ea>>2]|0;if(!y){Ba=Ca;C=91;break f}fa=Bc(p,y)|0;F=fa+F|0;if((F|0)>(Ca|0)){Ba=Ca;C=91;break f}sc(Line truncated
|
||||
|
||||
// EMSCRIPTEN_END_FUNCS
|
||||
var ia=[me,ac];var ja=[ne,bc,cc,gc,hc,Rc,ne,ne];return{___errno_location:ec,___muldi3:_d,___udivdi3:de,_bitshift64Lshr:ee,_bitshift64Shl:fe,_free:_b,_i64Add:$d,_i64Subtract:ae,_llvm_bswap_i32:ge,_main:ra,_malloc:Zb,_memcpy:he,_memset:ie,_sbrk:je,dynCall_ii:ke,dynCall_iiii:le,establishStackSpace:na,getTempRet0:qa,runPostSets:Yd,setTempRet0:pa,setThrew:oa,stackAlloc:ka,stackRestore:ma,stackSave:la}})
|
||||
|
||||
|
||||
// EMSCRIPTEN_END_ASM
|
||||
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _main=Module["_main"]=asm["_main"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];Module["asm"]=asm;Module["getMemory"]=getMemory;Module["addRunDependency"]=addRunDependency;Module["removeRunDependency"]=removeRunDependency;Module["FS"]=FS;Module["FS_createFolder"]=FS.createFolder;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createLink"]=FS.createLink;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;if(memoryInitializer){if(!isDataURI(memoryInitializer)){memoryInitializer=locateFile(memoryInitializer)}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=function callMain(args){args=args||[];ensureInitRuntime();var argc=args.length+1;var argv=stackAlloc((argc+1)*4);HEAP32[argv>>2]=allocateUTF8OnStack(Module["thisProgram"]);for(var i=1;i<argc;i++){HEAP32[(argv>>2)+i]=allocateUTF8OnStack(args[i-1])}HEAP32[(argv>>2)+argc]=0;try{var ret=Module["_main"](argc,argv,0);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="SimulateInfiniteLoop"){Module["noExitRuntime"]=true;return}else{var toLog=e;if(e&&typeof e==="object"&&e.stack){toLog=[e,e.stack]}err("exception thrown: "+toLog);Module["quit"](1,e)}}finally{calledMain=true}};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setLine truncated
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return bb2600basic;
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = bb2600basic;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return bb2600basic; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["bb2600basic"] = bb2600basic;
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
|
||||
var preprocess = (function() {
|
||||
var _scriptDir = typeof document !== 'undefined' && document.currentScript ? document.currentScript.src : undefined;
|
||||
return (
|
||||
function(preprocess) {
|
||||
preprocess = preprocess || {};
|
||||
|
||||
var Module=typeof preprocess!=="undefined"?preprocess:{};var moduleOverrides={};var key;for(key in Module){if(Module.hasOwnProperty(key)){moduleOverrides[key]=Module[key]}}Module["arguments"]=[];Module["thisProgram"]="./this.program";Module["quit"]=(function(status,toThrow){throw toThrow});Module["preRun"]=[];Module["postRun"]=[];var ENVIRONMENT_IS_WEB=false;var ENVIRONMENT_IS_WORKER=false;var ENVIRONMENT_IS_NODE=false;var ENVIRONMENT_IS_SHELL=false;ENVIRONMENT_IS_WEB=typeof window==="object";ENVIRONMENT_IS_WORKER=typeof importScripts==="function";ENVIRONMENT_IS_NODE=typeof process==="object"&&typeof require==="function"&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER;ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module["locateFile"](path,scriptDirectory)}else{return scriptDirectory+path}}if(ENVIRONMENT_IS_NODE){scriptDirectory=__dirname+"/";var nodeFS;var nodePath;Module["read"]=function shell_read(filename,binary){var ret;ret=tryParseAsDataURI(filename);if(!ret){if(!nodeFS)nodeFS=require("fs");if(!nodePath)nodePath=require("path");filename=nodePath["normalize"](filename);ret=nodeFS["readFileSync"](filename)}return binary?ret:ret.toString()};Module["readBinary"]=function readBinary(filename){var ret=Module["read"](filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}assert(ret.buffer);return ret};if(process["argv"].length>1){Module["thisProgram"]=process["argv"][1].replace(/\\/g,"/")}Module["arguments"]=process["argv"].slice(2);process["on"]("uncaughtException",(function(ex){if(!(ex instanceof ExitStatus)){throw ex}}));process["on"]("unhandledRejection",abort);Module["quit"]=(function(status){process["exit"](status)});Module["inspect"]=(function(){return"[Emscripten Module object]"})}else if(ENVIRONMENT_IS_SHELL){if(typeof read!="undefined"){Module["read"]=function shell_read(f){var data=tryParseAsDataURI(f);if(data){return intArrayToString(data)}return read(f)}}Module["readBinary"]=function readBinary(f){var data;data=tryParseAsDataURI(f);if(data){return data}if(typeof readbuffer==="function"){return new Uint8Array(readbuffer(f))}data=read(f,"binary");assert(typeof data==="object");return data};if(typeof scriptArgs!="undefined"){Module["arguments"]=scriptArgs}else if(typeof arguments!="undefined"){Module["arguments"]=arguments}if(typeof quit==="function"){Module["quit"]=(function(status){quit(status)})}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(document.currentScript){scriptDirectory=document.currentScript.src}if(_scriptDir){scriptDirectory=_scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.lastIndexOf("/")+1)}else{scriptDirectory=""}Module["read"]=function shell_read(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText}catch(err){var data=tryParseAsDataURI(url);if(data){return intArrayToString(data)}throw err}};if(ENVIRONMENT_IS_WORKER){Module["readBinary"]=function readBinary(url){try{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}catch(err){var data=tryParseAsDataURI(url);if(data){return data}throw err}}}Module["readAsync"]=function readAsync(url,onload,onerror){var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=function xhr_onload(){if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}var data=tryParseAsDataURI(url);if(data){onload(data.buffer);return}onerror()};xhr.onerror=onerror;xhr.send(null)};Module["setWindowTitle"]=(function(title){document.title=title})}else{}var out=Module["print"]||(typeof console!=="undefined"?console.log.bind(console):typeof print!=="undefined"?print:null);var err=Module["printErr"]||(typeof printErr!=="undefined"?printErr:typeof console!=="undefined"&&console.warn.bind(console)||out);for(key in moduleOverrides){if(moduleOverrides.hasOwnProperty(key)){Module[key]=moduleOverrides[key]}}moduleOverrides=undefined;var STACK_ALIGN=16;function staticAlloc(size){var ret=STATICTOP;STATICTOP=STATICTOP+size+15&-16;return ret}function dynamicAlloc(size){var ret=HEAP32[DYNAMICTOP_PTR>>2];var end=ret+size+15&-16;HEAP32[DYNAMICTOP_PTR>>2]=end;if(end>=TOTAL_MEMORY){var success=enlargeMemory();if(!success){HEAP32[DYNAMICTOP_PTR>>2]=ret;return 0}}return ret}function alignMemory(size,factor){if(!factor)factor=STACK_ALIGN;var ret=size=Math.ceil(size/factor)*factor;return ret}function getNativeTypeSize(type){switch(type){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:{if(type[type.length-1]==="*"){return 4}else if(type[0]==="i"){var bits=parseInt(type.substr(1));assert(bits%8===0);return bits/8}else{return 0}}}}function warnOnce(text){if(!warnOnce.shown)Line truncated
|
||||
var asm=(/** @suppress {uselessCode} */ function(global,env,buffer) {
|
||||
"use asm";var a=new global.Int8Array(buffer);var b=new global.Int16Array(buffer);var c=new global.Int32Array(buffer);var d=new global.Uint8Array(buffer);var e=new global.Uint16Array(buffer);var f=new global.Uint32Array(buffer);var g=new global.Float32Array(buffer);var h=new global.Float64Array(buffer);var i=env.o|0;var j=env.p|0;var k=env.q|0;var l=env.r|0;var m=0;var n=0;var o=0;var p=0;var q=global.NaN,r=global.Infinity;var s=0,t=0,u=0,v=0,w=0.0;var x=0;var y=global.Math.floor;var z=global.Math.abs;var A=global.Math.sqrt;var B=global.Math.pow;var C=global.Math.cos;var D=global.Math.sin;var E=global.Math.tan;var F=global.Math.acos;var G=global.Math.asin;var H=global.Math.atan;var I=global.Math.atan2;var J=global.Math.exp;var K=global.Math.log;var L=global.Math.ceil;var M=global.Math.imul;var N=global.Math.min;var O=global.Math.max;var P=global.Math.clz32;var Q=env.a;var R=env.b;var S=env.c;var T=env.d;var U=env.e;var V=env.f;var W=env.g;var X=env.h;var Y=env.i;var Z=env.j;var _=env.k;var $=env.l;var aa=env.m;var ba=env.n;var ca=0.0;
|
||||
// EMSCRIPTEN_START_FUNCS
|
||||
function fa(a){a=a|0;var b=0;b=k;k=k+a|0;k=k+15&-16;return b|0}function ga(){return k|0}function ha(a){a=a|0;k=a}function ia(a,b){a=a|0;b=b|0;k=a;l=b}function ja(a,b){a=a|0;b=b|0;if(!m){m=a;n=b}}function ka(a){a=a|0;x=a}function la(){return x|0}function ma(){var e=0,f=0,g=0,h=0,i=0,j=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0,O=0,P=0,Q=0,R=0,S=0,T=0,U=0,V=0,W=0,X=0,Y=0,Z=0,_=0,$=0,aa=0,ca=0,da=0,ea=0,fa=0,ga=0,ha=0,ia=0,ja=0,ka=0,la=0,ma=0,wa=0,xa=0,ya=0,za=0,Aa=0,Ba=0,Ca=0,Da=0,Ea=0,Fa=0,Ga=0,Ha=0,Ia=0,Ja=0,Ka=0,La=0,Ma=0,Na=0,Oa=0,Pa=0,Qa=0,Ra=0,Sa=0,Ta=0,Ua=0,Va=0,Wa=0,Xa=0,Ya=0,Za=0,_a=0,$a=0,ab=0,bb=0;e=k;k=k+656|0;f=e+608|0;g=e+600|0;h=e+592|0;i=e+584|0;j=e+576|0;l=e+568|0;m=e+560|0;n=e+552|0;o=e+544|0;p=e+536|0;q=e+528|0;r=e+520|0;s=e+512|0;t=e+504|0;u=e+496|0;v=e+488|0;w=e+480|0;x=e+472|0;y=e+464|0;z=e+456|0;A=e+448|0;B=e+440|0;C=e+432|0;D=e+424|0;E=e+416|0;F=e+408|0;G=e+400|0;H=e+392|0;I=e+384|0;J=e+376|0;K=e+368|0;L=e+360|0;M=e+352|0;N=e+344|0;O=e+336|0;P=e+328|0;Q=e+320|0;R=e+312|0;S=e+304|0;T=e+296|0;U=e+288|0;V=e+280|0;W=e+272|0;X=e+264|0;Y=e+256|0;Z=e+248|0;_=e+240|0;$=e+232|0;aa=e+224|0;ca=e+216|0;da=e+208|0;ea=e+200|0;fa=e+192|0;ga=e+184|0;ha=e+176|0;ia=e+168|0;ja=e+160|0;ka=e+152|0;la=e+144|0;ma=e+136|0;wa=e+128|0;xa=e+120|0;ya=e+112|0;za=e+104|0;Aa=e+96|0;Ba=e+88|0;Ca=e+80|0;Da=e+72|0;Ea=e+64|0;Fa=e+56|0;Ga=e+48|0;Ha=e+40|0;Ia=e+32|0;Ja=e+24|0;Ka=e+16|0;La=e+8|0;Ma=e;Na=e+636|0;Oa=e+632|0;Pa=e+628|0;Qa=e+624|0;Ra=e+640|0;Sa=e+620|0;Ta=e+616|0;if(!(c[2218]|0)){c[2218]=1;if(!(c[2219]|0))c[2219]=1;if(!(c[2216]|0))c[2216]=c[1421];if(!(c[2217]|0))c[2217]=c[1485];if(!(c[2220]|0?(c[c[2220]>>2]|0)!=0:0)){na();Ua=oa(c[2216]|0,16384)|0;c[c[2220]>>2]=Ua}pa()}a:while(1){c[Oa>>2]=c[2221];a[c[Oa>>2]>>0]=a[9476]|0;c[Pa>>2]=c[Oa>>2];c[Na>>2]=c[2219];c[Na>>2]=(c[Na>>2]|0)+(c[(c[c[2220]>>2]|0)+28>>2]|0);b:while(1){do{a[Ra>>0]=a[16+(d[c[Oa>>2]>>0]|0)>>0]|0;if(b[272+(c[Na>>2]<<1)>>1]|0){c[2222]=c[Na>>2];c[2223]=c[Oa>>2]}while(1){Va=c[Na>>2]|0;if((b[768+((b[1488+(c[Na>>2]<<1)>>1]|0)+(d[Ra>>0]|0)<<1)>>1]|0)==(c[Na>>2]|0))break;c[Na>>2]=b[2e3+(Va<<1)>>1];if((c[Na>>2]|0)>=248)a[Ra>>0]=a[2512+(d[Ra>>0]|0)>>0]|0}c[Na>>2]=b[2576+((b[1488+(Va<<1)>>1]|0)+(d[Ra>>0]|0)<<1)>>1];c[Oa>>2]=(c[Oa>>2]|0)+1}while((b[1488+(c[Na>>2]<<1)>>1]|0)!=302);c:while(1){c[Qa>>2]=b[272+(c[Na>>2]<<1)>>1];if(!(c[Qa>>2]|0)){c[Oa>>2]=c[2223];c[Na>>2]=c[2222];c[Qa>>2]=b[272+(c[Na>>2]<<1)>>1]}c[2224]=c[Pa>>2];c[2225]=(c[Oa>>2]|0)-(c[Pa>>2]|0);a[9476]=a[c[Oa>>2]>>0]|0;a[c[Oa>>2]>>0]=0;c[2221]=c[Oa>>2];d:while(1){switch(c[Qa>>2]|0){case 46:{Wa=161;break a;break}case 81:{Wa=266;break a;break}case 95:case 94:case 93:case 92:case 91:case 90:case 89:case 88:case 87:case 86:case 85:case 84:{Wa=272;break a;break}case 1:{Wa=29;break b;break}case 2:{Wa=32;break b;break}case 3:{Wa=34;break b;break}case 4:{Wa=37;break b;break}case 5:{Wa=40;break b;break}case 6:{Wa=43;break b;break}case 7:{Wa=46;break b;break}case 8:{Wa=49;break b;break}case 9:{Wa=52;break b;break}case 10:{Wa=55;break b;break}case 11:{Wa=58;break b;break}case 12:{Wa=61;break b;break}case 13:{Wa=64;break b;break}case 14:{Wa=67;break b;break}case 15:{Wa=70;break b;break}case 16:{Wa=73;break b;break}case 17:{Wa=76;break b;break}case 18:{Wa=79;break b;break}case 19:{Wa=82;break b;break}case 20:{Wa=85;break b;break}case 21:{Wa=88;break b;break}case 22:{Wa=91;break b;break}case 23:{Wa=94;break b;break}case 24:{Wa=97;break b;break}case 25:{Wa=100;break b;break}case 26:{Wa=103;break b;break}case 27:{Wa=106;break b;break}case 28:{Wa=109;break b;break}case 29:{Wa=112;break b;break}case 30:{Wa=115;break b;break}case 31:{Wa=117;break b;break}case 32:{Wa=120;break b;break}case 33:{Wa=123;break b;break}case 34:{Wa=126;break b;break}case 35:{Wa=129;break b;break}case 36:{Wa=132;break b;break}case 37:{Wa=135;break b;break}case 38:{Wa=138;break b;break}case 39:{Wa=141;break b;break}case 40:{Wa=144;break b;break}case 41:{Wa=147;break b;break}case 42:{Wa=150;break b;break}case 43:{Wa=153;break b;break}case 44:{Wa=156;break b;break}case 45:{Wa=159;break b;break}case 47:{Wa=164;break b;break}case 48:{Wa=167;break b;break}case 49:{Wa=170;break b;break}case 50:{Wa=173;break b;break}case 51:{Wa=176;break b;break}case 52:{Wa=179;break b;break}case 53:{Wa=182;break b;break}case 54:{Wa=185;break b;break}case 55:{Wa=188;break b;break}case 56:{Wa=191;break b;break}case 57:{Wa=194;break b;break}case 58:{Wa=197;break b;break}case 59:{Wa=200;break b;break}case 60:{Wa=203;break b;break}case 61:{Wa=206;break b;break}case 62:{Wa=209;break b;break}case 63:{Wa=212;break b;break}case 64:{Wa=215;break b;break}case 65:{Wa=218;break b;break}case 66:{Wa=221;break b;break}case 67:{Wa=224;break b;break}case 68:{Wa=227;break b;break}case 69:{Wa=230;break b;break}case 70:{Wa=233;break b;break}case 71:{Wa=236;break b;break}case 72:{Wa=239;break b;break}case 73:{Wa=242;break b;break}case 74:{Wa=245;break b;break}case 75:{Wa=248;break b;break}case 76:{Wa=251;break
Line truncated
|
||||
|
||||
// EMSCRIPTEN_END_FUNCS
|
||||
var da=[Vb,Ga];var ea=[Wb,Ha,Ia,Ma,Na,Wb,Wb,Wb];return{___errno_location:Ka,___muldi3:Hb,___udivdi3:Mb,_bitshift64Lshr:Nb,_bitshift64Shl:Ob,_free:Ca,_i64Add:Ib,_i64Subtract:Jb,_llvm_bswap_i32:Pb,_main:Aa,_malloc:Ba,_memcpy:Qb,_memset:Rb,_sbrk:Sb,dynCall_ii:Tb,dynCall_iiii:Ub,establishStackSpace:ia,getTempRet0:la,runPostSets:Fb,setTempRet0:ka,setThrew:ja,stackAlloc:fa,stackRestore:ha,stackSave:ga}})
|
||||
|
||||
|
||||
// EMSCRIPTEN_END_ASM
|
||||
(Module.asmGlobalArg,Module.asmLibraryArg,buffer);var ___errno_location=Module["___errno_location"]=asm["___errno_location"];var ___muldi3=Module["___muldi3"]=asm["___muldi3"];var ___udivdi3=Module["___udivdi3"]=asm["___udivdi3"];var _bitshift64Lshr=Module["_bitshift64Lshr"]=asm["_bitshift64Lshr"];var _bitshift64Shl=Module["_bitshift64Shl"]=asm["_bitshift64Shl"];var _free=Module["_free"]=asm["_free"];var _i64Add=Module["_i64Add"]=asm["_i64Add"];var _i64Subtract=Module["_i64Subtract"]=asm["_i64Subtract"];var _llvm_bswap_i32=Module["_llvm_bswap_i32"]=asm["_llvm_bswap_i32"];var _main=Module["_main"]=asm["_main"];var _malloc=Module["_malloc"]=asm["_malloc"];var _memcpy=Module["_memcpy"]=asm["_memcpy"];var _memset=Module["_memset"]=asm["_memset"];var _sbrk=Module["_sbrk"]=asm["_sbrk"];var establishStackSpace=Module["establishStackSpace"]=asm["establishStackSpace"];var getTempRet0=Module["getTempRet0"]=asm["getTempRet0"];var runPostSets=Module["runPostSets"]=asm["runPostSets"];var setTempRet0=Module["setTempRet0"]=asm["setTempRet0"];var setThrew=Module["setThrew"]=asm["setThrew"];var stackAlloc=Module["stackAlloc"]=asm["stackAlloc"];var stackRestore=Module["stackRestore"]=asm["stackRestore"];var stackSave=Module["stackSave"]=asm["stackSave"];var dynCall_ii=Module["dynCall_ii"]=asm["dynCall_ii"];var dynCall_iiii=Module["dynCall_iiii"]=asm["dynCall_iiii"];Module["asm"]=asm;Module["getMemory"]=getMemory;Module["addRunDependency"]=addRunDependency;Module["removeRunDependency"]=removeRunDependency;Module["FS"]=FS;Module["FS_createFolder"]=FS.createFolder;Module["FS_createPath"]=FS.createPath;Module["FS_createDataFile"]=FS.createDataFile;Module["FS_createPreloadedFile"]=FS.createPreloadedFile;Module["FS_createLazyFile"]=FS.createLazyFile;Module["FS_createLink"]=FS.createLink;Module["FS_createDevice"]=FS.createDevice;Module["FS_unlink"]=FS.unlink;if(memoryInitializer){if(!isDataURI(memoryInitializer)){memoryInitializer=locateFile(memoryInitializer)}if(ENVIRONMENT_IS_NODE||ENVIRONMENT_IS_SHELL){var data=Module["readBinary"](memoryInitializer);HEAPU8.set(data,GLOBAL_BASE)}else{addRunDependency("memory initializer");var applyMemoryInitializer=(function(data){if(data.byteLength)data=new Uint8Array(data);HEAPU8.set(data,GLOBAL_BASE);if(Module["memoryInitializerRequest"])delete Module["memoryInitializerRequest"].response;removeRunDependency("memory initializer")});function doBrowserLoad(){Module["readAsync"](memoryInitializer,applyMemoryInitializer,(function(){throw"could not load memory initializer "+memoryInitializer}))}var memoryInitializerBytes=tryParseAsDataURI(memoryInitializer);if(memoryInitializerBytes){applyMemoryInitializer(memoryInitializerBytes.buffer)}else if(Module["memoryInitializerRequest"]){function useRequest(){var request=Module["memoryInitializerRequest"];var response=request.response;if(request.status!==200&&request.status!==0){var data=tryParseAsDataURI(Module["memoryInitializerRequestURL"]);if(data){response=data.buffer}else{console.warn("a problem seems to have happened with Module.memoryInitializerRequest, status: "+request.status+", retrying "+memoryInitializer);doBrowserLoad();return}}applyMemoryInitializer(response)}if(Module["memoryInitializerRequest"].response){setTimeout(useRequest,0)}else{Module["memoryInitializerRequest"].addEventListener("load",useRequest)}}else{doBrowserLoad()}}}Module["then"]=(function(func){if(Module["calledRun"]){func(Module)}else{var old=Module["onRuntimeInitialized"];Module["onRuntimeInitialized"]=(function(){if(old)old();func(Module)})}return Module});function ExitStatus(status){this.name="ExitStatus";this.message="Program terminated with exit("+status+")";this.status=status}ExitStatus.prototype=new Error;ExitStatus.prototype.constructor=ExitStatus;var initialStackTop;var calledMain=false;dependenciesFulfilled=function runCaller(){if(!Module["calledRun"])run();if(!Module["calledRun"])dependenciesFulfilled=runCaller};Module["callMain"]=function callMain(args){args=args||[];ensureInitRuntime();var argc=args.length+1;var argv=stackAlloc((argc+1)*4);HEAP32[argv>>2]=allocateUTF8OnStack(Module["thisProgram"]);for(var i=1;i<argc;i++){HEAP32[(argv>>2)+i]=allocateUTF8OnStack(args[i-1])}HEAP32[(argv>>2)+argc]=0;try{var ret=Module["_main"](argc,argv,0);exit(ret,true)}catch(e){if(e instanceof ExitStatus){return}else if(e=="SimulateInfiniteLoop"){Module["noExitRuntime"]=true;return}else{var toLog=e;if(e&&typeof e==="object"&&e.stack){toLog=[e,e.stack]}err("exception thrown: "+toLog);Module["quit"](1,e)}}finally{calledMain=true}};function run(args){args=args||Module["arguments"];if(runDependencies>0){return}preRun();if(runDependencies>0)return;if(Module["calledRun"])return;function doRun(){if(Module["calledRun"])return;Module["calledRun"]=true;if(ABORT)return;ensureInitRuntime();preMain();if(Module["onRuntimeInitialized"])Module["onRuntimeInitialized"]();if(Module["_main"]&&shouldRunNow)Module["callMain"](args);postRun()}if(Module["setStatus"]){Module["setStatus"]("Running...");setLine truncated
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return preprocess;
|
||||
}
|
||||
);
|
||||
})();
|
||||
if (typeof exports === 'object' && typeof module === 'object')
|
||||
module.exports = preprocess;
|
||||
else if (typeof define === 'function' && define['amd'])
|
||||
define([], function() { return preprocess; });
|
||||
else if (typeof exports === 'object')
|
||||
exports["preprocess"] = preprocess;
|
||||
|
||||
Binary file not shown.
File diff suppressed because it is too large.
Load diff
+184
-88
@@ -1,100 +1,196 @@
|
||||
import { BuildStep, BuildStepResult, gatherFiles, getWorkFileAsString, populateFiles, putWorkFile, staleFiles } from "../builder";
|
||||
import { EmscriptenModule, emglobal, execMain, load, print_fn, setupFS, setupStdin } from "../wasmutils";
|
||||
// batari Basic compiler (WASI/wasmtime build, v1.9)
|
||||
// Pipeline: preprocess | 2600basic > bB.asm ; postprocess -i . > final.asm ;
|
||||
// dasm final.asm -I./includes -f3 -p20 -> .bin/.lst/.sym
|
||||
// (The optional optimize/bbfilter/relocateBB stages are not used here.)
|
||||
import { WASIRunner } from "../../common/wasi/wasishim";
|
||||
import { CodeListingMap, WorkerError } from "../../common/workertypes";
|
||||
import { BuildStep, BuildStepResult, gatherFiles, staleFiles, store, putWorkFile, anyTargetChanged } from "../builder";
|
||||
import { loadWASMBinary } from "../wasmutils";
|
||||
import { loadWASIFilesystemZip } from "../wasiutils";
|
||||
import { parseDASMListing, parseSymbolMap, re_usl } from "./dasm";
|
||||
import { msvcErrorMatcher } from "../listingutils";
|
||||
|
||||
function preprocessBatariBasic(code: string): string {
|
||||
load("bbpreprocess");
|
||||
var bbout = "";
|
||||
function addbbout_fn(s) {
|
||||
bbout += s;
|
||||
bbout += "\n";
|
||||
let bbModules: { [name: string]: WebAssembly.Module } = {};
|
||||
let bbFS: any = null;
|
||||
|
||||
function getBBModule(name: string): WebAssembly.Module {
|
||||
if (!bbModules[name]) {
|
||||
bbModules[name] = new WebAssembly.Module(loadWASMBinary("bb/" + name));
|
||||
}
|
||||
var BBPRE: EmscriptenModule = emglobal.preprocess({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addbbout_fn,
|
||||
printErr: print_fn,
|
||||
noFSInit: true,
|
||||
});
|
||||
var FS = BBPRE.FS;
|
||||
setupStdin(FS, code);
|
||||
BBPRE.callMain([]);
|
||||
console.log("preprocess " + code.length + " -> " + bbout.length + " bytes");
|
||||
return bbout;
|
||||
return bbModules[name];
|
||||
}
|
||||
|
||||
export function compileBatariBasic(step: BuildStep): BuildStepResult {
|
||||
load("bb2600basic");
|
||||
var params = step.params;
|
||||
// stdout
|
||||
var asmout = "";
|
||||
function addasmout_fn(s) {
|
||||
asmout += s;
|
||||
asmout += "\n";
|
||||
async function getBBFilesystem() {
|
||||
if (!bbFS) {
|
||||
bbFS = await loadWASIFilesystemZip("bb-fs.zip");
|
||||
}
|
||||
// stderr
|
||||
var re_err1 = /[(](\d+)[)]:?\s*(.+)/;
|
||||
var errors = [];
|
||||
var errline = 0;
|
||||
function match_fn(s) {
|
||||
console.log(s);
|
||||
var matches = re_err1.exec(s);
|
||||
if (matches) {
|
||||
errline = parseInt(matches[1]);
|
||||
errors.push({
|
||||
line: errline,
|
||||
msg: matches[2]
|
||||
});
|
||||
return bbFS;
|
||||
}
|
||||
|
||||
function makeRunner(name: string): WASIRunner {
|
||||
const wasi = new WASIRunner();
|
||||
wasi.initSync(getBBModule(name));
|
||||
wasi.fs.setParent(bbFS);
|
||||
wasi.addPreopenDirectory(".");
|
||||
return wasi;
|
||||
}
|
||||
|
||||
function runRunner(wasi: WASIRunner, name: string, args: string[], errors: WorkerError[]): void {
|
||||
wasi.setArgs([name, ...args]);
|
||||
try {
|
||||
wasi.run();
|
||||
} catch (e) {
|
||||
errors.push({ line: 0, msg: "" + e });
|
||||
}
|
||||
}
|
||||
|
||||
// match "line #: error msg" lines from the 2600basic stderr
|
||||
function matchBasicErrors(stderr: string, path: string, errors: WorkerError[]): void {
|
||||
// e.g. "(14): error: Unknown keyword"
|
||||
const re = /\((\d+)\):?\s*(.+)/;
|
||||
for (let line of stderr.split("\n")) {
|
||||
const m = re.exec(line);
|
||||
if (m) {
|
||||
errors.push({ path: path, line: parseInt(m[1]), msg: m[2] });
|
||||
} else if (line.indexOf("error") >= 0 || line.indexOf("Error") >= 0) {
|
||||
errors.push({ line: 0, msg: line.trim() });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function compileBatariBasic(step: BuildStep): Promise<BuildStepResult> {
|
||||
gatherFiles(step, { mainFilePath: "main.bas" });
|
||||
var destpath = step.prefix + '.asm';
|
||||
if (staleFiles(step, [destpath])) {
|
||||
var BB: EmscriptenModule = emglobal.bb2600basic({
|
||||
noInitialRun: true,
|
||||
//logReadFiles:true,
|
||||
print: addasmout_fn,
|
||||
printErr: match_fn,
|
||||
noFSInit: true,
|
||||
TOTAL_MEMORY: 64 * 1024 * 1024,
|
||||
});
|
||||
var FS = BB.FS;
|
||||
populateFiles(step, FS);
|
||||
// preprocess, pipe file to stdin
|
||||
var code = getWorkFileAsString(step.path);
|
||||
code = preprocessBatariBasic(code);
|
||||
setupStdin(FS, code);
|
||||
setupFS(FS, '2600basic');
|
||||
execMain(step, BB, ["-i", "/share", step.path]);
|
||||
if (errors.length)
|
||||
return { errors: errors };
|
||||
// build final assembly output from include file list
|
||||
var includesout = FS.readFile("includes.bB", { encoding: 'utf8' });
|
||||
var redefsout = FS.readFile("2600basic_variable_redefs.h", { encoding: 'utf8' });
|
||||
var includes = includesout.trim().split("\n");
|
||||
var combinedasm = "";
|
||||
var splitasm = asmout.split("bB.asm file is split here");
|
||||
for (var incfile of includes) {
|
||||
var inctext;
|
||||
if (incfile == "bB.asm")
|
||||
inctext = splitasm[0];
|
||||
else if (incfile == "bB2.asm")
|
||||
inctext = splitasm[1];
|
||||
else
|
||||
inctext = FS.readFile("/share/includes/" + incfile, { encoding: 'utf8' });
|
||||
console.log(incfile, inctext.length);
|
||||
combinedasm += "\n\n;;;" + incfile + "\n\n";
|
||||
combinedasm += inctext;
|
||||
const destpath = step.prefix + '.asm';
|
||||
const binpath = step.prefix + '.bin';
|
||||
const lstpath = step.prefix + '.lst';
|
||||
const sympath = step.prefix + '.sym';
|
||||
if (!staleFiles(step, [destpath])) {
|
||||
return;
|
||||
}
|
||||
await getBBFilesystem();
|
||||
const errors: WorkerError[] = [];
|
||||
const srcpath = step.path;
|
||||
const srcdata = store.getFileData(srcpath);
|
||||
const source = typeof srcdata === 'string' ? new TextEncoder().encode(srcdata) : srcdata;
|
||||
|
||||
// 1. preprocess: source on stdin -> tokenized output
|
||||
const pre = makeRunner("preprocess");
|
||||
pre.stdin.write(source);
|
||||
pre.stdin.offset = 0; // reset so fd_read starts at BOF
|
||||
runRunner(pre, "preprocess", [], errors);
|
||||
matchBasicErrors(pre.fds[2].getBytesAsString(), srcpath, errors);
|
||||
if (errors.length) return { errors };
|
||||
const preprocessed = pre.fds[1].getBytes();
|
||||
|
||||
// helper: fail if the compiler exited nonzero with no parsed errors
|
||||
function checkExit(wasi: WASIRunner, msg: string) {
|
||||
if (wasi.errno != 0 && !errors.length) {
|
||||
errors.push({ line: 0, msg: msg });
|
||||
}
|
||||
// TODO: ; bB.asm file is split here
|
||||
putWorkFile(destpath, combinedasm);
|
||||
putWorkFile("2600basic.h", FS.readFile("/share/includes/2600basic.h"));
|
||||
putWorkFile("2600basic_variable_redefs.h", redefsout);
|
||||
}
|
||||
|
||||
// 2. 2600basic: preprocessed code on stdin -> bB.asm on stdout,
|
||||
// writes includes.bB + 2600basic_variable_redefs.h to cwd (-i . => ./includes)
|
||||
const basic = makeRunner("2600basic");
|
||||
basic.stdin.write(preprocessed);
|
||||
basic.stdin.offset = 0;
|
||||
runRunner(basic, "2600basic", ["-i", "."], errors);
|
||||
const basicerr = basic.fds[2].getBytesAsString();
|
||||
matchBasicErrors(basicerr, srcpath, errors);
|
||||
checkExit(basic, "Compilation failed.");
|
||||
if (errors.length) return { errors };
|
||||
const bbasm = basic.fds[1].getBytes();
|
||||
|
||||
// 3. postprocess: reads includes.bB + bB.asm from cwd -> composite asm on stdout
|
||||
const post = makeRunner("postprocess");
|
||||
post.fs.putFile("./bB.asm", bbasm);
|
||||
for (const f of basic.fs.getFiles()) {
|
||||
if (!f.name.startsWith('./includes/')) post.fs.putFile(f.name, f.getBytes());
|
||||
}
|
||||
runRunner(post, "postprocess", ["-i", "."], errors);
|
||||
checkExit(post, "Postprocess failed.");
|
||||
if (errors.length) return { errors };
|
||||
const asmout = post.fds[1].getBytes();
|
||||
putWorkFile(destpath, asmout);
|
||||
|
||||
// 4. dasm: assemble composite asm with include dir
|
||||
const dasm = makeRunner("dasm");
|
||||
dasm.fs.putFile("./" + destpath, asmout);
|
||||
for (const f of basic.fs.getFiles()) {
|
||||
if (!f.name.startsWith('./includes/')) dasm.fs.putFile(f.name, f.getBytes());
|
||||
}
|
||||
runRunner(dasm, "dasm", [destpath, "-I./includes", "-f3", "-p20",
|
||||
"-l" + lstpath, "-s" + sympath, "-o" + binpath], errors);
|
||||
// parse dasm stdout/stderr for warnings/errors
|
||||
const matcher = msvcErrorMatcher(errors);
|
||||
const unresolved = {};
|
||||
for (let line of dasm.fds[1].getBytesAsString().split("\n")) {
|
||||
matcher(line);
|
||||
let m = re_usl.exec(line);
|
||||
if (m) {
|
||||
unresolved[m[1]] = 0;
|
||||
}
|
||||
}
|
||||
for (let line of dasm.fds[2].getBytesAsString().split("\n")) {
|
||||
matcher(line);
|
||||
}
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
const alst = dasm.fs.getFile("./" + lstpath).getBytesAsString();
|
||||
const listings: CodeListingMap = {};
|
||||
for (let path of [...step.files, destpath]) {
|
||||
listings[path] = { lines: [] };
|
||||
}
|
||||
parseDASMListing(lstpath, alst, listings, errors, unresolved);
|
||||
if (errors.length) {
|
||||
return { errors: errors };
|
||||
}
|
||||
let asym;
|
||||
try {
|
||||
asym = dasm.fs.getFile("./" + sympath).getBytesAsString();
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return { errors: [{ line: 0, msg: "No symbol table generated, maybe segment overflow?" }] };
|
||||
}
|
||||
const symbolmap = parseSymbolMap(asym);
|
||||
const aout = dasm.fs.getFile("./" + binpath).getBytes();
|
||||
putWorkFile(binpath, aout);
|
||||
putWorkFile(lstpath, alst);
|
||||
putWorkFile(sympath, asym);
|
||||
// return unchanged if no files changed
|
||||
if (!anyTargetChanged(step, [binpath]))
|
||||
return;
|
||||
// map asm listing onto the BASIC editor view
|
||||
let lst = listings[destpath];
|
||||
if (lst) {
|
||||
lst.asmlines = lst.lines;
|
||||
lst.text = alst;
|
||||
lst.lines = [];
|
||||
}
|
||||
return {
|
||||
nexttool: "dasm",
|
||||
path: destpath,
|
||||
args: [destpath],
|
||||
files: [destpath, "2600basic.h", "2600basic_variable_redefs.h"],
|
||||
bblines: true,
|
||||
output: aout,
|
||||
listings: listings,
|
||||
errors: errors,
|
||||
symbolmap: symbolmap,
|
||||
origin: getOrigin(listings),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// Determine likely origin address from listing
|
||||
function getOrigin(listings: CodeListingMap): number | undefined {
|
||||
let minOffset: number | undefined;
|
||||
for (let key in listings) {
|
||||
let lst = listings[key];
|
||||
if (lst && lst.asmlines) {
|
||||
for (let line of lst.asmlines) {
|
||||
if (line.iscode && line.offset > 0) {
|
||||
if (minOffset === undefined || line.offset < minOffset) {
|
||||
minOffset = line.offset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return minOffset;
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { BuildStep, BuildStepResult, populateFiles, putWorkFile, anyTargetChange
|
||||
import { msvcErrorMatcher, re_crlf, re_msvc } from "../listingutils";
|
||||
import { execMain, emglobal, EmscriptenModule, load, loadWASMBinary } from "../wasmutils";
|
||||
|
||||
function parseDASMListing(lstpath: string, lsttext: string, listings: CodeListingMap, errors: WorkerError[], unresolved: {}) {
|
||||
export function parseDASMListing(lstpath: string, lsttext: string, listings: CodeListingMap, errors: WorkerError[], unresolved: {}) {
|
||||
// TODO: this gets very slow
|
||||
// TODO: macros that are on adjacent lines don't get offset addresses
|
||||
// 4 08ee a9 00 start lda #01workermain.js:23:5
|
||||
@@ -120,9 +120,9 @@ function parseDASMListing(lstpath: string, lsttext: string, listings: CodeListin
|
||||
}
|
||||
}
|
||||
|
||||
var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/;
|
||||
export var re_usl = /(\w+)\s+0000\s+[?][?][?][?]/;
|
||||
|
||||
function parseSymbolMap(asym: string) {
|
||||
export function parseSymbolMap(asym: string) {
|
||||
var symbolmap = {};
|
||||
for (var s of asym.split("\n")) {
|
||||
var toks = s.split(/\s+/);
|
||||
|
||||
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
Executable
BIN
Binary file not shown.
@@ -136,6 +136,12 @@ describe('Worker', function() {
|
||||
it('should assemble DASM', function(done) {
|
||||
compile('dasm', '\tprocessor 6502\n\torg $f000\n MAC mack\n lda #0\n ENDM\nfoo: mack\n mack\n', 'vcs.mame', done, 4, 4);
|
||||
});
|
||||
it('should compile batari Basic', function(done) {
|
||||
compileFiles('bataribasic', ['bb/helloworld.bas'], 'vcs', done, 4096);
|
||||
});
|
||||
it('should NOT compile batari Basic (compile error)', function(done) {
|
||||
compile('bataribasic', 'foo bar baz\n', 'vcs', done, 0, 0, 1);
|
||||
});
|
||||
it('should NOT assemble DASM', function(done) {
|
||||
compile('dasm', '\tprocessor 6502\n\torg $f000 ; this is a comment\nfoo asl a\n', 'vcs', done, 0, 0, 2);
|
||||
});
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
import assert from "assert";
|
||||
import { WASIRunner } from "../../src/common/wasi/wasishim";
|
||||
import * as fs from "fs";
|
||||
import { unzipWASIFilesystem } from "../../src/worker/wasiutils";
|
||||
|
||||
async function loadBBRunner(filename: string, bbfs: any): Promise<WASIRunner> {
|
||||
const wasmdata = fs.readFileSync(`./src/worker/wasm/bb/${filename}.wasm`);
|
||||
let shim = new WASIRunner();
|
||||
await shim.loadAsync(wasmdata);
|
||||
shim.fs.setParent(bbfs);
|
||||
shim.addPreopenDirectory(".");
|
||||
return shim;
|
||||
}
|
||||
|
||||
// load the bB include filesystem zip
|
||||
async function loadBBFS() {
|
||||
const zipdata = fs.readFileSync(`./src/worker/fs/bb-fs.zip`);
|
||||
return unzipWASIFilesystem(zipdata as any, "./");
|
||||
}
|
||||
|
||||
describe('test batariBasic WASI pipeline', function () {
|
||||
|
||||
it('2600basic -v', async function () {
|
||||
let shim = await loadBBRunner('2600basic', null);
|
||||
shim.setArgs(["2600basic", "-v"]);
|
||||
let errno = shim.run();
|
||||
assert.strictEqual(errno, 0);
|
||||
const stdout = shim.fds[1].getBytesAsString();
|
||||
assert.ok(stdout.indexOf('batari Basic') >= 0, stdout);
|
||||
});
|
||||
|
||||
it('compile helloworld.bas end-to-end', async function () {
|
||||
const bbfs = await loadBBFS();
|
||||
|
||||
// 1. preprocess: source on stdin -> tokenized output on stdout
|
||||
let pre = await loadBBRunner('preprocess', bbfs);
|
||||
pre.stdin.write(new TextEncoder().encode(
|
||||
fs.readFileSync('./presets/vcs/bb/helloworld.bas', 'utf8')));
|
||||
pre.stdin.offset = 0; // reset so fd_read starts at BOF
|
||||
pre.setArgs(["preprocess"]);
|
||||
assert.strictEqual(pre.run(), 0, pre.fds[2].getBytesAsString());
|
||||
const preprocessed = pre.fds[1].getBytes();
|
||||
assert.ok(preprocessed.length > 100);
|
||||
|
||||
// 2. 2600basic: preprocessed input -> bB.asm on stdout (-i . => ./includes)
|
||||
let basic = await loadBBRunner('2600basic', bbfs);
|
||||
basic.stdin.write(preprocessed);
|
||||
basic.stdin.offset = 0;
|
||||
basic.setArgs(["2600basic", "-i", "."]);
|
||||
assert.strictEqual(basic.run(), 0, basic.fds[2].getBytesAsString());
|
||||
const basicerr = basic.fds[2].getBytesAsString();
|
||||
assert.ok(basicerr.indexOf('compilation complete') >= 0, basicerr);
|
||||
const bbasm = basic.fds[1].getBytes();
|
||||
assert.ok(bbasm.length > 500);
|
||||
|
||||
// copy compiler-generated files (includes.bB, variable redefs) to next stage
|
||||
function copyGeneratedFiles(dest: WASIRunner) {
|
||||
for (const f of basic.fs.getFiles()) {
|
||||
if (!f.name.startsWith('./includes/')) {
|
||||
dest.fs.putFile(f.name, f.getBytes());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 3. postprocess: reads includes.bB + bB.asm from cwd -> composite asm
|
||||
let post = await loadBBRunner('postprocess', bbfs);
|
||||
post.fs.putFile("./bB.asm", bbasm);
|
||||
copyGeneratedFiles(post);
|
||||
post.setArgs(["postprocess", "-i", "."]);
|
||||
assert.strictEqual(post.run(), 0, post.fds[2].getBytesAsString());
|
||||
const asmout = post.fds[1].getBytes();
|
||||
assert.ok(asmout.length > 10000);
|
||||
|
||||
// 4. dasm: assemble composite asm (+ generated headers) with -I./includes
|
||||
let dasm = await loadBBRunner('dasm', bbfs);
|
||||
dasm.fs.putFile("./main.bas.asm", asmout);
|
||||
copyGeneratedFiles(dasm);
|
||||
dasm.setArgs(["dasm", "main.bas.asm", "-I./includes", "-f3", "-p20",
|
||||
"-lmain.bas.lst", "-smain.bas.sym", "-omain.bas.bin"]);
|
||||
assert.strictEqual(dasm.run(), 0, dasm.fds[2].getBytesAsString());
|
||||
const bin = dasm.fs.getFile("./main.bas.bin");
|
||||
assert.ok(bin && bin.size >= 2048, "bin size " + (bin && bin.size));
|
||||
});
|
||||
});
|
||||
@@ -123,7 +123,7 @@ describe('Tool metadata registry', function () {
|
||||
// preloadFS-backed tools
|
||||
assert.equal(getSharedFileSystemName('cc65', 'nes'), '65-nes');
|
||||
assert.equal(getSharedFileSystemName('sdcc', 'coleco'), 'sdcc');
|
||||
assert.equal(getSharedFileSystemName('bataribasic', 'vcs'), '2600basic');
|
||||
assert.equal(getSharedFileSystemName('bataribasic', 'vcs'), 'wasi:bb-fs.zip');
|
||||
assert.equal(getSharedFileSystemName('wiz'), 'wiz');
|
||||
// WASI zip-backed tools (cc2600/cc7800/armtcc/oscar64/dialog)
|
||||
assert.equal(getSharedFileSystemName('cc2600'), 'wasi:cc2600-fs.zip');
|
||||
|
||||
Reference in new issue
Block a user