This commit is contained in:
Melefo
2020-02-12 14:31:16 +01:00
4 changed files with 41 additions and 4 deletions
+5 -2
View File
@@ -56,7 +56,9 @@ add_executable(unit_tests
sources/APU/Instructions/Standbys.cpp
tests/APU/testAPUInstructions.cpp
sources/APU/Instructions/ProgramStatusWord.cpp
tests/APU/testAPU.cpp sources/APU/Instructions/Bit.cpp)
sources/APU/Instructions/Bit.cpp
tests/APU/testAPU.cpp
)
# include criterion & coverage
target_link_libraries(unit_tests criterion -lgcov)
@@ -112,7 +114,8 @@ add_executable(ComSquare
sources/CPU/Instructions/MathematicalOperations.cpp
sources/APU/Instructions/Standbys.cpp
sources/APU/Instructions/ProgramStatusWord.cpp
sources/APU/Instructions/Bit.cpp)
sources/APU/Instructions/Bit.cpp
)
target_link_libraries(ComSquare
sfml-graphics
+26 -1
View File
@@ -157,18 +157,34 @@ namespace ComSquare::APU
switch (opcode) {
case 0x00:
return this->NOP();
case 0x02:
return SET1(_getDirectAddr(), 0);
case 0x20:
return this->CLRP();
case 0x22:
return SET1(_getDirectAddr(), 1);
case 0x40:
return this->SETP();
case 0x42:
return SET1(_getDirectAddr(), 2);
case 0x60:
return this->CLRC();
case 0x62:
return SET1(_getDirectAddr(), 3);
case 0x80:
return this->SETC();
case 0x82:
return SET1(_getDirectAddr(), 4);
case 0xA0:
return this->EI();
case 0xA2:
return SET1(_getDirectAddr(), 5);
case 0xC0:
return this->DI();
case 0xC2:
return SET1(_getDirectAddr(), 6);
case 0x32:
return SET1(_getDirectAddr(), 7);
case 0xED:
return this->NOTC();
case 0xEF:
@@ -190,4 +206,13 @@ namespace ComSquare::APU
if (this->_state == Running)
this->_paddingCycles = total - cycles;
}
}
uint24_t APU::_getDirectAddr()
{
uint8_t addr = read(this->_internalRegisters.pc++);
if (this->_internalRegisters.p)
addr += 0x100;
return addr;
}
}
+6
View File
@@ -156,6 +156,9 @@ namespace ComSquare::APU
//! @brief Keep the number of excess cycles executed to pad the next update
unsigned int _paddingCycles = 0;
//! @brief Get direct page offset
uint24_t _getDirectAddr();
//! @brief Execute a single instruction.
//! @return The number of cycles that the instruction took.
int executeInstruction();
@@ -183,6 +186,9 @@ namespace ComSquare::APU
int EI();
//! @brief Disable interrupts instruction, Set Zero flag to 0
int DI();
//! @brief Set 1-bit instruction, set a bit in direct page
int SET1(uint24_t dp, uint8_t bit);
public:
explicit APU();
+4 -1
View File
@@ -6,8 +6,11 @@
namespace ComSquare::APU
{
int SET1()
int APU::SET1(uint24_t dp, uint8_t bit)
{
uint8_t data = read(dp);
write(dp, data | (1u << bit));
return 4;
}
}