From 1a4d088ce25bae605e86d8c6ea1a1308018cb581 Mon Sep 17 00:00:00 2001 From: Steven Hugg Date: Mon, 6 Aug 2018 16:23:19 -0400 Subject: [PATCH] fixed apple2 code offset --- src/worker/workermain.js | 10 +++++----- test/cli/testworker.js | 6 ++++++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/worker/workermain.js b/src/worker/workermain.js index afa9911b..69f9ee5d 100644 --- a/src/worker/workermain.js +++ b/src/worker/workermain.js @@ -121,6 +121,7 @@ var PLATFORM_PARAMS = { define: '__APPLE2__', cfgfile: 'apple2-hgr.cfg', libargs: ['apple2.lib'], + __CODE_RUN__: 16384, }, 'apple2-e': { define: '__APPLE2__', @@ -597,7 +598,7 @@ function setupStdin(fs, code) { 000000r 1 .dbg line, "main.c", 3 000000r 1 A2 00 ldx #$00 */ -function parseCA65Listing(code, symbols, dbg) { +function parseCA65Listing(code, symbols, params, dbg) { var segofs = 0; // .dbg line, "main.c", 1 var segLineMatch = /[.]segment\s+"(\w+)"/; @@ -612,8 +613,7 @@ function parseCA65Listing(code, symbols, dbg) { if (segm) { var segname = segm[1]; var segsym = '__'+segname+'_RUN__'; - // TODO: doesn't work on apple2, needs __MAIN_START__? - segofs = parseInt(symbols[segsym])|0; + segofs = parseInt(symbols[segsym] || params[segsym]) || 0; } if (dbg) { var linem = dbgLineMatch.exec(line); @@ -734,8 +734,8 @@ function linkLD65(step) { for (var fn of step.files) { if (fn.endsWith('.lst')) { var lstout = FS.readFile(fn, {encoding:'utf8'}); - var asmlines = parseCA65Listing(lstout, symbolmap, false); - var srclines = parseCA65Listing(lstout, symbolmap, true); + var asmlines = parseCA65Listing(lstout, symbolmap, params, false); + var srclines = parseCA65Listing(lstout, symbolmap, params, true); putWorkFile(fn, lstout); listings[fn] = { asmlines:srclines.length ? asmlines : null, diff --git a/test/cli/testworker.js b/test/cli/testworker.js index dba3a2f4..0a65bd80 100644 --- a/test/cli/testworker.js +++ b/test/cli/testworker.js @@ -9,6 +9,8 @@ CACHE_WASM_MODULES = false; global.onmessage({data:{preload:'cc65', platform:'nes'}}); global.onmessage({data:{preload:'ca65', platform:'nes'}}); +global.onmessage({data:{preload:'cc65', platform:'apple2'}}); +global.onmessage({data:{preload:'ca65', platform:'apple2'}}); global.onmessage({data:{preload:'sdcc'}}); // TODO: check msg against spec @@ -290,6 +292,10 @@ describe('Worker', function() { var files = ['skeleton.sdcc', 'cp437.c']; compileFiles('sdcc', files, 'vicdual', done, 16416, [0,45], 0); // TODO? }); + it('should compile apple2 skeleton with CC65', function(done) { + var csource = ab2str(fs.readFileSync('presets/apple2/skeleton.cc65')); + compile('cc65', csource, 'apple2', done, 17349, 4, 0); + }); // TODO: test if compile, errors, then compile same file });