diff --git a/src/ui.js b/src/ui.js index d411bac5..18e2e82a 100644 --- a/src/ui.js +++ b/src/ui.js @@ -34,9 +34,6 @@ if (window.Javatari) Javatari.AUTO_START = false; var PRESETS; // presets array var platform_id; var platform; // platform object -var originalFileID; -var originalText; -var userPaused; var toolbar = $("#controls_top"); @@ -80,6 +77,19 @@ var TOOL_TO_SOURCE_STYLE = { } var worker = new Worker("./src/worker/workermain.js"); + +var disasmview = CodeMirror(document.getElementById('disassembly'), { + mode: 'z80', + theme: 'cobalt', + tabSize: 8, + readOnly: true, + styleActiveLine: true +}); + +var originalFileID; +var originalText; +var userPaused; + var editor; var current_output; var current_preset_entry; @@ -92,13 +102,6 @@ var compparams; var trace_pending_at_pc; var store; var pendingWorkerMessages = 0; -var disasmview = CodeMirror(document.getElementById('disassembly'), { - mode: 'z80', - theme: 'cobalt', - tabSize: 8, - readOnly: true, - styleActiveLine: true -}); //scrollProfileView(disasmview); var currentDebugLine; @@ -107,7 +110,15 @@ var lastDebugState; var memorylist; +function deleteEditor() { + if (editor) { + $("#editor").empty(); + editor = null; + } +} + function newEditor(mode) { + deleteEditor(); var isAsm = mode=='6502' || mode =='z80' || mode=='verilog' || mode=='gas'; // TODO editor = CodeMirror(document.getElementById('editor'), { theme: 'mbo', @@ -188,8 +199,8 @@ function loadFile(fileid, filename, preset) { if (text) { loadCode(text, fileid); } else if (!text && preset) { - if (filename.indexOf('.') <= 0) - filename += ".a"; // TODO? + if (platform_id == 'vcs' && filename.indexOf('.') <= 0) + filename += ".a"; // legacy stuff console.log("Loading preset", fileid, filename, preset); if (text.length == 0) { console.log("Fetching", filename); @@ -215,9 +226,10 @@ function loadFile(fileid, filename, preset) { }); } +// can pass integer or string id function loadPreset(preset_id) { - // TODO - var index = parseInt(preset_id+""); + preloadWorker(preset_id); // TODO: what if multiple files + var index = parseInt(preset_id+""); // might fail -1 for (var i=0; i buildstartseq; } -/*function anyFilesChanged() { - for (var key in workfs) - if (wasChanged(workfs[key])) return true; - return false; -}*/ - function populateEntry(fs, path, entry) { fs.writeFile(path, entry.data, {encoding:entry.encoding}); fs.utime(path, entry.ts, entry.ts); @@ -229,6 +223,18 @@ function staleFiles(step, targets) { return false; } +function anyTargetChanged(step, targets) { + if (!step.maxts) throw "call populateFiles() first"; + // see if any target files are more recent than inputs + for (var i=0; i step.maxts) + return true; + } + console.log("unchanged", step.maxts, targets); + return false; +} + function execMain(step, mod, args) { starttime(); mod.callMain(args); @@ -623,7 +629,7 @@ function linkLD65(step) { putWorkFile("main.map", mapout); putWorkFile("main.vice", viceout); // return unchanged if no files changed - if (!staleFiles(step, ["main", "main.map", "main.vice"])) + if (!anyTargetChanged(step, ["main", "main.map", "main.vice"])) return; // parse symbol map (TODO: omit segments, constants) var symbolmap = {}; @@ -830,7 +836,7 @@ function linkSDLDZ80(step) putWorkFile("main.ihx", hexout); putWorkFile("main.noi", mapout); // return unchanged if no files changed - if (!staleFiles(step, ["main.ihx", "main.noi"])) + if (!anyTargetChanged(step, ["main.ihx", "main.noi"])) return; var listings = {}; diff --git a/test/cli/testworker.js b/test/cli/testworker.js index 97b57dc7..7f62f9f8 100644 --- a/test/cli/testworker.js +++ b/test/cli/testworker.js @@ -165,6 +165,7 @@ describe('Worker', function() { ]; doBuild(msgs, done, 8192, [1,1], 0); }); + // TODO: doesn't fail it('should not build unchanged files with CC65', function(done) { var m = { "updates":[