1
0
mirror of https://github.com/sehugg/8bitworkshop.git synced 2024-11-26 10:49:17 +00:00

nicer disassembly window

This commit is contained in:
Steven Hugg 2017-01-08 10:51:19 -05:00
parent 6c8d52e64a
commit 65e59d350d
4 changed files with 53 additions and 10 deletions

View File

@ -252,10 +252,12 @@ a.dropdown-toggle {
<script src="codemirror/mode/6502/6502.js"></script>
<link rel="stylesheet" href="css/codemirror.css">
<link rel="stylesheet" href="codemirror/theme/mbo.css">
<link rel="stylesheet" href="codemirror/theme/cobalt.css">
<script src="codemirror/addon/search/search.js"></script>
<script src="codemirror/addon/search/searchcursor.js"></script>
<script src="codemirror/addon/search/jumpToLine.js"></script>
<script src="codemirror/addon/dialog/dialog.js"></script>
<script src="codemirror/addon/selection/active-line.js"></script>
<link rel="stylesheet" href="codemirror/addon/dialog/dialog.css">
<script src="javatari.js/release/javatari/javatari.js"></script>

View File

@ -68,7 +68,7 @@ function formatAbsoluteIndexedY (args) {
}
function formatIndirect (args) {
return this.name + " ($" + formatHex(args[0], 2) + ")";
return this.name + " ($" + formatHex(args[1], 2) + formatHex(args[0], 2) + ")";
}
function formatIndirectIndexedX (args) {

View File

@ -51,7 +51,15 @@ var editor = CodeMirror(document.getElementById('editor'), {
tabSize: 8,
gutters: ["CodeMirror-linenumbers", "gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"],
});
//editor.setSize("100%", "95%"); // TODO
var disasmview = CodeMirror(document.getElementById('disassembly'), {
mode: '6502',
theme: 'cobalt',
tabSize: 8,
readOnly: true,
styleActiveLine: true,
gutters: ["gutter-offset", "gutter-bytes", "gutter-clock", "gutter-info"],
});
editor.on('changes', function(ed, changeobj) {
var text = editor.getValue() || "";
setCode(text);
@ -705,17 +713,49 @@ function showLoopTimingForCurrentLine() {
function updateDisassembly() {
var div = $("#disassembly");
if (div.is(':visible')) {
div.empty();
disasmview.clearGutter("gutter-info");
disasmview.clearGutter("gutter-bytes");
disasmview.clearGutter("gutter-offset");
disasmview.clearGutter("gutter-clock");
var state = lastDebugState || platform.saveState();
var mem = state.b;
var pc = state.c.PC;
var disasm = new Disassembler6502().disassemble(mem, pc, pc+128, pcvisits);
var gutters = [];
var selline = 0;
// TODO: not perfect disassembler
function disassemble(start, end) {
if (start < 0) start = 0;
if (end > mem.length) end = mem.length;
var disasm = new Disassembler6502().disassemble(mem, start, end, pcvisits);
var s = "";
for (a in disasm) {
var line = hex(parseInt(a)) + " " + disasm[a] + "\n";
s += line;
var srclinenum = offset2line[a];
if (srclinenum) {
var srcline = editor.getLine(srclinenum-1);
if (srcline && srcline.trim().length) {
s += "; " + srclinenum + ":\t" + srcline + "\n";
gutters.push([a]);
}
$("<pre></pre>").appendTo(div).text(s);
}
var dline = hex(parseInt(a)) + "\t" + disasm[a] + "\n";
s += dline;
if (a == pc) selline = gutters.length;
gutters.push([]);
}
return s;
}
var text = disassemble(pc-96, pc) + disassemble(pc, pc+96);
disasmview.setValue(text);
/*
for (var i=0; i<gutters.length; i++) {
var g = gutters[i];
if (g[0]) disasmview.setGutterMarker(i, "gutter-offset", hex(g[0]));
}
*/
disasmview.setCursor(selline, 0);
// TODO: need to refresh when viewport changes
var scrinfo = disasmview.getScrollInfo();
disasmview.scrollTo(0, (scrinfo.height-scrinfo.clientHeight)/2);
}
}

View File

@ -181,6 +181,7 @@ function compilePLASMA(code) {
FS.writeFile("main.pla", code);
Module.callMain(["-A"]);
//console.log("plasm", code.length, "->", outstr.length);
console.log(outstr);
return assembleACME(outstr);
}
@ -260,7 +261,7 @@ function compileCC65(code, platform) {
var FS = CC65['FS'];
setupFS(FS);
FS.writeFile("main.c", code, {encoding:'utf8'});
CC65.callMain(['-v', '-T', '-g', '-Oirs', '-I', '/share/include', '-t', platform, "main.c"]);
CC65.callMain(['-v', '-T', '-g', '-Cl', '-Oirs', '-I', '/share/include', '-t', platform, "main.c"]);
var asmout = FS.readFile("main.s", {encoding:'utf8'});
return assemblelinkCA65(asmout, platform);
}