1
0
mirror of https://github.com/mre/mos6502.git synced 2024-11-24 11:31:00 +00:00

as clippy suggests, convert from bool to u8/i8

This commit is contained in:
Sam M W 2023-04-03 07:38:38 +01:00
parent 672defd817
commit 3accd8ce40

View File

@ -592,7 +592,7 @@ impl<M: Bus> CPU<M> {
let mask = 1 << 7; let mask = 1 << 7;
let is_bit_7_set = (*p_val & mask) == mask; let is_bit_7_set = (*p_val & mask) == mask;
let shifted = (*p_val & !(1 << 7)) << 1; let shifted = (*p_val & !(1 << 7)) << 1;
*p_val = shifted + if is_carry_set { 1 } else { 0 }; *p_val = shifted + u8::from(is_carry_set);
status.set_with_mask( status.set_with_mask(
Status::PS_CARRY, Status::PS_CARRY,
Status::new(StatusArgs { Status::new(StatusArgs {
@ -655,11 +655,7 @@ impl<M: Bus> CPU<M> {
fn add_with_carry(&mut self, value: i8) { fn add_with_carry(&mut self, value: i8) {
let a_before: i8 = self.registers.accumulator; let a_before: i8 = self.registers.accumulator;
let c_before: i8 = if self.registers.status.contains(Status::PS_CARRY) { let c_before: i8 = i8::from(self.registers.status.contains(Status::PS_CARRY));
1
} else {
0
};
let a_after: i8 = a_before.wrapping_add(c_before).wrapping_add(value); let a_after: i8 = a_before.wrapping_add(c_before).wrapping_add(value);
debug_assert_eq!( debug_assert_eq!(