diff --git a/src/instruction.rs b/src/instruction.rs index f0a96bb..45d0e99 100644 --- a/src/instruction.rs +++ b/src/instruction.rs @@ -254,6 +254,8 @@ impl AddressingMode { } } +pub type DecodedInstr = (Instruction, AMOut); + pub static g_opcodes: [Option<(Instruction, AddressingMode)>, ..256] = [ /*0x00*/ Some((BRK, Implied)), /*0x01*/ Some((ORA, IndexedIndirectX)), diff --git a/src/lib.rs b/src/lib.rs index bda0793..73b7b54 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -25,6 +25,13 @@ // 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)] + pub mod address; pub mod instruction; pub mod machine; diff --git a/src/machine.rs b/src/machine.rs index 0bfe58a..bcf552e 100644 --- a/src/machine.rs +++ b/src/machine.rs @@ -29,6 +29,7 @@ use std::fmt; use address::{AddressDiff}; use instruction; +use instruction::{DecodedInstr}; use memory::Memory; use registers::{ Registers, Status, StatusArgs }; use registers::{ ps_negative, ps_overflow, ps_zero, ps_carry }; @@ -38,16 +39,6 @@ pub struct Machine { pub memory: Memory } -pub type DecodedInstr = (instruction::Instruction, instruction::AMOut); - -/* -impl Iterator<()> for Machine { - fn next(&mut self) -> Option { - self.fetch_next_and_decode() - } -} -*/ - impl Machine { pub fn new() -> Machine { Machine{ @@ -136,15 +127,13 @@ impl Machine { } pub fn run(&mut self) { - while match self.fetch_next_and_decode() { - Some(decoded_instr) => { + loop { + if let Some(decoded_instr) = self.fetch_next_and_decode() { self.execute_instruction(decoded_instr); - true - }, - None => { - false + } else { + break } - } {} + } } fn load_register_with_flags(register: &mut i8,