mirror of
https://github.com/mre/mos6502.git
synced 2024-11-28 22:51:26 +00:00
Remove numerous warnings from bitflags! expanding to non-uppercase static constants.
This commit is contained in:
parent
db3ae89745
commit
6321266179
@ -34,7 +34,7 @@ use instruction;
|
||||
use instruction::{DecodedInstr};
|
||||
use memory::Memory;
|
||||
use registers::{ Registers, Status, StatusArgs };
|
||||
use registers::{ ps_negative, ps_overflow, ps_zero, ps_carry };
|
||||
use registers::{ PS_NEGATIVE, PS_OVERFLOW, PS_ZERO, PS_CARRY };
|
||||
|
||||
pub struct Machine {
|
||||
pub registers: Registers,
|
||||
@ -149,7 +149,7 @@ impl Machine {
|
||||
let is_negative = value < 0;
|
||||
|
||||
status.set_with_mask(
|
||||
ps_zero | ps_negative,
|
||||
PS_ZERO | PS_NEGATIVE,
|
||||
Status::new(StatusArgs { zero: is_zero,
|
||||
negative: is_negative,
|
||||
..StatusArgs::none() } ));
|
||||
@ -188,7 +188,7 @@ impl Machine {
|
||||
(a_before < 0 && value < 0 && a_after >= 0)
|
||||
|| (a_before > 0 && value > 0 && a_after <= 0);
|
||||
|
||||
let mask = ps_carry | ps_overflow;
|
||||
let mask = PS_CARRY | PS_OVERFLOW;
|
||||
|
||||
self.registers.status.set_with_mask(mask,
|
||||
Status::new(StatusArgs { carry: did_carry,
|
||||
@ -215,69 +215,69 @@ fn add_with_carry_test() {
|
||||
|
||||
machine.add_with_carry(1);
|
||||
assert_eq!(machine.registers.accumulator, 1);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
machine.add_with_carry(-1);
|
||||
assert_eq!(machine.registers.accumulator, 0);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
machine.add_with_carry(1);
|
||||
assert_eq!(machine.registers.accumulator, 2);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
let mut machine = Machine::new();
|
||||
|
||||
machine.add_with_carry(127);
|
||||
assert_eq!(machine.registers.accumulator, 127);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
machine.add_with_carry(-127);
|
||||
assert_eq!(machine.registers.accumulator, 0);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
machine.registers.status.remove(ps_carry);
|
||||
machine.registers.status.remove(PS_CARRY);
|
||||
machine.add_with_carry(-128);
|
||||
assert_eq!(machine.registers.accumulator, -128);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
machine.add_with_carry(127);
|
||||
assert_eq!(machine.registers.accumulator, -1);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
let mut machine = Machine::new();
|
||||
|
||||
machine.add_with_carry(127);
|
||||
assert_eq!(machine.registers.accumulator, 127);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), false);
|
||||
|
||||
machine.add_with_carry(1);
|
||||
assert_eq!(machine.registers.accumulator, -128);
|
||||
assert_eq!(machine.registers.status.contains(ps_carry), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_zero), false);
|
||||
assert_eq!(machine.registers.status.contains(ps_negative), true);
|
||||
assert_eq!(machine.registers.status.contains(ps_overflow), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_CARRY), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_ZERO), false);
|
||||
assert_eq!(machine.registers.status.contains(PS_NEGATIVE), true);
|
||||
assert_eq!(machine.registers.status.contains(PS_OVERFLOW), true);
|
||||
}
|
||||
|
@ -55,14 +55,14 @@ impl StatusArgs {
|
||||
|
||||
pub bitflags! {
|
||||
flags Status: u8 {
|
||||
static ps_negative = 0b10000000,
|
||||
static ps_overflow = 0b01000000,
|
||||
static ps_unused = 0b00100000, // JAM: Should this exist?
|
||||
static ps_brk = 0b00010000,
|
||||
static ps_decimal_mode = 0b00001000,
|
||||
static ps_disable_interrupts = 0b00000100,
|
||||
static ps_zero = 0b00000010,
|
||||
static ps_carry = 0b00000001,
|
||||
static PS_NEGATIVE = 0b10000000,
|
||||
static PS_OVERFLOW = 0b01000000,
|
||||
static PS_UNUSED = 0b00100000, // JAM: Should this exist?
|
||||
static PS_BRK = 0b00010000,
|
||||
static PS_DECIMAL_MODE = 0b00001000,
|
||||
static PS_DISABLE_INTERRUPTS = 0b00000100,
|
||||
static PS_ZERO = 0b00000010,
|
||||
static PS_CARRY = 0b00000001,
|
||||
}
|
||||
}
|
||||
|
||||
@ -91,14 +91,14 @@ impl Status {
|
||||
{
|
||||
let mut out = Status::empty();
|
||||
|
||||
if negative { out = out | ps_negative }
|
||||
if overflow { out = out | ps_overflow }
|
||||
if unused { out = out | ps_unused }
|
||||
if brk { out = out | ps_brk }
|
||||
if decimal_mode { out = out | ps_decimal_mode }
|
||||
if disable_interrupts { out = out | ps_disable_interrupts }
|
||||
if zero { out = out | ps_zero }
|
||||
if carry { out = out | ps_carry }
|
||||
if negative { out = out | PS_NEGATIVE }
|
||||
if overflow { out = out | PS_OVERFLOW }
|
||||
if unused { out = out | PS_UNUSED }
|
||||
if brk { out = out | PS_BRK }
|
||||
if decimal_mode { out = out | PS_DECIMAL_MODE }
|
||||
if disable_interrupts { out = out | PS_DISABLE_INTERRUPTS }
|
||||
if zero { out = out | PS_ZERO }
|
||||
if carry { out = out | PS_CARRY }
|
||||
|
||||
out
|
||||
}
|
||||
@ -108,7 +108,7 @@ impl Status {
|
||||
}
|
||||
|
||||
pub fn get_carry(self) -> i8 {
|
||||
if self.contains(ps_carry) { 1 } else { 0 }
|
||||
if self.contains(PS_CARRY) { 1 } else { 0 }
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user