use crate::address_mode::AddressMode;
use crate::constants::constants_isa_op::ISA_OP_NOP;
use crate::constants::constants_system::SIZE_64KB;
use crate::instruction::Instruction;
use crate::instruction_table::INSTRUCTION_TABLE;
use crate::mos6502cpu::Mos6502Cpu;
use crate::mos6502cpu::tick_stages::Mos6502TickStates::LoadingInstruction;
use crate::operand::Operand;
use crate::operation::Operation;

impl Default for Mos6502Cpu {
    fn default() -> Self {
        let mut working = Mos6502Cpu {
            memory: [0x00; SIZE_64KB],
            a: 0x00,
            x: 0x00,
            y: 0x00,
            flags: Default::default(),
            pc: 0xfffd,
            s: 0x00,
            microcode_step: 0x00,
            address_bus: 0x00,
            data_bus: 0x00,
            ir: Instruction {
                op: Operation::NOP,
                mode: AddressMode::Implied,
                operand: Operand::None,
            },
            oi: INSTRUCTION_TABLE[ISA_OP_NOP as usize].clone().unwrap(),
            has_reset: false,
            iv: 0xfffe,
            cycle_carry: 0x0000,
            ir_bytes: [0x00; 4],
            read_signal: true,
            reset_vector: 0x0000,
            int_vector: 0x0000,
            nmi_vector: 0x0000,
            tick_stage: LoadingInstruction
        };
        working.reset_cpu();
        working
    }
}