clean up remaining non conforming file and method names

This commit is contained in:
Alexander Bass 2024-03-13 02:25:15 -04:00
parent 9e7da12bf5
commit 96f1104734
7 changed files with 17 additions and 15 deletions

View file

@ -11,7 +11,7 @@ export type TempInstrState = {
params: Array<u8>; params: Array<u8>;
}; };
function init_banks(): [Uint8Array, Uint8Array, Uint8Array, Uint8Array] { function initBanks(): [Uint8Array, Uint8Array, Uint8Array, Uint8Array] {
const banks = []; const banks = [];
for (let i = 0; i < 4; i++) { for (let i = 0; i < 4; i++) {
banks.push(new Uint8Array(256)); banks.push(new Uint8Array(256));
@ -19,8 +19,8 @@ function init_banks(): [Uint8Array, Uint8Array, Uint8Array, Uint8Array] {
return banks as [Uint8Array, Uint8Array, Uint8Array, Uint8Array]; return banks as [Uint8Array, Uint8Array, Uint8Array, Uint8Array];
} }
export class Computer { export default class Computer {
private banks: [Uint8Array, Uint8Array, Uint8Array, Uint8Array] = init_banks(); private banks: [Uint8Array, Uint8Array, Uint8Array, Uint8Array] = initBanks();
private registers: Uint8Array = new Uint8Array(8); private registers: Uint8Array = new Uint8Array(8);
private call_stack: Array<u8> = []; private call_stack: Array<u8> = [];
private carry_flag: boolean = false; private carry_flag: boolean = false;
@ -41,7 +41,7 @@ export class Computer {
code: current_byte, code: current_byte,
}); });
console.log(`Invalid instruction: ${formatHex(current_byte)}`); console.log(`Invalid instruction: ${formatHex(current_byte)}`);
this.step_forward(); this.stepForward();
this.events.dispatch(CpuEvent.Cycle); this.events.dispatch(CpuEvent.Cycle);
return; return;
} }
@ -59,7 +59,7 @@ export class Computer {
} }
if (this.current_instr.pos === this.program_counter && this.current_instr.params.length > 0) { if (this.current_instr.pos === this.program_counter && this.current_instr.params.length > 0) {
this.step_forward(); this.stepForward();
this.events.dispatch(CpuEvent.Cycle); this.events.dispatch(CpuEvent.Cycle);
return; return;
} }
@ -75,7 +75,7 @@ export class Computer {
this.current_instr.params[this.current_instr.params_found] = current_byte; this.current_instr.params[this.current_instr.params_found] = current_byte;
this.current_instr.params_found += 1; this.current_instr.params_found += 1;
if (this.current_instr.params.length !== this.current_instr.params_found) { if (this.current_instr.params.length !== this.current_instr.params_found) {
this.step_forward(); this.stepForward();
this.events.dispatch(CpuEvent.Cycle); this.events.dispatch(CpuEvent.Cycle);
return; return;
} }
@ -92,7 +92,7 @@ export class Computer {
this.current_instr = null; this.current_instr = null;
if (execution_post_action_state.should_step) { if (execution_post_action_state.should_step) {
this.step_forward(); this.stepForward();
} }
this.events.dispatch(CpuEvent.Cycle); this.events.dispatch(CpuEvent.Cycle);
} }
@ -165,7 +165,7 @@ export class Computer {
reset(): void { reset(): void {
this.events.dispatch(CpuEvent.Reset); this.events.dispatch(CpuEvent.Reset);
this.banks = init_banks(); this.banks = initBanks();
this.registers = new Uint8Array(8); this.registers = new Uint8Array(8);
this.call_stack = []; this.call_stack = [];
this.current_instr = null; this.current_instr = null;
@ -205,7 +205,7 @@ export class Computer {
return this.banks; return this.banks;
} }
private step_forward(): void { private stepForward(): void {
this.program_counter = m256(this.program_counter + 1); this.program_counter = m256(this.program_counter + 1);
this.events.dispatch(CpuEvent.ProgramCounterChanged, { counter: this.program_counter }); this.events.dispatch(CpuEvent.ProgramCounterChanged, { counter: this.program_counter });
} }

View file

@ -3,11 +3,11 @@
* @copyright Alexander Bass 2024 * @copyright Alexander Bass 2024
* @license GPL-3.0 * @license GPL-3.0
*/ */
import { Computer } from "./computer"; import Computer from "./computer";
import UI from "./ui";
import { $ } from "./etc"; import { $ } from "./etc";
import { ISA } from "./instructionSet"; import { ISA } from "./instructionSet";
import { generateIsa } from "./isaGenerator"; import { generateIsa } from "./isaGenerator";
import { UI } from "./ui";
import { u8 } from "./num"; import { u8 } from "./num";
import "./style/style.scss"; import "./style/style.scss";
@ -47,6 +47,7 @@ function main(): void {
window.comp = computer; window.comp = computer;
window.ui = ui; window.ui = ui;
// Todo, move to ui component
$("ISA").textContent = generateIsa(ISA); $("ISA").textContent = generateIsa(ISA);
let fire = false; let fire = false;

View file

@ -5,18 +5,18 @@ import UiComponent, { UiComponentConstructor } from "./ui/uiComponent";
import MemoryView from "./ui/components/memoryView"; import MemoryView from "./ui/components/memoryView";
import frequencyIndicator from "./ui/components/frequencyIndicator"; import frequencyIndicator from "./ui/components/frequencyIndicator";
import RegisterView from "./ui/components/registerView"; import RegisterView from "./ui/components/registerView";
import BankSelector from "./ui/components/bank_view_selector"; import BankSelector from "./ui/components/bankViewSelector";
import EditButton from "./ui/components/editButton"; import EditButton from "./ui/components/editButton";
import pausePlay from "./ui/components/pausePlay"; import pausePlay from "./ui/components/pausePlay";
import SaveLoad from "./ui/components/saveLoad"; import SaveLoad from "./ui/components/saveLoad";
import ResetButtons from "./ui/components/reset_buttons"; import ResetButtons from "./ui/components/resetButtons";
// Window Components // Window Components
import InstructionExplainer from "./ui/windows/instructionExplainer"; import InstructionExplainer from "./ui/windows/instructionExplainer";
import Screen from "./ui/windows/screen"; import Screen from "./ui/windows/screen";
import Printout from "./ui/windows/printout"; import Printout from "./ui/windows/printout";
import BankVisualizer from "./ui/windows/bank_visualizer"; import BankVisualizer from "./ui/windows/bankVisualizer";
export class UI { export default class UI {
ui_events: UiEventHandler = new UiEventHandler(); ui_events: UiEventHandler = new UiEventHandler();
cpu_signaler: UiCpuSignalHandler = new UiCpuSignalHandler(); cpu_signaler: UiCpuSignalHandler = new UiCpuSignalHandler();
private components: Array<UiComponent> = []; private components: Array<UiComponent> = [];

View file

@ -34,6 +34,7 @@ class ElementInProgress<E extends HTMLElement> {
return this; return this;
} }
/** Return created element */
fin(): E { fin(): E {
return this.element; return this.element;
} }