Couple of small simplifications.

Signed-off-by: Adrian.Conlon <adrian.conlon@gmail.com>
This commit is contained in:
Adrian.Conlon 2017-06-13 23:43:21 +01:00
parent 828e081a6e
commit 66d3a5ae29
5 changed files with 17 additions and 17 deletions

View File

@ -83,8 +83,8 @@ namespace EightBit {
return cycles + instruction.count;
}
void adjustSign(uint8_t value) { F().S = ((value & 0x80) != 0); }
void adjustZero(uint8_t value) { F().Z = (value == 0); }
void adjustSign(uint8_t value) { F().S = ((value & Bit7) != 0); }
void adjustZero(uint8_t value) { F().Z = !value; }
void adjustParity(uint8_t value) {
static const uint8_t lookup[0x10] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 };
@ -108,12 +108,12 @@ namespace EightBit {
void postIncrement(uint8_t value) {
adjustSZP(value);
F().AC = lowNibble(value) == 0;
F().AC = !lowNibble(value);
}
void postDecrement(uint8_t value) {
adjustSZP(value);
F().AC = lowNibble(value) != 0xf;
F().AC = lowNibble(value) != Mask4;
}
static Instruction INS(instruction_t method, AddressingMode mode, std::string disassembly, int cycles);
@ -127,11 +127,11 @@ namespace EightBit {
uint16_t subtraction = A() - value;
adjustSZP((uint8_t)subtraction);
adjustAuxiliaryCarrySub(value, subtraction);
F().C = subtraction > 0xff;
F().C = subtraction & Bit8;
}
void anda(uint8_t value) {
F().AC = (((A() | value) & 0x8) != 0);
F().AC = (((A() | value) & Bit3) != 0);
F().C = false;
adjustSZP(A() &= value);
}
@ -151,7 +151,7 @@ namespace EightBit {
sum.word = A() + value + carry;
adjustAuxiliaryCarryAdd(value, sum.word);
A() = sum.low;
F().C = sum.word > 0xff;
F().C = sum.word & Bit8;
adjustSZP(A());
}
@ -170,7 +170,7 @@ namespace EightBit {
difference.word = A() - value - carry;
adjustAuxiliaryCarrySub(value, difference.word);
A() = difference.low;
F().C = difference.word > 0xff;
F().C = difference.word & Bit8;
adjustSZP(A());
}
@ -592,7 +592,7 @@ namespace EightBit {
// rotate
void rlc() {
auto carry = A() & 0x80;
auto carry = A() & Bit7;
A() <<= 1;
A() |= carry >> 7;
F().C = carry != 0;
@ -606,7 +606,7 @@ namespace EightBit {
}
void ral() {
auto carry = A() & 0x80;
auto carry = A() & Bit7;
A() <<= 1;
A() |= (uint8_t)F().C;
F().C = carry != 0;
@ -621,7 +621,7 @@ namespace EightBit {
// specials
void cma() { A() ^= 0xff; }
void cma() { A() ^= Mask8; }
void stc() { F().C = true; }
void cmc() { F().C = !F().C; }

View File

@ -95,7 +95,7 @@ namespace EightBit {
void loadBootRom(const std::string& path);
bool isBootRom(uint16_t address) const {
return (address < m_boot.size()) && (peek(BASE + BOOT_DISABLE) == 0);
return (address < m_boot.size()) && !peek(BASE + BOOT_DISABLE);
}
virtual uint8_t peek(uint16_t address) const;

View File

@ -356,7 +356,7 @@ void EightBit::LR35902::daa() {
uint8_t a = A();
auto lowAdjust = (F() & HC) | ((A() & 0xf) > 9);
auto lowAdjust = (F() & HC) | ((A() & Mask4) > 9);
auto highAdjust = (F() & CF) | (A() > 0x99);
if (F() & NF) {

View File

@ -516,7 +516,7 @@ void EightBit::Z80::neg() {
auto original = A();
A() = 0;
sub(A(), original);
setFlag(PF, original == 0x80);
setFlag(PF, original == Bit7);
setFlag(CF, original);
}
@ -524,7 +524,7 @@ void EightBit::Z80::daa() {
uint8_t a = A();
auto lowAdjust = (F() & HC) | ((A() & 0xf) > 9);
auto lowAdjust = (F() & HC) | ((A() & Mask4) > 9);
auto highAdjust = (F() & CF) | (A() > 0x99);
if (F() & NF) {

View File

@ -22,12 +22,12 @@ namespace EightBit {
bool calculateHalfCarryAdd(uint8_t before, uint8_t value, int calculation) {
auto index = buildHalfCarryIndex(before, value, calculation);
return m_halfCarryTableAdd[index & 0x7];
return m_halfCarryTableAdd[index & Mask3];
}
bool calculateHalfCarrySub(uint8_t before, uint8_t value, int calculation) {
auto index = buildHalfCarryIndex(before, value, calculation);
return m_halfCarryTableSub[index & 0x7];
return m_halfCarryTableSub[index & Mask3];
}
void push(uint8_t value);