major ui enhancements

This commit is contained in:
Alexander Bass 2024-02-15 00:32:54 -05:00
parent 2207683040
commit 51751c568b
5 changed files with 99 additions and 27 deletions

View file

@ -9,11 +9,30 @@
</head>
<body>
<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>
<div id="controls_bar">
<button type="button" id="pause_play_button">Start</button>
<button type="button" id="step_button">step</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>
</html>

View file

@ -133,12 +133,6 @@ export class Computer {
}
switch (inst.instr) {
case Instr.Print: {
const [register_no] = inst.params;
const value = this.registers[register_no];
// console.log(value);
break;
}
case Instr.Goto: {
const [parameter] = inst.params;
// console.log(`Goto ${parameter}`);
@ -225,6 +219,12 @@ export class Computer {
}
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: {
const [register_num] = inst.params;
const ASCIIbyte = this.registers[register_num];

View file

@ -3,10 +3,10 @@ export type u8 = number;
export const $ = (s: string): HTMLElement => document.getElementById(s) as HTMLElement;
export function el(type: string, id?: string): HTMLElement {
const div = document.createElement(type);
const element = document.createElement(type);
if (id === undefined) {
return div;
return element;
}
div.id = id;
return div;
element.id = id;
return element;
}

View file

@ -12,7 +12,7 @@ export class UI {
constructor(parent: HTMLElement) {
this.container = parent;
const program_mem = el("div", "program_memory");
const program_mem = $("memory");
this.program_memory_cells = [];
for (let i = 0; i < 256; i++) {
const mem_cell = el("div", `p_${i}`);
@ -24,7 +24,7 @@ export class UI {
this.program_memory = program_mem;
this.register_cells = [];
const registers = el("div", "registers");
const registers = $("registers");
for (let i = 0; i < 8; i++) {
const reg_cell = el("div", `R_${i}`);
reg_cell.textContent = "00";
@ -64,7 +64,7 @@ export class UI {
this.registers = registers;
this.container.append(registers, program_mem);
// this.container.append(registers, program_mem);
this.step_func = null;
this.auto_running = false;
const pp_button = $("pause_play_button");

View file

@ -1,11 +1,17 @@
#program_memory {
* {
box-sizing: border-box;
}
#memory {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
grid-gap: 5px;
padding: 10px;
border: 5px solid yellow;
color: lightgray;
}
#program_memory div {
#memory div {
aspect-ratio: 1;
text-align: center;
margin: auto;
@ -18,11 +24,37 @@ body {
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 {
display: flex;
flex-direction: row;
}
#title {
writing-mode: sideways-lr;
user-select: none;
text-orientation: mixed;
}
#printout {
border: 4px dashed yellow;
width: 1000px;
@ -32,26 +64,25 @@ body {
word-break: break-all;
}
#program_memory div.program_counter {
#memory div.program_counter {
outline: 3px solid orange;
}
#program_memory {
border: 5px solid yellow;
}
#program_memory div.instruction_argument {
#memory div.instruction_argument {
outline: 3px dashed purple;
}
#program_memory div.current_instruction {
#memory div.current_instruction {
outline: 3px dashed greenyellow;
}
#registers {
border: 5px solid yellow;
border-bottom: none;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
max-width: fit-content;
display: flex;
display: grid;
column-gap: 5px;
color: lightgray;
padding: 10px;
}
@ -60,3 +91,25 @@ body {
max-width: 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;
}