forked from Lea/invadeez
appease clippy
This commit is contained in:
parent
17a8509898
commit
7737ab8de5
|
@ -15,7 +15,7 @@ fn main() {
|
|||
let mut index: u32 = 0;
|
||||
|
||||
while let Some(byte) = data.next() {
|
||||
let current_index = index.clone();
|
||||
let current_index = index;
|
||||
index += 1;
|
||||
|
||||
let mut next = |len: u8| {
|
||||
|
|
|
@ -34,15 +34,14 @@ pub fn adi(byte: u8, state: &mut EmulatorState) {
|
|||
|
||||
/// Add values of `register` and `A` and add +1 if carry bit is set
|
||||
pub fn adc(register: Register, state: &mut EmulatorState) {
|
||||
let result =
|
||||
get_register(®ister, state) as u16 + state.a as u16 + if state.cc.c { 1 } else { 0 };
|
||||
let result = get_register(®ister, state) as u16 + state.a as u16 + u16::from(state.cc.c);
|
||||
set_cc(state, result, 0b1111);
|
||||
state.a = (result & 0xff) as u8;
|
||||
}
|
||||
|
||||
/// Add values of input byte and `A` and add +1 if carry bit is set
|
||||
pub fn aci(byte: u8, state: &mut EmulatorState) {
|
||||
let result = state.a as u16 + byte as u16 + if state.cc.c { 1 } else { 0 };
|
||||
let result = state.a as u16 + byte as u16 + u16::from(state.cc.c);
|
||||
set_cc(state, result, 0b1111);
|
||||
state.a = result as u8;
|
||||
}
|
||||
|
|
|
@ -36,9 +36,8 @@ fn main() {
|
|||
.expect("Provide a path to a ROM file to emulate as an argument");
|
||||
let file = fs::read(filename).expect("where file");
|
||||
|
||||
for i in 0..(MEMORY_SIZE.min(file.len())) {
|
||||
state.memory[i] = file[i];
|
||||
}
|
||||
let to_copy = MEMORY_SIZE.min(file.len());
|
||||
state.memory[..to_copy].copy_from_slice(&file[..to_copy]);
|
||||
|
||||
while state.pc < MEMORY_SIZE as u16 {
|
||||
tick(&mut state);
|
||||
|
@ -53,7 +52,7 @@ fn tick(state: &mut EmulatorState) {
|
|||
|
||||
let mut next_byte = || {
|
||||
state.pc += 1;
|
||||
return state.memory[state.pc as usize];
|
||||
state.memory[state.pc as usize]
|
||||
};
|
||||
|
||||
match instruction {
|
||||
|
|
|
@ -65,13 +65,13 @@ pub fn register_from_num(b: u8) -> Register {
|
|||
|
||||
pub fn get_register(register: &Register, state: &EmulatorState) -> u8 {
|
||||
match register {
|
||||
Register::B => state.b as u8,
|
||||
Register::C => state.c as u8,
|
||||
Register::D => state.d as u8,
|
||||
Register::E => state.e as u8,
|
||||
Register::H => state.h as u8,
|
||||
Register::L => state.l as u8,
|
||||
Register::A => state.a as u8,
|
||||
Register::B => state.b,
|
||||
Register::C => state.c,
|
||||
Register::D => state.d,
|
||||
Register::E => state.e,
|
||||
Register::H => state.h,
|
||||
Register::L => state.l,
|
||||
Register::A => state.a,
|
||||
Register::M => state.memory[u16::from_le_bytes([state.l, state.h]) as usize],
|
||||
Register::SP => unreachable!(),
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue