major ui enhancements
This commit is contained in:
parent
2207683040
commit
51751c568b
27
index.html
27
index.html
|
@ -9,11 +9,30 @@
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="main">
|
<div id="main">
|
||||||
<div id="container"></div>
|
<div id="title">VIRTUAL 8-BIT COMPUTER</div>
|
||||||
|
<div id="container">
|
||||||
|
<div id="subcontainer">
|
||||||
|
<div id="registers"></div>
|
||||||
|
<div id="labelcontainer">
|
||||||
|
<div id="registers_label">←REGISTERS</div>
|
||||||
|
<div id="memory_label">MEMORY↯</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div id="memory"></div>
|
||||||
|
</div>
|
||||||
<div id="printout"></div>
|
<div id="printout"></div>
|
||||||
</div>
|
</div>
|
||||||
<button type="button" id="pause_play_button">Start</button>
|
<div id="controls_bar">
|
||||||
<button type="button" id="step_button">step</button>
|
<button type="button" id="pause_play_button">Start</button>
|
||||||
<input type="file" name="binary_upload" id="binary_upload" />
|
<button type="button" id="step_button">Step</button>
|
||||||
|
<label for="binary_upload" class="button">Load Binary</label>
|
||||||
|
<input
|
||||||
|
id="binary_upload"
|
||||||
|
name="binary_upload"
|
||||||
|
id="binary_upload"
|
||||||
|
style="visibility: hidden"
|
||||||
|
type="file"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
|
@ -133,12 +133,6 @@ export class Computer {
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (inst.instr) {
|
switch (inst.instr) {
|
||||||
case Instr.Print: {
|
|
||||||
const [register_no] = inst.params;
|
|
||||||
const value = this.registers[register_no];
|
|
||||||
// console.log(value);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case Instr.Goto: {
|
case Instr.Goto: {
|
||||||
const [parameter] = inst.params;
|
const [parameter] = inst.params;
|
||||||
// console.log(`Goto ${parameter}`);
|
// console.log(`Goto ${parameter}`);
|
||||||
|
@ -225,6 +219,12 @@ export class Computer {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case Instr.Print: {
|
||||||
|
const [register_no] = inst.params;
|
||||||
|
const value = this.registers[register_no];
|
||||||
|
$("printout").textContent += this.registers[register_no].toString(10);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case Instr.PrintASCII: {
|
case Instr.PrintASCII: {
|
||||||
const [register_num] = inst.params;
|
const [register_num] = inst.params;
|
||||||
const ASCIIbyte = this.registers[register_num];
|
const ASCIIbyte = this.registers[register_num];
|
||||||
|
|
|
@ -3,10 +3,10 @@ export type u8 = number;
|
||||||
|
|
||||||
export const $ = (s: string): HTMLElement => document.getElementById(s) as HTMLElement;
|
export const $ = (s: string): HTMLElement => document.getElementById(s) as HTMLElement;
|
||||||
export function el(type: string, id?: string): HTMLElement {
|
export function el(type: string, id?: string): HTMLElement {
|
||||||
const div = document.createElement(type);
|
const element = document.createElement(type);
|
||||||
if (id === undefined) {
|
if (id === undefined) {
|
||||||
return div;
|
return element;
|
||||||
}
|
}
|
||||||
div.id = id;
|
element.id = id;
|
||||||
return div;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ export class UI {
|
||||||
constructor(parent: HTMLElement) {
|
constructor(parent: HTMLElement) {
|
||||||
this.container = parent;
|
this.container = parent;
|
||||||
|
|
||||||
const program_mem = el("div", "program_memory");
|
const program_mem = $("memory");
|
||||||
this.program_memory_cells = [];
|
this.program_memory_cells = [];
|
||||||
for (let i = 0; i < 256; i++) {
|
for (let i = 0; i < 256; i++) {
|
||||||
const mem_cell = el("div", `p_${i}`);
|
const mem_cell = el("div", `p_${i}`);
|
||||||
|
@ -24,7 +24,7 @@ export class UI {
|
||||||
this.program_memory = program_mem;
|
this.program_memory = program_mem;
|
||||||
|
|
||||||
this.register_cells = [];
|
this.register_cells = [];
|
||||||
const registers = el("div", "registers");
|
const registers = $("registers");
|
||||||
for (let i = 0; i < 8; i++) {
|
for (let i = 0; i < 8; i++) {
|
||||||
const reg_cell = el("div", `R_${i}`);
|
const reg_cell = el("div", `R_${i}`);
|
||||||
reg_cell.textContent = "00";
|
reg_cell.textContent = "00";
|
||||||
|
@ -64,7 +64,7 @@ export class UI {
|
||||||
|
|
||||||
this.registers = registers;
|
this.registers = registers;
|
||||||
|
|
||||||
this.container.append(registers, program_mem);
|
// this.container.append(registers, program_mem);
|
||||||
this.step_func = null;
|
this.step_func = null;
|
||||||
this.auto_running = false;
|
this.auto_running = false;
|
||||||
const pp_button = $("pause_play_button");
|
const pp_button = $("pause_play_button");
|
||||||
|
|
73
style.css
73
style.css
|
@ -1,11 +1,17 @@
|
||||||
#program_memory {
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
#memory {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
||||||
grid-gap: 5px;
|
grid-gap: 5px;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
|
border: 5px solid yellow;
|
||||||
|
color: lightgray;
|
||||||
}
|
}
|
||||||
|
|
||||||
#program_memory div {
|
#memory div {
|
||||||
aspect-ratio: 1;
|
aspect-ratio: 1;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
margin: auto;
|
margin: auto;
|
||||||
|
@ -18,11 +24,37 @@ body {
|
||||||
font-family: monospace;
|
font-family: monospace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#registers div {
|
||||||
|
max-height: min-content;
|
||||||
|
margin-block: auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
#subcontainer {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: row;
|
||||||
|
column-gap: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
#labelcontainer {
|
||||||
|
column-gap: 18px;
|
||||||
|
font-size: 0.85em;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
|
||||||
#main {
|
#main {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: row;
|
flex-direction: row;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#title {
|
||||||
|
writing-mode: sideways-lr;
|
||||||
|
user-select: none;
|
||||||
|
text-orientation: mixed;
|
||||||
|
}
|
||||||
|
|
||||||
#printout {
|
#printout {
|
||||||
border: 4px dashed yellow;
|
border: 4px dashed yellow;
|
||||||
width: 1000px;
|
width: 1000px;
|
||||||
|
@ -32,26 +64,25 @@ body {
|
||||||
word-break: break-all;
|
word-break: break-all;
|
||||||
}
|
}
|
||||||
|
|
||||||
#program_memory div.program_counter {
|
#memory div.program_counter {
|
||||||
outline: 3px solid orange;
|
outline: 3px solid orange;
|
||||||
}
|
}
|
||||||
|
|
||||||
#program_memory {
|
#memory div.instruction_argument {
|
||||||
border: 5px solid yellow;
|
|
||||||
}
|
|
||||||
|
|
||||||
#program_memory div.instruction_argument {
|
|
||||||
outline: 3px dashed purple;
|
outline: 3px dashed purple;
|
||||||
}
|
}
|
||||||
#program_memory div.current_instruction {
|
#memory div.current_instruction {
|
||||||
outline: 3px dashed greenyellow;
|
outline: 3px dashed greenyellow;
|
||||||
}
|
}
|
||||||
|
|
||||||
#registers {
|
#registers {
|
||||||
border: 5px solid yellow;
|
border: 5px solid yellow;
|
||||||
|
border-bottom: none;
|
||||||
|
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
|
||||||
max-width: fit-content;
|
max-width: fit-content;
|
||||||
display: flex;
|
display: grid;
|
||||||
column-gap: 5px;
|
column-gap: 5px;
|
||||||
|
color: lightgray;
|
||||||
padding: 10px;
|
padding: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,3 +91,25 @@ body {
|
||||||
max-width: min-content;
|
max-width: min-content;
|
||||||
max-height: min-content;
|
max-height: min-content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
button,
|
||||||
|
label.button {
|
||||||
|
border: 4px solid yellow;
|
||||||
|
color: gray;
|
||||||
|
margin: 10px;
|
||||||
|
margin-inline: 8px;
|
||||||
|
padding: 10px;
|
||||||
|
font-size: 0.8em;
|
||||||
|
font-family: monospace;
|
||||||
|
background-color: transparent;
|
||||||
|
cursor: pointer;
|
||||||
|
user-select: none;
|
||||||
|
}
|
||||||
|
button:hover,
|
||||||
|
label.button:hover {
|
||||||
|
color: white;
|
||||||
|
}
|
||||||
|
#controls_bar {
|
||||||
|
margin-left: 1.12em;
|
||||||
|
display: flex;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue