use crate::computers::kim1::Kim1;

impl Kim1 {
    pub fn tick(&mut self) {
        println!("<- START KIM-1 Backplane Tick");
        let (address_bus, data, rw) = self.cpu.tick2(self.address_bus, self.data_bus);
        self.address_bus = address_bus;
        self.data_bus = data;
        self.cpu_read = rw;
        // now tick the various items connected

        self.rriot1.tick(self.address_bus, self.data_bus, false, self.cpu_read);
        self.rriot2.tick(self.address_bus, self.data_bus, false, self.cpu_read);
        self.ram.tick(self.address_bus, self.data_bus, self.cpu_read, true);


        let (rr1_io, rr1_ram, rr1_rom) = self.rriot1.dump_data();
        let (rr2_io, rr2_ram, rr2_rom) = self.rriot2.dump_data();

        println!(" 0x0000 -> RAM / {}", self.ram.dump_data());
        println!(" 0x1700 -> RRIOT 1 / 0x{rr1_io:04x}/0x{rr1_ram:04x}/0x{rr1_rom:04x}");
        println!(" 0x1740 -> RRIOT 2 / 0x{rr2_io:04x}/0x{rr2_ram:04x}/0x{rr2_rom:04x}");
        // display the memory map and device states
        println!("-> FINISH KIM-1 Backplane Tick");
    }
}