mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-05-22 14:32:03 +00:00
Implemnting the STP
This commit is contained in:
@@ -205,6 +205,8 @@ namespace ComSquare::CPU
|
||||
{
|
||||
unsigned cycles = 0;
|
||||
|
||||
if (this->_isStopped)
|
||||
return 0xFF;
|
||||
for (int i = 0; i < 0xFF; i++)
|
||||
cycles += this->_executeInstruction(this->readPC());
|
||||
return cycles;
|
||||
|
||||
+5
-1
@@ -188,6 +188,8 @@ namespace ComSquare::CPU
|
||||
Registers _registers{};
|
||||
//! @brief Is the CPU running in emulation mode (in 8bits)
|
||||
bool _isEmulationMode = true;
|
||||
//! @brief If the processor is stopped (using an STP instruction), the clock is stopped and no instruction will be run until a manual reset.
|
||||
bool _isStopped = false;
|
||||
//! @brief Internal registers of the CPU (accessible from the bus via addr $4200 to $421F).
|
||||
InternalRegisters _internalRegisters{};
|
||||
//! @brief The memory bus to use for read/write.
|
||||
@@ -439,6 +441,8 @@ namespace ComSquare::CPU
|
||||
int PEI(uint24_t, AddressingMode);
|
||||
//! @brief Push Effective Absolute Address
|
||||
int PEA(uint24_t, AddressingMode);
|
||||
//! @brief Stop the processor
|
||||
int STP(uint24_t, AddressingMode);
|
||||
|
||||
//! @brief All the instructions of the CPU.
|
||||
//! @info Instructions are indexed by their opcode
|
||||
@@ -662,7 +666,7 @@ namespace ComSquare::CPU
|
||||
{&CPU::CLD, 2, "cld", AddressingMode::Implied, 2}, // D8
|
||||
{&CPU::CMP, 4, "cmp", AddressingMode::AbsoluteIndexedByY, 3}, // D9
|
||||
{&CPU::PHX, 3, "phx", AddressingMode::Implied, 1}, // DA
|
||||
{&CPU::BRK, 7, "stp #-#", AddressingMode::Implied, 2}, // DB
|
||||
{&CPU::STP, 3, "stp", AddressingMode::Implied, 1}, // DB
|
||||
{&CPU::JML, 7, "jml", AddressingMode::AbsoluteIndirectLong, 2}, // DC
|
||||
{&CPU::CMP, 4, "cmp", AddressingMode::AbsoluteIndexedByX, 3}, // DD
|
||||
{&CPU::DEC, 7, "dec", AddressingMode::AbsoluteIndexedByX, 3}, // DE
|
||||
|
||||
@@ -320,4 +320,10 @@ namespace ComSquare::CPU
|
||||
this->_registers.dbr = this->_pop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
int CPU::STP(uint24_t, AddressingMode)
|
||||
{
|
||||
this->_isStopped = true;
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ namespace ComSquare::CPU
|
||||
this->_registers.d = 0x0000;
|
||||
this->_registers.sh = 0x01; // the low bit of the stack pointer is undefined on reset.
|
||||
this->_registers.pc = this->_cartridgeHeader.emulationInterrupts.reset;
|
||||
this->_isStopped = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user