1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-28 22:51:26 +00:00

Merge pull request #34 from typelist/master

Fix the build
This commit is contained in:
Johannes Muenzel 2014-12-18 18:06:40 -05:00
commit 94c67395a9
6 changed files with 15 additions and 16 deletions

View File

@ -28,15 +28,15 @@
// The idea here is that it doesn't make sense to add two addresses, but it // 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 // does make sense to add an address and an "address-difference". (If this
// is too annoying to work with we should let it go.) // 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); pub struct AddressDiff(pub i32);
#[deriving(PartialEq, Eq, PartialOrd, Ord, Show)] #[deriving(Copy, PartialEq, Eq, PartialOrd, Ord, Show)]
pub struct Address(pub u16); pub struct Address(pub u16);
impl Add<AddressDiff, Address> for Address { impl Add<AddressDiff, Address> for Address {
fn add(&self, &AddressDiff(rhs): &AddressDiff) -> Address { fn add(self, AddressDiff(rhs): AddressDiff) -> Address {
let &Address(lhs) = self; let Address(lhs) = self;
// TODO akeeton: Do a checked cast. // TODO akeeton: Do a checked cast.
Address(((lhs as i32) + rhs) as u16) Address(((lhs as i32) + rhs) as u16)
@ -44,8 +44,8 @@ impl Add<AddressDiff, Address> for Address {
} }
impl Add<AddressDiff, AddressDiff> for AddressDiff { impl Add<AddressDiff, AddressDiff> for AddressDiff {
fn add(&self, &AddressDiff(rhs): &AddressDiff) -> AddressDiff { fn add(self, AddressDiff(rhs): AddressDiff) -> AddressDiff {
let &AddressDiff(lhs) = self; let AddressDiff(lhs) = self;
AddressDiff(lhs + rhs) AddressDiff(lhs + rhs)
} }
} }

View File

@ -46,7 +46,7 @@ use machine::Machine;
// PC | program counter // PC | program counter
// //
#[deriving(Show, PartialEq, Eq)] #[deriving(Copy, Show, PartialEq, Eq)]
pub enum Instruction pub enum Instruction
// i/o vars should be listed as follows: // i/o vars should be listed as follows:
// NV BDIZC A X Y S PC M // NV BDIZC A X Y S PC M
@ -113,6 +113,7 @@ pub enum Instruction
, TYA // Transfer Y to Accumulator..... | N. ...Z. A = Y , TYA // Transfer Y to Accumulator..... | N. ...Z. A = Y
} }
#[deriving(Copy)]
pub enum OpInput { pub enum OpInput {
UseImplied, UseImplied,
UseImmediate(u8), UseImmediate(u8),
@ -120,6 +121,7 @@ pub enum OpInput {
UseAddress(Address), UseAddress(Address),
} }
#[deriving(Copy)]
pub enum AddressingMode pub enum AddressingMode
// length // length
{ Accumulator // 1 LSR A work directly on accumulator { Accumulator // 1 LSR A work directly on accumulator

View File

@ -25,13 +25,6 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE. // 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 // Needed for debug! / log! macros
#![feature(phase)] #![feature(phase)]

View File

@ -35,6 +35,7 @@ use registers::{ Registers, StackPointer, Status, StatusArgs };
use registers::{ PS_NEGATIVE, PS_DECIMAL_MODE, PS_OVERFLOW, PS_ZERO, PS_CARRY, use registers::{ PS_NEGATIVE, PS_DECIMAL_MODE, PS_OVERFLOW, PS_ZERO, PS_CARRY,
PS_DISABLE_INTERRUPTS }; PS_DISABLE_INTERRUPTS };
#[deriving(Copy)]
pub struct Machine { pub struct Machine {
pub registers: Registers, pub registers: Registers,
pub memory: Memory pub memory: Memory

View File

@ -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; 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 { pub struct Memory {
bytes: [u8, ..MEMORY_SIZE] bytes: [u8, ..MEMORY_SIZE]
} }

View File

@ -29,6 +29,7 @@ use address::{Address, AddressDiff};
use memory::{STACK_ADDRESS_LO, STACK_ADDRESS_HI}; use memory::{STACK_ADDRESS_LO, STACK_ADDRESS_HI};
// Useful for constructing Status instances // Useful for constructing Status instances
#[deriving(Copy)]
pub struct StatusArgs { pub struct StatusArgs {
pub negative: bool, pub negative: bool,
pub overflow: 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); pub struct StackPointer(pub u8);
impl StackPointer { impl StackPointer {
@ -143,7 +144,7 @@ impl StackPointer {
} }
} }
#[deriving(PartialEq, Eq, Show)] #[deriving(Copy, PartialEq, Eq, Show)]
pub struct Registers { pub struct Registers {
pub accumulator: i8, pub accumulator: i8,
pub index_x: i8, pub index_x: i8,