From 203bfa624418a518db9f573017d3d635ee03953f Mon Sep 17 00:00:00 2001 From: Andrew Keeton Date: Sun, 28 Sep 2014 21:06:12 -0400 Subject: [PATCH] Integrate IRQ. --- 6502emu/src/memory.rs | 11 +++++---- 6502emu/src/registers.rs | 48 ++++++++++++++++++++-------------------- 2 files changed, 31 insertions(+), 28 deletions(-) diff --git a/6502emu/src/memory.rs b/6502emu/src/memory.rs index 7d9ff35..9d2f5e7 100644 --- a/6502emu/src/memory.rs +++ b/6502emu/src/memory.rs @@ -29,10 +29,13 @@ use address::Address; use address::AddressDiff; use registers::StackPointer; -pub static MEMORY_ADDRESS_BEGIN: Address = Address(0x0000); -pub static MEMORY_ADDRESS_END: Address = Address(0xffff); -pub static STACK_ADDRESS_BEGIN: Address = Address(0x0100); -pub static STACK_ADDRESS_END: Address = Address(0x01ff); +pub static MEMORY_ADDRESS_BEGIN: Address = Address(0x0000); +pub static MEMORY_ADDRESS_END: Address = Address(0xFFFF); +pub static STACK_ADDRESS_BEGIN: Address = Address(0x0100); +pub static STACK_ADDRESS_END: Address = Address(0x01FF); +pub static IRQ_INTERRUPT_VECTOR_LO: Address = Address(0xFFFE); +pub static IRQ_INTERRUPT_VECTOR_HI: Address = Address(0xFFFF); + // static MEMORY_SIZE: uint = MEMORY_ADDRESS_END - MEMORY_ADDRESS_BEGIN + 1; pub struct Memory { diff --git a/6502emu/src/registers.rs b/6502emu/src/registers.rs index 9cb331f..9a7072c 100644 --- a/6502emu/src/registers.rs +++ b/6502emu/src/registers.rs @@ -29,39 +29,39 @@ use memory::STACK_ADDRESS_END; use util::{ BitFlag, Off, On }; pub struct Status { - pub carry: BitFlag, - pub zero: BitFlag, - pub interrupt: BitFlag, - pub decimal_mode: BitFlag, - pub brk: BitFlag, - pub unused: BitFlag, - pub overflow: BitFlag, - pub negative: BitFlag + pub carry: BitFlag, + pub zero: BitFlag, + pub disable_interrupts: BitFlag, + pub decimal_mode: BitFlag, + pub brk: BitFlag, + pub unused: BitFlag, + pub overflow: BitFlag, + pub negative: BitFlag } impl Status { pub fn to_byte(&self) -> u8 { - self.carry.to_bit() << 0 - | self.zero.to_bit() << 1 - | self.interrupt.to_bit() << 2 - | self.decimal_mode.to_bit() << 3 - | self.brk.to_bit() << 4 - | self.unused.to_bit() << 5 - | self.overflow.to_bit() << 6 - | self.negative.to_bit() << 7 + self.carry.to_bit() << 0 + | self.zero.to_bit() << 1 + | self.disable_interrupts.to_bit() << 2 + | self.decimal_mode.to_bit() << 3 + | self.brk.to_bit() << 4 + | self.unused.to_bit() << 5 + | self.overflow.to_bit() << 6 + | self.negative.to_bit() << 7 } pub fn new() -> Status { // TODO akeeton: Revisit these defaults. Status { - carry: Off, - zero: Off, - interrupt: Off, - decimal_mode: Off, - brk: Off, - unused: On, - overflow: Off, - negative: Off + carry: Off, + zero: Off, + disable_interrupts: On, + decimal_mode: Off, + brk: Off, + unused: On, + overflow: Off, + negative: Off } } }