From d5efabdd36612ae060dc0d2861c58f378da48006 Mon Sep 17 00:00:00 2001 From: Trevor Merritt Date: Mon, 21 Jul 2025 13:41:17 -0400 Subject: [PATCH] prep to do big tick method --- cli/src/bin/rom_only.rs | 10 ---------- cli/src/bin/rom_only_widetick.rs | 20 ++++++++++++++++++++ core/src/computers/ram_rom/backplane.rs | 1 + core/src/computers/rom_only/mod.rs | 9 +++++++++ core/src/computers/rom_only/rom_chunks.rs | 2 +- 5 files changed, 31 insertions(+), 11 deletions(-) create mode 100644 cli/src/bin/rom_only_widetick.rs diff --git a/cli/src/bin/rom_only.rs b/cli/src/bin/rom_only.rs index 1142f7b..af192ce 100644 --- a/cli/src/bin/rom_only.rs +++ b/cli/src/bin/rom_only.rs @@ -1,19 +1,9 @@ use std::fs; -use clap::Parser; use core::computers::rom_only::RomOnlyComputer; use core::periph::backplane::Backplane; -#[derive(Parser)] -struct CliOptions { - offset: u16, - bytes: u16, - filename: String -} - fn main() { println!("Taxation is theft"); - - // let opts = CliOptions::parse(); let path = "/home/tmerritt/Projects/mos6502/resources/test/periph/at28c256/checksum.bin"; let bytes = match fs::read(path) { Ok(bytes) => { diff --git a/cli/src/bin/rom_only_widetick.rs b/cli/src/bin/rom_only_widetick.rs new file mode 100644 index 0000000..4f0ed4a --- /dev/null +++ b/cli/src/bin/rom_only_widetick.rs @@ -0,0 +1,20 @@ +use std::fs; +use core::computers::rom_only::RomOnlyComputer; + +fn main() { + println!("Taxation is theft"); + let path = "/home/tmerritt/Projects/mos6502/resources/test/periph/at28c256/checksum.bin"; + let bytes = match fs::read(path) { + Ok(bytes) => { + println!("Loaded {} bytes", bytes.len()); + bytes + }, + Err(e) => vec![] + }; + + let mut rom_only = RomOnlyComputer::program((&bytes[..]).to_vec()); + + rom_only.tick2(0x05, 0b0000_0001, 0x05); + println!("COMPUTER: Read {:02x} from ROM", rom_only.data_bus()) ; + println!("COMPUTER: Read {:04x} from Address Bus", rom_only.address_bus()); +} \ No newline at end of file diff --git a/core/src/computers/ram_rom/backplane.rs b/core/src/computers/ram_rom/backplane.rs index 2d1c15f..78c4a7f 100644 --- a/core/src/computers/ram_rom/backplane.rs +++ b/core/src/computers/ram_rom/backplane.rs @@ -47,6 +47,7 @@ impl Backplane for RamRomComputer { } } } + fn set_read_mode(&mut self, new_mode: bool) { self.read_mode = new_mode; } diff --git a/core/src/computers/rom_only/mod.rs b/core/src/computers/rom_only/mod.rs index 8c3c708..99352d9 100644 --- a/core/src/computers/rom_only/mod.rs +++ b/core/src/computers/rom_only/mod.rs @@ -11,4 +11,13 @@ pub struct RomOnlyComputer { pub(crate) data_bus: u8, pub(crate) address_bus: u16, pub(crate) read_mode: bool, +} + +impl RomOnlyComputer { + pub fn tick2(&mut self, address: u16, control: u8, data: u8) -> (u8) { + // tick the parts... + + let (_, new_data) = self.rom.tick(address, data, control == 0x01); + new_data + } } \ No newline at end of file diff --git a/core/src/computers/rom_only/rom_chunks.rs b/core/src/computers/rom_only/rom_chunks.rs index 6b8682d..6941a6f 100644 --- a/core/src/computers/rom_only/rom_chunks.rs +++ b/core/src/computers/rom_only/rom_chunks.rs @@ -5,4 +5,4 @@ impl RomOnlyComputer { pub fn rom_chunks(&self, size: usize) -> Chunks { self.rom.chunks(size) } -} \ No newline at end of file +}