mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2025-02-22 05:29:01 +00:00
Some *small* consistency changes. Perhaps some performance gains.
Signed-off-by: Adrian Conlon <Adrian.conlon@gmail.com>
This commit is contained in:
parent
d818095815
commit
4b4f6b1a49
@ -149,9 +149,9 @@ namespace EightBit {
|
||||
void di();
|
||||
void ei();
|
||||
|
||||
bool returnConditionalFlag(uint8_t& f, int flag);
|
||||
bool jumpConditionalFlag(uint8_t& f, int flag);
|
||||
bool callConditionalFlag(uint8_t& f, int flag);
|
||||
bool returnConditionalFlag(uint8_t f, int flag);
|
||||
bool jumpConditionalFlag(uint8_t f, int flag);
|
||||
bool callConditionalFlag(uint8_t f, int flag);
|
||||
|
||||
static void add(uint8_t& f, register16_t& operand, register16_t value);
|
||||
|
||||
@ -170,9 +170,9 @@ namespace EightBit {
|
||||
|
||||
static void daa(uint8_t& a, uint8_t& f);
|
||||
|
||||
static void cma(uint8_t& a, uint8_t& f);
|
||||
static void stc(uint8_t& a, uint8_t& f);
|
||||
static void cmc(uint8_t& a, uint8_t& f);
|
||||
static void cma(uint8_t& a);
|
||||
static void stc(uint8_t& f);
|
||||
static void cmc(uint8_t& f);
|
||||
|
||||
void xhtl(register16_t& operand);
|
||||
|
||||
|
@ -47,7 +47,7 @@ void EightBit::Intel8080::decrement(uint8_t& f, uint8_t& operand) {
|
||||
setFlag(f, AC, lowNibble(operand) != Mask4);
|
||||
}
|
||||
|
||||
bool EightBit::Intel8080::jumpConditionalFlag(uint8_t& f, int flag) {
|
||||
bool EightBit::Intel8080::jumpConditionalFlag(const uint8_t f, const int flag) {
|
||||
switch (flag) {
|
||||
case 0: // NZ
|
||||
return jumpConditional(!(f & ZF));
|
||||
@ -70,7 +70,7 @@ bool EightBit::Intel8080::jumpConditionalFlag(uint8_t& f, int flag) {
|
||||
}
|
||||
}
|
||||
|
||||
bool EightBit::Intel8080::returnConditionalFlag(uint8_t& f, int flag) {
|
||||
bool EightBit::Intel8080::returnConditionalFlag(const uint8_t f, const int flag) {
|
||||
switch (flag) {
|
||||
case 0: // NZ
|
||||
return returnConditional(!(f & ZF));
|
||||
@ -93,7 +93,7 @@ bool EightBit::Intel8080::returnConditionalFlag(uint8_t& f, int flag) {
|
||||
}
|
||||
}
|
||||
|
||||
bool EightBit::Intel8080::callConditionalFlag(uint8_t& f, int flag) {
|
||||
bool EightBit::Intel8080::callConditionalFlag(const uint8_t f, int flag) {
|
||||
switch (flag) {
|
||||
case 0: // NZ
|
||||
return callConditional(!(f & ZF));
|
||||
@ -215,15 +215,15 @@ void EightBit::Intel8080::daa(uint8_t& a, uint8_t& f) {
|
||||
setFlag(f, CF, carry);
|
||||
}
|
||||
|
||||
void EightBit::Intel8080::cma(uint8_t& a, uint8_t& f) {
|
||||
void EightBit::Intel8080::cma(uint8_t& a) {
|
||||
a = ~a;
|
||||
}
|
||||
|
||||
void EightBit::Intel8080::stc(uint8_t& a, uint8_t& f) {
|
||||
void EightBit::Intel8080::stc(uint8_t& f) {
|
||||
setFlag(f, CF);
|
||||
}
|
||||
|
||||
void EightBit::Intel8080::cmc(uint8_t& a, uint8_t& f) {
|
||||
void EightBit::Intel8080::cmc(uint8_t& f) {
|
||||
clearFlag(f, CF, f & CF);
|
||||
}
|
||||
|
||||
@ -429,13 +429,13 @@ void EightBit::Intel8080::execute(uint8_t& a, uint8_t& f, int x, int y, int z, i
|
||||
daa(a, f);
|
||||
break;
|
||||
case 5:
|
||||
cma(a, f);
|
||||
cma(a);
|
||||
break;
|
||||
case 6:
|
||||
stc(a, f);
|
||||
stc(f);
|
||||
break;
|
||||
case 7:
|
||||
cmc(a, f);
|
||||
cmc(f);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE;
|
||||
@ -509,7 +509,7 @@ void EightBit::Intel8080::execute(uint8_t& a, uint8_t& f, int x, int y, int z, i
|
||||
addCycles(10);
|
||||
break;
|
||||
case 2: // JP HL
|
||||
PC() = HL();
|
||||
jump(HL());
|
||||
addCycles(4);
|
||||
break;
|
||||
case 3: // LD SP,HL
|
||||
@ -529,7 +529,7 @@ void EightBit::Intel8080::execute(uint8_t& a, uint8_t& f, int x, int y, int z, i
|
||||
case 3: // Assorted operations
|
||||
switch (y) {
|
||||
case 0: // JP nn
|
||||
jump(MEMPTR() = fetchWord());
|
||||
jump(fetchWord());
|
||||
addCycles(10);
|
||||
break;
|
||||
case 2: // OUT (n),A
|
||||
@ -572,7 +572,7 @@ void EightBit::Intel8080::execute(uint8_t& a, uint8_t& f, int x, int y, int z, i
|
||||
case 1:
|
||||
switch (p) {
|
||||
case 0: // CALL nn
|
||||
call(MEMPTR() = fetchWord());
|
||||
call(fetchWord());
|
||||
addCycles(17);
|
||||
break;
|
||||
}
|
||||
|
@ -688,7 +688,7 @@ void EightBit::GameBoy::LR35902::executeOther(uint8_t& a, uint8_t& f, int x, int
|
||||
addCycles(4);
|
||||
break;
|
||||
case 2: // JP HL
|
||||
PC() = HL();
|
||||
jump(HL());
|
||||
addCycle();
|
||||
break;
|
||||
case 3: // LD SP,HL
|
||||
@ -738,7 +738,7 @@ void EightBit::GameBoy::LR35902::executeOther(uint8_t& a, uint8_t& f, int x, int
|
||||
switch (y) {
|
||||
case 0: // JP nn
|
||||
MEMPTR() = fetchWord();
|
||||
jump();
|
||||
jump(MEMPTR());
|
||||
addCycles(4);
|
||||
break;
|
||||
case 1: // CB prefix
|
||||
@ -770,7 +770,7 @@ void EightBit::GameBoy::LR35902::executeOther(uint8_t& a, uint8_t& f, int x, int
|
||||
switch (p) {
|
||||
case 0: // CALL nn
|
||||
MEMPTR() = fetchWord();
|
||||
call();
|
||||
call(MEMPTR());
|
||||
addCycles(6);
|
||||
break;
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ int EightBit::MOS6502::step() {
|
||||
|
||||
void EightBit::MOS6502::reset() {
|
||||
Processor::reset();
|
||||
PC() = getWordPaged(0xff, RSTvector);
|
||||
jump(getWordPaged(0xff, RSTvector));
|
||||
}
|
||||
|
||||
EightBit::register16_t EightBit::MOS6502::getWordPaged(uint8_t page, uint8_t offset) {
|
||||
@ -75,7 +75,7 @@ void EightBit::MOS6502::interrupt(uint8_t vector) {
|
||||
pushWord(PC());
|
||||
push(P());
|
||||
setFlag(P(), IF);
|
||||
PC() = getWordPaged(0xff, vector);
|
||||
jump(getWordPaged(0xff, vector));
|
||||
}
|
||||
|
||||
int EightBit::MOS6502::execute(uint8_t cell) {
|
||||
@ -543,5 +543,5 @@ void EightBit::MOS6502::BRK() {
|
||||
pushWord(PC());
|
||||
PHP();
|
||||
setFlag(P(), IF);
|
||||
PC() = getWordPaged(0xff, IRQvector);
|
||||
jump(getWordPaged(0xff, IRQvector));
|
||||
}
|
||||
|
@ -495,20 +495,12 @@ void EightBit::Z80::cpd(const uint8_t a, uint8_t& f) {
|
||||
|
||||
bool EightBit::Z80::cpir(const uint8_t a, uint8_t& f) {
|
||||
cpi(a, f);
|
||||
MEMPTR() = PC();
|
||||
const auto again = (f & PF) && !(f & ZF); // See CPI
|
||||
if (LIKELY(again))
|
||||
--MEMPTR().word;
|
||||
return again;
|
||||
return (f & PF) && !(f & ZF); // See CPI
|
||||
}
|
||||
|
||||
bool EightBit::Z80::cpdr(const uint8_t a, uint8_t& f) {
|
||||
cpd(a, f);
|
||||
MEMPTR().word = PC().word - 1;
|
||||
const auto again = (f & PF) && !(f & ZF); // See CPD
|
||||
if (UNLIKELY(!again))
|
||||
--MEMPTR().word;
|
||||
return again;
|
||||
return (f & PF) && !(f & ZF); // See CPD
|
||||
}
|
||||
|
||||
void EightBit::Z80::blockLoad(const uint8_t a, uint8_t& f, const register16_t source, const register16_t destination) {
|
||||
@ -535,18 +527,12 @@ void EightBit::Z80::ldi(const uint8_t a, uint8_t& f) {
|
||||
|
||||
bool EightBit::Z80::ldir(const uint8_t a, uint8_t& f) {
|
||||
ldi(a, f);
|
||||
const auto again = (f & PF) != 0;
|
||||
if (LIKELY(again)) // See LDI
|
||||
MEMPTR().word = PC().word - 1;
|
||||
return again;
|
||||
return !!(f & PF); // See LDI
|
||||
}
|
||||
|
||||
bool EightBit::Z80::lddr(const uint8_t a, uint8_t& f) {
|
||||
ldd(a, f);
|
||||
const auto again = (f & PF) != 0;
|
||||
if (LIKELY(again)) // See LDR
|
||||
MEMPTR().word = PC().word - 1;
|
||||
return again;
|
||||
return !!(f & PF); // See LDD
|
||||
}
|
||||
|
||||
void EightBit::Z80::ini(uint8_t& f) {
|
||||
@ -999,13 +985,15 @@ void EightBit::Z80::executeED(uint8_t& a, uint8_t& f, const int x, const int y,
|
||||
break;
|
||||
case 6: // LDIR
|
||||
if (LIKELY(ldir(a, f))) {
|
||||
PC().word -= 2;
|
||||
MEMPTR().word = --PC().word;
|
||||
--PC().word;
|
||||
addCycles(5);
|
||||
}
|
||||
break;
|
||||
case 7: // LDDR
|
||||
if (LIKELY(lddr(a, f))) {
|
||||
PC().word -= 2;
|
||||
MEMPTR().word = --PC().word;
|
||||
--PC().word;
|
||||
addCycles(5);
|
||||
}
|
||||
break;
|
||||
@ -1021,14 +1009,18 @@ void EightBit::Z80::executeED(uint8_t& a, uint8_t& f, const int x, const int y,
|
||||
break;
|
||||
case 6: // CPIR
|
||||
if (LIKELY(cpir(a, f))) {
|
||||
PC().word -= 2;
|
||||
MEMPTR().word = --PC().word;
|
||||
--PC().word;
|
||||
addCycles(5);
|
||||
}
|
||||
break;
|
||||
case 7: // CPDR
|
||||
if (LIKELY(cpdr(a, f))) {
|
||||
PC().word -= 2;
|
||||
MEMPTR().word = --PC().word;
|
||||
--PC().word;
|
||||
addCycles(5);
|
||||
} else {
|
||||
MEMPTR().word = PC().word - 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
@ -1382,7 +1374,7 @@ void EightBit::Z80::executeOther(uint8_t& a, uint8_t& f, const int x, const int
|
||||
addCycles(4);
|
||||
break;
|
||||
case 2: // JP HL
|
||||
PC() = HL2();
|
||||
jump(HL2());
|
||||
addCycles(4);
|
||||
break;
|
||||
case 3: // LD SP,HL
|
||||
|
Loading…
x
Reference in New Issue
Block a user