From 96f1104734163b7830aee392b4dab54132e83c13 Mon Sep 17 00:00:00 2001 From: Alexander Bass Date: Wed, 13 Mar 2024 02:25:15 -0400 Subject: [PATCH] clean up remaining non conforming file and method names --- src/computer.ts | 18 +++++++++--------- src/index.ts | 5 +++-- src/ui.ts | 8 ++++---- ...nk_view_selector.ts => bankViewSelector.ts} | 0 .../{reset_buttons.ts => resetButtons.ts} | 0 .../{bank_visualizer.ts => bankVisualizer.ts} | 0 src/util/elementMaker.ts | 1 + 7 files changed, 17 insertions(+), 15 deletions(-) rename src/ui/components/{bank_view_selector.ts => bankViewSelector.ts} (100%) rename src/ui/components/{reset_buttons.ts => resetButtons.ts} (100%) rename src/ui/windows/{bank_visualizer.ts => bankVisualizer.ts} (100%) diff --git a/src/computer.ts b/src/computer.ts index 61873b4..17292bc 100644 --- a/src/computer.ts +++ b/src/computer.ts @@ -11,7 +11,7 @@ export type TempInstrState = { params: Array; }; -function init_banks(): [Uint8Array, Uint8Array, Uint8Array, Uint8Array] { +function initBanks(): [Uint8Array, Uint8Array, Uint8Array, Uint8Array] { const banks = []; for (let i = 0; i < 4; i++) { banks.push(new Uint8Array(256)); @@ -19,8 +19,8 @@ function init_banks(): [Uint8Array, Uint8Array, Uint8Array, Uint8Array] { return banks as [Uint8Array, Uint8Array, Uint8Array, Uint8Array]; } -export class Computer { - private banks: [Uint8Array, Uint8Array, Uint8Array, Uint8Array] = init_banks(); +export default class Computer { + private banks: [Uint8Array, Uint8Array, Uint8Array, Uint8Array] = initBanks(); private registers: Uint8Array = new Uint8Array(8); private call_stack: Array = []; private carry_flag: boolean = false; @@ -41,7 +41,7 @@ export class Computer { code: current_byte, }); console.log(`Invalid instruction: ${formatHex(current_byte)}`); - this.step_forward(); + this.stepForward(); this.events.dispatch(CpuEvent.Cycle); return; } @@ -59,7 +59,7 @@ export class Computer { } if (this.current_instr.pos === this.program_counter && this.current_instr.params.length > 0) { - this.step_forward(); + this.stepForward(); this.events.dispatch(CpuEvent.Cycle); return; } @@ -75,7 +75,7 @@ export class Computer { this.current_instr.params[this.current_instr.params_found] = current_byte; this.current_instr.params_found += 1; if (this.current_instr.params.length !== this.current_instr.params_found) { - this.step_forward(); + this.stepForward(); this.events.dispatch(CpuEvent.Cycle); return; } @@ -92,7 +92,7 @@ export class Computer { this.current_instr = null; if (execution_post_action_state.should_step) { - this.step_forward(); + this.stepForward(); } this.events.dispatch(CpuEvent.Cycle); } @@ -165,7 +165,7 @@ export class Computer { reset(): void { this.events.dispatch(CpuEvent.Reset); - this.banks = init_banks(); + this.banks = initBanks(); this.registers = new Uint8Array(8); this.call_stack = []; this.current_instr = null; @@ -205,7 +205,7 @@ export class Computer { return this.banks; } - private step_forward(): void { + private stepForward(): void { this.program_counter = m256(this.program_counter + 1); this.events.dispatch(CpuEvent.ProgramCounterChanged, { counter: this.program_counter }); } diff --git a/src/index.ts b/src/index.ts index 1a84be6..670dd37 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,11 +3,11 @@ * @copyright Alexander Bass 2024 * @license GPL-3.0 */ -import { Computer } from "./computer"; +import Computer from "./computer"; +import UI from "./ui"; import { $ } from "./etc"; import { ISA } from "./instructionSet"; import { generateIsa } from "./isaGenerator"; -import { UI } from "./ui"; import { u8 } from "./num"; import "./style/style.scss"; @@ -47,6 +47,7 @@ function main(): void { window.comp = computer; window.ui = ui; + // Todo, move to ui component $("ISA").textContent = generateIsa(ISA); let fire = false; diff --git a/src/ui.ts b/src/ui.ts index 12f5b22..0ea7305 100644 --- a/src/ui.ts +++ b/src/ui.ts @@ -5,18 +5,18 @@ import UiComponent, { UiComponentConstructor } from "./ui/uiComponent"; import MemoryView from "./ui/components/memoryView"; import frequencyIndicator from "./ui/components/frequencyIndicator"; 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 pausePlay from "./ui/components/pausePlay"; import SaveLoad from "./ui/components/saveLoad"; -import ResetButtons from "./ui/components/reset_buttons"; +import ResetButtons from "./ui/components/resetButtons"; // Window Components import InstructionExplainer from "./ui/windows/instructionExplainer"; import Screen from "./ui/windows/screen"; 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(); cpu_signaler: UiCpuSignalHandler = new UiCpuSignalHandler(); private components: Array = []; diff --git a/src/ui/components/bank_view_selector.ts b/src/ui/components/bankViewSelector.ts similarity index 100% rename from src/ui/components/bank_view_selector.ts rename to src/ui/components/bankViewSelector.ts diff --git a/src/ui/components/reset_buttons.ts b/src/ui/components/resetButtons.ts similarity index 100% rename from src/ui/components/reset_buttons.ts rename to src/ui/components/resetButtons.ts diff --git a/src/ui/windows/bank_visualizer.ts b/src/ui/windows/bankVisualizer.ts similarity index 100% rename from src/ui/windows/bank_visualizer.ts rename to src/ui/windows/bankVisualizer.ts diff --git a/src/util/elementMaker.ts b/src/util/elementMaker.ts index d43b458..aa51212 100644 --- a/src/util/elementMaker.ts +++ b/src/util/elementMaker.ts @@ -34,6 +34,7 @@ class ElementInProgress { return this; } + /** Return created element */ fin(): E { return this.element; }