Finishing the TSB

This commit is contained in:
Anonymus Raccoon
2020-04-08 11:39:43 +02:00
parent 5485534006
commit b9ff47584e
2 changed files with 30 additions and 2 deletions
@@ -2,6 +2,7 @@
// Created by anonymus-raccoon on 2/20/20.
//
#include <iostream>
#include "../../Models/Int24.hpp"
#include "../CPU.hpp"
@@ -9,9 +10,13 @@ namespace ComSquare::CPU
{
int CPU::TSB(uint24_t valueAddr, AddressingMode mode)
{
uint8_t value = this->_bus->read(valueAddr);
uint16_t value = this->_bus->read(valueAddr);
if (!this->_registers.p.m)
value += this->_bus->read(valueAddr + 1) << 8u;
value |= this->_registers.a;
this->_bus->write(valueAddr, value);
if (!this->_registers.p.m)
this->_bus->write(valueAddr + 1, value >> 8u);
this->_registers.p.z = value == 0;
+24 -1
View File
@@ -35,7 +35,6 @@ Test(AND, nativeNegative)
cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
}
Test(AND, emulationTest)
{
Init()
@@ -48,3 +47,27 @@ Test(AND, emulationTest)
cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
}
Test(TSB, emulationTest)
{
Init()
snes.wram->_data[0] = 0b00110011;
snes.cpu->_registers.a = 0b00110111;
snes.cpu->_registers.p.m = true;
snes.cpu->TSB(0x0, ComSquare::CPU::AddressingMode::Implied);
cr_assert_eq(snes.wram->_data[0], 0b00110111, "The data in ram should be 0b00110111 but it was %x", snes.wram->_data[0]);
cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
}
Test(TSB, nativeTest)
{
Init()
snes.wram->_data[0] = 0xF0;
snes.wram->_data[1] = 0x0F;
snes.cpu->_registers.a = 0x8008;
snes.cpu->_registers.p.m = false;
snes.cpu->TSB(0x0, ComSquare::CPU::AddressingMode::Implied);
cr_assert_eq(snes.wram->_data[0], 0xF8, "The first data in ram should be 0xF8 but it was %x", snes.wram->_data[0]);
cr_assert_eq(snes.wram->_data[1], 0x8F, "The second data in ram should be 0x8F but it was %x", snes.wram->_data[1]);
cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
}