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

Some cleanup. Enable experimental 'if let' Rust language feature

This commit is contained in:
Johannes Muenzel 2014-10-04 16:47:42 -04:00
parent 7adc2bbcb4
commit dae32caada
3 changed files with 15 additions and 17 deletions

View File

@ -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)),

View File

@ -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;

View File

@ -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<DecodedInstr> {
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,