Changing timing management

This commit is contained in:
AnonymusRaccoon
2020-02-13 13:55:01 +01:00
parent 475fa68974
commit 4d30a35620
7 changed files with 101 additions and 92 deletions
+7 -12
View File
@@ -6,7 +6,7 @@
namespace ComSquare::CPU
{
unsigned CPU::RESB()
void CPU::RESB()
{
this->_registers.p.i = true;
this->_registers.p.d = false;
@@ -18,10 +18,9 @@ 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;
return 0;
}
unsigned CPU::BRK()
void CPU::BRK()
{
// TODO rework this. The PC should be pushed to the stack.
// Info here: http://softpixel.com/~cwright/sianse/docs/65816NFO.HTM at BRK Software Break
@@ -33,18 +32,14 @@ namespace ComSquare::CPU
else
this->_registers.pc = this->_cartridgeHeader.nativeInterrupts.brk;
this->_registers.p.d = false;
return !this->_isEmulationMode;
}
unsigned CPU::RTI()
void CPU::RTI()
{
this->_registers.p.flags = this->pop();
this->_registers.pc = this->pop16();
this->_registers.p.flags = this->_pop();
this->_registers.pc = this->_pop16();
if (!this->_isEmulationMode) {
this->_registers.pbr = this->pop16();
return 1;
}
return 0;
if (!this->_isEmulationMode)
this->_registers.pbr = this->_pop16();
}
}
@@ -7,7 +7,7 @@
namespace ComSquare::CPU
{
unsigned CPU::ADC(uint24_t valueAddr)
void CPU::ADC(uint24_t valueAddr)
{
unsigned value = this->_bus->read(valueAddr) + this->_registers.p.c;
if (this->_registers.p.m)
@@ -25,6 +25,5 @@ namespace ComSquare::CPU
this->_registers.a %= 0x100;
this->_registers.p.z = this->_registers.a == 0;
this->_registers.p.n = this->_registers.a & negativeMask;
return this->_extraMemoryCycles + !this->_registers.p.m;
}
}
@@ -0,0 +1,18 @@
//
// Created by anonymus-raccoon on 2/13/20.
//
#include "../CPU.hpp"
namespace ComSquare::CPU
{
void CPU::STA(uint24_t addr)
{
if (this->_registers.p.m)
this->_bus->write(addr, this->_registers.al);
else {
this->_bus->write(addr, this->_registers.al);
this->_bus->write(addr + 1, this->_registers.ah);
}
}
}