diff --git a/src/address.rs b/src/address.rs index 6b4b334..8eab3f0 100644 --- a/src/address.rs +++ b/src/address.rs @@ -28,15 +28,15 @@ // The idea here is that it doesn't make sense to add two addresses, but it // does make sense to add an address and an "address-difference". (If this // is too annoying to work with we should let it go.) -#[deriving(PartialEq, Eq, PartialOrd, Ord, Show)] +#[deriving(Copy, PartialEq, Eq, PartialOrd, Ord, Show)] pub struct AddressDiff(pub i32); -#[deriving(PartialEq, Eq, PartialOrd, Ord, Show)] +#[deriving(Copy, PartialEq, Eq, PartialOrd, Ord, Show)] pub struct Address(pub u16); impl Add for Address { - fn add(&self, &AddressDiff(rhs): &AddressDiff) -> Address { - let &Address(lhs) = self; + fn add(self, AddressDiff(rhs): AddressDiff) -> Address { + let Address(lhs) = self; // TODO akeeton: Do a checked cast. Address(((lhs as i32) + rhs) as u16) @@ -44,8 +44,8 @@ impl Add for Address { } impl Add for AddressDiff { - fn add(&self, &AddressDiff(rhs): &AddressDiff) -> AddressDiff { - let &AddressDiff(lhs) = self; + fn add(self, AddressDiff(rhs): AddressDiff) -> AddressDiff { + let AddressDiff(lhs) = self; AddressDiff(lhs + rhs) } } diff --git a/src/instruction.rs b/src/instruction.rs index d108f5a..8b4b88b 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -46,7 +46,7 @@ use machine::Machine; // PC | program counter // -#[deriving(Show, PartialEq, Eq)] +#[deriving(Copy, Show, PartialEq, Eq)] pub enum Instruction // i/o vars should be listed as follows: // NV BDIZC A X Y S PC M @@ -113,6 +113,7 @@ pub enum Instruction , TYA // Transfer Y to Accumulator..... | N. ...Z. A = Y } +#[deriving(Copy)] pub enum OpInput { UseImplied, UseImmediate(u8), @@ -120,6 +121,7 @@ pub enum OpInput { UseAddress(Address), } +#[deriving(Copy)] pub enum AddressingMode // length { Accumulator // 1 LSR A work directly on accumulator diff --git a/src/lib.rs b/src/lib.rs index a04965b..1befb1b 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,13 +25,6 @@ // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // POSSIBILITY OF SUCH DAMAGE. -// JAM: 'if let' syntax is great for situations where want to match only a -// single pattern and ignore all others. -// -// if let Some(x) = foo() { ... } -// -#![feature(if_let)] - // Needed for debug! / log! macros #![feature(phase)] diff --git a/src/machine.rs b/src/machine.rs index 0462268..e2a62c3 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -35,6 +35,7 @@ use registers::{ Registers, StackPointer, Status, StatusArgs }; use registers::{ PS_NEGATIVE, PS_DECIMAL_MODE, PS_OVERFLOW, PS_ZERO, PS_CARRY, PS_DISABLE_INTERRUPTS }; +#[deriving(Copy)] pub struct Machine { pub registers: Registers, pub memory: Memory diff --git a/src/memory.rs b/src/memory.rs index 7a489ea..068b338 100644 --- a/src/memory.rs +++ b/src/memory.rs @@ -48,6 +48,8 @@ pub const IRQ_INTERRUPT_VECTOR_HI: Address = Address(0xFFFF); const MEMORY_SIZE: uint = (ADDR_HI_BARE - ADDR_LO_BARE) as uint + 1u; +// FIXME: Should this use indirection for `bytes`? +#[deriving(Copy)] pub struct Memory { bytes: [u8, ..MEMORY_SIZE] } diff --git a/src/registers.rs b/src/registers.rs index 00335c3..3a7c7ac 100644 --- a/src/registers.rs +++ b/src/registers.rs @@ -29,6 +29,7 @@ use address::{Address, AddressDiff}; use memory::{STACK_ADDRESS_LO, STACK_ADDRESS_HI}; // Useful for constructing Status instances +#[deriving(Copy)] pub struct StatusArgs { pub negative: bool, pub overflow: bool, @@ -120,7 +121,7 @@ impl Status { } } -#[deriving(PartialEq, Eq, PartialOrd, Ord, Show)] +#[deriving(Copy, PartialEq, Eq, PartialOrd, Ord, Show)] pub struct StackPointer(pub u8); impl StackPointer { @@ -143,7 +144,7 @@ impl StackPointer { } } -#[deriving(PartialEq, Eq, Show)] +#[deriving(Copy, PartialEq, Eq, Show)] pub struct Registers { pub accumulator: i8, pub index_x: i8,