HALT fix, QoL tweaks

This commit is contained in:
2021-09-20 14:32:09 +00:00
parent 89feaaa3e9
commit b33a6c3055
7 changed files with 89 additions and 56 deletions
+1 -1
View File
@@ -121,7 +121,7 @@ globalThis.App = class App {
// ROM buffer has been configured
setROM(msg) {
let dbg = this.debuggers[msg.sim];
dbg.refresh();
dbg.refresh(true);
}
+2 -2
View File
@@ -46,8 +46,8 @@ globalThis.Debugger = class Debugger {
}
// Reload all output
refresh() {
this.cpu .refresh();
refresh(seekToPC) {
this.cpu .refresh(seekToPC);
this.memory.refresh();
}
+1 -1
View File
@@ -234,7 +234,7 @@
case "ReadBuffer" : this.readBuffer (msg); break;
case "SetRegister" : this.setRegister (msg); break;
case "RunNext": case "SingleStep":
this.refresh(true); break;
this.debug.refresh(true); break;
}
}
+4 -2
View File
@@ -345,8 +345,10 @@
let reg2 = this.PROREGNAMES[bits >> 21 & 31];
let reg1 = this.PROREGNAMES[bits >> 16 & 31];
let disp = this.signExtend(bits & 0xFFFF, 16);
disp = disp == 0 ? "" : (disp < 0 ? "-" : "") + "0x" +
Math.abs(disp).toString(16).toUpperCase();
disp = disp == 0 ? "" : (disp < -255 || disp > 255) ? "0x" +
("000" + (disp & 0xFFFF).toString(16).toUpperCase()).slice(-4) :
(disp < 0 ? "-" : "") + "0x" +
Math.abs(disp).toString(16).toUpperCase();
switch (inst.opcode) {
case 0b110000: // LD.B
case 0b110001: // LD.H
+28 -9
View File
@@ -99,8 +99,8 @@ globalThis.MemoryWindow = class MemoryWindow extends Toolkit.Window {
// Message received
message(msg) {
switch (msg.command) {
case "ReadBuffer": this.readBuffer(msg); break;
case "Write" : this.debug.refresh(); break;
case "ReadBuffer": this.readBuffer(msg) ; break;
case "Write" : this.debug.refresh(false); break;
}
}
@@ -380,6 +380,7 @@ MemoryWindow.Row = class Row extends Toolkit.Panel {
// Configure element
this.element.setAttribute("role", "row");
this.element.addEventListener("pointerdown", e=>this.onpointerdown(e));
// Address label
this.addr = this.add(parent.newLabel({ text: "\u00a0" }));
@@ -418,6 +419,31 @@ MemoryWindow.Row = class Row extends Toolkit.Panel {
return (this.wnd.address + this.offset & 0xFFFFFFFF) >>> 0;
}
// Pointer down event handler
onpointerdown(e) {
// Error checking
if (e.button != 0)
return;
// Check whether the click is within the columns of cells
let next = this.cells[0].getBounds();
if (e.x < next.left)
return;
// Compute which cell was clicked
for (let x = 0; x < 16; x++) {
let cur = next;
if (x < 15) {
next = this.cells[x + 1].getBounds();
if (e.x < (cur.right + next.left) / 2)
return this.wnd.setSelected(this.cells[x].address());
} else if (e.x < cur.right)
return this.wnd.setSelected(this.cells[x].address());
}
}
};
// One cell of output
@@ -435,7 +461,6 @@ MemoryWindow.Cell = class Cell extends Toolkit.Label {
// Configure element
this.element.setAttribute("role", "gridcell");
this.element.setAttribute("name", "byte");
this.element.addEventListener("pointerdown", e=>this.onpointerdown(e));
parent.add(this);
}
@@ -473,10 +498,4 @@ MemoryWindow.Cell = class Cell extends Toolkit.Label {
return (this.wnd.address + this.offset & 0xFFFFFFFF) >>> 0;
}
// Pointer down event handler
onpointerdown(e) {
if (e.button == 0)
this.wnd.setSelected(this.address());
}
};