use log::debug;
use crate::periph::mos6530::mos6530::Mos6530;

impl Mos6530 {
    pub fn tick(&mut self, address_bus: u16, data_bus: u8, reset: bool, rw: bool) {
        debug!("Starting tick of MOS6530 RRIOT with 0x{address_bus:04x} / 0b{data_bus:08b} / R:{reset} / RW:{rw} (OFFSETS: I{:04x}, RA{:04x}, RO{:04x})", self.io_offset, self.ram_offset, self.rom_offset);
        let io_max = self.io_offset + 0x3f;
        let ram_max = self.ram_offset + 0x3f;
        let rom_max = self.rom_offset + 0x400;

        if address_bus.ge(&self.io_offset) && address_bus.le(&io_max) {
            let effective = address_bus - self.io_offset;
            println!("IO Activity at effective 0x{effective:02x}");
        }

        if address_bus.ge(&self.ram_offset) && address_bus.le(&ram_max) {
            let effective = address_bus - self.ram_offset;
            println!("RAM Activity at effective 0x{effective:02x}");
        }

        if address_bus.ge(&self.rom_offset) && address_bus.le(&rom_max) {
            let effective = address_bus - self.rom_offset;
            println!("Rom Activity at effective 0x{effective:02x}");
        }
    }
}
