Skip to content

Commit

Permalink
Add LED register display
Browse files Browse the repository at this point in the history
  • Loading branch information
stopnoanime committed Oct 20, 2024
1 parent 14a123e commit c341405
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/app/cpu-status/cpu-status.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,11 @@
<div>Stack Pointer: {{ toHex(simProp.stackPointer) }}</div>
<div>Carry Flag: {{ simProp.carry ? "True" : "False" }}</div>
<div>Zero Flag: {{ simProp.zero ? "True" : "False" }}</div>
<div>
LED:
<div
class="w-4 h-4 inline-block align-middle"
[style.background]="ledRGB"
></div>
</div>
</div>
5 changes: 5 additions & 0 deletions src/app/cpu-status/cpu-status.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,10 @@ import { toHex } from '../toHex';
export class CpuStatusComponent {
toHex = toHex;

public get ledRGB(): string {
const v = this.simProp.led;
return `rgb(${(v & 4) * 255} ${(v & 2) * 255} ${(v & 1) * 255})`;
}

@Input() simProp!: simPropType;
}
2 changes: 2 additions & 0 deletions src/app/sim.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export class SimService {
memory: this.sim.memory,
stack: this.sim.stack,
stackPointer: this.sim.stackPointer,
led: this.sim.led,
};
}

Expand Down Expand Up @@ -206,4 +207,5 @@ export type simPropType = {
memory: Uint16Array;
stack: Uint16Array;
stackPointer: number;
led: number;
};

0 comments on commit c341405

Please sign in to comment.