mirror of
https://github.com/mre/mos6502.git
synced 2024-11-25 02:33:26 +00:00
Fix the build
This commit is contained in:
parent
aa7db5e623
commit
3355699a94
@ -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<AddressDiff, Address> 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<AddressDiff, Address> for Address {
|
||||
}
|
||||
|
||||
impl Add<AddressDiff, AddressDiff> 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)
|
||||
}
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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)]
|
||||
|
||||
|
@ -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
|
||||
|
@ -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]
|
||||
}
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user