Fixing the BRK/COP

This commit is contained in:
Anonymus Raccoon
2020-04-03 22:23:54 +02:00
parent 4ac1169dc2
commit 1feab12fec
4 changed files with 11 additions and 15 deletions
+2 -2
View File
@@ -384,9 +384,9 @@ namespace ComSquare::CPU
//! @brief All the instructions of the CPU.
//! @info Instructions are indexed by their opcode
Instruction _instructions[0x100] = {
{&CPU::BRK, 7, "brk", AddressingMode::Implied, 2}, // 00
{&CPU::BRK, 7, "brk", AddressingMode::Immediate8bits, 2}, // 00
{&CPU::ORA, 6, "ora", AddressingMode::DirectPageIndirectIndexedByX, 2}, // 01
{&CPU::COP, 7, "cop", AddressingMode::Implied, 2}, // 02
{&CPU::COP, 7, "cop", AddressingMode::Immediate8bits, 2}, // 02
{&CPU::ORA, 4, "ora", AddressingMode::StackRelative, 2}, // 03
{&CPU::BRK, 7, "tsb #-#", AddressingMode::Implied, 2}, // 04
{&CPU::ORA, 3, "ora", AddressingMode::DirectPage, 2}, // 05
+2 -6
View File
@@ -24,16 +24,14 @@ namespace ComSquare::CPU
int CPU::BRK(uint24_t, AddressingMode)
{
if (this->_isEmulationMode) {
this->_registers.pc += 2;
this->_push(this->_registers.pc);
this->_registers.p.x_b = true;
this->_push(this->_registers.p.flags);
this->_registers.p.i = true;
this->_registers.p.d = false;
this->_registers.pbr = 0x0;
this->_registers.pc = this->_cartridgeHeader.emulationInterrupts.brk;
} else {
this->_push(this->_registers.pbr);
this->_registers.pc += 2;
this->_push(this->_registers.pc);
this->_push(this->_registers.p.flags);
this->_registers.p.i = true;
@@ -47,16 +45,14 @@ namespace ComSquare::CPU
int CPU::COP(uint24_t, AddressingMode)
{
if (this->_isEmulationMode) {
this->_registers.pc += 2;
this->_push(this->_registers.pc);
this->_push(this->_registers.p.flags);
this->_registers.p.i = true;
this->_registers.p.d = false;
this->_registers.pbr = 0x0;
this->_registers.pc = this->_cartridgeHeader.emulationInterrupts.cop;
} else {
this->_push(this->_registers.pbr);
this->_registers.pc += 2;
this->_push(this->_registers.pc);
this->_push(this->_registers.p.flags);
this->_registers.p.i = true;