mirror of
https://github.com/sehugg/8bitworkshop.git
synced 2025-04-06 17:39:40 +00:00
WASM support for SDCC compiler; had to fix some presets
This commit is contained in:
parent
00d6b8aefa
commit
6d972bf580
@ -14,6 +14,18 @@ wasm/%.js: js/%.bc
|
||||
emcc -Oz --memory-init-file 0 \
|
||||
-s WASM=1 \
|
||||
-s MODULARIZE=1 \
|
||||
-s BINARYEN_ASYNC_COMPILATION=0 \
|
||||
-s TOTAL_MEMORY=256MB \
|
||||
-s NO_EXIT_RUNTIME=1 \
|
||||
-s EXPORT_NAME=\"'$*'\" \
|
||||
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=["FS"]' \
|
||||
-s FORCE_FILESYSTEM=1 \
|
||||
$< -o $@ $(ARGS_$*) \
|
||||
|
||||
|
||||
mainwasm/%.js: js/%.bc
|
||||
emcc -Oz --memory-init-file 0 \
|
||||
-s WASM=1 \
|
||||
-s EXPORT_NAME=\"'$*'\" \
|
||||
-s 'EXTRA_EXPORTED_RUNTIME_METHODS=["FS"]' \
|
||||
-s FORCE_FILESYSTEM=1 \
|
||||
|
@ -43,7 +43,7 @@ cd ../..
|
||||
echo Making SDCC...
|
||||
emmake make
|
||||
|
||||
echo Making JS files...
|
||||
echo Making Emscripten files...
|
||||
popd
|
||||
mkdir -p ./js ./wasm
|
||||
cp /tmp/sdcc/sdcc/bin/sdcc js/sdcc.bc
|
||||
|
@ -137,24 +137,23 @@ void clrscr() {
|
||||
|
||||
volatile byte video_framecount; // actual framecount
|
||||
|
||||
void reset_video_framecount() __critical {
|
||||
video_framecount = 0;
|
||||
}
|
||||
|
||||
void _buffer() {
|
||||
__asm
|
||||
; padding to get to offset 0x66
|
||||
ld ix,#0
|
||||
ld ix,#0
|
||||
ld ix,#0
|
||||
nop
|
||||
__endasm;
|
||||
}
|
||||
|
||||
// needs to start at offset 0x66
|
||||
void rst_66() __interrupt {
|
||||
video_framecount++;
|
||||
}
|
||||
|
||||
void reset_video_framecount() __critical {
|
||||
video_framecount = 0;
|
||||
}
|
||||
|
||||
byte getchar(byte x, byte y) {
|
||||
return vram[29-x][y];
|
||||
}
|
||||
@ -734,3 +733,4 @@ void main() {
|
||||
play_round();
|
||||
main();
|
||||
}
|
||||
|
||||
|
@ -143,11 +143,6 @@ void _buffer() {
|
||||
__asm
|
||||
; padding to get to offset 0x66
|
||||
ld ix,#0
|
||||
ld ix,#0
|
||||
ld ix,#0
|
||||
nop
|
||||
nop
|
||||
nop
|
||||
__endasm;
|
||||
}
|
||||
|
||||
|
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
14
src/worker/wasm/sdasz80.js
Normal file
14
src/worker/wasm/sdasz80.js
Normal file
File diff suppressed because one or more lines are too long
BIN
src/worker/wasm/sdasz80.wasm
Normal file
BIN
src/worker/wasm/sdasz80.wasm
Normal file
Binary file not shown.
14
src/worker/wasm/sdcc.js
Normal file
14
src/worker/wasm/sdcc.js
Normal file
File diff suppressed because one or more lines are too long
BIN
src/worker/wasm/sdcc.wasm
Normal file
BIN
src/worker/wasm/sdcc.wasm
Normal file
Binary file not shown.
14
src/worker/wasm/sdldz80.js
Normal file
14
src/worker/wasm/sdldz80.js
Normal file
File diff suppressed because one or more lines are too long
BIN
src/worker/wasm/sdldz80.wasm
Normal file
BIN
src/worker/wasm/sdldz80.wasm
Normal file
Binary file not shown.
@ -808,18 +808,13 @@ function compileSDCC(code, platform) {
|
||||
var params = PLATFORM_PARAMS[platform];
|
||||
if (!params) throw Error("Platform not supported: " + platform);
|
||||
|
||||
load("sdcc");
|
||||
//loadWASM("sdcc");
|
||||
//var wasmmod = new WebAssembly.Module(wasmBlob['sdcc']);
|
||||
//var wasminst = new WebAssembly.Instance(wasmmod);
|
||||
//var webasm = WebAssembly.instantiate(wasmBlob['sdcc']).then(foo => console.log(foo));
|
||||
// detect WASM
|
||||
if (typeof WebAssembly === 'object')
|
||||
loadWASM("sdcc");
|
||||
else
|
||||
load("sdcc");
|
||||
var SDCC = sdcc({
|
||||
instantiateWasm: function(info, recv) {
|
||||
var inst = new WebAssembly.Instance(wasmmod, info);
|
||||
recv(inst);
|
||||
return true;
|
||||
},
|
||||
//wasmBinary: wasmBlob['sdcc'],
|
||||
wasmBinary: wasmBlob['sdcc'],
|
||||
noInitialRun:true,
|
||||
noFSInit:true,
|
||||
print:print_fn,
|
||||
@ -835,7 +830,8 @@ function compileSDCC(code, platform) {
|
||||
var args = ['--vc', '--std-sdcc99', '-mz80', //'-Wall',
|
||||
'--c1mode', // '--debug',
|
||||
//'-S', 'main.c',
|
||||
//'--asm=z80asm',
|
||||
//'--asm=sdasz80',
|
||||
//'--reserve-regs-iy',
|
||||
'--less-pedantic',
|
||||
///'--fomit-frame-pointer',
|
||||
'--opt-code-speed',
|
||||
@ -849,7 +845,7 @@ function compileSDCC(code, platform) {
|
||||
SDCC.callMain(args);
|
||||
var t2 = new Date();
|
||||
//console.profileEnd();
|
||||
//console.log(t2.getTime() - t1.getTime());
|
||||
console.log(t2.getTime() - t1.getTime() + " ms");
|
||||
/*
|
||||
// ignore if all are warnings (TODO?)
|
||||
var nwarnings = 0;
|
||||
|
@ -105,10 +105,10 @@ describe('Worker', function() {
|
||||
compile('plasm', 'word x = ', 'apple2', done, 0, 0, 1);
|
||||
});
|
||||
it('should compile CC65', function(done) {
|
||||
compile('cc65', '#include <stdio.h>\nint main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'apple2', done, 2947, 4);
|
||||
compile('cc65', 'int main() {\nint x=1;\nreturn x+2;\n}', 'nes-conio', done, 2947, 4);
|
||||
});
|
||||
it('should NOT compile CC65', function(done) {
|
||||
compile('cc65', 'int main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'apple2', done, 0, 0, 1);
|
||||
compile('cc65', 'int main() {\nint x=1;\nprintf("%d",x);\nreturn x+2;\n}', 'nes-conio', done, 0, 0, 1);
|
||||
});
|
||||
it('should assemble Z80ASM', function(done) {
|
||||
compile('z80asm', '\tMODULE test\n\tXREF _puts\n\tld hl,$0000\n\tret\n', 'mw8080bw', done, 4, 2, 0);
|
||||
|
Loading…
x
Reference in New Issue
Block a user