mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-01 17:55:30 +00:00
Merge branch 'master' of https://github.com/AnonymusRaccoon/ComSquare into APU
This commit is contained in:
+5
-2
@@ -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
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user