mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2024-11-28 23:49:20 +00:00
added cc65, asm/link to wasm, new timer funcs
This commit is contained in:
parent
6d972bf580
commit
041a0a056c
@ -1,5 +1,5 @@
|
|||||||
|
|
||||||
CC65FLAGS=-I/home/huggvey/compilers/cc65/include -I/home/huggvey/compilers/cc65/include/nes -L/home/huggvey/compilers/cc65/lib --cfg-path /home/huggvey/compilers/cc65/cfg/
|
CC65FLAGS=-I/home/hugg/compilers/cc65/include -I/home/hugg/compilers/cc65/include/nes -L/home/hugg/compilers/cc65/lib --cfg-path /home/hugg/compilers/cc65/cfg/ -v
|
||||||
|
|
||||||
all: \
|
all: \
|
||||||
default_neslib.neslib.nes default_conio.conio.nes \
|
default_neslib.neslib.nes default_conio.conio.nes \
|
||||||
@ -19,7 +19,7 @@ clean:
|
|||||||
cl65 $(CC65FLAGS) -o $@ -t nes $*.c nes.lib
|
cl65 $(CC65FLAGS) -o $@ -t nes $*.c nes.lib
|
||||||
|
|
||||||
%.rom: %.s
|
%.rom: %.s
|
||||||
ld65 -o $@ -C atarivec.cfg $*.o atari2600.lib
|
time ld65 -o $@ -C atarivec.cfg $*.o atari2600.lib
|
||||||
|
|
||||||
%.lzg: %.nes
|
%.lzg: %.nes
|
||||||
lzg $< | hexdump -v -e '"\n" 32/1 "%u,"' > $@
|
lzg $< | hexdump -v -e '"\n" 32/1 "%u,"' > $@
|
||||||
|
14
src/worker/wasm/ca65.js
Normal file
14
src/worker/wasm/ca65.js
Normal file
File diff suppressed because one or more lines are too long
BIN
src/worker/wasm/ca65.wasm
Normal file
BIN
src/worker/wasm/ca65.wasm
Normal file
Binary file not shown.
14
src/worker/wasm/cc65.js
Normal file
14
src/worker/wasm/cc65.js
Normal file
File diff suppressed because one or more lines are too long
BIN
src/worker/wasm/cc65.wasm
Normal file
BIN
src/worker/wasm/cc65.wasm
Normal file
Binary file not shown.
14
src/worker/wasm/ld65.js
Normal file
14
src/worker/wasm/ld65.js
Normal file
File diff suppressed because one or more lines are too long
BIN
src/worker/wasm/ld65.wasm
Normal file
BIN
src/worker/wasm/ld65.wasm
Normal file
Binary file not shown.
@ -96,6 +96,10 @@ var document = noop();
|
|||||||
document.documentElement = noop();
|
document.documentElement = noop();
|
||||||
document.documentElement.style = noop();
|
document.documentElement.style = noop();
|
||||||
|
|
||||||
|
var _t1, _t2;
|
||||||
|
function starttime() { _t1 = new Date(); }
|
||||||
|
function endtime(msg) { _t2 = new Date(); console.log(msg, _t2.getTime() - _t1.getTime(), "ms"); }
|
||||||
|
|
||||||
var fsMeta = {};
|
var fsMeta = {};
|
||||||
var fsBlob = {};
|
var fsBlob = {};
|
||||||
var wasmBlob = {};
|
var wasmBlob = {};
|
||||||
@ -138,6 +142,15 @@ function loadWASM(modulename, debug) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function loadNative(modulename, debug) {
|
||||||
|
// detect WASM
|
||||||
|
if (typeof WebAssembly === 'object') {
|
||||||
|
loadWASM(modulename);
|
||||||
|
return wasmBlob['sdcc'];
|
||||||
|
} else {
|
||||||
|
load(modulename);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var ATARI_CFG =
|
var ATARI_CFG =
|
||||||
"FEATURES {\nSTARTADDRESS: default = $9000;\n}\n"
|
"FEATURES {\nSTARTADDRESS: default = $9000;\n}\n"
|
||||||
@ -520,11 +533,12 @@ function assemblelinkCA65(code, platform, warnings) {
|
|||||||
function error_fn(s) {
|
function error_fn(s) {
|
||||||
errors += s + "\n";
|
errors += s + "\n";
|
||||||
}
|
}
|
||||||
load("ca65");
|
loadNative("ca65");
|
||||||
load("ld65");
|
loadNative("ld65");
|
||||||
var objout, lstout;
|
var objout, lstout;
|
||||||
{
|
{
|
||||||
var CA65 = ca65({
|
var CA65 = ca65({
|
||||||
|
wasmBinary: wasmBlob['ca65'],
|
||||||
noInitialRun:true,
|
noInitialRun:true,
|
||||||
//logReadFiles:true,
|
//logReadFiles:true,
|
||||||
print:print_fn,
|
print:print_fn,
|
||||||
@ -533,11 +547,14 @@ function assemblelinkCA65(code, platform, warnings) {
|
|||||||
var FS = CA65['FS'];
|
var FS = CA65['FS'];
|
||||||
setupFS(FS, '65');
|
setupFS(FS, '65');
|
||||||
FS.writeFile("main.s", code, {encoding:'utf8'});
|
FS.writeFile("main.s", code, {encoding:'utf8'});
|
||||||
|
starttime();
|
||||||
CA65.callMain(['-v', '-g', '-I', '/share/asminc', '-l', 'main.lst', "main.s"]);
|
CA65.callMain(['-v', '-g', '-I', '/share/asminc', '-l', 'main.lst', "main.s"]);
|
||||||
|
endtime("assemble");
|
||||||
objout = FS.readFile("main.o", {encoding:'binary'});
|
objout = FS.readFile("main.o", {encoding:'binary'});
|
||||||
lstout = FS.readFile("main.lst", {encoding:'utf8'});
|
lstout = FS.readFile("main.lst", {encoding:'utf8'});
|
||||||
}{
|
}{
|
||||||
var LD65 = ld65({
|
var LD65 = ld65({
|
||||||
|
wasmBinary: wasmBlob['ld65'],
|
||||||
noInitialRun:true,
|
noInitialRun:true,
|
||||||
//logReadFiles:true,
|
//logReadFiles:true,
|
||||||
print:print_fn,
|
print:print_fn,
|
||||||
@ -548,10 +565,12 @@ function assemblelinkCA65(code, platform, warnings) {
|
|||||||
setupFS(FS, '65');
|
setupFS(FS, '65');
|
||||||
FS.writeFile("main.o", objout, {encoding:'binary'});
|
FS.writeFile("main.o", objout, {encoding:'binary'});
|
||||||
var libargs = params.libargs;
|
var libargs = params.libargs;
|
||||||
|
starttime();
|
||||||
LD65.callMain(['--cfg-path', '/share/cfg', '--lib-path', '/share/lib',
|
LD65.callMain(['--cfg-path', '/share/cfg', '--lib-path', '/share/lib',
|
||||||
'-C', params.cfgfile,
|
'-C', params.cfgfile,
|
||||||
//'--dbgfile', 'main.dbg',
|
//'--dbgfile', 'main.dbg',
|
||||||
'-o', 'main', '-m', 'main.map', 'main.o'].concat(libargs));
|
'-o', 'main', '-m', 'main.map', 'main.o'].concat(libargs));
|
||||||
|
endtime("link");
|
||||||
if (errors.length) {
|
if (errors.length) {
|
||||||
return {errors:[{line:1,msg:errors}]};
|
return {errors:[{line:1,msg:errors}]};
|
||||||
}
|
}
|
||||||
@ -599,11 +618,13 @@ function compileCC65(code, platform) {
|
|||||||
var FS = CC65['FS'];
|
var FS = CC65['FS'];
|
||||||
setupFS(FS, '65');
|
setupFS(FS, '65');
|
||||||
FS.writeFile("main.c", code, {encoding:'utf8'});
|
FS.writeFile("main.c", code, {encoding:'utf8'});
|
||||||
|
starttime();
|
||||||
CC65.callMain(['-T', '-g', /*'-Cl',*/
|
CC65.callMain(['-T', '-g', /*'-Cl',*/
|
||||||
'-Oirs',
|
'-Oirs',
|
||||||
'-I', '/share/include',
|
'-I', '/share/include',
|
||||||
'-D' + params.define,
|
'-D' + params.define,
|
||||||
"main.c"]);
|
"main.c"]);
|
||||||
|
endtime("compile");
|
||||||
try {
|
try {
|
||||||
var asmout = FS.readFile("main.s", {encoding:'utf8'});
|
var asmout = FS.readFile("main.s", {encoding:'utf8'});
|
||||||
//console.log(asmout);
|
//console.log(asmout);
|
||||||
@ -700,8 +721,8 @@ function parseIHX(ihx, rom_start, rom_size) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function assemblelinkSDASZ80(code, platform) {
|
function assemblelinkSDASZ80(code, platform) {
|
||||||
load("sdasz80");
|
loadNative("sdasz80");
|
||||||
load("sdldz80");
|
loadNative("sdldz80");
|
||||||
var objout, lstout, symout;
|
var objout, lstout, symout;
|
||||||
var params = PLATFORM_PARAMS[platform];
|
var params = PLATFORM_PARAMS[platform];
|
||||||
if (!params) throw Error("Platform not supported: " + platform);
|
if (!params) throw Error("Platform not supported: " + platform);
|
||||||
@ -721,6 +742,7 @@ function assemblelinkSDASZ80(code, platform) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
var ASZ80 = sdasz80({
|
var ASZ80 = sdasz80({
|
||||||
|
wasmBinary: wasmBlob['sdasz80'],
|
||||||
noInitialRun:true,
|
noInitialRun:true,
|
||||||
//logReadFiles:true,
|
//logReadFiles:true,
|
||||||
print:match_asm_fn,
|
print:match_asm_fn,
|
||||||
@ -728,7 +750,9 @@ function assemblelinkSDASZ80(code, platform) {
|
|||||||
});
|
});
|
||||||
var FS = ASZ80['FS'];
|
var FS = ASZ80['FS'];
|
||||||
FS.writeFile("main.asm", code, {encoding:'utf8'});
|
FS.writeFile("main.asm", code, {encoding:'utf8'});
|
||||||
|
starttime();
|
||||||
ASZ80.callMain(['-plosgffwy', 'main.asm']);
|
ASZ80.callMain(['-plosgffwy', 'main.asm']);
|
||||||
|
endtime("assemble");
|
||||||
if (msvc_errors.length) {
|
if (msvc_errors.length) {
|
||||||
return {errors:msvc_errors};
|
return {errors:msvc_errors};
|
||||||
}
|
}
|
||||||
@ -749,6 +773,7 @@ function assemblelinkSDASZ80(code, platform) {
|
|||||||
}
|
}
|
||||||
var updateListing = !params.extra_link_args;
|
var updateListing = !params.extra_link_args;
|
||||||
var LDZ80 = sdldz80({
|
var LDZ80 = sdldz80({
|
||||||
|
wasmBinary: wasmBlob['sdldz80'],
|
||||||
noInitialRun:true,
|
noInitialRun:true,
|
||||||
//logReadFiles:true,
|
//logReadFiles:true,
|
||||||
print:match_aslink_fn,
|
print:match_aslink_fn,
|
||||||
@ -771,7 +796,9 @@ function assemblelinkSDASZ80(code, platform) {
|
|||||||
} else {
|
} else {
|
||||||
args.push('main.rel');
|
args.push('main.rel');
|
||||||
}
|
}
|
||||||
|
starttime();
|
||||||
LDZ80.callMain(args);
|
LDZ80.callMain(args);
|
||||||
|
endtime("link");
|
||||||
var hexout = FS.readFile("main.ihx", {encoding:'utf8'});
|
var hexout = FS.readFile("main.ihx", {encoding:'utf8'});
|
||||||
var mapout = FS.readFile("main.noi", {encoding:'utf8'});
|
var mapout = FS.readFile("main.noi", {encoding:'utf8'});
|
||||||
var rstout = updateListing ? FS.readFile("main.rst", {encoding:'utf8'}) : lstout;
|
var rstout = updateListing ? FS.readFile("main.rst", {encoding:'utf8'}) : lstout;
|
||||||
@ -808,11 +835,7 @@ function compileSDCC(code, platform) {
|
|||||||
var params = PLATFORM_PARAMS[platform];
|
var params = PLATFORM_PARAMS[platform];
|
||||||
if (!params) throw Error("Platform not supported: " + platform);
|
if (!params) throw Error("Platform not supported: " + platform);
|
||||||
|
|
||||||
// detect WASM
|
loadNative('sdcc');
|
||||||
if (typeof WebAssembly === 'object')
|
|
||||||
loadWASM("sdcc");
|
|
||||||
else
|
|
||||||
load("sdcc");
|
|
||||||
var SDCC = sdcc({
|
var SDCC = sdcc({
|
||||||
wasmBinary: wasmBlob['sdcc'],
|
wasmBinary: wasmBlob['sdcc'],
|
||||||
noInitialRun:true,
|
noInitialRun:true,
|
||||||
@ -826,7 +849,6 @@ function compileSDCC(code, platform) {
|
|||||||
setupFS(FS, 'sdcc');
|
setupFS(FS, 'sdcc');
|
||||||
//FS.writeFile("main.c", code, {encoding:'utf8'});
|
//FS.writeFile("main.c", code, {encoding:'utf8'});
|
||||||
msvc_errors = [];
|
msvc_errors = [];
|
||||||
var t1 = new Date();
|
|
||||||
var args = ['--vc', '--std-sdcc99', '-mz80', //'-Wall',
|
var args = ['--vc', '--std-sdcc99', '-mz80', //'-Wall',
|
||||||
'--c1mode', // '--debug',
|
'--c1mode', // '--debug',
|
||||||
//'-S', 'main.c',
|
//'-S', 'main.c',
|
||||||
@ -842,10 +864,9 @@ function compileSDCC(code, platform) {
|
|||||||
if (params.extra_compile_args) {
|
if (params.extra_compile_args) {
|
||||||
args.push.apply(args, params.extra_compile_args);
|
args.push.apply(args, params.extra_compile_args);
|
||||||
}
|
}
|
||||||
|
starttime();
|
||||||
SDCC.callMain(args);
|
SDCC.callMain(args);
|
||||||
var t2 = new Date();
|
endtime("compile");
|
||||||
//console.profileEnd();
|
|
||||||
console.log(t2.getTime() - t1.getTime() + " ms");
|
|
||||||
/*
|
/*
|
||||||
// ignore if all are warnings (TODO?)
|
// ignore if all are warnings (TODO?)
|
||||||
var nwarnings = 0;
|
var nwarnings = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user