mirror of
https://github.com/mre/mos6502.git
synced 2025-02-20 09:29:02 +00:00
Simplify some expressions by using the assign op pattern.
See also https://rust-lang-nursery.github.io/rust-clippy/v0.0.212/index.html#assign_op_pattern
This commit is contained in:
parent
7df3f75934
commit
8239b298cb
@ -448,7 +448,7 @@ impl CPU {
|
|||||||
fn shift_right_with_flags(p_val: &mut u8, status: &mut Status) {
|
fn shift_right_with_flags(p_val: &mut u8, status: &mut Status) {
|
||||||
let mask = 1;
|
let mask = 1;
|
||||||
let is_bit_0_set = (*p_val & mask) == mask;
|
let is_bit_0_set = (*p_val & mask) == mask;
|
||||||
*p_val = *p_val >> 1;
|
*p_val >>= 1;
|
||||||
status.set_with_mask(
|
status.set_with_mask(
|
||||||
PS_CARRY,
|
PS_CARRY,
|
||||||
Status::new(StatusArgs {
|
Status::new(StatusArgs {
|
||||||
|
@ -100,39 +100,39 @@ impl Status {
|
|||||||
let mut out = Status::empty();
|
let mut out = Status::empty();
|
||||||
|
|
||||||
if negative {
|
if negative {
|
||||||
out = out | PS_NEGATIVE
|
out |= PS_NEGATIVE
|
||||||
}
|
}
|
||||||
if overflow {
|
if overflow {
|
||||||
out = out | PS_OVERFLOW
|
out |= PS_OVERFLOW
|
||||||
}
|
}
|
||||||
if unused {
|
if unused {
|
||||||
out = out | PS_UNUSED
|
out |= PS_UNUSED
|
||||||
}
|
}
|
||||||
if brk {
|
if brk {
|
||||||
out = out | PS_BRK
|
out |= PS_BRK
|
||||||
}
|
}
|
||||||
if decimal_mode {
|
if decimal_mode {
|
||||||
out = out | PS_DECIMAL_MODE
|
out |= PS_DECIMAL_MODE
|
||||||
}
|
}
|
||||||
if disable_interrupts {
|
if disable_interrupts {
|
||||||
out = out | PS_DISABLE_INTERRUPTS
|
out |= PS_DISABLE_INTERRUPTS
|
||||||
}
|
}
|
||||||
if zero {
|
if zero {
|
||||||
out = out | PS_ZERO
|
out |= PS_ZERO
|
||||||
}
|
}
|
||||||
if carry {
|
if carry {
|
||||||
out = out | PS_CARRY
|
out |= PS_CARRY
|
||||||
}
|
}
|
||||||
|
|
||||||
out
|
out
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn and(&mut self, rhs: Status) {
|
pub fn and(&mut self, rhs: Status) {
|
||||||
*self = *self & rhs;
|
*self &= rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn or(&mut self, rhs: Status) {
|
pub fn or(&mut self, rhs: Status) {
|
||||||
*self = *self | rhs;
|
*self |= rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_with_mask(&mut self, mask: Status, rhs: Status) {
|
pub fn set_with_mask(&mut self, mask: Status, rhs: Status) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user