Adding 16-bit Data Transmission Operations

This commit is contained in:
Melefo
2020-02-25 19:27:29 +01:00
parent ebc3df354b
commit 9928eb721d
5 changed files with 62 additions and 2 deletions
@@ -0,0 +1,26 @@
//
// Created by Melefo on 25/02/2020.
//
#include "../APU.hpp"
namespace ComSquare::APU
{
int APU::MOVW(uint24_t addr, bool to_ya)
{
uint24_t addr2 = addr + 1 + (this->_internalRegisters.p ? 0x0100 : 0);
if (to_ya) {
uint16_t value = ((this->_internalRead(addr2) << 8u) | this->_internalRead(addr));
this->_internalRegisters.ya = value;
this->_internalRegisters.n = value & 0x8000u;
this->_internalRegisters.z = !value;
}
else {
this->_internalWrite(addr, this->_internalRegisters.a);
this->_internalWrite(addr2, this->_internalRegisters.y);
}
return 5;
}
}