1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-30 20:51:21 +00:00

Fix modules.

This commit is contained in:
Andrew Keeton 2014-09-27 22:09:31 -04:00
parent 1f896fb4e9
commit 2e2ba84d61
5 changed files with 85 additions and 90 deletions

View File

@ -25,14 +25,13 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
mod address {
#[deriving(PartialEq)]
#[deriving(Eq)]
#[deriving(PartialOrd)]
#[deriving(Ord)]
pub struct Address(u16);
#[deriving(PartialEq)]
#[deriving(Eq)]
#[deriving(PartialOrd)]
#[deriving(Ord)]
pub struct Address(u16);
impl Address {
impl Address {
/* TODO akeeton: Hide struct Address(u16) "constructor."
pub fn new(address_: u16) -> Address {
Address(address_)
@ -51,5 +50,4 @@ mod address {
pub fn is_valid(&self) -> bool {
Address::min() <= *self && *self <= Address::max()
}
}
}

View File

@ -25,9 +25,9 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
mod registers;
mod address;
mod memory;
use registers::Registers;
use address::Address;
use memory::Memory;
struct Machine {
registers: Registers,

View File

@ -26,6 +26,9 @@
// POSSIBILITY OF SUCH DAMAGE.
mod machine;
mod registers;
mod address;
mod memory;
fn main() {
let machine = machine::Machine::new();

View File

@ -25,16 +25,13 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
mod address;
use address::Address;
mod memory {
use address::Address;
pub struct Memory {
pub struct Memory {
bytes: [u8,.. 256]
}
}
impl Memory {
impl Memory {
fn address_to_byte_offset(address: &Address) -> uint {
(address.to_int() - Address::min().to_int()) as uint
}
@ -65,5 +62,4 @@ mod memory {
return old_value;
}
}
}
}

View File

@ -25,9 +25,8 @@
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
// POSSIBILITY OF SUCH DAMAGE.
mod registers {
// Each status flag should be 0 or 1.
pub struct Status {
// Each status flag should be 0 or 1.
pub struct Status {
pub carry: u8,
pub zero: u8,
pub interrupt: u8,
@ -36,9 +35,9 @@ mod registers {
pub unused: u8,
pub overflow: u8,
pub sign: u8
}
}
impl Status {
impl Status {
pub fn to_byte(&self) -> u8 {
self.carry << 0
| self.zero << 1
@ -49,17 +48,16 @@ mod registers {
| self.overflow << 6
| self.sign << 7
}
}
}
pub struct Registers {
pub struct Registers {
pub accumulator: i8,
pub index_x: i8,
pub index_y: i8,
pub stack_pointer: u8,
pub program_counter: u16,
pub status: Status
}
impl Registers {
}
}
impl Registers {
}