pub mod reset;
pub mod bus_device;
pub mod via_chip;
pub mod new;
pub mod tick;

use crate::traits::bus_device::BusDevice;
use crate::traits::memory_chip::MemoryChip;
use crate::traits::ram_chip::RamChip;
use crate::traits::rom_chip::RomChip;
use crate::traits::via_chip::ViaChip;

/*
The MCS6520 Peripheral Adapter is designed to solve a broad range of peripheral
control problems in the implementation of microcomputer systems. This device allows
a very effective trade-off between software and hardware by providing significant
capability and flexibility in a low cost chip. When coupled with the power and
speed of the MCS6500 family of microprocessors, the MCS6S20 allows implementation
of very complex systems at a minimum overall cost.
Control of peripheral devices is handled primarily through two 8-bit bi-directional ports.

Each of these lines can be programmed to act as either an input or
an output. In addition, four peripheral control/interrupt input lines are provided.
These lines can be used to interrupt the processor or for "hand-shaking" data
be tween the processor and a peripheral device.
 */
pub struct Mos6520 {
    // Parallel ports A & B data registers
    port_a: u8,
    out_a: u8,
    in_a: u8,
    ddra: u8,
    port_b: u8,
    out_b: u8,
    in_b: u8,
    ddrb: u8,
    // Interrupt control register
    icr: u8,
    // External Address and Data Bus
    address_bus: u16,
    data_bus: u8,
    // Offsets
    offset: u16,
    max_offset: u16
}

impl Mos6520 {
    pub fn debug_dump(&self) {
        println!("DUMPING STATE: \nPORT_A:\t{:08b}\nIN_A:\t{:08b}\nOUT_A:\t{:08b}\nDDRA:\t{:08b}", self.port_a, self.in_a, self.out_a, self.ddra);
    }
}
