mirror of
https://github.com/MoleskiCoder/EightBit.git
synced 2024-06-01 07:41:51 +00:00
Merge branch 'master' of https://github.com/MoleskiCoder/EightBit
This commit is contained in:
commit
e670482721
BIN
LR35902/documentation/gbctr.pdf
Normal file
BIN
LR35902/documentation/gbctr.pdf
Normal file
Binary file not shown.
|
@ -71,19 +71,19 @@
|
|||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;C:\Libraries\boost_1_65_1;$(IncludePath)</IncludePath>
|
||||
<IncludePath>..\inc;..\..\inc;..\..\MC6850\inc;$(SolutionDir)modules\catch2\single_include\catch2;$(IncludePath)</IncludePath>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
|
|
|
@ -80,7 +80,7 @@ namespace EightBit {
|
|||
}
|
||||
|
||||
void exxAF() {
|
||||
m_accumulatorFlagsSet = !m_accumulatorFlagsSet;
|
||||
m_accumulatorFlagsSet ^= 1;
|
||||
}
|
||||
|
||||
DECLARE_PIN_INPUT(NMI)
|
||||
|
@ -282,26 +282,26 @@ namespace EightBit {
|
|||
return setBit(f, HC, calculateHalfCarryAdd(before, value, calculation));
|
||||
}
|
||||
|
||||
static void adjustHalfCarrySub(uint8_t& f, const uint8_t before, const uint8_t value, const int calculation) {
|
||||
f = setBit(f, HC, calculateHalfCarrySub(before, value, calculation));
|
||||
[[nodiscard]] static uint8_t adjustHalfCarrySub(uint8_t f, const uint8_t before, const uint8_t value, const int calculation) {
|
||||
return setBit(f, HC, calculateHalfCarrySub(before, value, calculation));
|
||||
}
|
||||
|
||||
static void adjustOverflowAdd(uint8_t& f, const uint8_t before, const uint8_t value, const uint8_t calculation) {
|
||||
adjustOverflowAdd(f, before & SF, value & SF, calculation & SF);
|
||||
[[nodiscard]] static uint8_t adjustOverflowAdd(uint8_t f, const uint8_t before, const uint8_t value, const uint8_t calculation) {
|
||||
return adjustOverflowAdd(f, before & SF, value & SF, calculation & SF);
|
||||
}
|
||||
|
||||
static void adjustOverflowAdd(uint8_t& f, const int beforeNegative, const int valueNegative, const int afterNegative) {
|
||||
[[nodiscard]] static uint8_t adjustOverflowAdd(uint8_t f, const int beforeNegative, const int valueNegative, const int afterNegative) {
|
||||
const auto overflow = (beforeNegative == valueNegative) && (beforeNegative != afterNegative);
|
||||
f = setBit(f, VF, overflow);
|
||||
return setBit(f, VF, overflow);
|
||||
}
|
||||
|
||||
static void adjustOverflowSub(uint8_t& f, const uint8_t before, const uint8_t value, const uint8_t calculation) {
|
||||
adjustOverflowSub(f, before & SF, value & SF, calculation & SF);
|
||||
[[nodiscard]] static uint8_t adjustOverflowSub(uint8_t f, const uint8_t before, const uint8_t value, const uint8_t calculation) {
|
||||
return adjustOverflowSub(f, before & SF, value & SF, calculation & SF);
|
||||
}
|
||||
|
||||
static void adjustOverflowSub(uint8_t& f, const int beforeNegative, const int valueNegative, const int afterNegative) {
|
||||
[[nodiscard]] static uint8_t adjustOverflowSub(uint8_t f, const int beforeNegative, const int valueNegative, const int afterNegative) {
|
||||
const auto overflow = (beforeNegative != valueNegative) && (beforeNegative != afterNegative);
|
||||
f = setBit(f, VF, overflow);
|
||||
return setBit(f, VF, overflow);
|
||||
}
|
||||
|
||||
static uint8_t subtract(uint8_t& f, uint8_t operand, uint8_t value, int carry = 0);
|
||||
|
|
|
@ -253,13 +253,12 @@ bool EightBit::Z80::callConditionalFlag(const uint8_t f, const int flag) {
|
|||
EightBit::register16_t EightBit::Z80::sbc(uint8_t& f, const register16_t operand, const register16_t value) {
|
||||
|
||||
const auto subtraction = operand.word - value.word - (f & CF);
|
||||
|
||||
const register16_t result = subtraction;
|
||||
|
||||
f = setBit(f, NF);
|
||||
f = clearBit(f, ZF, result.word);
|
||||
f = setBit(f, CF, subtraction & Bit16);
|
||||
adjustHalfCarrySub(f, operand.high, value.high, result.high);
|
||||
f = adjustHalfCarrySub(f, operand.high, value.high, result.high);
|
||||
f = adjustXY<Z80>(f, result.high);
|
||||
|
||||
const auto beforeNegative = operand.high & SF;
|
||||
|
@ -267,7 +266,7 @@ EightBit::register16_t EightBit::Z80::sbc(uint8_t& f, const register16_t operand
|
|||
const auto afterNegative = result.high & SF;
|
||||
|
||||
f = setBit(f, SF, afterNegative);
|
||||
adjustOverflowSub(f, beforeNegative, valueNegative, afterNegative);
|
||||
f = adjustOverflowSub(f, beforeNegative, valueNegative, afterNegative);
|
||||
|
||||
MEMPTR() = operand + 1;
|
||||
|
||||
|
@ -284,7 +283,7 @@ EightBit::register16_t EightBit::Z80::adc(uint8_t& f, const register16_t operand
|
|||
const auto afterNegative = result.high & SF;
|
||||
|
||||
f = setBit(f, SF, afterNegative);
|
||||
adjustOverflowAdd(f, beforeNegative, valueNegative, afterNegative);
|
||||
f = adjustOverflowAdd(f, beforeNegative, valueNegative, afterNegative);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
@ -310,7 +309,7 @@ uint8_t EightBit::Z80::add(uint8_t& f, const uint8_t operand, const uint8_t valu
|
|||
const auto result = addition.low;
|
||||
|
||||
f = adjustHalfCarryAdd(f, operand, value, result);
|
||||
adjustOverflowAdd(f, operand, value, result);
|
||||
f = adjustOverflowAdd(f, operand, value, result);
|
||||
|
||||
f = clearBit(f, NF);
|
||||
f = setBit(f, CF, addition.high & CF);
|
||||
|
@ -328,8 +327,8 @@ uint8_t EightBit::Z80::subtract(uint8_t& f, const uint8_t operand, const uint8_t
|
|||
const register16_t subtraction = operand - value - carry;
|
||||
const auto result = subtraction.low;
|
||||
|
||||
adjustHalfCarrySub(f, operand, value, result);
|
||||
adjustOverflowSub(f, operand, value, result);
|
||||
f = adjustHalfCarrySub(f, operand, value, result);
|
||||
f = adjustOverflowSub(f, operand, value, result);
|
||||
|
||||
f = setBit(f, NF);
|
||||
f = setBit(f, CF, subtraction.high & CF);
|
||||
|
@ -465,7 +464,7 @@ uint8_t EightBit::Z80::res(const int n, const uint8_t operand) {
|
|||
uint8_t EightBit::Z80::set(const int n, const uint8_t operand) {
|
||||
ASSUME(n >= 0);
|
||||
ASSUME(n <= 7);
|
||||
return operand | Chip::bit(n);
|
||||
return setBit(operand, Chip::bit(n));
|
||||
}
|
||||
|
||||
uint8_t EightBit::Z80::neg(uint8_t& f, uint8_t operand) {
|
||||
|
@ -476,8 +475,8 @@ uint8_t EightBit::Z80::neg(uint8_t& f, uint8_t operand) {
|
|||
|
||||
const uint8_t result = (~operand + 1); // two's complement
|
||||
|
||||
adjustHalfCarrySub(f, 0U, operand, result);
|
||||
adjustOverflowSub(f, 0U, operand, result);
|
||||
f = adjustHalfCarrySub(f, 0U, operand, result);
|
||||
f = adjustOverflowSub(f, 0U, operand, result);
|
||||
|
||||
f = adjustSZXY<Z80>(f, result);
|
||||
|
||||
|
@ -549,7 +548,7 @@ void EightBit::Z80::blockCompare(uint8_t& f, const uint8_t value, const register
|
|||
f = setBit(f, PF, --counter.word);
|
||||
|
||||
f = adjustSZ<Z80>(f, result);
|
||||
adjustHalfCarrySub(f, value, contents, result);
|
||||
f = adjustHalfCarrySub(f, value, contents, result);
|
||||
f = setBit(f, NF);
|
||||
|
||||
result -= ((f & HC) >> 4);
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 9e1bdca4667295fcb16265eae00efa8423f07007
|
||||
Subproject commit 930f49a641aa6a495d264d7b5e7c007734da0b0c
|
Loading…
Reference in New Issue
Block a user