use std::fs;
use core::computers::rom_only::RomOnlyComputer;
use core::traits::backplane::Backplane;

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!("Read {} bytes.", bytes.len());
            bytes
        },
        Err(e) => {
            eprintln!("FAIL to read rom.");
            panic!("No rom no run.");
            vec![]
        }
    };

    let mut rom_only = RomOnlyComputer::program((&bytes[..]).to_vec());

    rom_only.set_read_mode(true);
    rom_only.set_address_bus(0x05);
    rom_only.tick();

    println!("COMPUTER: Read {:02x} from ROM", rom_only.data_bus()) ;
    println!("COMPUTER: Read {:04x} from Address Bus", rom_only.address_bus());

    println!("----");
    rom_only.set_read_mode(true);
    rom_only.set_address_bus(0x07);
    rom_only.tick();

    println!("COMPUTER: Read {:02x} from ROM", rom_only.data_bus()) ;
    println!("COMPUTER: Read {:04x} from Address Bus", rom_only.address_bus());
    println!("----");
}
