From 95f17c06a8db3ad95de6ccec2006e8bb16297097 Mon Sep 17 00:00:00 2001
From: Anonymus Raccoon
Date: Tue, 24 Mar 2020 01:53:45 +0100
Subject: [PATCH] Finishing to clean tests and adding the start of the bus
logger
---
CMakeLists.txt | 19 +-
sources/APU/APU.cpp | 10 +-
sources/APU/APU.hpp | 7 +-
sources/APU/DSP/DSP.cpp | 8 +-
sources/APU/DSP/DSP.hpp | 11 +-
sources/APU/Instructions/Subroutine.cpp | 5 +
sources/CPU/AddressingModes.cpp | 2 +-
sources/CPU/CPU.hpp | 7 +-
.../CPU/Instructions/InternalInstruction.cpp | 5 +
sources/Cartridge/Cartridge.cpp | 2 +-
sources/Cartridge/Cartridge.hpp | 4 +-
sources/Debugger/MemoryBusDebug.cpp | 80 +-
sources/Debugger/MemoryBusDebug.hpp | 54 +-
sources/Debugger/MemoryViewer.cpp | 4 +-
sources/Memory/AMemory.cpp | 40 +
sources/Memory/{IMemory.hpp => AMemory.hpp} | 21 +-
...ctangleMemory.cpp => ARectangleMemory.cpp} | 12 +-
...ctangleMemory.hpp => ARectangleMemory.hpp} | 20 +-
sources/Memory/IMemory.cpp | 35 -
sources/Memory/MemoryBus.cpp | 8 +-
sources/Memory/MemoryBus.hpp | 10 +-
sources/Memory/MemoryShadow.cpp | 9 +-
sources/Memory/MemoryShadow.hpp | 22 +-
sources/Memory/RectangleShadow.cpp | 9 +-
sources/Memory/RectangleShadow.hpp | 16 +-
sources/PPU/PPU.cpp | 5 +
sources/PPU/PPU.hpp | 13 +-
sources/Ram/Ram.cpp | 11 +-
sources/Ram/Ram.hpp | 13 +-
sources/Renderer/QtRenderer/QtSFML.cpp | 4 +-
sources/SNES.cpp | 4 +-
tests/APU/testAPU.cpp | 67 +-
tests/APU/testAPUInstructions.cpp | 122 +-
tests/CPU/Math/testADC.cpp | 164 +--
tests/CPU/Math/testSBC.cpp | 124 +-
tests/CPU/TransferRegisters.cpp | 192 +--
tests/CPU/testAddressingMode.cpp | 364 +++---
tests/CPU/testBits.cpp | 52 +-
tests/CPU/testInternal.cpp | 1082 ++++++++---------
tests/CPU/testInterupts.cpp | 112 +-
tests/CPU/testStore.cpp | 174 +--
tests/PPU/testPpuWrite.cpp | 282 ++---
tests/PPU/testPpuWriteFromVmain.cpp | 320 ++---
tests/testMemoryBus.cpp | 309 +++--
tests/tests.cpp | 24 -
tests/tests.hpp | 16 +-
ui/busView.ui | 723 +++++------
47 files changed, 2421 insertions(+), 2176 deletions(-)
create mode 100644 sources/Memory/AMemory.cpp
rename sources/Memory/{IMemory.hpp => AMemory.hpp} (82%)
rename sources/Memory/{IRectangleMemory.cpp => ARectangleMemory.cpp} (85%)
rename sources/Memory/{IRectangleMemory.hpp => ARectangleMemory.hpp} (89%)
delete mode 100644 sources/Memory/IMemory.cpp
delete mode 100644 tests/tests.cpp
diff --git a/CMakeLists.txt b/CMakeLists.txt
index bdf401a..c9aa11d 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -10,7 +10,6 @@ add_compile_options(-W -Wall -Wextra -Wshadow)
# make unit tests
add_executable(unit_tests
tests/CPU/testAddressingMode.cpp
- tests/tests.cpp
tests/CPU/testInterupts.cpp
tests/testMemoryBus.cpp
tests/tests.hpp
@@ -18,8 +17,8 @@ add_executable(unit_tests
sources/SNES.hpp
sources/Memory/MemoryBus.cpp
sources/Memory/MemoryBus.hpp
- sources/Memory/IMemory.hpp
- sources/Memory/IMemory.cpp
+ sources/Memory/AMemory.hpp
+ sources/Memory/AMemory.cpp
sources/PPU/PPU.cpp
sources/PPU/PPU.hpp
sources/CPU/CPU.cpp
@@ -37,8 +36,8 @@ add_executable(unit_tests
sources/Ram/Ram.hpp
sources/Memory/MemoryShadow.cpp
sources/Memory/MemoryShadow.hpp
- sources/Memory/IRectangleMemory.cpp
- sources/Memory/IRectangleMemory.hpp
+ sources/Memory/ARectangleMemory.cpp
+ sources/Memory/ARectangleMemory.hpp
sources/APU/DSP/DSP.cpp
sources/APU/DSP/DSP.hpp
sources/Renderer/IRenderer.hpp
@@ -58,7 +57,6 @@ add_executable(unit_tests
tests/APU/testAPU.cpp
sources/CPU/Instructions/MathematicalOperations.cpp
tests/CPU/testAddressingMode.cpp
- tests/tests.cpp
tests/PPU/testPpuWrite.cpp
tests/PPU/testPpuWriteFromVmain.cpp
sources/CPU/Instructions/MathematicalOperations.cpp
@@ -104,8 +102,8 @@ add_executable(ComSquare
sources/SNES.hpp
sources/Memory/MemoryBus.cpp
sources/Memory/MemoryBus.hpp
- sources/Memory/IMemory.hpp
- sources/Memory/IMemory.cpp
+ sources/Memory/AMemory.hpp
+ sources/Memory/AMemory.cpp
sources/PPU/PPU.cpp
sources/PPU/PPU.hpp
sources/CPU/CPU.cpp
@@ -123,8 +121,8 @@ add_executable(ComSquare
sources/Ram/Ram.hpp
sources/Memory/MemoryShadow.cpp
sources/Memory/MemoryShadow.hpp
- sources/Memory/IRectangleMemory.cpp
- sources/Memory/IRectangleMemory.hpp
+ sources/Memory/ARectangleMemory.cpp
+ sources/Memory/ARectangleMemory.hpp
sources/APU/DSP/DSP.cpp
sources/APU/DSP/DSP.hpp
sources/Renderer/IRenderer.hpp
@@ -155,6 +153,7 @@ add_executable(ComSquare
ui/ramView.ui
ui/cartridgeView.ui
ui/apuView.ui
+ ui/busView.ui
resources/appResources.qrc
sources/Utility/Utility.hpp
sources/Debugger/MemoryViewer.cpp
diff --git a/sources/APU/APU.cpp b/sources/APU/APU.cpp
index a4d9a7e..9b97357 100644
--- a/sources/APU/APU.cpp
+++ b/sources/APU/APU.cpp
@@ -13,7 +13,7 @@ namespace ComSquare::APU
{
APU::APU(std::shared_ptr &map) :
_map(map),
- _dsp(new DSP::DSP)
+ _dsp(new DSP::DSP())
{
this->reset();
}
@@ -359,10 +359,10 @@ namespace ComSquare::APU
}
MemoryMap::MemoryMap() :
- Page0(0x00F0),
- Page1(0x0100),
- Memory(0xFDC0),
- IPL(0x0040)
+ Page0(0x00F0, "APU's Page 0"),
+ Page1(0x0100, "APU's Page 1"),
+ Memory(0xFDC0, "APU's Ram"),
+ IPL(0x0040, "IPL Rom")
{
}
diff --git a/sources/APU/APU.hpp b/sources/APU/APU.hpp
index f71afc0..0e58ad3 100644
--- a/sources/APU/APU.hpp
+++ b/sources/APU/APU.hpp
@@ -7,7 +7,7 @@
#include
#include "DSP/DSP.hpp"
-#include "../Memory/IMemory.hpp"
+#include "../Memory/AMemory.hpp"
#include "../Ram/Ram.hpp"
namespace ComSquare::APU
@@ -131,7 +131,7 @@ namespace ComSquare::APU
~MemoryMap() = default;
};
- class APU : public Memory::IMemory {
+ class APU : public Memory::AMemory {
protected:
//! @brief All the registers of the APU CPU
Registers _registers{};
@@ -155,6 +155,9 @@ namespace ComSquare::APU
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
void _internalWrite(uint24_t addr, uint8_t data);
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
+
//! @brief Current state of APU CPU
StateMode _state = Running;
diff --git a/sources/APU/DSP/DSP.cpp b/sources/APU/DSP/DSP.cpp
index 0f926ce..1b895c7 100644
--- a/sources/APU/DSP/DSP.cpp
+++ b/sources/APU/DSP/DSP.cpp
@@ -7,9 +7,6 @@
namespace ComSquare::APU::DSP
{
- DSP::DSP()
- { }
-
uint8_t DSP::read(uint24_t addr)
{
switch (addr) {
@@ -591,4 +588,9 @@ namespace ComSquare::APU::DSP
{
return this->_channels;
}
+
+ std::string DSP::getName()
+ {
+ return "DSP";
+ }
}
\ No newline at end of file
diff --git a/sources/APU/DSP/DSP.hpp b/sources/APU/DSP/DSP.hpp
index 603a0db..9e25c6a 100644
--- a/sources/APU/DSP/DSP.hpp
+++ b/sources/APU/DSP/DSP.hpp
@@ -7,7 +7,7 @@
#include
#include
-#include "../../Memory/IMemory.hpp"
+#include "../../Memory/AMemory.hpp"
namespace ComSquare::APU::DSP
{
@@ -113,7 +113,7 @@ namespace ComSquare::APU::DSP
uint8_t coeff;
};
- class DSP : public Memory::IMemory {
+ class DSP : public Memory::AMemory {
private:
//! @brief All registers of the DSP
Registers _registers{};
@@ -121,10 +121,10 @@ namespace ComSquare::APU::DSP
//! @brief 8x channels of sample used to make sound
std::array _channels{};
public:
- explicit DSP();
+ DSP() = default;
DSP(const DSP &) = default;
DSP &operator=(const DSP &) = default;
- ~DSP() = default;
+ ~DSP() override = default;
Registers getRegisters();
@@ -140,6 +140,9 @@ namespace ComSquare::APU::DSP
//! @param data The new value of the register.
//! @throw InvalidAddress will be thrown if the address is more than $7F (the number of register).
void write(uint24_t addr, uint8_t data) override;
+
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
};
}
diff --git a/sources/APU/Instructions/Subroutine.cpp b/sources/APU/Instructions/Subroutine.cpp
index 34eb031..3dcf2c3 100644
--- a/sources/APU/Instructions/Subroutine.cpp
+++ b/sources/APU/Instructions/Subroutine.cpp
@@ -52,4 +52,9 @@ namespace ComSquare::APU
this->RET();
return 6;
}
+
+ std::string APU::getName()
+ {
+ return "APU";
+ }
}
\ No newline at end of file
diff --git a/sources/CPU/AddressingModes.cpp b/sources/CPU/AddressingModes.cpp
index cbe52ff..edcb35f 100644
--- a/sources/CPU/AddressingModes.cpp
+++ b/sources/CPU/AddressingModes.cpp
@@ -2,7 +2,7 @@
// Created by anonymus-raccoon on 3/20/20.
//
-#include "../Models/Int24.hpp"$
+#include "../Models/Int24.hpp"
#include "CPU.hpp"
namespace ComSquare::CPU
diff --git a/sources/CPU/CPU.hpp b/sources/CPU/CPU.hpp
index 8efd3d8..cdecf8b 100644
--- a/sources/CPU/CPU.hpp
+++ b/sources/CPU/CPU.hpp
@@ -5,7 +5,7 @@
#ifndef COMSQUARE_CPU_HPP
#define COMSQUARE_CPU_HPP
-#include "../Memory/IMemory.hpp"
+#include "../Memory/AMemory.hpp"
#include "../Memory/MemoryBus.hpp"
#include "../Models/Int24.hpp"
#include "../Cartridge/Cartridge.hpp"
@@ -363,7 +363,7 @@ namespace ComSquare::CPU
};
//! @brief The main CPU
- class CPU : public Memory::IMemory {
+ class CPU : public Memory::AMemory {
protected:
//! @brief All the registers of the CPU
Registers _registers{};
@@ -570,6 +570,9 @@ namespace ComSquare::CPU
//! @throw InvalidAddress will be thrown if the address is more than $1F (the number of register).
void write(uint24_t addr, uint8_t data) override;
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
+
//! @brief Reset interrupt - Called on boot and when the reset button is pressed.
virtual void RESB();
diff --git a/sources/CPU/Instructions/InternalInstruction.cpp b/sources/CPU/Instructions/InternalInstruction.cpp
index 6c16c0c..3b3d5f6 100644
--- a/sources/CPU/Instructions/InternalInstruction.cpp
+++ b/sources/CPU/Instructions/InternalInstruction.cpp
@@ -307,4 +307,9 @@ namespace ComSquare::CPU
{
this->_registers.pac = value;
}
+
+ std::string CPU::getName()
+ {
+ return "CPU";
+ }
}
\ No newline at end of file
diff --git a/sources/Cartridge/Cartridge.cpp b/sources/Cartridge/Cartridge.cpp
index dd326fd..61ce1e0 100644
--- a/sources/Cartridge/Cartridge.cpp
+++ b/sources/Cartridge/Cartridge.cpp
@@ -13,7 +13,7 @@
namespace ComSquare::Cartridge
{
Cartridge::Cartridge(const std::string &romPath)
- : Ram::Ram(0)
+ : Ram::Ram(0, "Cartridge")
{
try {
if (romPath.empty())
diff --git a/sources/Cartridge/Cartridge.hpp b/sources/Cartridge/Cartridge.hpp
index ff9461f..9dc7c73 100644
--- a/sources/Cartridge/Cartridge.hpp
+++ b/sources/Cartridge/Cartridge.hpp
@@ -6,9 +6,9 @@
#define COMSQUARE_CARTRIDGE_HPP
#include
-#include "../Memory/IMemory.hpp"
+#include "../Memory/AMemory.hpp"
#include "../Models/Int24.hpp"
-#include "../Memory/IRectangleMemory.hpp"
+#include "../Memory/ARectangleMemory.hpp"
#include "InterruptVectors.hpp"
#include "../Ram/Ram.hpp"
diff --git a/sources/Debugger/MemoryBusDebug.cpp b/sources/Debugger/MemoryBusDebug.cpp
index 725cdf8..3c16a07 100644
--- a/sources/Debugger/MemoryBusDebug.cpp
+++ b/sources/Debugger/MemoryBusDebug.cpp
@@ -4,6 +4,7 @@
#include "MemoryBusDebug.hpp"
#include "../SNES.hpp"
+#include "../Utility/Utility.hpp"
namespace ComSquare::Debugger
{
@@ -11,12 +12,20 @@ namespace ComSquare::Debugger
: MemoryBus(bus),
_window(new ClosableWindow(*this, &MemoryBusDebug::disableViewer)),
_snes(snes),
- _ui()
+ _ui(),
+ _model()
{
this->_window->setContextMenuPolicy(Qt::NoContextMenu);
this->_window->setAttribute(Qt::WA_QuitOnClose, false);
+ this->_window->setAttribute(Qt::WA_DeleteOnClose);
this->_ui.setupUi(this->_window);
+ this->_ui.log->setModel(&this->_model);
+ this->_ui.log->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+ this->_ui.log->horizontalHeader()->setStretchLastSection(true);
+ this->_ui.log->horizontalHeader()->setSectionsMovable(true);
+ for (int i = 0; i < 5; i++)
+ this->_ui.log->setColumnWidth(i, this->_ui.log->width());
this->_window->show();
}
@@ -34,4 +43,71 @@ namespace ComSquare::Debugger
{
return true;
}
-}
\ No newline at end of file
+
+ uint8_t MemoryBusDebug::read(uint24_t addr)
+ {
+ return MemoryBus::read(addr);
+ }
+
+ void MemoryBusDebug::write(uint24_t addr, uint8_t data)
+ {
+ MemoryBus::write(addr, data);
+ }
+}
+
+int BusLogModel::rowCount(const QModelIndex &) const
+{
+ return this->_logs.size();
+}
+
+int BusLogModel::columnCount(const QModelIndex &) const
+{
+ return 5;
+}
+
+QVariant BusLogModel::data(const QModelIndex &index, int role) const
+{
+ if (role == Qt::TextAlignmentRole)
+ return Qt::AlignCenter;
+ if (role != Qt::DisplayRole)
+ return QVariant();
+ ComSquare::Debugger::BusLog log = this->_logs[index.row()];
+ switch (index.column()) {
+ case 0:
+ return QString(log.write ? "Write" : "Read");
+ case 1:
+ return QString(ComSquare::Utility::to_hex(log.addr).c_str());
+ case 2:
+ return QString(log.accessor.getName().c_str());
+ case 3:
+ return QString(log.accessor.getValueName(log.addr - log.accessor.getStart()).c_str());
+ case 4:
+ return QString(ComSquare::Utility::to_hex(log.oldData).c_str());
+ case 5:
+ return QString(ComSquare::Utility::to_hex(log.newData).c_str());
+ default:
+ return QVariant();
+ }
+}
+
+QVariant BusLogModel::headerData(int section, Qt::Orientation orientation, int role) const
+{
+ if (role != Qt::DisplayRole || orientation == Qt::Vertical)
+ return QVariant();
+ switch (section) {
+ case 0:
+ return QString("Type");
+ case 1:
+ return QString("Address");
+ case 2:
+ return QString("Component");
+ case 3:
+ return QString("Data Name");
+ case 4:
+ return QString("Old Data");
+ case 5:
+ return QString("New Data");
+ default:
+ return QString("");
+ }
+}
diff --git a/sources/Debugger/MemoryBusDebug.hpp b/sources/Debugger/MemoryBusDebug.hpp
index 6edd4f6..6d9bcb5 100644
--- a/sources/Debugger/MemoryBusDebug.hpp
+++ b/sources/Debugger/MemoryBusDebug.hpp
@@ -10,6 +10,43 @@
#include "../../ui/ui_busView.h"
#include "ClosableWindow.hpp"
+namespace ComSquare::Debugger
+{
+ //! @brief The struct used to represent memory bus logs.
+ struct BusLog {
+ bool write;
+ uint24_t addr;
+ Memory::AMemory &accessor;
+ uint8_t oldData;
+ uint8_t newData;
+ };
+}
+
+
+//! @brief The qt model that bind the logs to the view.
+class BusLogModel : public QAbstractTableModel
+{
+Q_OBJECT
+private:
+ //! @brief The logs to display.
+ std::vector _logs;
+public:
+ BusLogModel() = default;
+ BusLogModel(const BusLogModel &) = delete;
+ const BusLogModel &operator=(const BusLogModel &) = delete;
+ ~BusLogModel() override = default;
+
+ //! @brief The number of row the table has.
+ int rowCount(const QModelIndex &parent) const override;
+ //! @brief The number of column the table has.
+ int columnCount(const QModelIndex &parent) const override;
+ //! @brief Return a data representing the table cell.
+ QVariant data(const QModelIndex &index, int role) const override;
+ //! @brief Override the headers to use hex values.
+ QVariant headerData(int section, Qt::Orientation orientation, int role) const override;
+};
+
+
namespace ComSquare::Debugger
{
//! @brief window that allow the user to view all data going through the memory bus.
@@ -21,7 +58,12 @@ namespace ComSquare::Debugger
SNES &_snes;
//! @brief A widget that contain the whole UI.
Ui::BusView _ui;
- public slots:
+ //! @brief The Log visualizer model for QT.
+ BusLogModel _model;
+
+ //! @brief Log a read/write to the debugger.
+// void log()
+ public:
//! @brief Called when the window is closed. Turn off the debugger and revert to a basic CPU.
void disableViewer();
public:
@@ -30,6 +72,16 @@ namespace ComSquare::Debugger
MemoryBusDebug &operator=(const MemoryBusDebug &) = delete;
~MemoryBusDebug() = default;
+ //! @brief Read data at a global address and log it to the debugger.
+ //! @param addr The address to read from.
+ //! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
+ uint8_t read(uint24_t addr) override;
+
+ //! @brief Write a data to a global address and log it to the debugger.
+ //! @param addr The address to write to.
+ //! @param data The data to write.
+ void write(uint24_t addr, uint8_t data) override;
+
//! @brief Focus the debugger's window.
void focus();
diff --git a/sources/Debugger/MemoryViewer.cpp b/sources/Debugger/MemoryViewer.cpp
index 748b9b7..1e59b53 100644
--- a/sources/Debugger/MemoryViewer.cpp
+++ b/sources/Debugger/MemoryViewer.cpp
@@ -149,10 +149,10 @@ namespace ComSquare::Debugger
unsigned MemoryViewer::switchToAddrTab(uint24_t addr)
{
- std::shared_ptr accessor = this->_bus.getAccessor(addr);
+ std::shared_ptr accessor = this->_bus.getAccessor(addr);
if (!accessor)
throw InvalidAddress("Memory viewer switch to address", addr);
- Memory::IMemory *ptr;
+ Memory::AMemory *ptr;
if (accessor->isMirror())
ptr = accessor->getMirrored().get();
else
diff --git a/sources/Memory/AMemory.cpp b/sources/Memory/AMemory.cpp
new file mode 100644
index 0000000..ce51b16
--- /dev/null
+++ b/sources/Memory/AMemory.cpp
@@ -0,0 +1,40 @@
+//
+// Created by anonymus-raccoon on 1/23/20.
+//
+
+#include "AMemory.hpp"
+#include
+
+namespace ComSquare::Memory
+{
+ void AMemory::setMemoryRegion(uint24_t start, uint24_t end)
+ {
+ this->_start = start;
+ this->_end = end;
+ }
+
+ bool AMemory::hasMemoryAt(uint24_t addr)
+ {
+ return this->_start <= addr && addr <= this->_end;
+ }
+
+ uint32_t AMemory::getStart()
+ {
+ return this->_start;
+ }
+
+ bool AMemory::isMirror()
+ {
+ return false;
+ }
+
+ std::shared_ptr AMemory::getMirrored()
+ {
+ return nullptr;
+ }
+
+ std::string AMemory::getValueName(uint24_t)
+ {
+ return "???";
+ }
+}
\ No newline at end of file
diff --git a/sources/Memory/IMemory.hpp b/sources/Memory/AMemory.hpp
similarity index 82%
rename from sources/Memory/IMemory.hpp
rename to sources/Memory/AMemory.hpp
index 78aa385..ab2fd7b 100644
--- a/sources/Memory/IMemory.hpp
+++ b/sources/Memory/AMemory.hpp
@@ -2,8 +2,8 @@
// Created by anonymus-raccoon on 1/23/20.
//
-#ifndef COMSQUARE_IMEMORY_HPP
-#define COMSQUARE_IMEMORY_HPP
+#ifndef COMSQUARE_AMEMORY_HPP
+#define COMSQUARE_AMEMORY_HPP
#include
@@ -14,7 +14,7 @@
namespace ComSquare::Memory
{
//! @brief Common interface implemented by all components mapping memory.
- class IMemory {
+ class AMemory {
private:
//! @brief The starting address mapped to this component.
uint24_t _start = 0;
@@ -34,7 +34,7 @@ namespace ComSquare::Memory
//! @brief Change starting and ending points of this mapped memory.
//! @param start The first address mapped to this component.
//! @param end The last address mapped to this component.
- //! @warning The start/end address should be a continuous range. You can't map address 0x0 and 0x2 but not 0x1. To do that, use two IMemory.
+ //! @warning The start/end address should be a continuous range. You can't map address 0x0 and 0x2 but not 0x1. To do that, use two AMemory.
void setMemoryRegion(uint24_t start, uint24_t end);
//! @brief Return true if this component has mapped the address.
//! @param addr The address to check.
@@ -46,14 +46,17 @@ namespace ComSquare::Memory
//! @brief Check if this memory is a mirror or not.
//! @return True if this memory is a mirror. False otherwise.
virtual bool isMirror();
+ //! @brief Get the name of this accessor (used for debug purpose)
+ virtual std::string getName() = 0;
+ //! @brief Get the name of the data at the address
+ //! @param addr The address (in local space)
+ virtual std::string getValueName(uint24_t addr);
//! @brief Return the memory accessor this accessor mirror if any
//! @return nullptr if isMirror is false, the source otherwise.
- virtual std::shared_ptr getMirrored();
- // TODO add destructors everywhere
- // TODO rename this as an abstract.
- virtual ~IMemory() = default;
+ virtual std::shared_ptr getMirrored();
+ virtual ~AMemory() = default;
};
};
-#endif //COMSQUARE_IMEMORY_HPP
+#endif //COMSQUARE_AMEMORY_HPP
diff --git a/sources/Memory/IRectangleMemory.cpp b/sources/Memory/ARectangleMemory.cpp
similarity index 85%
rename from sources/Memory/IRectangleMemory.cpp
rename to sources/Memory/ARectangleMemory.cpp
index 98ccea5..b60aa66 100644
--- a/sources/Memory/IRectangleMemory.cpp
+++ b/sources/Memory/ARectangleMemory.cpp
@@ -3,12 +3,12 @@
//
#include
-#include "IRectangleMemory.hpp"
+#include "ARectangleMemory.hpp"
#include "../Exceptions/InvalidAddress.hpp"
namespace ComSquare::Memory
{
- uint8_t IRectangleMemory::read(uint24_t addr)
+ uint8_t ARectangleMemory::read(uint24_t addr)
{
addr += this->getStart();
uint8_t bank = addr >> 16u;
@@ -25,7 +25,7 @@ namespace ComSquare::Memory
return this->read_internal(page);
}
- void IRectangleMemory::write(uint24_t addr, uint8_t data)
+ void ARectangleMemory::write(uint24_t addr, uint8_t data)
{
addr += this->getStart();
uint8_t bank = addr >> 16u;
@@ -42,7 +42,7 @@ namespace ComSquare::Memory
this->write_internal(page, data);
}
- bool IRectangleMemory::hasMemoryAt(uint24_t addr)
+ bool ARectangleMemory::hasMemoryAt(uint24_t addr)
{
uint8_t bank = addr >> 16u;
uint16_t page = addr;
@@ -53,12 +53,12 @@ namespace ComSquare::Memory
return false;
}
- uint24_t IRectangleMemory::getStart()
+ uint24_t ARectangleMemory::getStart()
{
return (this->_startBank << 16u) + this->_startPage;
}
- void IRectangleMemory::setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
+ void ARectangleMemory::setMemoryRegion(uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
{
this->_startBank = startBank;
this->_endBank = endBank;
diff --git a/sources/Memory/IRectangleMemory.hpp b/sources/Memory/ARectangleMemory.hpp
similarity index 89%
rename from sources/Memory/IRectangleMemory.hpp
rename to sources/Memory/ARectangleMemory.hpp
index 4c99985..f3adb8f 100644
--- a/sources/Memory/IRectangleMemory.hpp
+++ b/sources/Memory/ARectangleMemory.hpp
@@ -2,16 +2,16 @@
// Created by anonymus-raccoon on 1/29/20.
//
-#ifndef COMSQUARE_IRECTANGLEMEMORY_HPP
-#define COMSQUARE_IRECTANGLEMEMORY_HPP
+#ifndef COMSQUARE_ARECTANGLEMEMORY_HPP
+#define COMSQUARE_ARECTANGLEMEMORY_HPP
-#include "IMemory.hpp"
+#include "AMemory.hpp"
namespace ComSquare::Memory
{
- //! @brief Superset of the IMemory to map non continuous rectangle to the memory. (A rectangle that spam across more than one bank but that does not start at 0000 or end at FFFF).
- class IRectangleMemory : public IMemory {
+ //! @brief Superset of the AMemory to map non continuous rectangle to the memory. (A rectangle that spam across more than one bank but that does not start at 0000 or end at FFFF).
+ class ARectangleMemory : public AMemory {
private:
//! @brief The first bank to map to.
uint8_t _startBank = 0;
@@ -22,22 +22,22 @@ namespace ComSquare::Memory
//! @brief The last address of each bank to map.
uint16_t _endPage = 0;
public:
- //! @brief Read data from the component using the same method as the basic IMemory.
+ //! @brief Read data from the component using the same method as the basic AMemory.
//! @param addr The global 24 bits address. This method is responsible of mapping to the component's read.
//! @throw InvalidAddress if the address is not mapped to the component.
//! @return Return the data at the address given as parameter.
uint8_t read(uint24_t addr) override;
- //! @brief Write data to this component using the same method as the basic IMemory.
+ //! @brief Write data to this component using the same method as the basic AMemory.
//! @param addr The global 24 bits address. This method is responsible of mapping to the component's write.
//! @param data The new data to write.
//! @throw InvalidAddress if the address is not mapped to the component.
void write(uint24_t addr, uint8_t data) override;
- //! @brief Internal component read. Implement this as you would implement a basic IMemory's read.
+ //! @brief Internal component read. Implement this as you would implement a basic AMemory's read.
//! @param addr The local address to read from. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
//! @return Return the data at the address given as parameter.
virtual uint8_t read_internal(uint24_t addr) = 0;
- //! @brief Internal component write. Implement this as you would implement a basic IMemory's write.
+ //! @brief Internal component write. Implement this as you would implement a basic AMemory's write.
//! @param addr The local address to write to. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
//! @param data The new data to write.
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
@@ -59,4 +59,4 @@ namespace ComSquare::Memory
};
}
-#endif //COMSQUARE_IRECTANGLEMEMORY_HPP
+#endif //COMSQUARE_ARECTANGLEMEMORY_HPP
diff --git a/sources/Memory/IMemory.cpp b/sources/Memory/IMemory.cpp
deleted file mode 100644
index eff2491..0000000
--- a/sources/Memory/IMemory.cpp
+++ /dev/null
@@ -1,35 +0,0 @@
-//
-// Created by anonymus-raccoon on 1/23/20.
-//
-
-#include "IMemory.hpp"
-#include
-
-namespace ComSquare::Memory
-{
- void IMemory::setMemoryRegion(uint24_t start, uint24_t end)
- {
- this->_start = start;
- this->_end = end;
- }
-
- bool IMemory::hasMemoryAt(uint24_t addr)
- {
- return this->_start <= addr && addr <= this->_end;
- }
-
- uint32_t IMemory::getStart()
- {
- return this->_start;
- }
-
- bool IMemory::isMirror()
- {
- return false;
- }
-
- std::shared_ptr IMemory::getMirrored()
- {
- return nullptr;
- }
-}
\ No newline at end of file
diff --git a/sources/Memory/MemoryBus.cpp b/sources/Memory/MemoryBus.cpp
index 2e3177a..5f8a252 100644
--- a/sources/Memory/MemoryBus.cpp
+++ b/sources/Memory/MemoryBus.cpp
@@ -11,9 +11,9 @@
namespace ComSquare::Memory
{
- std::shared_ptr MemoryBus::getAccessor(uint24_t addr)
+ std::shared_ptr MemoryBus::getAccessor(uint24_t addr)
{
- auto it = std::find_if(this->_memoryAccessors.begin(), this->_memoryAccessors.end(), [addr](std::shared_ptr &accessor)
+ auto it = std::find_if(this->_memoryAccessors.begin(), this->_memoryAccessors.end(), [addr](std::shared_ptr &accessor)
{
return accessor->hasMemoryAt(addr);
});
@@ -24,7 +24,7 @@ namespace ComSquare::Memory
uint8_t MemoryBus::read(uint24_t addr)
{
- std::shared_ptr handler = this->getAccessor(addr);
+ std::shared_ptr handler = this->getAccessor(addr);
if (!handler) {
std::cout << "Unknown memory accessor for address " << std::hex << addr << ". Using open bus." << std::endl;
@@ -37,7 +37,7 @@ namespace ComSquare::Memory
void MemoryBus::write(uint24_t addr, uint8_t data)
{
- std::shared_ptr handler = this->getAccessor(addr);
+ std::shared_ptr handler = this->getAccessor(addr);
if (!handler) {
std::cout << "Unknown memory accessor for address " << std::hex << addr << ". Warning, it was a write." << std::endl;
diff --git a/sources/Memory/MemoryBus.hpp b/sources/Memory/MemoryBus.hpp
index bf67793..5647ac4 100644
--- a/sources/Memory/MemoryBus.hpp
+++ b/sources/Memory/MemoryBus.hpp
@@ -8,7 +8,7 @@
#include
#include
#include
-#include "IMemory.hpp"
+#include "AMemory.hpp"
namespace ComSquare
{
@@ -20,7 +20,7 @@ namespace ComSquare
class MemoryBus {
private:
//! @brief The list of components registered inside the bus. Every components that can read/write to a public address should be in this vector.
- std::vector> _memoryAccessors;
+ std::vector> _memoryAccessors;
//! @brief The last value read via the memory bus.
uint8_t _openBus = 0;
@@ -39,12 +39,12 @@ namespace ComSquare
//! @brief Read data at a global address.
//! @param addr The address to read from.
//! @return The value that the component returned for this address. If the address was mapped to ram, it simply returned the value. If the address was mapped to a register the component returned the register.
- uint8_t read(uint24_t addr);
+ virtual uint8_t read(uint24_t addr);
//! @brief Write a data to a global address.
//! @param addr The address to write to.
//! @param data The data to write.
- void write(uint24_t addr, uint8_t data);
+ virtual void write(uint24_t addr, uint8_t data);
//! @brief Map components to the address space using the currently loaded cartridge to set the right mapping mode.
//! @param console All the components.
@@ -53,7 +53,7 @@ namespace ComSquare
//! @brief Helper function to get the components that is responsible of read/write at an address.
//! @param addr The address you want to look for.
//! @return The components responsible for the address param or nullptr if none was found.
- std::shared_ptr getAccessor(uint24_t addr);
+ std::shared_ptr getAccessor(uint24_t addr);
//! @brief Return true if the Bus is overloaded with debugging features.
virtual bool isDebugger();
diff --git a/sources/Memory/MemoryShadow.cpp b/sources/Memory/MemoryShadow.cpp
index 4256c52..246e7c6 100644
--- a/sources/Memory/MemoryShadow.cpp
+++ b/sources/Memory/MemoryShadow.cpp
@@ -8,7 +8,7 @@
namespace ComSquare::Memory
{
- MemoryShadow::MemoryShadow(std::shared_ptr initial, uint24_t start, uint24_t end)
+ MemoryShadow::MemoryShadow(std::shared_ptr initial, uint24_t start, uint24_t end)
: _initial(std::move(initial))
{
this->setMemoryRegion(start, end);
@@ -29,8 +29,13 @@ namespace ComSquare::Memory
return true;
}
- std::shared_ptr MemoryShadow::getMirrored()
+ std::shared_ptr MemoryShadow::getMirrored()
{
return this->_initial;
}
+
+ std::string MemoryShadow::getName()
+ {
+ return this->_initial->getName();
+ }
}
\ No newline at end of file
diff --git a/sources/Memory/MemoryShadow.hpp b/sources/Memory/MemoryShadow.hpp
index 0653522..673eaf3 100644
--- a/sources/Memory/MemoryShadow.hpp
+++ b/sources/Memory/MemoryShadow.hpp
@@ -6,37 +6,39 @@
#define COMSQUARE_MEMORYSHADOW_HPP
#include
-#include "IMemory.hpp"
+#include "AMemory.hpp"
namespace ComSquare::Memory
{
- class MemoryShadow : public IMemory {
+ class MemoryShadow : public AMemory {
private:
//! @brief Memory to shadow from.
- std::shared_ptr _initial;
+ std::shared_ptr _initial;
public:
//! @brief Create a shadow for the memory given as parameter.
- explicit MemoryShadow(std::shared_ptr initial, uint24_t start, uint24_t end);
+ explicit MemoryShadow(std::shared_ptr initial, uint24_t start, uint24_t end);
MemoryShadow(const MemoryShadow &) = default;
MemoryShadow &operator=(const MemoryShadow &) = default;
~MemoryShadow() = default;
- //! @brief Read from the initial IMemory given.
- //! @param addr The address to read from. The address 0x0 should refer to the first byte of the initial IMemory.
- //! @throw InvalidAddress will be thrown if the address is more than the size of the initial IMemory.
+ //! @brief Read from the initial AMemory given.
+ //! @param addr The address to read from. The address 0x0 should refer to the first byte of the initial AMemory.
+ //! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
//! @return Return the data at the address.
uint8_t read(uint24_t addr) override;
//! @brief Write data to the ram.
- //! @param addr The address to write to. The address 0x0 should refer to the first byte of the initial IMemory.
+ //! @param addr The address to write to. The address 0x0 should refer to the first byte of the initial AMemory.
//! @param data The data to write.
- //! @throw InvalidAddress will be thrown if the address is more than the size of the initial IMemory.
+ //! @throw InvalidAddress will be thrown if the address is more than the size of the initial AMemory.
void write(uint24_t addr, uint8_t data) override;
//! @brief Check if this memory is a mirror or not.
//! @return True if this memory is a mirror. False otherwise.
bool isMirror() override;
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
//! @brief Return the memory accessor this accessor mirror if any
//! @return nullptr if isMirror is false, the source otherwise.
- std::shared_ptr getMirrored() override;
+ std::shared_ptr getMirrored() override;
};
}
diff --git a/sources/Memory/RectangleShadow.cpp b/sources/Memory/RectangleShadow.cpp
index 09e9a48..f798389 100644
--- a/sources/Memory/RectangleShadow.cpp
+++ b/sources/Memory/RectangleShadow.cpp
@@ -9,7 +9,7 @@
namespace ComSquare::Memory
{
- RectangleShadow::RectangleShadow(std::shared_ptr initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
+ RectangleShadow::RectangleShadow(std::shared_ptr initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage)
: _initial(std::move(initial))
{
this->setMemoryRegion(startBank, endBank, startPage, endPage);
@@ -38,8 +38,13 @@ namespace ComSquare::Memory
return true;
}
- std::shared_ptr RectangleShadow::getMirrored()
+ std::shared_ptr RectangleShadow::getMirrored()
{
return this->_initial;
}
+
+ std::string RectangleShadow::getName()
+ {
+ return this->_initial->getName();
+ }
}
\ No newline at end of file
diff --git a/sources/Memory/RectangleShadow.hpp b/sources/Memory/RectangleShadow.hpp
index e1486e1..756ab0d 100644
--- a/sources/Memory/RectangleShadow.hpp
+++ b/sources/Memory/RectangleShadow.hpp
@@ -6,30 +6,30 @@
#define COMSQUARE_RECTANGLESHADOW_HPP
#include
-#include "IRectangleMemory.hpp"
+#include "ARectangleMemory.hpp"
#include "MemoryShadow.hpp"
namespace ComSquare::Memory
{
- class RectangleShadow : public IRectangleMemory {
+ class RectangleShadow : public ARectangleMemory {
private:
//! @brief Memory to shadow from.
- std::shared_ptr _initial;
+ std::shared_ptr _initial;
//! @brief The number of banks to add to the memory before accessing it from the initial data.
uint8_t _bankOffset = 0;
public:
//! @brief Create a shadow for the memory given as parameter.
- explicit RectangleShadow(std::shared_ptr initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
+ explicit RectangleShadow(std::shared_ptr initial, uint8_t startBank, uint8_t endBank, uint16_t startPage, uint16_t endPage);
RectangleShadow(const RectangleShadow &) = default;
RectangleShadow &operator=(const RectangleShadow &) = default;
~RectangleShadow() = default;
- //! @brief Internal component read. Implement this as you would implement a basic IMemory's read.
+ //! @brief Internal component read. Implement this as you would implement a basic AMemory's read.
//! @param addr The local address to read from. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
//! @return Return the data at the address given as parameter.
uint8_t read_internal(uint24_t addr) override;
- //! @brief Internal component write. Implement this as you would implement a basic IMemory's write.
+ //! @brief Internal component write. Implement this as you would implement a basic AMemory's write.
//! @param addr The local address to write to. 0x0 refer to the first byte of your data and the address is in the component's space. That means that you can consider this address as continuous
//! @param data The new data to write.
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
@@ -37,9 +37,11 @@ namespace ComSquare::Memory
//! @brief Check if this memory is a mirror or not.
//! @return True if this memory is a mirror. False otherwise.
bool isMirror() override;
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
//! @brief Return the memory accessor this accessor mirror if any
//! @return nullptr if isMirror is false, the source otherwise.
- std::shared_ptr getMirrored() override;
+ std::shared_ptr getMirrored() override;
RectangleShadow *setBankOffset(uint8_t bankOffset);
};
diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp
index 92d40a6..9fd377e 100644
--- a/sources/PPU/PPU.cpp
+++ b/sources/PPU/PPU.cpp
@@ -244,4 +244,9 @@ namespace ComSquare::PPU
}
this->_renderer.drawScreen();
}
+
+ std::string PPU::getName()
+ {
+ return "PPU";
+ }
}
\ No newline at end of file
diff --git a/sources/PPU/PPU.hpp b/sources/PPU/PPU.hpp
index 85ed2aa..ec0d8d4 100644
--- a/sources/PPU/PPU.hpp
+++ b/sources/PPU/PPU.hpp
@@ -6,7 +6,7 @@
#define COMSQUARE_PPU_HPP
#include
-#include "../Memory/IMemory.hpp"
+#include "../Memory/AMemory.hpp"
#include "../Memory/MemoryBus.hpp"
#include "../Renderer/IRenderer.hpp"
#include "../Ram/ExtendedRam.hpp"
@@ -156,7 +156,7 @@ namespace ComSquare::PPU
};
//! @brief The class containing all the registers the PPU
- class PPU : public Memory::IMemory {
+ class PPU : public Memory::AMemory {
private:
/* struct _layerInfo {
bool _characterSize;
@@ -549,10 +549,10 @@ namespace ComSquare::PPU
Ram::ExtendedRam _oamram;
Ram::ExtendedRam _cgram;
public:
- PPU(Renderer::IRenderer &renderer);
- PPU(const PPU &) = default;
+ explicit PPU(Renderer::IRenderer &renderer);
+ PPU(const PPU &) = delete;
PPU &operator=(const PPU &) = delete;
- ~PPU() = default;
+ ~PPU() override = default;
//! @brief Read data from the component.
//! @param addr The local address to read from (0x0 should refer to the first byte of this component).
@@ -564,6 +564,9 @@ namespace ComSquare::PPU
//! @param data The new data to write.
//! @throw This function should thrown an InvalidAddress for address that are not mapped to the component.
void write(uint24_t addr, uint8_t data) override;
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
+
//! @brief Update the PPU of n cycles.
//! @param The number of cycles to update.
void update(unsigned cycles);
diff --git a/sources/Ram/Ram.cpp b/sources/Ram/Ram.cpp
index 4209e8d..320834e 100644
--- a/sources/Ram/Ram.cpp
+++ b/sources/Ram/Ram.cpp
@@ -3,13 +3,15 @@
//
#include
+#include
#include "Ram.hpp"
#include "../Exceptions/InvalidAddress.hpp"
namespace ComSquare::Ram
{
- Ram::Ram(size_t size)
- : _size(size)
+ Ram::Ram(size_t size, std::string ramName)
+ : _size(size),
+ _ramName(std::move(ramName))
{
if (size == 0)
this->_data = nullptr;
@@ -51,4 +53,9 @@ namespace ComSquare::Ram
{
return this->_size;
}
+
+ std::string Ram::getName()
+ {
+ return this->_ramName;
+ }
}
diff --git a/sources/Ram/Ram.hpp b/sources/Ram/Ram.hpp
index 26a3871..24b7f88 100644
--- a/sources/Ram/Ram.hpp
+++ b/sources/Ram/Ram.hpp
@@ -5,25 +5,27 @@
#ifndef COMSQUARE_RAM_HPP
#define COMSQUARE_RAM_HPP
-#include "../Memory/IRectangleMemory.hpp"
+#include "../Memory/ARectangleMemory.hpp"
namespace ComSquare::Ram
{
- class Ram : public Memory::IRectangleMemory {
+ class Ram : public Memory::ARectangleMemory {
protected:
//! @brief The ram. (Can be used for WRam, SRam, VRam etc)
uint8_t *_data;
//! @brief The size of the ram (iny bytes).
size_t _size;
+ //! @brief The name of this ram.
+ std::string _ramName;
public:
//! @brief Create a ram of a given size in bytes.
- explicit Ram(size_t size);
+ explicit Ram(size_t size, std::string ramName);
//! @brief The ram can't be copied.
Ram(const Ram &) = delete;
//! @brief The ram can't be assigned.
Ram &operator=(Ram &) = delete;
//! @brief Destructor that free the ram.
- ~Ram();
+ ~Ram() override;
//! @brief Read from the ram.
//! @param addr The address to read from. The address 0x0 should refer to the first byte of this ram.
//! @throw InvalidAddress will be thrown if the address is more than the size of the ram.
@@ -41,6 +43,9 @@ namespace ComSquare::Ram
//! @param value replace value
void memset(uint24_t start, uint24_t end, uint8_t value);
+ //! @brief Get the name of this accessor (used for debug purpose)
+ std::string getName() override;
+
//! @brief Get the size of the ram in bytes.
size_t getSize();
};
diff --git a/sources/Renderer/QtRenderer/QtSFML.cpp b/sources/Renderer/QtRenderer/QtSFML.cpp
index 9020d62..0471f67 100644
--- a/sources/Renderer/QtRenderer/QtSFML.cpp
+++ b/sources/Renderer/QtRenderer/QtSFML.cpp
@@ -33,12 +33,12 @@ namespace ComSquare::Renderer
//TODO implement rom openning from this menu.
(void)file;
- QMenu *game = this->_window.menuBar()->addMenu("Game");
+ QMenu *game = this->_window.menuBar()->addMenu("&Game");
QAction *reset = new QAction("Reset", &this->_window);
QMainWindow::connect(reset, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::reset);
game->addAction(reset);
- QMenu *debugger = this->_window.menuBar()->addMenu("Debugger");
+ QMenu *debugger = this->_window.menuBar()->addMenu("&Debugger");
QAction *cpuDebugger = new QAction("CPU's Debugger", &this->_window);
cpuDebugger->setShortcut(Qt::Key_F1);
QMainWindow::connect(cpuDebugger, &QAction::triggered, this->_sfWidget.get(), &QtFullSFML::enableDebugCPU);
diff --git a/sources/SNES.cpp b/sources/SNES.cpp
index e286c9e..5cc42a8 100644
--- a/sources/SNES.cpp
+++ b/sources/SNES.cpp
@@ -17,8 +17,8 @@ namespace ComSquare
SNES::SNES(const std::string &romPath, Renderer::IRenderer &renderer) :
_bus(std::make_shared()),
cartridge(new Cartridge::Cartridge(romPath)),
- wram(new Ram::Ram(16384)),
- sram(new Ram::Ram(this->cartridge->header.sramSize)),
+ wram(new Ram::Ram(16384, "WRam")),
+ sram(new Ram::Ram(this->cartridge->header.sramSize, "SRam")),
apuRam(new APU::MemoryMap()),
cpu(new CPU::CPU(this->_bus, cartridge->header)),
ppu(new PPU::PPU(renderer)),
diff --git a/tests/APU/testAPU.cpp b/tests/APU/testAPU.cpp
index 7357cc9..2c54013 100644
--- a/tests/APU/testAPU.cpp
+++ b/tests/APU/testAPU.cpp
@@ -19,8 +19,8 @@ using namespace ComSquare;
Test(_internalRead, register)
{
- auto apu = Init().second.apu;
- uint8_t result = 0;
+ Init()
+ auto apu = snes.apu;int8_t result = 0;
apu->_registers.counter0 = 123;
result = apu->_internalRead(0x00FD);
@@ -29,7 +29,8 @@ Test(_internalRead, register)
Test(_internalRead, Page0)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
uint8_t result = 0;
apu->_map->Page0._data[0x0010] = 123;
@@ -39,7 +40,8 @@ Test(_internalRead, Page0)
Test(_internalRead, Page1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
uint8_t result = 0;
apu->_map->Page1._data[0x0042] = 123;
@@ -49,7 +51,8 @@ Test(_internalRead, Page1)
Test(_internalRead, Memory)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
uint8_t result = 0;
apu->_map->Memory._data[0xFCDC] = 123;
@@ -59,7 +62,8 @@ Test(_internalRead, Memory)
Test(_internalRead, IPL)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
uint8_t result = 0;
apu->_map->IPL._data[0x001F] = 123;
@@ -69,7 +73,8 @@ Test(_internalRead, IPL)
Test(_internalRead, Invalid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
cr_assert_throw(apu->_internalRead(0x10000), InvalidAddress);
}
@@ -82,7 +87,8 @@ Test(_internalRead, Invalid)
Test(_internalWrite, Page0)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalWrite(0x0001, 123);
cr_assert_eq(apu->_map->Page0._data[0x0001], 123);
@@ -90,7 +96,8 @@ Test(_internalWrite, Page0)
Test(_internalWrite, register)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalWrite(0x00F4, 123);
cr_assert_eq(apu->_registers.port0, 123);
@@ -98,7 +105,8 @@ Test(_internalWrite, register)
Test(_internalWrite, Page1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalWrite(0x01FF, 123);
cr_assert_eq(apu->_map->Page1._data[0x00FF], 123);
@@ -106,7 +114,8 @@ Test(_internalWrite, Page1)
Test(_internalWrite, Memory)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalWrite(0x0789, 123);
cr_assert_eq(apu->_map->Memory._data[0x0589], 123);
@@ -114,7 +123,8 @@ Test(_internalWrite, Memory)
Test(_internalWrite, IPL)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalWrite(0xFFF0, 123);
cr_assert_eq(apu->_map->IPL._data[0x0030], 123);
@@ -122,7 +132,8 @@ Test(_internalWrite, IPL)
Test(_internalWrite, Invalid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
cr_assert_throw(apu->_internalWrite(0x10000, 123), InvalidAddress);
}
@@ -135,7 +146,8 @@ Test(_internalWrite, Invalid)
Test(read, Valid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
uint8_t result = 0;
apu->_registers.port2 = 123;
@@ -145,7 +157,8 @@ Test(read, Valid)
Test(read, Invalid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
cr_assert_throw(apu->read(0x10000), InvalidAddress);
}
@@ -158,7 +171,8 @@ Test(read, Invalid)
Test(write, Valid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->write(0x03, 123);
cr_assert_eq(apu->_registers.port3, 123);
@@ -166,7 +180,8 @@ Test(write, Valid)
Test(write, Invalid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
cr_assert_throw(apu->write(0x04, 123), InvalidAddress);
}
@@ -179,7 +194,8 @@ Test(write, Invalid)
Test(executeInstruction, Valid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
uint8_t result = 0;
apu->_internalRegisters.pc = 0x00;
@@ -189,7 +205,8 @@ Test(executeInstruction, Valid)
Test(executeInstruction, Invalid)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalRegisters.pc = 0xFFFF;
cr_assert_throw(apu->_executeInstruction(), InvalidOpcode);
@@ -203,7 +220,8 @@ Test(executeInstruction, Invalid)
Test(update, running)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalRegisters.pc = 0x00;
apu->update(1);
@@ -212,7 +230,8 @@ Test(update, running)
Test(update, stopped)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_state = APU::Stopped;
apu->update(1);
@@ -227,7 +246,8 @@ Test(update, stopped)
Test(_get, direct)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalRegisters.pc = 0x32;
apu->_internalWrite(0x32, 123);
@@ -236,7 +256,8 @@ Test(_get, direct)
Test(_get, absolute)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
apu->_internalRegisters.pc = 0x32;
apu->_internalWrite(0x32, 0b00001111);
diff --git a/tests/APU/testAPUInstructions.cpp b/tests/APU/testAPUInstructions.cpp
index cf3b5c4..e632a3b 100644
--- a/tests/APU/testAPUInstructions.cpp
+++ b/tests/APU/testAPUInstructions.cpp
@@ -12,7 +12,7 @@
using namespace ComSquare;
-////////////////////
+////////////////////Init()\n\tauto apu = snes.apu
// //
// Standbys tests //
// //
@@ -20,7 +20,8 @@ using namespace ComSquare;
Test(Standbys, NOP)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->NOP();
@@ -29,7 +30,8 @@ Test(Standbys, NOP)
Test(Standbys, SLEEP)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->SLEEP();
@@ -39,7 +41,8 @@ Test(Standbys, SLEEP)
Test(Standbys, STOP)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->STOP();
@@ -55,7 +58,8 @@ Test(Standbys, STOP)
Test(PSW, CLRC)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->CLRC();
@@ -65,7 +69,8 @@ Test(PSW, CLRC)
Test(PSW, SETC)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->SETC();
@@ -75,7 +80,8 @@ Test(PSW, SETC)
Test(PSW, NOTC)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.c = false;
@@ -86,7 +92,8 @@ Test(PSW, NOTC)
Test(PSW, CLRV)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->CLRV();
@@ -97,7 +104,8 @@ Test(PSW, CLRV)
Test(PSW, CLRP)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->CLRP();
@@ -107,7 +115,8 @@ Test(PSW, CLRP)
Test(PSW, SETP)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->SETP();
@@ -117,7 +126,8 @@ Test(PSW, SETP)
Test(PSW, EI)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->EI();
@@ -127,7 +137,8 @@ Test(PSW, EI)
Test(PSW, DI)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
result = apu->DI();
@@ -143,7 +154,8 @@ Test(PSW, DI)
Test(Bit, SET1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.pc = 0x32;
@@ -157,7 +169,8 @@ Test(Bit, SET1)
Test(Bit, CLR1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.pc = 0x32;
@@ -171,7 +184,8 @@ Test(Bit, CLR1)
Test(Bit, TSET1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -190,7 +204,8 @@ Test(Bit, TSET1)
Test(Bit, TCLR1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 0x80;
@@ -209,7 +224,8 @@ Test(Bit, TCLR1)
Test(Bit, AND1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -226,7 +242,8 @@ Test(Bit, AND1)
Test(Bit, AND1_invert)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -243,7 +260,8 @@ Test(Bit, AND1_invert)
Test(Bit, OR1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -260,7 +278,8 @@ Test(Bit, OR1)
Test(Bit, OR1_invert)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -277,7 +296,8 @@ Test(Bit, OR1_invert)
Test(Bit, EOR1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -294,7 +314,8 @@ Test(Bit, EOR1)
Test(Bit, NOT1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -311,7 +332,8 @@ Test(Bit, NOT1)
Test(Bit, MOV1)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -328,7 +350,8 @@ Test(Bit, MOV1)
Test(Bit, MOV1_carry)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 42;
@@ -351,7 +374,8 @@ Test(Bit, MOV1_carry)
Test(Stack, PUSH)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.a = 56;
@@ -363,7 +387,8 @@ Test(Stack, PUSH)
Test(Stack, POP)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(++apu->_internalRegisters.sp | 0x100u, 82);
@@ -381,7 +406,8 @@ Test(Stack, POP)
Test(Subroutine, CALL)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_getAbsoluteAddr(), 23);
@@ -395,7 +421,8 @@ Test(Subroutine, CALL)
Test(Subroutine, PCALL)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 123);
@@ -406,7 +433,8 @@ Test(Subroutine, PCALL)
Test(Subroutine, TCALL)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(0xFFD0, 45);
@@ -417,7 +445,8 @@ Test(Subroutine, TCALL)
Test(Subroutine, BRK)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalRegisters.pch = 0xFF;
@@ -438,7 +467,8 @@ Test(Subroutine, BRK)
Test(Subroutine, RET)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(++apu->_internalRegisters.sp | 0x100u, 0x12);
@@ -452,7 +482,8 @@ Test(Subroutine, RET)
Test(Subroutine, RETI)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(++apu->_internalRegisters.sp | 0x100u, 0x12);
@@ -474,7 +505,8 @@ Test(Subroutine, RETI)
Test(ProgramFlow, BRA)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -486,7 +518,8 @@ Test(ProgramFlow, BRA)
Test(ProgramFlow, BEQ)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -501,7 +534,8 @@ Test(ProgramFlow, BEQ)
Test(ProgramFlow, BNE)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -517,7 +551,8 @@ Test(ProgramFlow, BNE)
Test(ProgramFlow, BCS)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -532,7 +567,8 @@ Test(ProgramFlow, BCS)
Test(ProgramFlow, BCC)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -548,7 +584,8 @@ Test(ProgramFlow, BCC)
Test(ProgramFlow, BVS)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -563,7 +600,8 @@ Test(ProgramFlow, BVS)
Test(ProgramFlow, BVC)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -579,7 +617,8 @@ Test(ProgramFlow, BVC)
Test(ProgramFlow, BMI)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
@@ -594,7 +633,8 @@ Test(ProgramFlow, BMI)
Test(ProgramFlow, BPL)
{
- auto apu = Init().second.apu;
+ Init()
+ auto apu = snes.apu;
int result = 0;
apu->_internalWrite(apu->_internalRegisters.pc, 23);
diff --git a/tests/CPU/Math/testADC.cpp b/tests/CPU/Math/testADC.cpp
index 137493b..67222fd 100644
--- a/tests/CPU/Math/testADC.cpp
+++ b/tests/CPU/Math/testADC.cpp
@@ -10,114 +10,114 @@ using namespace ComSquare;
Test(ADC, addingOne)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.a = 0;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 1, "The accumulator's value should be 0x1 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.a = 0;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 1, "The accumulator's value should be 0x1 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(ADC, addingOneEmulation)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.a = 0;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 1, "The accumulator's value should be 0x1 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.a = 0;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 1, "The accumulator's value should be 0x1 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(ADC, overflow)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.a = 0xFFFF;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0, "The accumulator's value should be 0x0 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flags should be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.a = 0xFFFF;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0, "The accumulator's value should be 0x0 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flags should be set.");
}
Test(ADC, overflowEmulation)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.a = 0xFF;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0, "The accumulator's value should be 0x0 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flags should be set.");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.a = 0xFF;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0, "The accumulator's value should be 0x0 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flags should be set.");
}
Test(ADC, signedOverflow)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.a = 0x7FFF;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0x8000, "The accumulator's value should be 0x8000 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, true, "The overflow flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.a = 0x7FFF;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0x8000, "The accumulator's value should be 0x8000 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, true, "The overflow flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(ADC, signedOverflowEmulated)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.a = 0x007F;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0x0080, "The accumulator's value should be 0x0080 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, true, "The overflow flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.a = 0x007F;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0x0080, "The accumulator's value should be 0x0080 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, true, "The overflow flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(ADC, negative)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.a = 0x8FFF;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0x9000, "The accumulator's value should be 0x9000 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.a = 0x8FFF;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0x9000, "The accumulator's value should be 0x9000 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(ADC, memoryTwoBytes)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.a = 0x000F;
- pair.second.wram->_data[0] = 0x01;
- pair.second.wram->_data[1] = 0x04;
- pair.second.cpu->ADC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0x0410, "The accumulator's value should be 0x0410 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.a = 0x000F;
+ snes.wram->_data[0] = 0x01;
+ snes.wram->_data[1] = 0x04;
+ snes.cpu->ADC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0x0410, "The accumulator's value should be 0x0410 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
\ No newline at end of file
diff --git a/tests/CPU/Math/testSBC.cpp b/tests/CPU/Math/testSBC.cpp
index 4543749..22c2a9e 100644
--- a/tests/CPU/Math/testSBC.cpp
+++ b/tests/CPU/Math/testSBC.cpp
@@ -10,83 +10,83 @@ using namespace ComSquare;
Test(SBC, removingOne)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.c = true;
- pair.second.cpu->_registers.a = 0x1;
- pair.second.wram->_data[0] = 0x1;
- pair.second.cpu->SBC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0, "The accumulator's value should be 0x0 but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flags should be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.c = true;
+ snes.cpu->_registers.a = 0x1;
+ snes.wram->_data[0] = 0x1;
+ snes.cpu->SBC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0, "The accumulator's value should be 0x0 but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flags should be set.");
}
Test(SBC, legitOverflowWithCarry)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.a = 0x1;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.p.c = true;
- pair.second.wram->_data[0] = 0x03;
- pair.second.wram->_data[1] = 0x20;
- pair.second.cpu->SBC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0xDFFE, "The accumulator's value should be 0xDFFE but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.a = 0x1;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.p.c = true;
+ snes.wram->_data[0] = 0x03;
+ snes.wram->_data[1] = 0x20;
+ snes.cpu->SBC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0xDFFE, "The accumulator's value should be 0xDFFE but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(SBC, overflowWithCarry)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.a = 0x1;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.p.c = true;
- pair.second.wram->_data[0] = 0x03;
- pair.second.wram->_data[1] = 0x20;
- pair.second.cpu->SBC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0xDFFE, "The accumulator's value should be 0xDFFE but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should be not set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.a = 0x1;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.p.c = true;
+ snes.wram->_data[0] = 0x03;
+ snes.wram->_data[1] = 0x20;
+ snes.cpu->SBC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0xDFFE, "The accumulator's value should be 0xDFFE but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should be not set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should not be set.");
}
Test(SBC, overflowEmulation)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.a = 0x1;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.p.c = false;
- pair.second.wram->_data[0] = 0x02;
- pair.second.cpu->SBC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0xFE, "The accumulator's value should be 0xFE but it was 0x%x.", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flags should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should be not set.");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.a = 0x1;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.p.c = false;
+ snes.wram->_data[0] = 0x02;
+ snes.cpu->SBC(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0xFE, "The accumulator's value should be 0xFE but it was 0x%x.", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flags should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should be not set.");
}
//Test(SBC, decimal)
//{
-// auto pair = Init();
-// pair.second.cpu->_isEmulationMode = true;
-// pair.second.cpu->_registers.a = 0x1;
-// pair.second.cpu->_registers.p.d = true;
-// pair.second.cpu->_registers.p.m = false;
-// pair.second.wram->_data[0] = 0x03;
-// pair.second.wram->_data[1] = 0x20;
-// pair.second.cpu->SBC(0x0);
-// cr_assert_eq(pair.second.cpu->_registers.a, 0x7998, "The accumulator's value should be 0x7998 but it was 0x%x.", pair.second.cpu->_registers.a);
-// cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flags should not be set.");
-// cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flags should not be set.");
-// cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flags should not be set.");
-// cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flags should be not set.");
+// Init()
+// snes.cpu->_isEmulationMode = true;
+// snes.cpu->_registers.a = 0x1;
+// snes.cpu->_registers.p.d = true;
+// snes.cpu->_registers.p.m = false;
+// snes.wram->_data[0] = 0x03;
+// snes.wram->_data[1] = 0x20;
+// snes.cpu->SBC(0x0);
+// cr_assert_eq(snes.cpu->_registers.a, 0x7998, "The accumulator's value should be 0x7998 but it was 0x%x.", snes.cpu->_registers.a);
+// cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flags should not be set.");
+// cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flags should not be set.");
+// cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flags should not be set.");
+// cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flags should be not set.");
//}
diff --git a/tests/CPU/TransferRegisters.cpp b/tests/CPU/TransferRegisters.cpp
index 9dd6069..7ee8e76 100644
--- a/tests/CPU/TransferRegisters.cpp
+++ b/tests/CPU/TransferRegisters.cpp
@@ -11,137 +11,137 @@ using namespace ComSquare;
Test(TAX, 16bitsTo16Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.x = 0xABCD;
- pair.second.cpu->_registers.a = 0xFEDC;
- pair.second.cpu->TAX();
- cr_assert_eq(pair.second.cpu->_registers.x, 0xFEDC, "The flags should be 0xFEDC but it was %x", pair.second.cpu->_registers.x);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.x = 0xABCD;
+ snes.cpu->_registers.a = 0xFEDC;
+ snes.cpu->TAX();
+ cr_assert_eq(snes.cpu->_registers.x, 0xFEDC, "The flags should be 0xFEDC but it was %x", snes.cpu->_registers.x);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
}
Test(TAX, 16bitsTo8Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.x = 0xFEDC;
- pair.second.cpu->_registers.a = 0xAB00;
- pair.second.cpu->TAX();
- cr_assert_eq(pair.second.cpu->_registers.x, 0xFE00, "The flags should be 0xFE00 but it was %x", pair.second.cpu->_registers.x);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.x = 0xFEDC;
+ snes.cpu->_registers.a = 0xAB00;
+ snes.cpu->TAX();
+ cr_assert_eq(snes.cpu->_registers.x, 0xFE00, "The flags should be 0xFE00 but it was %x", snes.cpu->_registers.x);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.");
}
Test(TAX, 8bitsTo16Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.p.m = true;
- pair.second.cpu->_registers.x = 0xFEDC;
- pair.second.cpu->_registers.a = 0xAB;
- pair.second.cpu->TAX();
- cr_assert_eq(pair.second.cpu->_registers.x, 0x00AB, "The flags should be 0x00AB but it was %x", pair.second.cpu->_registers.x);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.p.m = true;
+ snes.cpu->_registers.x = 0xFEDC;
+ snes.cpu->_registers.a = 0xAB;
+ snes.cpu->TAX();
+ cr_assert_eq(snes.cpu->_registers.x, 0x00AB, "The flags should be 0x00AB but it was %x", snes.cpu->_registers.x);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
}
Test(TAX, 8bitsTo8Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.m = true;
- pair.second.cpu->_registers.x = 0xFE;
- pair.second.cpu->_registers.a = 0xAB;
- pair.second.cpu->TAX();
- cr_assert_eq(pair.second.cpu->_registers.x, 0xAB, "The flags should be 0xAB but it was %x", pair.second.cpu->_registers.x);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should be not set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.m = true;
+ snes.cpu->_registers.x = 0xFE;
+ snes.cpu->_registers.a = 0xAB;
+ snes.cpu->TAX();
+ cr_assert_eq(snes.cpu->_registers.x, 0xAB, "The flags should be 0xAB but it was %x", snes.cpu->_registers.x);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should be not set.");
}
Test(TAY, 16bitsTo16Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.y = 0xABCD;
- pair.second.cpu->_registers.a = 0xFEDC;
- pair.second.cpu->TAY();
- cr_assert_eq(pair.second.cpu->_registers.y, 0xFEDC, "The y register should be 0xFEDC but it was %x", pair.second.cpu->_registers.y);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.y = 0xABCD;
+ snes.cpu->_registers.a = 0xFEDC;
+ snes.cpu->TAY();
+ cr_assert_eq(snes.cpu->_registers.y, 0xFEDC, "The y register should be 0xFEDC but it was %x", snes.cpu->_registers.y);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
}
Test(TAY, 16bitsTo8Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.y = 0xFEDC;
- pair.second.cpu->_registers.a = 0xAB00;
- pair.second.cpu->TAY();
- cr_assert_eq(pair.second.cpu->_registers.y, 0xFE00, "The y register should be 0xFE00 but it was %x", pair.second.cpu->_registers.y);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.y = 0xFEDC;
+ snes.cpu->_registers.a = 0xAB00;
+ snes.cpu->TAY();
+ cr_assert_eq(snes.cpu->_registers.y, 0xFE00, "The y register should be 0xFE00 but it was %x", snes.cpu->_registers.y);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.");
}
Test(TAY, 8bitsTo16Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.p.m = true;
- pair.second.cpu->_registers.y = 0xFEDC;
- pair.second.cpu->_registers.a = 0xAB;
- pair.second.cpu->TAY();
- cr_assert_eq(pair.second.cpu->_registers.y, 0x00AB, "The y register should be 0x00AB but it was %x", pair.second.cpu->_registers.y);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.p.m = true;
+ snes.cpu->_registers.y = 0xFEDC;
+ snes.cpu->_registers.a = 0xAB;
+ snes.cpu->TAY();
+ cr_assert_eq(snes.cpu->_registers.y, 0x00AB, "The y register should be 0x00AB but it was %x", snes.cpu->_registers.y);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
}
Test(TAY, 8bitsTo8Bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.m = true;
- pair.second.cpu->_registers.y = 0xFE;
- pair.second.cpu->_registers.a = 0xAB;
- pair.second.cpu->TAY();
- cr_assert_eq(pair.second.cpu->_registers.y, 0xAB, "The y register should be 0xAB but it was %x", pair.second.cpu->_registers.y);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should be not set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.m = true;
+ snes.cpu->_registers.y = 0xFE;
+ snes.cpu->_registers.a = 0xAB;
+ snes.cpu->TAY();
+ cr_assert_eq(snes.cpu->_registers.y, 0xAB, "The y register should be 0xAB but it was %x", snes.cpu->_registers.y);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should be not set.");
}
Test(TXS, 16bitsIndex)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.x = 0xABCD;
- pair.second.cpu->TXS();
- cr_assert_eq(pair.second.cpu->_registers.s, 0xABCD, "The stack pointer should be 0xABCD but it was %x", pair.second.cpu->_registers.s);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should be not set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.x = 0xABCD;
+ snes.cpu->TXS();
+ cr_assert_eq(snes.cpu->_registers.s, 0xABCD, "The stack pointer should be 0xABCD but it was %x", snes.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should be not set.");
}
Test(TXS, 8bitsIndex)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.x = 0xABCD;
- pair.second.cpu->TXS();
- cr_assert_eq(pair.second.cpu->_registers.s, 0x00CD, "The stack pointer should be 0x00CD but it was %x", pair.second.cpu->_registers.s);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should be not set.");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.x = 0xABCD;
+ snes.cpu->TXS();
+ cr_assert_eq(snes.cpu->_registers.s, 0x00CD, "The stack pointer should be 0x00CD but it was %x", snes.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should be not set.");
}
\ No newline at end of file
diff --git a/tests/CPU/testAddressingMode.cpp b/tests/CPU/testAddressingMode.cpp
index 0c7cf4f..0ae047f 100644
--- a/tests/CPU/testAddressingMode.cpp
+++ b/tests/CPU/testAddressingMode.cpp
@@ -12,290 +12,290 @@ using namespace ComSquare;
Test(AddrModeInit, LegitBus)
{
- auto pair = Init();
- cr_assert_eq(pair.first.get(), pair.second.cpu->_bus.get(), "Warning, the CPU's bus is not the same the SNES's bus. Next tests of the CPU may fail.");
+ Init()
+ cr_assert_eq(snes._bus.get(), snes.cpu->_bus.get(), "Warning, the CPU's bus is not the same the SNES's bus. Next tests of the CPU may fail.");
}
Test(AddrMode, Immediate)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x000015;
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.m = false;
- cr_assert_eq(pair.second.cpu->_getImmediateAddrForA(), 0x000015, "Got %x, Expected 0x000015");
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x000017);
+ Init()
+ snes.cpu->_registers.pac = 0x000015;
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.m = false;
+ cr_assert_eq(snes.cpu->_getImmediateAddrForA(), 0x000015, "Got %x, Expected 0x000015");
+ cr_assert_eq(snes.cpu->_registers.pac, 0x000017);
}
Test(AddrMode, ImmediateMemoryFlag)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.pac = 0x000015;
- pair.second.cpu->_registers.p.m = false;
- cr_assert_eq(pair.second.cpu->_getImmediateAddrForA(), 0x000015, "Got %x, Expected 0x000015");
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x000017);
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.pac = 0x000015;
+ snes.cpu->_registers.p.m = false;
+ cr_assert_eq(snes.cpu->_getImmediateAddrForA(), 0x000015, "Got %x, Expected 0x000015");
+ cr_assert_eq(snes.cpu->_registers.pac, 0x000017);
}
Test(AddrMode, ImmediateBankChange)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x00FFFF;
- pair.second.cpu->_registers.p.m = true;
- cr_assert_eq(pair.second.cpu->_getImmediateAddrForA(), 0x00FFFF);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x010000);
+ Init()
+ snes.cpu->_registers.pac = 0x00FFFF;
+ snes.cpu->_registers.p.m = true;
+ cr_assert_eq(snes.cpu->_getImmediateAddrForA(), 0x00FFFF);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x010000);
}
Test(AddrMode, Direct)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x15;
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cpu->_registers.d = 0x1000;
- cr_assert_eq(pair.second.cpu->_getDirectAddr(), 0x1015, "Returned address was %x but was expecting 0x1015.", pair.second.cpu->_getDirectAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ Init()
+ snes.cartridge->_data[0] = 0x15;
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cpu->_registers.d = 0x1000;
+ cr_assert_eq(snes.cpu->_getDirectAddr(), 0x1015, "Returned address was %x but was expecting 0x1015.", snes.cpu->_getDirectAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, Absolute)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x1C;
- pair.second.cartridge->_data[1] = 0x90;
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cpu->_registers.dbr = 0x88;
- cr_assert_eq(pair.second.cpu->_getAbsoluteAddr(), 0x88901C, "Returned address was %x but was expecting 0x88901C.", pair.second.cpu->_getAbsoluteAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
+ Init()
+ snes.cartridge->_data[0] = 0x1C;
+ snes.cartridge->_data[1] = 0x90;
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cpu->_registers.dbr = 0x88;
+ cr_assert_eq(snes.cpu->_getAbsoluteAddr(), 0x88901C, "Returned address was %x but was expecting 0x88901C.", snes.cpu->_getAbsoluteAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808002);
}
Test(AddrMode, AbsoluteLong)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x1C;
- pair.second.cartridge->_data[1] = 0x90;
- pair.second.cartridge->_data[2] = 0xFF;
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cpu->_registers.dbr = 0x88;
- cr_assert_eq(pair.second.cpu->_getAbsoluteLongAddr(), 0xFF901C, "Returned address was %x but was expecting 0xFF901C.", pair.second.cpu->_getAbsoluteLongAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808003);
+ Init()
+ snes.cartridge->_data[0] = 0x1C;
+ snes.cartridge->_data[1] = 0x90;
+ snes.cartridge->_data[2] = 0xFF;
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cpu->_registers.dbr = 0x88;
+ cr_assert_eq(snes.cpu->_getAbsoluteLongAddr(), 0xFF901C, "Returned address was %x but was expecting 0xFF901C.", snes.cpu->_getAbsoluteLongAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808003);
}
Test(AddrMode, DirectIndirectIndexed)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.wram->_data[0x1010] = 0x30;
- pair.second.wram->_data[0x1011] = 0x40;
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cpu->_registers.dbr = 0x80;
- pair.second.cpu->_registers.y = 0x0001;
- pair.second.cpu->_registers.d = 0x1000;
- cr_assert_eq(pair.second.cpu->_getDirectIndirectIndexedYAddr(), 0x804031, "Returned address was %x but was expecting 0x804031.",
- pair.second.cpu->_getDirectIndirectIndexedYAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ Init()
+ snes.cartridge->_data[0] = 0x10;
+ snes.wram->_data[0x1010] = 0x30;
+ snes.wram->_data[0x1011] = 0x40;
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cpu->_registers.dbr = 0x80;
+ snes.cpu->_registers.y = 0x0001;
+ snes.cpu->_registers.d = 0x1000;
+ cr_assert_eq(snes.cpu->_getDirectIndirectIndexedYAddr(), 0x804031, "Returned address was %x but was expecting 0x804031.",
+ snes.cpu->_getDirectIndirectIndexedYAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, DirectIndirectIndexedLong)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cpu->_registers.d = 0x1000;
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.wram->_data[0x1010] = 0x30;
- pair.second.wram->_data[0x1011] = 0x40;
- pair.second.wram->_data[0x1012] = 0x23;
- cr_assert_eq(pair.second.cpu->_getDirectIndirectIndexedYLongAddr(), 0x234030, "Returned address was %x but was expecting 0x234030.",
- pair.second.cpu->_getDirectIndirectIndexedYLongAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cpu->_registers.d = 0x1000;
+ snes.cartridge->_data[0] = 0x10;
+ snes.wram->_data[0x1010] = 0x30;
+ snes.wram->_data[0x1011] = 0x40;
+ snes.wram->_data[0x1012] = 0x23;
+ cr_assert_eq(snes.cpu->_getDirectIndirectIndexedYLongAddr(), 0x234030, "Returned address was %x but was expecting 0x234030.",
+ snes.cpu->_getDirectIndirectIndexedYLongAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, DirectIndexedIndirect)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.cpu->_registers.d = 0x1000;
- pair.second.cpu->_registers.x = 0x0002;
- pair.second.wram->_data[0x1012] = 0x30;
- pair.second.wram->_data[0x1013] = 0x40;
- pair.second.cpu->_registers.dbr = 0x80;
- pair.second.cpu->_registers.pac = 0x808000;
- cr_assert_eq(pair.second.cpu->_getDirectIndirectIndexedXAddr(), 0x804030, "Returned address was %x but was expecting 0x804030.",
- pair.second.cpu->_getDirectIndirectIndexedXAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ Init()
+ snes.cartridge->_data[0] = 0x10;
+ snes.cpu->_registers.d = 0x1000;
+ snes.cpu->_registers.x = 0x0002;
+ snes.wram->_data[0x1012] = 0x30;
+ snes.wram->_data[0x1013] = 0x40;
+ snes.cpu->_registers.dbr = 0x80;
+ snes.cpu->_registers.pac = 0x808000;
+ cr_assert_eq(snes.cpu->_getDirectIndirectIndexedXAddr(), 0x804030, "Returned address was %x but was expecting 0x804030.",
+ snes.cpu->_getDirectIndirectIndexedXAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, DirectIndexedByX)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.cpu->_registers.d = 0x1000;
- pair.second.cpu->_registers.x = 0x0002;
- pair.second.cpu->_registers.pac = 0x808000;
- cr_assert_eq(pair.second.cpu->_getDirectIndexedByXAddr(), 0x1012, "Returned address was %x but was expecting 0x1012.", pair.second.cpu->_getDirectIndexedByXAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ Init()
+ snes.cartridge->_data[0] = 0x10;
+ snes.cpu->_registers.d = 0x1000;
+ snes.cpu->_registers.x = 0x0002;
+ snes.cpu->_registers.pac = 0x808000;
+ cr_assert_eq(snes.cpu->_getDirectIndexedByXAddr(), 0x1012, "Returned address was %x but was expecting 0x1012.", snes.cpu->_getDirectIndexedByXAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, DirectIndexedByY)
{
- auto pair = Init();
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.cpu->_registers.d = 0x1000;
- pair.second.cpu->_registers.y = 0x0002;
- pair.second.cpu->_registers.pac = 0x808000;
- cr_assert_eq(pair.second.cpu->_getDirectIndexedByYAddr(), 0x1012, "Returned address was %x but was expecting 0x1012.", pair.second.cpu->_getDirectIndexedByYAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ Init()
+ snes.cartridge->_data[0] = 0x10;
+ snes.cpu->_registers.d = 0x1000;
+ snes.cpu->_registers.y = 0x0002;
+ snes.cpu->_registers.pac = 0x808000;
+ cr_assert_eq(snes.cpu->_getDirectIndexedByYAddr(), 0x1012, "Returned address was %x but was expecting 0x1012.", snes.cpu->_getDirectIndexedByYAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, AbsoluteIndexByX)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.cartridge->_data[1] = 0xAC;
- pair.second.cpu->_registers.dbr = 0xEF;
- pair.second.cpu->_registers.x = 0x0005;
- cr_assert_eq(pair.second.cpu->_getAbsoluteIndexedByXAddr(), 0xEFAC15, "Returned address was %x but was expecting 0xEFAC15.", pair.second.cpu->_getAbsoluteIndexedByXAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x10;
+ snes.cartridge->_data[1] = 0xAC;
+ snes.cpu->_registers.dbr = 0xEF;
+ snes.cpu->_registers.x = 0x0005;
+ cr_assert_eq(snes.cpu->_getAbsoluteIndexedByXAddr(), 0xEFAC15, "Returned address was %x but was expecting 0xEFAC15.", snes.cpu->_getAbsoluteIndexedByXAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808002);
}
Test(AddrMode, AbsoluteIndexByY)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.cartridge->_data[1] = 0xAC;
- pair.second.cpu->_registers.dbr = 0xEF;
- pair.second.cpu->_registers.y = 0x0005;
- cr_assert_eq(pair.second.cpu->_getAbsoluteIndexedByYAddr(), 0xEFAC15, "Returned address was %x but was expecting 0xEFAC15.", pair.second.cpu->_getAbsoluteIndexedByYAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x10;
+ snes.cartridge->_data[1] = 0xAC;
+ snes.cpu->_registers.dbr = 0xEF;
+ snes.cpu->_registers.y = 0x0005;
+ cr_assert_eq(snes.cpu->_getAbsoluteIndexedByYAddr(), 0xEFAC15, "Returned address was %x but was expecting 0xEFAC15.", snes.cpu->_getAbsoluteIndexedByYAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808002);
}
Test(AddrMode, AbsoluteLongIndexByX)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x10;
- pair.second.cartridge->_data[1] = 0xAC;
- pair.second.cartridge->_data[2] = 0xEF;
- pair.second.cpu->_registers.x = 0x0005;
- cr_assert_eq(pair.second.cpu->_getAbsoluteIndexedByXLongAddr(), 0xEFAC15, "Returned address was %x but was expecting 0xEFAC15.",
- pair.second.cpu->_getAbsoluteIndexedByXLongAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808003);
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x10;
+ snes.cartridge->_data[1] = 0xAC;
+ snes.cartridge->_data[2] = 0xEF;
+ snes.cpu->_registers.x = 0x0005;
+ cr_assert_eq(snes.cpu->_getAbsoluteIndexedByXLongAddr(), 0xEFAC15, "Returned address was %x but was expecting 0xEFAC15.",
+ snes.cpu->_getAbsoluteIndexedByXLongAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808003);
}
Test(AddrMode, ProgramCounterRelativePositive)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808010;
- pair.second.cartridge->_data[0x10] = 0x15;
- cr_assert_eq(pair.second.cpu->_getProgramCounterRelativeAddr(), 0x808025, "Returned address was %x but was expecting 0x808025.", pair.second.cpu->_getProgramCounterRelativeAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808011);
+ Init()
+ snes.cpu->_registers.pac = 0x808010;
+ snes.cartridge->_data[0x10] = 0x15;
+ cr_assert_eq(snes.cpu->_getProgramCounterRelativeAddr(), 0x808025, "Returned address was %x but was expecting 0x808025.", snes.cpu->_getProgramCounterRelativeAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808011);
}
Test(AddrMode, ProgramCounterRelativeNegative)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808010;
- pair.second.cartridge->_data[0x10] = -0x15;
- cr_assert_eq(pair.second.cpu->_getProgramCounterRelativeAddr(), 0x807FFB, "Returned address was %x but was expecting 0x807FFB.", pair.second.cpu->_getProgramCounterRelativeAddr());
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808011);
+ Init()
+ snes.cpu->_registers.pac = 0x808010;
+ snes.cartridge->_data[0x10] = -0x15;
+ cr_assert_eq(snes.cpu->_getProgramCounterRelativeAddr(), 0x807FFB, "Returned address was %x but was expecting 0x807FFB.", snes.cpu->_getProgramCounterRelativeAddr());
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808011);
}
Test(AddrMode, ProgramCounterRelativeLongPositive)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808010;
- pair.second.cartridge->_data[0x10] = 0x15;
- pair.second.cartridge->_data[0x11] = 0x10;
- auto addr = pair.second.cpu->_getProgramCounterRelativeLongAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808010;
+ snes.cartridge->_data[0x10] = 0x15;
+ snes.cartridge->_data[0x11] = 0x10;
+ auto addr = snes.cpu->_getProgramCounterRelativeLongAddr();
cr_assert_eq(addr, 0x809025, "Returned address was %x but was expecting 0x809025.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808012);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808012);
}
Test(AddrMode, ProgramCounterRelativeLongNegative)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808010;
- pair.second.cartridge->_data[0x10] = 0x10;
- pair.second.cartridge->_data[0x11] = -0x15;
- auto addr = pair.second.cpu->_getProgramCounterRelativeLongAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808010;
+ snes.cartridge->_data[0x10] = 0x10;
+ snes.cartridge->_data[0x11] = -0x15;
+ auto addr = snes.cpu->_getProgramCounterRelativeLongAddr();
cr_assert_eq(addr, 0x806B00, "Returned address was %x but was expecting 0x806B00.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808012);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808012);
}
Test(AddrMode, AbsoluteIndirect)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0xAB;
- pair.second.cartridge->_data[1] = 0x01;
- pair.second.wram->_data[0x01AB] = 0xEF;
- pair.second.wram->_data[0x01AC] = 0x01;
- auto addr = pair.second.cpu->_getAbsoluteIndirectAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0xAB;
+ snes.cartridge->_data[1] = 0x01;
+ snes.wram->_data[0x01AB] = 0xEF;
+ snes.wram->_data[0x01AC] = 0x01;
+ auto addr = snes.cpu->_getAbsoluteIndirectAddr();
cr_assert_eq(addr, 0x01EF, "Returned address was %x but was expecting 0x01EF.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808002);
}
Test(AddrMode, AbsoluteIndexedIndirect)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0xAB;
- pair.second.cartridge->_data[1] = 0x01;
- pair.second.cpu->_registers.x = 2;
- pair.second.wram->_data[0x01AD] = 0xEF;
- pair.second.wram->_data[0x01AE] = 0x01;
- auto addr = pair.second.cpu->_getAbsoluteIndirectIndexedByXAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0xAB;
+ snes.cartridge->_data[1] = 0x01;
+ snes.cpu->_registers.x = 2;
+ snes.wram->_data[0x01AD] = 0xEF;
+ snes.wram->_data[0x01AE] = 0x01;
+ auto addr = snes.cpu->_getAbsoluteIndirectIndexedByXAddr();
cr_assert_eq(addr, 0x01EF, "Returned address was %x but was expecting 0x01EF.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808002);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808002);
}
Test(AddrMode, DirectIndirect)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x01;
- pair.second.cpu->_registers.d = 0x1010;
- pair.second.wram->_data[0x1011] = 0xEF;
- pair.second.wram->_data[0x1012] = 0x01;
- pair.second.cpu->_registers.dbr = 0x88;
- auto addr = pair.second.cpu->_getDirectIndirectAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x01;
+ snes.cpu->_registers.d = 0x1010;
+ snes.wram->_data[0x1011] = 0xEF;
+ snes.wram->_data[0x1012] = 0x01;
+ snes.cpu->_registers.dbr = 0x88;
+ auto addr = snes.cpu->_getDirectIndirectAddr();
cr_assert_eq(addr, 0x8801EF, "Returned address was %x but was expecting 0x8801EF.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, DirectIndirectLong)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x06;
- pair.second.cpu->_registers.d = 0x1010;
- pair.second.wram->_data[0x1016] = 0xEF;
- pair.second.wram->_data[0x1017] = 0x01;
- pair.second.wram->_data[0x1018] = 0x88;
- auto addr = pair.second.cpu->_getDirectIndirectLongAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x06;
+ snes.cpu->_registers.d = 0x1010;
+ snes.wram->_data[0x1016] = 0xEF;
+ snes.wram->_data[0x1017] = 0x01;
+ snes.wram->_data[0x1018] = 0x88;
+ auto addr = snes.cpu->_getDirectIndirectLongAddr();
cr_assert_eq(addr, 0x8801EF, "Returned address was %x but was expecting 0x8801EF.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, StackRelative)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x06;
- pair.second.cpu->_registers.s = 0x1010;
- auto addr = pair.second.cpu->_getStackRelativeAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x06;
+ snes.cpu->_registers.s = 0x1010;
+ auto addr = snes.cpu->_getStackRelativeAddr();
cr_assert_eq(addr, 0x1016, "Returned address was %x but was expecting 0x1016.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
Test(AddrMode, StackRelativeIndirectIndexed)
{
- auto pair = Init();
- pair.second.cpu->_registers.pac = 0x808000;
- pair.second.cartridge->_data[0] = 0x06;
- pair.second.cpu->_registers.s = 0x1010;
- pair.second.cpu->_registers.y = 0x5;
- pair.second.cpu->_registers.dbr = 0x88;
- auto addr = pair.second.cpu->_getStackRelativeIndirectIndexedYAddr();
+ Init()
+ snes.cpu->_registers.pac = 0x808000;
+ snes.cartridge->_data[0] = 0x06;
+ snes.cpu->_registers.s = 0x1010;
+ snes.cpu->_registers.y = 0x5;
+ snes.cpu->_registers.dbr = 0x88;
+ auto addr = snes.cpu->_getStackRelativeIndirectIndexedYAddr();
cr_assert_eq(addr, 0x88101B, "Returned address was %x but was expecting 0x88101B.", addr);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x808001);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x808001);
}
\ No newline at end of file
diff --git a/tests/CPU/testBits.cpp b/tests/CPU/testBits.cpp
index 2902dfd..04b3fe6 100644
--- a/tests/CPU/testBits.cpp
+++ b/tests/CPU/testBits.cpp
@@ -11,40 +11,40 @@ using namespace ComSquare;
Test(AND, emulation)
{
- auto pair = Init();
- pair.second.wram->_data[0] = 0x00;
- pair.second.cpu->_registers.a = 0xFF;
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->AND(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0x00, "The flags should be 0x00 but it was %x", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.");
+ Init()
+ snes.wram->_data[0] = 0x00;
+ snes.cpu->_registers.a = 0xFF;
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->AND(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0x00, "The flags should be 0x00 but it was %x", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
}
Test(AND, nativeNegative)
{
- auto pair = Init();
- pair.second.wram->_data[0] = 0xF0;
- pair.second.wram->_data[1] = 0xF0;
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.a = 0xFF00;
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->AND(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0xF000, "The flags should be 0xF000 but it was %x", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.");
+ Init()
+ snes.wram->_data[0] = 0xF0;
+ snes.wram->_data[1] = 0xF0;
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.a = 0xFF00;
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->AND(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0xF000, "The flags should be 0xF000 but it was %x", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.");
}
Test(AND, emulationTest)
{
- auto pair = Init();
- pair.second.wram->_data[0] = 0b00110011;
- pair.second.cpu->_registers.a = 0b00110111;
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->AND(0x0);
- cr_assert_eq(pair.second.cpu->_registers.a, 0b00110011, "The flags should be 0b00110011 but it was %x", pair.second.cpu->_registers.a);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.");
+ Init()
+ snes.wram->_data[0] = 0b00110011;
+ snes.cpu->_registers.a = 0b00110111;
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->AND(0x0);
+ cr_assert_eq(snes.cpu->_registers.a, 0b00110011, "The flags should be 0b00110011 but it was %x", snes.cpu->_registers.a);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.");
}
diff --git a/tests/CPU/testInternal.cpp b/tests/CPU/testInternal.cpp
index 888caf4..7caa8ea 100644
--- a/tests/CPU/testInternal.cpp
+++ b/tests/CPU/testInternal.cpp
@@ -14,889 +14,889 @@ using namespace ComSquare;
Test(SEP, setall)
{
- auto pair = Init();
- pair.second.cpu->SEP(0xFF);
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.cpu->SEP(0xFF);
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0xFF, "The flag should be 0xFF but it was %x", data);
}
Test(SEP, setsome)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0b01000000;
- pair.second.cpu->SEP(0b10110101);
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.cpu->_registers.p.flags = 0b01000000;
+ snes.cpu->SEP(0b10110101);
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0b11110101, "The flag should be 245 but it was %i", data);
}
Test(REP, resetall)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->REP(0xFF);
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->REP(0xFF);
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0x00, "The flag should be 0x00 but it was %x", data);
}
Test(REP, resetsome)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.flags = 0b01000000;
- pair.second.cpu->REP(0b01000000);
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.flags = 0b01000000;
+ snes.cpu->REP(0b01000000);
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0x0, "The flag should be 0 but it was %x", data);
}
Test(REP, resetallEmulation)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->REP(0xFF);
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->REP(0xFF);
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0b00110000, "The flag should be 0b00110000 but it was %x", data);
}
Test(REP, resetsomeEmulation)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.flags = 0b01000101;
- pair.second.cpu->REP(0b01000001);
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.flags = 0b01000101;
+ snes.cpu->REP(0b01000001);
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0b00110100, "The flag should be 0b00110100 but it was %x", data);
}
Test(JSR, jump)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0xABCD;
- pair.second.cpu->_registers.s = 0x0123;
- pair.second.cpu->JSR(0xABFF);
- auto pc = pair.second.cpu->_registers.pc;
+ Init()
+ snes.cpu->_registers.pc = 0xABCD;
+ snes.cpu->_registers.s = 0x0123;
+ snes.cpu->JSR(0xABFF);
+ auto pc = snes.cpu->_registers.pc;
cr_assert_eq(pc, 0xABFF, "The PC should be 0xABFF but it was %x", pc);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x0121, "The stack pointer should be 0x0121 but it was %x", pair.second.cpu->_registers.s);
- auto pushed = pair.second.cpu->_pop16();
+ cr_assert_eq(snes.cpu->_registers.s, 0x0121, "The stack pointer should be 0x0121 but it was %x", snes.cpu->_registers.s);
+ auto pushed = snes.cpu->_pop16();
cr_assert_eq(pushed, 0xABCC, "The value pushed to the stack should be 0xABCC but it was %x", pushed);
}
Test(JSL, jump)
{
- auto pair = Init();
- pair.second.cpu->_registers.pbr = 0xFF;
- pair.second.cpu->_registers.pc = 0xABCD;
- pair.second.cpu->_registers.s = 0x0123;
- pair.second.cpu->JSL(0xCDABFF);
- auto pac = pair.second.cpu->_registers.pac;
+ Init()
+ snes.cpu->_registers.pbr = 0xFF;
+ snes.cpu->_registers.pc = 0xABCD;
+ snes.cpu->_registers.s = 0x0123;
+ snes.cpu->JSL(0xCDABFF);
+ auto pac = snes.cpu->_registers.pac;
cr_assert_eq(pac, 0xCDABFF, "The PC should be 0xCDABFF but it was %x", pac);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x0120, "The stack pointer should be 0x0120 but it was %x", pair.second.cpu->_registers.s);
- auto pushed = pair.second.cpu->_pop16() + (pair.second.cpu->_pop() << 16u);
+ cr_assert_eq(snes.cpu->_registers.s, 0x0120, "The stack pointer should be 0x0120 but it was %x", snes.cpu->_registers.s);
+ auto pushed = snes.cpu->_pop16() + (snes.cpu->_pop() << 16u);
cr_assert_eq(pushed, 0xFFABCC, "The value pushed to the stack should be 0xFFABCD but it was %x", pushed);
}
Test(PHA, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.a = 0xABCD;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHA();
- cr_assert_eq(pair.second.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", pair.second.wram->_data[1]);
- cr_assert_eq(pair.second.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.a = 0xABCD;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHA();
+ cr_assert_eq(snes.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", snes.wram->_data[1]);
+ cr_assert_eq(snes.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", snes.cpu->_registers.s);
}
Test(PHB, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.dbr = 0xFF;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHB();
- cr_assert_eq(pair.second.wram->_data[2], 0xFF, "The first value pushed to the stack should be 0xFF but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.dbr = 0xFF;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHB();
+ cr_assert_eq(snes.wram->_data[2], 0xFF, "The first value pushed to the stack should be 0xFF but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PHD, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.d = 0xABCD;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHD();
- cr_assert_eq(pair.second.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", pair.second.wram->_data[1]);
- cr_assert_eq(pair.second.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.d = 0xABCD;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHD();
+ cr_assert_eq(snes.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", snes.wram->_data[1]);
+ cr_assert_eq(snes.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", snes.cpu->_registers.s);
}
Test(PHK, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.pbr = 0xFF;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHK();
- cr_assert_eq(pair.second.wram->_data[2], 0xFF, "The first value pushed to the stack should be 0xFF but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.pbr = 0xFF;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHK();
+ cr_assert_eq(snes.wram->_data[2], 0xFF, "The first value pushed to the stack should be 0xFF but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PHP, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0xFF;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHP();
- cr_assert_eq(pair.second.wram->_data[2], 0xFF, "The first value pushed to the stack should be 0xFF but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.p.flags = 0xFF;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHP();
+ cr_assert_eq(snes.wram->_data[2], 0xFF, "The first value pushed to the stack should be 0xFF but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PHX, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.x = 0xABCD;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHX();
- cr_assert_eq(pair.second.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", pair.second.wram->_data[1]);
- cr_assert_eq(pair.second.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.x = 0xABCD;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHX();
+ cr_assert_eq(snes.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", snes.wram->_data[1]);
+ cr_assert_eq(snes.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", snes.cpu->_registers.s);
}
Test(PHY, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.y = 0xABCD;
- pair.second.cpu->_registers.s = 0x02;
- pair.second.cpu->PHY();
- cr_assert_eq(pair.second.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", pair.second.wram->_data[1]);
- cr_assert_eq(pair.second.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", pair.second.wram->_data[2]);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", pair.second.cpu->_registers.s);
+ Init()
+ snes.cpu->_registers.y = 0xABCD;
+ snes.cpu->_registers.s = 0x02;
+ snes.cpu->PHY();
+ cr_assert_eq(snes.wram->_data[1], 0xCD, "The second value pushed to the stack should be 0xCD but it was %x", snes.wram->_data[1]);
+ cr_assert_eq(snes.wram->_data[2], 0xAB, "The first value pushed to the stack should be 0xAB but it was %x", snes.wram->_data[2]);
+ cr_assert_eq(snes.cpu->_registers.s, 0x0, "The Stack pointer should be equal to 0x0 but it was %x", snes.cpu->_registers.s);
}
Test(PLA, basic)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0xCD;
- pair.second.wram->_data[2] = 0x7B;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLA();
- auto data = pair.second.cpu->_registers.a;
+ Init()
+ snes.wram->_data[1] = 0xCD;
+ snes.wram->_data[2] = 0x7B;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLA();
+ auto data = snes.cpu->_registers.a;
cr_assert_eq(data, 0x7BCD, "The accumulator should be 0x7BCD but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLA, zero)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0x00;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLA();
- auto data = pair.second.cpu->_registers.a;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0x00;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLA();
+ auto data = snes.cpu->_registers.a;
cr_assert_eq(data, 0x0000, "The accumulator should be 0x0000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLA, negative)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0xA0;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLA();
- auto data = pair.second.cpu->_registers.a;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0xA0;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLA();
+ auto data = snes.cpu->_registers.a;
cr_assert_eq(data, 0xA000, "The accumulator should be 0xA000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag not should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag not should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLX, basic)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0xCD;
- pair.second.wram->_data[2] = 0x7B;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLX();
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.wram->_data[1] = 0xCD;
+ snes.wram->_data[2] = 0x7B;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLX();
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x7BCD, "The X register should be 0x7BCD but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLX, zero)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0x00;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLX();
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0x00;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLX();
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x0000, "The x register should be 0x0000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLX, negative)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0xA0;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLX();
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0xA0;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLX();
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0xA000, "The x register should be 0xA000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag not should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag not should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLY, basic)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0xCD;
- pair.second.wram->_data[2] = 0x7B;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLY();
- auto data = pair.second.cpu->_registers.y;
+ Init()
+ snes.wram->_data[1] = 0xCD;
+ snes.wram->_data[2] = 0x7B;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLY();
+ auto data = snes.cpu->_registers.y;
cr_assert_eq(data, 0x7BCD, "The Y register should be 0x7BCD but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLY, zero)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0x00;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLY();
- auto data = pair.second.cpu->_registers.y;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0x00;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLY();
+ auto data = snes.cpu->_registers.y;
cr_assert_eq(data, 0x0000, "The y register should be 0x0000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLY, negative)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0xA0;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLY();
- auto data = pair.second.cpu->_registers.y;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0xA0;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLY();
+ auto data = snes.cpu->_registers.y;
cr_assert_eq(data, 0xA000, "The y register should be 0xA000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag not should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag not should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLD, basic)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0xCD;
- pair.second.wram->_data[2] = 0x7B;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLD();
- auto data = pair.second.cpu->_registers.d;
+ Init()
+ snes.wram->_data[1] = 0xCD;
+ snes.wram->_data[2] = 0x7B;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLD();
+ auto data = snes.cpu->_registers.d;
cr_assert_eq(data, 0x7BCD, "The D register should be 0x7BCD but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLD, zero)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0x00;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLD();
- auto data = pair.second.cpu->_registers.d;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0x00;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLD();
+ auto data = snes.cpu->_registers.d;
cr_assert_eq(data, 0x0000, "The d register should be 0x0000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLD, negative)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.wram->_data[2] = 0xA0;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLD();
- auto data = pair.second.cpu->_registers.d;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.wram->_data[2] = 0xA0;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLD();
+ auto data = snes.cpu->_registers.d;
cr_assert_eq(data, 0xA000, "The D register should be 0xA000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag not should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag not should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x2, "The Stack pointer should be equal to 0x2 but it was %x", snes.cpu->_registers.s);
}
Test(PLB, basic)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x7D;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLB();
- auto data = pair.second.cpu->_registers.dbr;
+ Init()
+ snes.wram->_data[1] = 0x7D;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLB();
+ auto data = snes.cpu->_registers.dbr;
cr_assert_eq(data, 0x7D, "The DBR should be 0x7D but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PLB, zero)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLB();
- auto data = pair.second.cpu->_registers.dbr;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLB();
+ auto data = snes.cpu->_registers.dbr;
cr_assert_eq(data, 0x00, "The dbr should be 0x00 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PLB, negative)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0xA0;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->PLB();
- auto data = pair.second.cpu->_registers.dbr;
+ Init()
+ snes.wram->_data[1] = 0xA0;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->PLB();
+ auto data = snes.cpu->_registers.dbr;
cr_assert_eq(data, 0xA0, "The D register should be 0xA0 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag not should be set.", pair.second.cpu->_registers.p.z);
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set.", pair.second.cpu->_registers.p.n);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag not should be set.", snes.cpu->_registers.p.z);
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set.", snes.cpu->_registers.p.n);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PLP, basic)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x7D;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->PLP();
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.wram->_data[1] = 0x7D;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->PLP();
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0x7D, "The flags should be 0x7D but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(PLP, emulation)
{
- auto pair = Init();
- pair.second.wram->_data[1] = 0x00;
- pair.second.cpu->_registers.s = 0x00;
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->PLP();
- auto data = pair.second.cpu->_registers.p.flags;
+ Init()
+ snes.wram->_data[1] = 0x00;
+ snes.cpu->_registers.s = 0x00;
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->PLP();
+ auto data = snes.cpu->_registers.p.flags;
cr_assert_eq(data, 0b00110000, "The flags should be 0b00110000 but it was %x", data);
- cr_assert_eq(pair.second.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", pair.second.cpu->_registers.s);
+ cr_assert_eq(snes.cpu->_registers.s, 0x1, "The Stack pointer should be equal to 0x1 but it was %x", snes.cpu->_registers.s);
}
Test(CLC, clear)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0xFF;
- pair.second.cpu->CLC();
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flag should not be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0xFF;
+ snes.cpu->CLC();
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flag should not be set");
}
Test(CLI, clear)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0xFF;
- pair.second.cpu->CLI();
- cr_assert_eq(pair.second.cpu->_registers.p.i, false, "The interrupt flag should not be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0xFF;
+ snes.cpu->CLI();
+ cr_assert_eq(snes.cpu->_registers.p.i, false, "The interrupt flag should not be set");
}
Test(CLD, clear)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0xFF;
- pair.second.cpu->CLD();
- cr_assert_eq(pair.second.cpu->_registers.p.d, false, "The decimal flag should not be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0xFF;
+ snes.cpu->CLD();
+ cr_assert_eq(snes.cpu->_registers.p.d, false, "The decimal flag should not be set");
}
Test(CLV, clear)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0xFF;
- pair.second.cpu->CLV();
- cr_assert_eq(pair.second.cpu->_registers.p.v, false, "The overflow flag should not be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0xFF;
+ snes.cpu->CLV();
+ cr_assert_eq(snes.cpu->_registers.p.v, false, "The overflow flag should not be set");
}
Test(SEC, set)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0x00;
- pair.second.cpu->SEC();
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flag should be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0x00;
+ snes.cpu->SEC();
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flag should be set");
}
Test(SEI, set)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0x00;
- pair.second.cpu->SEI();
- cr_assert_eq(pair.second.cpu->_registers.p.i, true, "The interrupt disabled flag should be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0x00;
+ snes.cpu->SEI();
+ cr_assert_eq(snes.cpu->_registers.p.i, true, "The interrupt disabled flag should be set");
}
Test(SED, set)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0x00;
- pair.second.cpu->SED();
- cr_assert_eq(pair.second.cpu->_registers.p.d, true, "The decimal flag should be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0x00;
+ snes.cpu->SED();
+ cr_assert_eq(snes.cpu->_registers.p.d, true, "The decimal flag should be set");
}
Test(XCE, enableEmulation)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.p.c = true;
- pair.second.cpu->_registers.xh = 0xFF;
- pair.second.cpu->_registers.yh = 0xFF;
- pair.second.cpu->XCE();
- cr_assert_eq(pair.second.cpu->_isEmulationMode, true, "The e flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.m, false, "The memory width flag should be untouched (unset)");
- cr_assert_eq(pair.second.cpu->_registers.p.x_b, false, "The index width flag should be untouched (unset)");
- cr_assert_eq(pair.second.cpu->_registers.xh, 0xFF, "The high byte of the x index flag should be untouched (0xFF)");
- cr_assert_eq(pair.second.cpu->_registers.yh, 0xFF, "The high byte of the y index flag should be untouched (0xFF)");
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.p.c = true;
+ snes.cpu->_registers.xh = 0xFF;
+ snes.cpu->_registers.yh = 0xFF;
+ snes.cpu->XCE();
+ cr_assert_eq(snes.cpu->_isEmulationMode, true, "The e flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.m, false, "The memory width flag should be untouched (unset)");
+ cr_assert_eq(snes.cpu->_registers.p.x_b, false, "The index width flag should be untouched (unset)");
+ cr_assert_eq(snes.cpu->_registers.xh, 0xFF, "The high byte of the x index flag should be untouched (0xFF)");
+ cr_assert_eq(snes.cpu->_registers.yh, 0xFF, "The high byte of the y index flag should be untouched (0xFF)");
}
Test(XCE, enableNative)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.xh = 0xFF;
- pair.second.cpu->_registers.yh = 0xFF;
- pair.second.cpu->XCE();
- cr_assert_eq(pair.second.cpu->_isEmulationMode, false, "The e flag should be not set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.m, true, "The memory width flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.x_b, true, "The index width flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.xh, 0, "The high byte of the x index flag should be set to 0");
- cr_assert_eq(pair.second.cpu->_registers.yh, 0, "The high byte of the y index flag should be set to 0");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.xh = 0xFF;
+ snes.cpu->_registers.yh = 0xFF;
+ snes.cpu->XCE();
+ cr_assert_eq(snes.cpu->_isEmulationMode, false, "The e flag should be not set");
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.m, true, "The memory width flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.x_b, true, "The index width flag should be set");
+ cr_assert_eq(snes.cpu->_registers.xh, 0, "The high byte of the x index flag should be set to 0");
+ cr_assert_eq(snes.cpu->_registers.yh, 0, "The high byte of the y index flag should be set to 0");
}
Test(INX, basic)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.x = 0xFF;
- pair.second.cpu->INX();
- cr_assert_eq(pair.second.cpu->_registers.x, 0x0100, "The x register should be equal to 0x0100 but it was 0x%x.", pair.second.cpu->_registers.x);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.x = 0xFF;
+ snes.cpu->INX();
+ cr_assert_eq(snes.cpu->_registers.x, 0x0100, "The x register should be equal to 0x0100 but it was 0x%x.", snes.cpu->_registers.x);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set");
}
Test(INX, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.x = 0xFF;
- pair.second.cpu->INX();
- cr_assert_eq(pair.second.cpu->_registers.x, 0x00, "The x register should be equal to 0x00 but it was 0x%x.", pair.second.cpu->_registers.x);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.x = 0xFF;
+ snes.cpu->INX();
+ cr_assert_eq(snes.cpu->_registers.x, 0x00, "The x register should be equal to 0x00 but it was 0x%x.", snes.cpu->_registers.x);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set");
}
Test(INY, basic)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.y = 0xFF;
- pair.second.cpu->INY();
- cr_assert_eq(pair.second.cpu->_registers.y, 0x0100, "The y register should be equal to 0x0100 but it was 0x%x.", pair.second.cpu->_registers.y);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.y = 0xFF;
+ snes.cpu->INY();
+ cr_assert_eq(snes.cpu->_registers.y, 0x0100, "The y register should be equal to 0x0100 but it was 0x%x.", snes.cpu->_registers.y);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set");
}
Test(INY, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.y = 0xFF;
- pair.second.cpu->INY();
- cr_assert_eq(pair.second.cpu->_registers.y, 0x00, "The y register should be equal to 0x00 but it was 0x%x.", pair.second.cpu->_registers.y);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set");
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.y = 0xFF;
+ snes.cpu->INY();
+ cr_assert_eq(snes.cpu->_registers.y, 0x00, "The y register should be equal to 0x00 but it was 0x%x.", snes.cpu->_registers.y);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set");
}
Test(CPX, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.x = 0xFF;
- pair.second.wram->_data[0] = 0xFF;
- pair.second.cpu->CPX(0x0);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flag should be set");
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.x = 0xFF;
+ snes.wram->_data[0] = 0xFF;
+ snes.cpu->CPX(0x0);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flag should be set");
}
Test(CPX, negative)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.x = 0x80;
- pair.second.wram->_data[0] = 0xFF;
- pair.second.cpu->CPX(0x0);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flag should not be set");
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.x = 0x80;
+ snes.wram->_data[0] = 0xFF;
+ snes.cpu->CPX(0x0);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flag should not be set");
}
Test(CPX, 16bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.x = 0x8888;
- pair.second.wram->_data[0] = 0x88;
- pair.second.wram->_data[1] = 0x98;
- pair.second.cpu->CPX(0x0);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flag should not be set");
+ Init()
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.x = 0x8888;
+ snes.wram->_data[0] = 0x88;
+ snes.wram->_data[1] = 0x98;
+ snes.cpu->CPX(0x0);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flag should not be set");
}
Test(CPY, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.y = 0xFF;
- pair.second.wram->_data[0] = 0xFF;
- pair.second.cpu->CPY(0x0);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, true, "The carry flag should be set");
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.y = 0xFF;
+ snes.wram->_data[0] = 0xFF;
+ snes.cpu->CPY(0x0);
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.c, true, "The carry flag should be set");
}
Test(CPY, negative)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.p.flags = 0;
- pair.second.cpu->_registers.y = 0x80;
- pair.second.wram->_data[0] = 0xFF;
- pair.second.cpu->CPY(0x0);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag should not be set");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag should be set");
- cr_assert_eq(pair.second.cpu->_registers.p.c, false, "The carry flag should not be set");
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.p.flags = 0;
+ snes.cpu->_registers.y = 0x80;
+ snes.wram->_data[0] = 0xFF;
+ snes.cpu->CPY(0x0);
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag should not be set");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag should be set");
+ cr_assert_eq(snes.cpu->_registers.p.c, false, "The carry flag should not be set");
}
Test(BCC, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.c = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BCC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.c = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BCC(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BCC, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.c = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BCC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.c = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BCC(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BCC, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.c = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BCC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.c = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BCC(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BCS, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.c = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BCS(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.c = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BCS(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BCS, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.c = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BCS(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.c = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BCS(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BCS, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.c = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BCS(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.c = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BCS(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BEQ, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.z = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BEQ(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.z = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BEQ(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BEQ, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.z = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BEQ(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.z = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BEQ(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BEQ, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.z = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BEQ(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.z = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BEQ(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BNE, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.z = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BNE(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.z = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BNE(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BNE, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.z = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BNE(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.z = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BNE(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BNE, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.z = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BNE(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.z = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BNE(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BMI, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.n = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BMI(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.n = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BMI(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BMI, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.n = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BMI(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.n = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BMI(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BMI, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.n = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BMI(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.n = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BMI(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BPL, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.n = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BPL(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.n = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BPL(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BPL, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.n = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BPL(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.n = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BPL(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BPL, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.n = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BPL(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.n = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BPL(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BRA, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BRA(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BRA(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BRA, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BRA(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BRA(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BRL, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0x8080;
- pair.second.wram->_data[0] = 0x00;
- pair.second.wram->_data[1] = 0x10;
- pair.second.cpu->BRL(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x9080, "The program counter should be equal to 0x9080 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.pc = 0x8080;
+ snes.wram->_data[0] = 0x00;
+ snes.wram->_data[1] = 0x10;
+ snes.cpu->BRL(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x9080, "The program counter should be equal to 0x9080 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BRL, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0x8080;
- pair.second.wram->_data[0] = 0x00;
- pair.second.wram->_data[1] = 0xF0;
- pair.second.cpu->BRL(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x7080, "The program counter should be equal to 0x7080 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.pc = 0x8080;
+ snes.wram->_data[0] = 0x00;
+ snes.wram->_data[1] = 0xF0;
+ snes.cpu->BRL(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x7080, "The program counter should be equal to 0x7080 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BVC, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.v = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BVC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.v = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BVC(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BVC, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.v = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BVC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.v = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BVC(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BVC, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.v = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BVC(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.v = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BVC(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BVS, basic)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.v = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x50;
- pair.second.cpu->BVS(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.v = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x50;
+ snes.cpu->BVS(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0xD0, "The program counter should be equal to 0xD0 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BVS, negativeJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.v = true;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0xF0;
- pair.second.cpu->BVS(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.v = true;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0xF0;
+ snes.cpu->BVS(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x70, "The program counter should be equal to 0x70 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(BVS, noJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.v = false;
- pair.second.cpu->_registers.pc = 0x80;
- pair.second.wram->_data[0] = 0x90;
- pair.second.cpu->BVS(0x0);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.p.v = false;
+ snes.cpu->_registers.pc = 0x80;
+ snes.wram->_data[0] = 0x90;
+ snes.cpu->BVS(0x0);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x80, "The program counter should be equal to 0x80 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(JMP, simpleJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0x8000;
- pair.second.cpu->JMP(0x1000);
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x1000, "The program counter should be equal to 0x9000 but it was 0x%x.", pair.second.cpu->_registers.pc);
+ Init()
+ snes.cpu->_registers.pc = 0x8000;
+ snes.cpu->JMP(0x1000);
+ cr_assert_eq(snes.cpu->_registers.pc, 0x1000, "The program counter should be equal to 0x9000 but it was 0x%x.", snes.cpu->_registers.pc);
}
Test(JML, simpleJump)
{
- auto pair = Init();
- pair.second.cpu->_registers.pc = 0x8000;
- pair.second.cpu->JML(0x10AB00);
- cr_assert_eq(pair.second.cpu->_registers.pac, 0x10AB00, "The program counter should be equal to 0x10AB00 but it was 0x%x.", pair.second.cpu->_registers.pac);
+ Init()
+ snes.cpu->_registers.pc = 0x8000;
+ snes.cpu->JML(0x10AB00);
+ cr_assert_eq(snes.cpu->_registers.pac, 0x10AB00, "The program counter should be equal to 0x10AB00 but it was 0x%x.", snes.cpu->_registers.pac);
}
\ No newline at end of file
diff --git a/tests/CPU/testInterupts.cpp b/tests/CPU/testInterupts.cpp
index 3773285..9d26dd2 100644
--- a/tests/CPU/testInterupts.cpp
+++ b/tests/CPU/testInterupts.cpp
@@ -12,82 +12,82 @@ using namespace ComSquare;
Test(CPU_emulated, BRK)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cartridge->header.emulationInterrupts.brk = 0x123u;
- pair.second.cpu->_registers.p.flags = 0xF1;
- pair.second.cpu->_registers.pc = 0x156u;
- pair.second.cpu->_registers.pbr = 0x15;
- pair.second.cpu->BRK();
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", pair.second.cpu->_registers.pc);
- cr_assert_eq(pair.second.cpu->_registers.pbr, 0x15, "The PBR should be 0x15 but it was 0x%X", pair.second.cpu->_registers.pbr);
- cr_assert_eq(pair.second.cpu->_registers.p.d, false, "The decimal flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.x_b, true, "The break flag should be set.");
- int data = pair.second.cpu->_pop();
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cartridge->header.emulationInterrupts.brk = 0x123u;
+ snes.cpu->_registers.p.flags = 0xF1;
+ snes.cpu->_registers.pc = 0x156u;
+ snes.cpu->_registers.pbr = 0x15;
+ snes.cpu->BRK();
+ cr_assert_eq(snes.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", snes.cpu->_registers.pc);
+ cr_assert_eq(snes.cpu->_registers.pbr, 0x15, "The PBR should be 0x15 but it was 0x%X", snes.cpu->_registers.pbr);
+ cr_assert_eq(snes.cpu->_registers.p.d, false, "The decimal flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.x_b, true, "The break flag should be set.");
+ int data = snes.cpu->_pop();
cr_assert_eq(data, 0xF1, "The Status Registers should be pushed into the stack with the value 0xF1 but it was 0x%X (expected 0xF1).", data);
- data = pair.second.cpu->_pop16();
+ data = snes.cpu->_pop16();
cr_assert_eq(data, 0x158u, "The program counter should be incremented by two and pushed on the stack but it was 0x%X (expected 0x158).", data);
}
Test(CPU_native, BRK)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cartridge->header.nativeInterrupts.brk = 0x123u;
- pair.second.cpu->_registers.p.flags = 0xF1;
- pair.second.cpu->_registers.pc = 0x156u;
- pair.second.cpu->_registers.pbr = 0x15;
- pair.second.cpu->BRK();
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", pair.second.cpu->_registers.pc);
- cr_assert_eq(pair.second.cpu->_registers.pbr, 0x0, "The PBR should be 0x0 but it was 0x%X", pair.second.cpu->_registers.pbr);
- cr_assert_eq(pair.second.cpu->_registers.p.d, false, "The decimal flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
- int data = pair.second.cpu->_pop();
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cartridge->header.nativeInterrupts.brk = 0x123u;
+ snes.cpu->_registers.p.flags = 0xF1;
+ snes.cpu->_registers.pc = 0x156u;
+ snes.cpu->_registers.pbr = 0x15;
+ snes.cpu->BRK();
+ cr_assert_eq(snes.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", snes.cpu->_registers.pc);
+ cr_assert_eq(snes.cpu->_registers.pbr, 0x0, "The PBR should be 0x0 but it was 0x%X", snes.cpu->_registers.pbr);
+ cr_assert_eq(snes.cpu->_registers.p.d, false, "The decimal flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
+ int data = snes.cpu->_pop();
cr_assert_eq(data, 0xF1, "The Status Registers should be pushed into the stack with the value 0xF1 but it was 0x%X (expected 0xF1).", data);
- data = pair.second.cpu->_pop16();
+ data = snes.cpu->_pop16();
cr_assert_eq(data, 0x158u, "The program counter should be incremented by two and pushed on the stack but it was 0x%X (expected 0x158).", data);
- data = pair.second.cpu->_pop();
+ data = snes.cpu->_pop();
cr_assert_eq(data, 0x15, "The program bank register should be pushed on the stack but it was 0x%X (expected 0x15).", data);
}
Test(CPU_emulated, COP)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = true;
- pair.second.cartridge->header.emulationInterrupts.cop = 0x123u;
- pair.second.cpu->_registers.p.flags = 0x0F;
- pair.second.cpu->_registers.pc = 0x156u;
- pair.second.cpu->_registers.pbr = 0x15;
- pair.second.cpu->COP();
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", pair.second.cpu->_registers.pc);
- cr_assert_eq(pair.second.cpu->_registers.pbr, 0x15, "The PBR should be 0x15 but it was 0x%X", pair.second.cpu->_registers.pbr);
- cr_assert_eq(pair.second.cpu->_registers.p.d, false, "The decimal flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.x_b, false, "The break flag should not be set.");
- int data = pair.second.cpu->_pop();
+ Init()
+ snes.cpu->_isEmulationMode = true;
+ snes.cartridge->header.emulationInterrupts.cop = 0x123u;
+ snes.cpu->_registers.p.flags = 0x0F;
+ snes.cpu->_registers.pc = 0x156u;
+ snes.cpu->_registers.pbr = 0x15;
+ snes.cpu->COP();
+ cr_assert_eq(snes.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", snes.cpu->_registers.pc);
+ cr_assert_eq(snes.cpu->_registers.pbr, 0x15, "The PBR should be 0x15 but it was 0x%X", snes.cpu->_registers.pbr);
+ cr_assert_eq(snes.cpu->_registers.p.d, false, "The decimal flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.x_b, false, "The break flag should not be set.");
+ int data = snes.cpu->_pop();
cr_assert_eq(data, 0x0F, "The Status Registers should be pushed into the stack with the value 0x0F but it was 0x%X (expected 0xF1).", data);
- data = pair.second.cpu->_pop16();
+ data = snes.cpu->_pop16();
cr_assert_eq(data, 0x158u, "The program counter should be incremented by two and pushed on the stack but it was 0x%X (expected 0x158).", data);
}
Test(CPU_native, COP)
{
- auto pair = Init();
- pair.second.cpu->_isEmulationMode = false;
- pair.second.cartridge->header.nativeInterrupts.cop = 0x123u;
- pair.second.cpu->_registers.p.flags = 0xF1;
- pair.second.cpu->_registers.pc = 0x156u;
- pair.second.cpu->_registers.pbr = 0x15;
- pair.second.cpu->COP();
- cr_assert_eq(pair.second.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", pair.second.cpu->_registers.pc);
- cr_assert_eq(pair.second.cpu->_registers.pbr, 0x0, "The PBR should be 0x0 but it was 0x%X", pair.second.cpu->_registers.pbr);
- cr_assert_eq(pair.second.cpu->_registers.p.d, false, "The decimal flag should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
- int data = pair.second.cpu->_pop();
+ Init()
+ snes.cpu->_isEmulationMode = false;
+ snes.cartridge->header.nativeInterrupts.cop = 0x123u;
+ snes.cpu->_registers.p.flags = 0xF1;
+ snes.cpu->_registers.pc = 0x156u;
+ snes.cpu->_registers.pbr = 0x15;
+ snes.cpu->COP();
+ cr_assert_eq(snes.cpu->_registers.pc, 0x123u, "The program counter should be 0x123u but it was 0x%X", snes.cpu->_registers.pc);
+ cr_assert_eq(snes.cpu->_registers.pbr, 0x0, "The PBR should be 0x0 but it was 0x%X", snes.cpu->_registers.pbr);
+ cr_assert_eq(snes.cpu->_registers.p.d, false, "The decimal flag should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.i, true, "The Interrupt disable flag should be set.");
+ int data = snes.cpu->_pop();
cr_assert_eq(data, 0xF1, "The Status Registers should be pushed into the stack with the value 0xF1 but it was 0x%X (expected 0xF1).", data);
- data = pair.second.cpu->_pop16();
+ data = snes.cpu->_pop16();
cr_assert_eq(data, 0x158u, "The program counter should be incremented by two and pushed on the stack but it was 0x%X (expected 0x158).", data);
- data = pair.second.cpu->_pop();
+ data = snes.cpu->_pop();
cr_assert_eq(data, 0x15, "The program bank register should be pushed on the stack but it was 0x%X (expected 0x15).", data);
}
\ No newline at end of file
diff --git a/tests/CPU/testStore.cpp b/tests/CPU/testStore.cpp
index 2c61114..3bd0a97 100644
--- a/tests/CPU/testStore.cpp
+++ b/tests/CPU/testStore.cpp
@@ -11,157 +11,157 @@ using namespace ComSquare;
Test(STA, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.m = true;
- pair.second.cpu->_registers.a = 0x11;
- pair.second.cpu->STA(0x0);
- auto data = pair.second.wram->_data[0];
+ Init()
+ snes.cpu->_registers.p.m = true;
+ snes.cpu->_registers.a = 0x11;
+ snes.cpu->STA(0x0);
+ auto data = snes.wram->_data[0];
cr_assert_eq(data, 0x11, "The stored value should be 0x11 but it was 0x%x.", data);
}
Test(STA, 16bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.m = false;
- pair.second.cpu->_registers.a = 0x11AB;
- pair.second.cpu->STA(0x0);
- auto data = pair.second.wram->_data[0] + (pair.second.wram->_data[1] << 8u);
+ Init()
+ snes.cpu->_registers.p.m = false;
+ snes.cpu->_registers.a = 0x11AB;
+ snes.cpu->STA(0x0);
+ auto data = snes.wram->_data[0] + (snes.wram->_data[1] << 8u);
cr_assert_eq(data, 0x11AB, "The stored value should be 0x11AB but it was 0x%x.", data);
}
Test(STX, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.x = 0x11;
- pair.second.cpu->STX(0x0);
- auto data = pair.second.wram->_data[0];
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.x = 0x11;
+ snes.cpu->STX(0x0);
+ auto data = snes.wram->_data[0];
cr_assert_eq(data, 0x11, "The stored value should be 0x11 but it was 0x%x.", data);
}
Test(STX, 16bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.x = 0x11AB;
- pair.second.cpu->STX(0x0);
- auto data = pair.second.wram->_data[0] + (pair.second.wram->_data[1] << 8u);
+ Init()
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.x = 0x11AB;
+ snes.cpu->STX(0x0);
+ auto data = snes.wram->_data[0] + (snes.wram->_data[1] << 8u);
cr_assert_eq(data, 0x11AB, "The stored value should be 0x11AB but it was 0x%x.", data);
}
Test(STY, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.cpu->_registers.y = 0x11;
- pair.second.cpu->STY(0x0);
- auto data = pair.second.wram->_data[0];
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.cpu->_registers.y = 0x11;
+ snes.cpu->STY(0x0);
+ auto data = snes.wram->_data[0];
cr_assert_eq(data, 0x11, "The stored value should be 0x11 but it was 0x%x.", data);
}
Test(STY, 16bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.cpu->_registers.y = 0x11AB;
- pair.second.cpu->STY(0x0);
- auto data = pair.second.wram->_data[0] + (pair.second.wram->_data[1] << 8u);
+ Init()
+ snes.cpu->_registers.p.x_b = false;
+ snes.cpu->_registers.y = 0x11AB;
+ snes.cpu->STY(0x0);
+ auto data = snes.wram->_data[0] + (snes.wram->_data[1] << 8u);
cr_assert_eq(data, 0x11AB, "The stored value should be 0x11AB but it was 0x%x.", data);
}
Test(STZ, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.m = true;
- pair.second.wram->_data[0] = 0x11;
- pair.second.cpu->STZ(0x0);
- auto data = pair.second.wram->_data[0];
+ Init()
+ snes.cpu->_registers.p.m = true;
+ snes.wram->_data[0] = 0x11;
+ snes.cpu->STZ(0x0);
+ auto data = snes.wram->_data[0];
cr_assert_eq(data, 0x00, "The stored value should be 0x00 but it was 0x%x.", data);
}
Test(STZ, 16bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.m = false;
- pair.second.wram->_data[0] = 0x11;
- pair.second.wram->_data[1] = 0x11;
- pair.second.cpu->STZ(0x0);
- auto data = pair.second.wram->_data[0] + (pair.second.wram->_data[1] << 8u);
+ Init()
+ snes.cpu->_registers.p.m = false;
+ snes.wram->_data[0] = 0x11;
+ snes.wram->_data[1] = 0x11;
+ snes.cpu->STZ(0x0);
+ auto data = snes.wram->_data[0] + (snes.wram->_data[1] << 8u);
cr_assert_eq(data, 0x00, "The stored value should be 0x00 but it was 0x%x.", data);
}
Test(LDX, 8bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.wram->_data[0] = 0x01;
- pair.second.cpu->LDX(0x0);
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.wram->_data[0] = 0x01;
+ snes.cpu->LDX(0x0);
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x01, "The stored value should be 0x01 but it was 0x%x.", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag register should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag register should not be set.");
}
Test(LDX, 8bitsNegative)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.wram->_data[0] = 0x11;
- pair.second.cpu->LDX(0x0);
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.wram->_data[0] = 0x11;
+ snes.cpu->LDX(0x0);
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x11, "The stored value should be 0x11 but it was 0x%x.", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag register should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag register should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag register should be set.");
}
Test(LDX, 8bitsZero)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = true;
- pair.second.wram->_data[0] = 0x00;
- pair.second.wram->_data[1] = 0x11;
- pair.second.cpu->LDX(0x0);
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.cpu->_registers.p.x_b = true;
+ snes.wram->_data[0] = 0x00;
+ snes.wram->_data[1] = 0x11;
+ snes.cpu->LDX(0x0);
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x00, "The stored value should be 0x00 but it was 0x%x.", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag register should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag register should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag register should not be set.");
}
Test(LDX, 16bits)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.wram->_data[0] = 0xAB;
- pair.second.wram->_data[1] = 001;
- pair.second.cpu->LDX(0x0);
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.cpu->_registers.p.x_b = false;
+ snes.wram->_data[0] = 0xAB;
+ snes.wram->_data[1] = 001;
+ snes.cpu->LDX(0x0);
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x01AB, "The stored value should be 0x01AB but it was 0x%x.", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag register should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag register should not be set.");
}
Test(LDX, 16bitsNegative)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.wram->_data[0] = 0xAB;
- pair.second.wram->_data[1] = 0x11;
- pair.second.cpu->LDX(0x0);
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.cpu->_registers.p.x_b = false;
+ snes.wram->_data[0] = 0xAB;
+ snes.wram->_data[1] = 0x11;
+ snes.cpu->LDX(0x0);
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x11AB, "The stored value should be 0x11AB but it was 0x%x.", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, false, "The zero flag register should not be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, true, "The negative flag register should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, false, "The zero flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, true, "The negative flag register should be set.");
}
Test(LDX, 16bitsZero)
{
- auto pair = Init();
- pair.second.cpu->_registers.p.x_b = false;
- pair.second.wram->_data[0] = 0x00;
- pair.second.wram->_data[1] = 0x00;
- pair.second.cpu->LDX(0x0);
- auto data = pair.second.cpu->_registers.x;
+ Init()
+ snes.cpu->_registers.p.x_b = false;
+ snes.wram->_data[0] = 0x00;
+ snes.wram->_data[1] = 0x00;
+ snes.cpu->LDX(0x0);
+ auto data = snes.cpu->_registers.x;
cr_assert_eq(data, 0x0000, "The stored value should be 0x0000 but it was 0x%x.", data);
- cr_assert_eq(pair.second.cpu->_registers.p.z, true, "The zero flag register should be set.");
- cr_assert_eq(pair.second.cpu->_registers.p.n, false, "The negative flag register should not be set.");
+ cr_assert_eq(snes.cpu->_registers.p.z, true, "The zero flag register should be set.");
+ cr_assert_eq(snes.cpu->_registers.p.n, false, "The negative flag register should not be set.");
}
\ No newline at end of file
diff --git a/tests/PPU/testPpuWrite.cpp b/tests/PPU/testPpuWrite.cpp
index 926771d..814edb9 100644
--- a/tests/PPU/testPpuWrite.cpp
+++ b/tests/PPU/testPpuWrite.cpp
@@ -13,253 +13,253 @@ using namespace ComSquare;
Test(PPU_write, inidisp_data_full_ones)
{
- auto pair = Init();
- pair.first->write(0x2100, 0b11111111);
- cr_assert_eq(pair.second.ppu->_inidisp.fblank, true);
- cr_assert_eq(pair.second.ppu->_inidisp.brightness, 0xF);
+ Init()
+ snes._bus->write(0x2100, 0b11111111);
+ cr_assert_eq(snes.ppu->_inidisp.fblank, true);
+ cr_assert_eq(snes.ppu->_inidisp.brightness, 0xF);
}
Test(PPU_write, inidisp_data_full_zeros)
{
- auto pair = Init();
- pair.first->write(0x2100, 0b00000000);
- cr_assert_eq(pair.second.ppu->_inidisp.fblank, false);
- cr_assert_eq(pair.second.ppu->_inidisp.brightness, 0x0);
+ Init()
+ snes._bus->write(0x2100, 0b00000000);
+ cr_assert_eq(snes.ppu->_inidisp.fblank, false);
+ cr_assert_eq(snes.ppu->_inidisp.brightness, 0x0);
}
Test(PPU_write, inidisp_data_fBlank_on_brghtness_off)
{
- auto pair = Init();
- pair.first->write(0x2100, 0b10000000);
- cr_assert_eq(pair.second.ppu->_inidisp.fblank, true);
- cr_assert_eq(pair.second.ppu->_inidisp.brightness, 0x0);
+ Init()
+ snes._bus->write(0x2100, 0b10000000);
+ cr_assert_eq(snes.ppu->_inidisp.fblank, true);
+ cr_assert_eq(snes.ppu->_inidisp.brightness, 0x0);
}
Test(PPU_write, inidisp_data_fBlank_off_brghtness_max)
{
- auto pair = Init();
- pair.first->write(0x2100, 0b00001111);
- cr_assert_eq(pair.second.ppu->_inidisp.fblank, false);
- cr_assert_eq(pair.second.ppu->_inidisp.brightness, 0xF);
+ Init()
+ snes._bus->write(0x2100, 0b00001111);
+ cr_assert_eq(snes.ppu->_inidisp.fblank, false);
+ cr_assert_eq(snes.ppu->_inidisp.brightness, 0xF);
}
Test(PPU_write, inidisp_data_fBlank_off_brghtness_half)
{
- auto pair = Init();
- pair.first->write(0x2100, 0b00000101);
- cr_assert_eq(pair.second.ppu->_inidisp.fblank, false);
- cr_assert_eq(pair.second.ppu->_inidisp.brightness, 0x5);
+ Init()
+ snes._bus->write(0x2100, 0b00000101);
+ cr_assert_eq(snes.ppu->_inidisp.fblank, false);
+ cr_assert_eq(snes.ppu->_inidisp.brightness, 0x5);
}
Test(PPU_write, obsel_111_object_size_and_all_null)
{
- auto pair = Init();
- pair.first->write(0x2101, 0b11100000);
- cr_assert_eq(pair.second.ppu->_obsel.objectSize, 0b111);
- cr_assert_eq(pair.second.ppu->_obsel.nameSelect, 0b00);
- cr_assert_eq(pair.second.ppu->_obsel.nameBaseSelect, 0b000);
+ Init()
+ snes._bus->write(0x2101, 0b11100000);
+ cr_assert_eq(snes.ppu->_obsel.objectSize, 0b111);
+ cr_assert_eq(snes.ppu->_obsel.nameSelect, 0b00);
+ cr_assert_eq(snes.ppu->_obsel.nameBaseSelect, 0b000);
}
Test(PPU_write, obsel_data_full)
{
- auto pair = Init();
- pair.first->write(0x2101, 0b11111111);
- cr_assert_eq(pair.second.ppu->_obsel.objectSize, 0b111);
- cr_assert_eq(pair.second.ppu->_obsel.nameSelect, 0b11);
- cr_assert_eq(pair.second.ppu->_obsel.nameBaseSelect, 0b111);
+ Init()
+ snes._bus->write(0x2101, 0b11111111);
+ cr_assert_eq(snes.ppu->_obsel.objectSize, 0b111);
+ cr_assert_eq(snes.ppu->_obsel.nameSelect, 0b11);
+ cr_assert_eq(snes.ppu->_obsel.nameBaseSelect, 0b111);
}
Test(PPU_write, obsel_data_full_nameselect)
{
- auto pair = Init();
- pair.first->write(0x2101, 0b00011000);
- cr_assert_eq(pair.second.ppu->_obsel.objectSize, 0b000);
- cr_assert_eq(pair.second.ppu->_obsel.nameSelect, 0b11);
- cr_assert_eq(pair.second.ppu->_obsel.nameBaseSelect, 0b000);
+ Init()
+ snes._bus->write(0x2101, 0b00011000);
+ cr_assert_eq(snes.ppu->_obsel.objectSize, 0b000);
+ cr_assert_eq(snes.ppu->_obsel.nameSelect, 0b11);
+ cr_assert_eq(snes.ppu->_obsel.nameBaseSelect, 0b000);
}
Test(PPU_write, obsel_data_full_baseselect)
{
- auto pair = Init();
- pair.first->write(0x2101, 0b00000111);
- cr_assert_eq(pair.second.ppu->_obsel.objectSize, 0b000);
- cr_assert_eq(pair.second.ppu->_obsel.nameSelect, 0b00);
- cr_assert_eq(pair.second.ppu->_obsel.nameBaseSelect, 0b111);
+ Init()
+ snes._bus->write(0x2101, 0b00000111);
+ cr_assert_eq(snes.ppu->_obsel.objectSize, 0b000);
+ cr_assert_eq(snes.ppu->_obsel.nameSelect, 0b00);
+ cr_assert_eq(snes.ppu->_obsel.nameBaseSelect, 0b111);
}
Test(PPU_write, oamaddl_data_full)
{
- auto pair = Init();
- pair.first->write(0x2102, 0b11111111);
- cr_assert_eq(pair.second.ppu->_oamadd.oamAddress, 0b011111111);
+ Init()
+ snes._bus->write(0x2102, 0b11111111);
+ cr_assert_eq(snes.ppu->_oamadd.oamAddress, 0b011111111);
}
Test(PPU_write, oamaddh_data_full)
{
- auto pair = Init();
- pair.first->write(0x2103, 0b11111111);
- cr_assert_eq(pair.second.ppu->_oamadd.objPriorityActivationBit, true);
- cr_assert_eq(pair.second.ppu->_oamadd.oamAddress, 0b100000000);
+ Init()
+ snes._bus->write(0x2103, 0b11111111);
+ cr_assert_eq(snes.ppu->_oamadd.objPriorityActivationBit, true);
+ cr_assert_eq(snes.ppu->_oamadd.oamAddress, 0b100000000);
}
Test(PPU_write, oamaddlh_data_full)
{
- auto pair = Init();
- pair.first->write(0x2102, 0b11111111);
- pair.first->write(0x2103, 0b11111111);
- cr_assert_eq(pair.second.ppu->_oamadd.objPriorityActivationBit, true);
- cr_assert_eq(pair.second.ppu->_oamadd.oamAddress, 0b111111111);
+ Init()
+ snes._bus->write(0x2102, 0b11111111);
+ snes._bus->write(0x2103, 0b11111111);
+ cr_assert_eq(snes.ppu->_oamadd.objPriorityActivationBit, true);
+ cr_assert_eq(snes.ppu->_oamadd.oamAddress, 0b111111111);
}
Test(PPU_write, oamaddlh_data_full_priorityBit_off)
{
- auto pair = Init();
- pair.first->write(0x2102, 0b11111111);
- pair.first->write(0x2103, 0b01111111);
- cr_assert_eq(pair.second.ppu->_oamadd.objPriorityActivationBit, false);
- cr_assert_eq(pair.second.ppu->_oamadd.oamAddress, 0b111111111);
+ Init()
+ snes._bus->write(0x2102, 0b11111111);
+ snes._bus->write(0x2103, 0b01111111);
+ cr_assert_eq(snes.ppu->_oamadd.objPriorityActivationBit, false);
+ cr_assert_eq(snes.ppu->_oamadd.oamAddress, 0b111111111);
}
Test(PPU_write, oamaddlh_oamAdress_11_priorityBit_on)
{
- auto pair = Init();
- pair.first->write(0x2102, 0b00001011);
- pair.first->write(0x2103, 0b10011100);
- cr_assert_eq(pair.second.ppu->_oamadd.objPriorityActivationBit, true);
- cr_assert_eq(pair.second.ppu->_oamadd.oamAddress, 11);
+ Init()
+ snes._bus->write(0x2102, 0b00001011);
+ snes._bus->write(0x2103, 0b10011100);
+ cr_assert_eq(snes.ppu->_oamadd.objPriorityActivationBit, true);
+ cr_assert_eq(snes.ppu->_oamadd.oamAddress, 11);
}
Test(PPU_write, bgmode_data_full)
{
- auto pair = Init();
- pair.first->write(0x2105, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgmode.bgMode, 7);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg1, true);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg2, true);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg3, true);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg4, true);
- cr_assert_eq(pair.second.ppu->_bgmode.mode1Bg3PriorityBit, true);
+ Init()
+ snes._bus->write(0x2105, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgmode.bgMode, 7);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg1, true);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg2, true);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg3, true);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg4, true);
+ cr_assert_eq(snes.ppu->_bgmode.mode1Bg3PriorityBit, true);
}
Test(PPU_write, bgmode_bgmode_5_and_bg24_on)
{
- auto pair = Init();
- pair.first->write(0x2105, 0b10100101);
- cr_assert_eq(pair.second.ppu->_bgmode.bgMode, 5);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg1, false);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg2, true);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg3, false);
- cr_assert_eq(pair.second.ppu->_bgmode.characterSizeBg4, true);
- cr_assert_eq(pair.second.ppu->_bgmode.mode1Bg3PriorityBit, false);
+ Init()
+ snes._bus->write(0x2105, 0b10100101);
+ cr_assert_eq(snes.ppu->_bgmode.bgMode, 5);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg1, false);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg2, true);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg3, false);
+ cr_assert_eq(snes.ppu->_bgmode.characterSizeBg4, true);
+ cr_assert_eq(snes.ppu->_bgmode.mode1Bg3PriorityBit, false);
}
Test(PPU_write, mosaic_data_full)
{
- auto pair = Init();
- pair.first->write(0x2106, 0b11111111);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg1, true);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg2, true);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg3, true);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg4, true);
- cr_assert_eq(pair.second.ppu->_mosaic.pixelSize, 0xF);
+ Init()
+ snes._bus->write(0x2106, 0b11111111);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg1, true);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg2, true);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg3, true);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg4, true);
+ cr_assert_eq(snes.ppu->_mosaic.pixelSize, 0xF);
}
Test(PPU_write, mosaic_affectbg23_w_1x1_size)
{
- auto pair = Init();
- pair.first->write(0x2106, 0b00000110);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg1, false);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg2, true);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg3, true);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg4, false);
- cr_assert_eq(pair.second.ppu->_mosaic.pixelSize, 0x0);
+ Init()
+ snes._bus->write(0x2106, 0b00000110);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg1, false);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg2, true);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg3, true);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg4, false);
+ cr_assert_eq(snes.ppu->_mosaic.pixelSize, 0x0);
}
Test(PPU_write, mosaic_affectbg14_w_2x2_size)
{
- auto pair = Init();
- pair.first->write(0x2106, 0b00101001);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg1, true);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg2, false);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg3, false);
- cr_assert_eq(pair.second.ppu->_mosaic.affectBg4, true);
- cr_assert_eq(pair.second.ppu->_mosaic.pixelSize, 0x2);
+ Init()
+ snes._bus->write(0x2106, 0b00101001);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg1, true);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg2, false);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg3, false);
+ cr_assert_eq(snes.ppu->_mosaic.affectBg4, true);
+ cr_assert_eq(snes.ppu->_mosaic.pixelSize, 0x2);
}
Test(PPU_write, bg1sc_data_full)
{
- auto pair = Init();
- pair.first->write(0x2107, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgsc[0].tilemapAddress, 0b111111);
- cr_assert_eq(pair.second.ppu->_bgsc[0].tilemapHorizontalMirroring, true);
- cr_assert_eq(pair.second.ppu->_bgsc[0].tilemapVerticalMirroring, true);
+ Init()
+ snes._bus->write(0x2107, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgsc[0].tilemapAddress, 0b111111);
+ cr_assert_eq(snes.ppu->_bgsc[0].tilemapHorizontalMirroring, true);
+ cr_assert_eq(snes.ppu->_bgsc[0].tilemapVerticalMirroring, true);
}
Test(PPU_write, bg2sc_data_full)
{
- auto pair = Init();
- pair.first->write(0x2108, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgsc[1].tilemapAddress, 0b111111);
- cr_assert_eq(pair.second.ppu->_bgsc[1].tilemapHorizontalMirroring, true);
- cr_assert_eq(pair.second.ppu->_bgsc[1].tilemapVerticalMirroring, true);
+ Init()
+ snes._bus->write(0x2108, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgsc[1].tilemapAddress, 0b111111);
+ cr_assert_eq(snes.ppu->_bgsc[1].tilemapHorizontalMirroring, true);
+ cr_assert_eq(snes.ppu->_bgsc[1].tilemapVerticalMirroring, true);
}
Test(PPU_write, bg3sc_data_full)
{
- auto pair = Init();
- pair.first->write(0x2109, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgsc[2].tilemapAddress, 0b111111);
- cr_assert_eq(pair.second.ppu->_bgsc[2].tilemapHorizontalMirroring, true);
- cr_assert_eq(pair.second.ppu->_bgsc[2].tilemapVerticalMirroring, true);
+ Init()
+ snes._bus->write(0x2109, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgsc[2].tilemapAddress, 0b111111);
+ cr_assert_eq(snes.ppu->_bgsc[2].tilemapHorizontalMirroring, true);
+ cr_assert_eq(snes.ppu->_bgsc[2].tilemapVerticalMirroring, true);
}
Test(PPU_write, bg4sc_data_full)
{
- auto pair = Init();
- pair.first->write(0x210A, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapAddress, 0b111111);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapHorizontalMirroring, true);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapVerticalMirroring, true);
+ Init()
+ snes._bus->write(0x210A, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapAddress, 0b111111);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapHorizontalMirroring, true);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapVerticalMirroring, true);
}
Test(PPU_write, bg4sc_data_null)
{
- auto pair = Init();
- pair.first->write(0x210A, 0b00000000);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapAddress, 0);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapHorizontalMirroring, false);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapVerticalMirroring, false);
+ Init()
+ snes._bus->write(0x210A, 0b00000000);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapAddress, 0);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapHorizontalMirroring, false);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapVerticalMirroring, false);
}
Test(PPU_write, bg4sc_horizontal_off_vertical_on_random_tilemapAdress)
{
- auto pair = Init();
- pair.first->write(0x210A, 0b11000110);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapAddress, 0b110001);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapHorizontalMirroring, false);
- cr_assert_eq(pair.second.ppu->_bgsc[3].tilemapVerticalMirroring, true);
+ Init()
+ snes._bus->write(0x210A, 0b11000110);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapAddress, 0b110001);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapHorizontalMirroring, false);
+ cr_assert_eq(snes.ppu->_bgsc[3].tilemapVerticalMirroring, true);
}
Test(PPU_write, bg12nba_data_full)
{
- auto pair = Init();
- pair.first->write(0x210B, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgnba[0].baseAddressBg1a3, 0b1111);
- cr_assert_eq(pair.second.ppu->_bgnba[0].baseAddressBg2a4, 0b1111);
+ Init()
+ snes._bus->write(0x210B, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgnba[0].baseAddressBg1a3, 0b1111);
+ cr_assert_eq(snes.ppu->_bgnba[0].baseAddressBg2a4, 0b1111);
}
Test(PPU_write, bg34nba_data_full)
{
- auto pair = Init();
- pair.first->write(0x210C, 0b11111111);
- cr_assert_eq(pair.second.ppu->_bgnba[1].baseAddressBg1a3, 0b1111);
- cr_assert_eq(pair.second.ppu->_bgnba[1].baseAddressBg2a4, 0b1111);
+ Init()
+ snes._bus->write(0x210C, 0b11111111);
+ cr_assert_eq(snes.ppu->_bgnba[1].baseAddressBg1a3, 0b1111);
+ cr_assert_eq(snes.ppu->_bgnba[1].baseAddressBg2a4, 0b1111);
}
Test(PPU_write, bg12nba_data_random_data)
{
- auto pair = Init();
- pair.first->write(0x210B, 0b10101010);
- cr_assert_eq(pair.second.ppu->_bgnba[0].baseAddressBg1a3, 0b1010);
- cr_assert_eq(pair.second.ppu->_bgnba[0].baseAddressBg2a4, 0b1010);
+ Init()
+ snes._bus->write(0x210B, 0b10101010);
+ cr_assert_eq(snes.ppu->_bgnba[0].baseAddressBg1a3, 0b1010);
+ cr_assert_eq(snes.ppu->_bgnba[0].baseAddressBg2a4, 0b1010);
}
\ No newline at end of file
diff --git a/tests/PPU/testPpuWriteFromVmain.cpp b/tests/PPU/testPpuWriteFromVmain.cpp
index fe21962..d8fdae7 100644
--- a/tests/PPU/testPpuWriteFromVmain.cpp
+++ b/tests/PPU/testPpuWriteFromVmain.cpp
@@ -13,260 +13,260 @@ using namespace ComSquare;
Test(PPU_write_2, vmain_data_full)
{
- auto pair = Init();
- pair.first->write(0x2115, 0b11111111);
- cr_assert_eq(pair.second.ppu->_vmain.incrementMode, true);
- cr_assert_eq(pair.second.ppu->_vmain.addressRemapping, 0b11);
- cr_assert_eq(pair.second.ppu->_vmain.incrementAmount, 0b11);
+ Init()
+ snes._bus->write(0x2115, 0b11111111);
+ cr_assert_eq(snes.ppu->_vmain.incrementMode, true);
+ cr_assert_eq(snes.ppu->_vmain.addressRemapping, 0b11);
+ cr_assert_eq(snes.ppu->_vmain.incrementAmount, 0b11);
}
Test(PPU_write_2, vmain_incrementmode_off_false_else_full)
{
- auto pair = Init();
- pair.first->write(0x2115, 0b01111111);
- cr_assert_eq(pair.second.ppu->_vmain.incrementMode, false);
- cr_assert_eq(pair.second.ppu->_vmain.addressRemapping, 0b11);
- cr_assert_eq(pair.second.ppu->_vmain.incrementAmount, 0b11);
+ Init()
+ snes._bus->write(0x2115, 0b01111111);
+ cr_assert_eq(snes.ppu->_vmain.incrementMode, false);
+ cr_assert_eq(snes.ppu->_vmain.addressRemapping, 0b11);
+ cr_assert_eq(snes.ppu->_vmain.incrementAmount, 0b11);
}
Test(PPU_write_2, vmain_addressremaping_null_else_full)
{
- auto pair = Init();
- pair.first->write(0x2115, 0b11110011);
- cr_assert_eq(pair.second.ppu->_vmain.incrementMode, true);
- cr_assert_eq(pair.second.ppu->_vmain.addressRemapping, 0b00);
- cr_assert_eq(pair.second.ppu->_vmain.incrementAmount, 0b11);
+ Init()
+ snes._bus->write(0x2115, 0b11110011);
+ cr_assert_eq(snes.ppu->_vmain.incrementMode, true);
+ cr_assert_eq(snes.ppu->_vmain.addressRemapping, 0b00);
+ cr_assert_eq(snes.ppu->_vmain.incrementAmount, 0b11);
}
Test(PPU_write_2, vmain_incrementamount_null_else_full)
{
- auto pair = Init();
- pair.first->write(0x2115, 0b11111100);
- cr_assert_eq(pair.second.ppu->_vmain.incrementMode, true);
- cr_assert_eq(pair.second.ppu->_vmain.addressRemapping, 0b11);
- cr_assert_eq(pair.second.ppu->_vmain.incrementAmount, 0b00);
+ Init()
+ snes._bus->write(0x2115, 0b11111100);
+ cr_assert_eq(snes.ppu->_vmain.incrementMode, true);
+ cr_assert_eq(snes.ppu->_vmain.addressRemapping, 0b11);
+ cr_assert_eq(snes.ppu->_vmain.incrementAmount, 0b00);
}
Test(PPU_write_2, vmadd_full_data)
{
- auto pair = Init();
- pair.first->write(0x2116, 0b11111111);
- pair.first->write(0x2117, 0b11111111);
- cr_assert_eq(pair.second.ppu->_vmadd.vmadd, 0b1111111111111111);
+ Init()
+ snes._bus->write(0x2116, 0b11111111);
+ snes._bus->write(0x2117, 0b11111111);
+ cr_assert_eq(snes.ppu->_vmadd.vmadd, 0b1111111111111111);
}
Test(PPU_write_2, vmadd_full_high_byte_null)
{
- auto pair = Init();
- pair.first->write(0x2116, 0b11111111);
- pair.first->write(0x2117, 0b00000000);
- cr_assert_eq(pair.second.ppu->_vmadd.vmadd, 0b0000000011111111);
+ Init()
+ snes._bus->write(0x2116, 0b11111111);
+ snes._bus->write(0x2117, 0b00000000);
+ cr_assert_eq(snes.ppu->_vmadd.vmadd, 0b0000000011111111);
}
Test(PPU_write_2, vmdata_full_data)
{
- auto pair = Init();
- pair.first->write(0x2118, 0b11111111);
- pair.first->write(0x2119, 0b11111111);
- cr_assert_eq(pair.second.ppu->_vmdata.vmdata, 0b1111111111111111);
+ Init()
+ snes._bus->write(0x2118, 0b11111111);
+ snes._bus->write(0x2119, 0b11111111);
+ cr_assert_eq(snes.ppu->_vmdata.vmdata, 0b1111111111111111);
}
Test(PPU_write_2, vmdata_full_high_byte_null)
{
- auto pair = Init();
- pair.first->write(0x2118, 0b11111111);
- pair.first->write(0x2119, 0b00000000);
- cr_assert_eq(pair.second.ppu->_vmdata.vmdata, 0b0000000011111111);
+ Init()
+ snes._bus->write(0x2118, 0b11111111);
+ snes._bus->write(0x2119, 0b00000000);
+ cr_assert_eq(snes.ppu->_vmdata.vmdata, 0b0000000011111111);
}
Test(PPU_write_2, cgadd_full_high_byte_null)
{
- auto pair = Init();
- pair.first->write(0x2121, 0b11111111);
- cr_assert_eq(pair.second.ppu->_cgadd, 0b11111111);
- cr_assert_eq(pair.second.ppu->_isLowByte, true);
+ Init()
+ snes._bus->write(0x2121, 0b11111111);
+ cr_assert_eq(snes.ppu->_cgadd, 0b11111111);
+ cr_assert_eq(snes.ppu->_isLowByte, true);
}
Test(PPU_write_2, cgdata_data_full)
{
- auto pair = Init();
- pair.first->write(0x2121, 0x0);
- pair.first->write(0x2122, 0b11111111);
- cr_assert_eq(pair.second.ppu->_cgdata.cgdatal, 0b11111111);
- cr_assert_eq(pair.second.ppu->_isLowByte, false);
- int address = pair.second.ppu->_cgadd;
- pair.first->write(0x2122, 0b11111000);
- cr_assert_eq(pair.second.ppu->_cgdata.cgdatah, 0b11111000);
- cr_assert_eq(pair.second.ppu->_isLowByte, true);
- cr_assert_eq(pair.second.ppu->_cgadd, address + 1);
+ Init()
+ snes._bus->write(0x2121, 0x0);
+ snes._bus->write(0x2122, 0b11111111);
+ cr_assert_eq(snes.ppu->_cgdata.cgdatal, 0b11111111);
+ cr_assert_eq(snes.ppu->_isLowByte, false);
+ int address = snes.ppu->_cgadd;
+ snes._bus->write(0x2122, 0b11111000);
+ cr_assert_eq(snes.ppu->_cgdata.cgdatah, 0b11111000);
+ cr_assert_eq(snes.ppu->_isLowByte, true);
+ cr_assert_eq(snes.ppu->_cgadd, address + 1);
}
Test(PPU_write_2, m7sel_data_full)
{
- auto pair = Init();
- pair.first->write(0x211A, 0b11111111);
- cr_assert_eq(pair.second.ppu->_m7sel.playingFieldSize, true);
- cr_assert_eq(pair.second.ppu->_m7sel.emptySpaceFill, true);
- cr_assert_eq(pair.second.ppu->_m7sel.horizontalMirroring, true);
- cr_assert_eq(pair.second.ppu->_m7sel.verticalMirroring, true);
+ Init()
+ snes._bus->write(0x211A, 0b11111111);
+ cr_assert_eq(snes.ppu->_m7sel.playingFieldSize, true);
+ cr_assert_eq(snes.ppu->_m7sel.emptySpaceFill, true);
+ cr_assert_eq(snes.ppu->_m7sel.horizontalMirroring, true);
+ cr_assert_eq(snes.ppu->_m7sel.verticalMirroring, true);
}
Test(PPU_write_2, m7sel_data_actual)
{
- auto pair = Init();
- pair.first->write(0x211A, 0b01111101);
- cr_assert_eq(pair.second.ppu->_m7sel.playingFieldSize, false);
- cr_assert_eq(pair.second.ppu->_m7sel.emptySpaceFill, true);
- cr_assert_eq(pair.second.ppu->_m7sel.horizontalMirroring, true);
- cr_assert_eq(pair.second.ppu->_m7sel.verticalMirroring, false);
+ Init()
+ snes._bus->write(0x211A, 0b01111101);
+ cr_assert_eq(snes.ppu->_m7sel.playingFieldSize, false);
+ cr_assert_eq(snes.ppu->_m7sel.emptySpaceFill, true);
+ cr_assert_eq(snes.ppu->_m7sel.horizontalMirroring, true);
+ cr_assert_eq(snes.ppu->_m7sel.verticalMirroring, false);
}
Test(PPU_write_2, w12sel_data_full)
{
- auto pair = Init();
- pair.first->write(0x2123, 0b11111111);
- cr_assert_eq(pair.second.ppu->_wsel[0].window1InversionForBg1Bg2Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].enableWindow1ForBg1Bg2Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].window2InversionForBg1Bg3Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].enableWindow2ForBg1Bg3Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].window1InversionForBg2Bg4Color, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].enableWindow1ForBg2Bg4Color, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].window2InversionForBg2Bg4Color, true);
- cr_assert_eq(pair.second.ppu->_wsel[0].enableWindow2ForBg2Bg4Color, true);
+ Init()
+ snes._bus->write(0x2123, 0b11111111);
+ cr_assert_eq(snes.ppu->_wsel[0].window1InversionForBg1Bg2Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[0].enableWindow1ForBg1Bg2Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[0].window2InversionForBg1Bg3Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[0].enableWindow2ForBg1Bg3Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[0].window1InversionForBg2Bg4Color, true);
+ cr_assert_eq(snes.ppu->_wsel[0].enableWindow1ForBg2Bg4Color, true);
+ cr_assert_eq(snes.ppu->_wsel[0].window2InversionForBg2Bg4Color, true);
+ cr_assert_eq(snes.ppu->_wsel[0].enableWindow2ForBg2Bg4Color, true);
}
Test(PPU_write_2, w34sel_data_full)
{
- auto pair = Init();
- pair.first->write(0x2124, 0b10101010);
- cr_assert_eq(pair.second.ppu->_wsel[1].window1InversionForBg1Bg2Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[1].enableWindow1ForBg1Bg2Obj, false);
- cr_assert_eq(pair.second.ppu->_wsel[1].window2InversionForBg1Bg3Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[1].enableWindow2ForBg1Bg3Obj, false);
- cr_assert_eq(pair.second.ppu->_wsel[1].window1InversionForBg2Bg4Color, true);
- cr_assert_eq(pair.second.ppu->_wsel[1].enableWindow1ForBg2Bg4Color, false);
- cr_assert_eq(pair.second.ppu->_wsel[1].window2InversionForBg2Bg4Color, true);
- cr_assert_eq(pair.second.ppu->_wsel[1].enableWindow2ForBg2Bg4Color, false);
+ Init()
+ snes._bus->write(0x2124, 0b10101010);
+ cr_assert_eq(snes.ppu->_wsel[1].window1InversionForBg1Bg2Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[1].enableWindow1ForBg1Bg2Obj, false);
+ cr_assert_eq(snes.ppu->_wsel[1].window2InversionForBg1Bg3Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[1].enableWindow2ForBg1Bg3Obj, false);
+ cr_assert_eq(snes.ppu->_wsel[1].window1InversionForBg2Bg4Color, true);
+ cr_assert_eq(snes.ppu->_wsel[1].enableWindow1ForBg2Bg4Color, false);
+ cr_assert_eq(snes.ppu->_wsel[1].window2InversionForBg2Bg4Color, true);
+ cr_assert_eq(snes.ppu->_wsel[1].enableWindow2ForBg2Bg4Color, false);
}
Test(PPU_write_2, wobjsel_data_full)
{
- auto pair = Init();
- pair.first->write(0x2125, 0b10110001);
- cr_assert_eq(pair.second.ppu->_wsel[2].window1InversionForBg1Bg2Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[2].enableWindow1ForBg1Bg2Obj, false);
- cr_assert_eq(pair.second.ppu->_wsel[2].window2InversionForBg1Bg3Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[2].enableWindow2ForBg1Bg3Obj, true);
- cr_assert_eq(pair.second.ppu->_wsel[2].window1InversionForBg2Bg4Color, false);
- cr_assert_eq(pair.second.ppu->_wsel[2].enableWindow1ForBg2Bg4Color, false);
- cr_assert_eq(pair.second.ppu->_wsel[2].window2InversionForBg2Bg4Color, false);
- cr_assert_eq(pair.second.ppu->_wsel[2].enableWindow2ForBg2Bg4Color, true);
+ Init()
+ snes._bus->write(0x2125, 0b10110001);
+ cr_assert_eq(snes.ppu->_wsel[2].window1InversionForBg1Bg2Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[2].enableWindow1ForBg1Bg2Obj, false);
+ cr_assert_eq(snes.ppu->_wsel[2].window2InversionForBg1Bg3Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[2].enableWindow2ForBg1Bg3Obj, true);
+ cr_assert_eq(snes.ppu->_wsel[2].window1InversionForBg2Bg4Color, false);
+ cr_assert_eq(snes.ppu->_wsel[2].enableWindow1ForBg2Bg4Color, false);
+ cr_assert_eq(snes.ppu->_wsel[2].window2InversionForBg2Bg4Color, false);
+ cr_assert_eq(snes.ppu->_wsel[2].enableWindow2ForBg2Bg4Color, true);
}
Test(PPU_write_2, wbglog_data_full)
{
- auto pair = Init();
- pair.first->write(0x212A, 0b10110001);
- cr_assert_eq(pair.second.ppu->_wbglog.maskLogicBg1, 0b10);
- cr_assert_eq(pair.second.ppu->_wbglog.maskLogicBg2, 0b11);
- cr_assert_eq(pair.second.ppu->_wbglog.maskLogicBg3, 0b00);
- cr_assert_eq(pair.second.ppu->_wbglog.maskLogicBg4, 0b01);
+ Init()
+ snes._bus->write(0x212A, 0b10110001);
+ cr_assert_eq(snes.ppu->_wbglog.maskLogicBg1, 0b10);
+ cr_assert_eq(snes.ppu->_wbglog.maskLogicBg2, 0b11);
+ cr_assert_eq(snes.ppu->_wbglog.maskLogicBg3, 0b00);
+ cr_assert_eq(snes.ppu->_wbglog.maskLogicBg4, 0b01);
}
Test(PPU_write_2, wobjlog_data_full)
{
- auto pair = Init();
- pair.first->write(0x212B, 0b10110001);
- cr_assert_eq(pair.second.ppu->_wobjlog.maskLogicObj, 0b01);
- cr_assert_eq(pair.second.ppu->_wobjlog.maskLogicColor, 0b00);
+ Init()
+ snes._bus->write(0x212B, 0b10110001);
+ cr_assert_eq(snes.ppu->_wobjlog.maskLogicObj, 0b01);
+ cr_assert_eq(snes.ppu->_wobjlog.maskLogicColor, 0b00);
}
Test(PPU_write_2, tm_data_full)
{
- auto pair = Init();
- pair.first->write(0x212C, 0b10110001);
- cr_assert_eq(pair.second.ppu->_t[0].enableWindowDisplayBg1, true);
- cr_assert_eq(pair.second.ppu->_t[0].enableWindowDisplayBg2, false);
- cr_assert_eq(pair.second.ppu->_t[0].enableWindowDisplayBg3, false);
- cr_assert_eq(pair.second.ppu->_t[0].enableWindowDisplayBg4, false);
- cr_assert_eq(pair.second.ppu->_t[0].enableWindowDisplayObj, true);
+ Init()
+ snes._bus->write(0x212C, 0b10110001);
+ cr_assert_eq(snes.ppu->_t[0].enableWindowDisplayBg1, true);
+ cr_assert_eq(snes.ppu->_t[0].enableWindowDisplayBg2, false);
+ cr_assert_eq(snes.ppu->_t[0].enableWindowDisplayBg3, false);
+ cr_assert_eq(snes.ppu->_t[0].enableWindowDisplayBg4, false);
+ cr_assert_eq(snes.ppu->_t[0].enableWindowDisplayObj, true);
}
Test(PPU_write_2, ts_data_full)
{
- auto pair = Init();
- pair.first->write(0x212D, 0b10101110);
- cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayBg1, false);
- cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayBg2, true);
- cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayBg3, true);
- cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayBg4, true);
- cr_assert_eq(pair.second.ppu->_t[1].enableWindowDisplayObj, false);
+ Init()
+ snes._bus->write(0x212D, 0b10101110);
+ cr_assert_eq(snes.ppu->_t[1].enableWindowDisplayBg1, false);
+ cr_assert_eq(snes.ppu->_t[1].enableWindowDisplayBg2, true);
+ cr_assert_eq(snes.ppu->_t[1].enableWindowDisplayBg3, true);
+ cr_assert_eq(snes.ppu->_t[1].enableWindowDisplayBg4, true);
+ cr_assert_eq(snes.ppu->_t[1].enableWindowDisplayObj, false);
}
Test(PPU_write_2, tmw_data_full)
{
- auto pair = Init();
- pair.first->write(0x212E, 0b10101110);
- cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg1, false);
- cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg2, true);
- cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg3, true);
- cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingBg4, true);
- cr_assert_eq(pair.second.ppu->_tw[0].enableWindowMaskingObj, false);
+ Init()
+ snes._bus->write(0x212E, 0b10101110);
+ cr_assert_eq(snes.ppu->_tw[0].enableWindowMaskingBg1, false);
+ cr_assert_eq(snes.ppu->_tw[0].enableWindowMaskingBg2, true);
+ cr_assert_eq(snes.ppu->_tw[0].enableWindowMaskingBg3, true);
+ cr_assert_eq(snes.ppu->_tw[0].enableWindowMaskingBg4, true);
+ cr_assert_eq(snes.ppu->_tw[0].enableWindowMaskingObj, false);
}
Test(PPU_write_2, tsw_data_full)
{
- auto pair = Init();
- pair.first->write(0x212F, 0b10100011);
- cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg1, true);
- cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg2, true);
- cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg3, false);
- cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingBg4, false);
- cr_assert_eq(pair.second.ppu->_tw[1].enableWindowMaskingObj, false);
+ Init()
+ snes._bus->write(0x212F, 0b10100011);
+ cr_assert_eq(snes.ppu->_tw[1].enableWindowMaskingBg1, true);
+ cr_assert_eq(snes.ppu->_tw[1].enableWindowMaskingBg2, true);
+ cr_assert_eq(snes.ppu->_tw[1].enableWindowMaskingBg3, false);
+ cr_assert_eq(snes.ppu->_tw[1].enableWindowMaskingBg4, false);
+ cr_assert_eq(snes.ppu->_tw[1].enableWindowMaskingObj, false);
}
Test(PPU_write_2, cgwsel_data_full)
{
- auto pair = Init();
- pair.first->write(0x2130, 0b10111001);
- cr_assert_eq(pair.second.ppu->_cgwsel.clipColorToBlackBeforeMath, 0b10);
- cr_assert_eq(pair.second.ppu->_cgwsel.preventColorMath, 0b11);
- cr_assert_eq(pair.second.ppu->_cgwsel.addSubscreen, false);
- cr_assert_eq(pair.second.ppu->_cgwsel.directColorMode, true);
+ Init()
+ snes._bus->write(0x2130, 0b10111001);
+ cr_assert_eq(snes.ppu->_cgwsel.clipColorToBlackBeforeMath, 0b10);
+ cr_assert_eq(snes.ppu->_cgwsel.preventColorMath, 0b11);
+ cr_assert_eq(snes.ppu->_cgwsel.addSubscreen, false);
+ cr_assert_eq(snes.ppu->_cgwsel.directColorMode, true);
}
Test(PPU_write_2, cgadsub_data_full)
{
- auto pair = Init();
- pair.first->write(0x2131, 0b10111001);
- cr_assert_eq(pair.second.ppu->_cgadsub.addSubtractSelect, true);
- cr_assert_eq(pair.second.ppu->_cgadsub.halfColorMath, false);
- cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBackdrop, true);
- cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathObj, true);
- cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg4, true);
- cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg3, false);
- cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg2, false);
- cr_assert_eq(pair.second.ppu->_cgadsub.enableColorMathBg1, true);
+ Init()
+ snes._bus->write(0x2131, 0b10111001);
+ cr_assert_eq(snes.ppu->_cgadsub.addSubtractSelect, true);
+ cr_assert_eq(snes.ppu->_cgadsub.halfColorMath, false);
+ cr_assert_eq(snes.ppu->_cgadsub.enableColorMathBackdrop, true);
+ cr_assert_eq(snes.ppu->_cgadsub.enableColorMathObj, true);
+ cr_assert_eq(snes.ppu->_cgadsub.enableColorMathBg4, true);
+ cr_assert_eq(snes.ppu->_cgadsub.enableColorMathBg3, false);
+ cr_assert_eq(snes.ppu->_cgadsub.enableColorMathBg2, false);
+ cr_assert_eq(snes.ppu->_cgadsub.enableColorMathBg1, true);
}
Test(PPU_write_2, coldata_data_full)
{
- auto pair = Init();
- pair.first->write(0x2132, 0b10111001);
- cr_assert_eq(pair.second.ppu->_coldata.blue, true);
- cr_assert_eq(pair.second.ppu->_coldata.green, false);
- cr_assert_eq(pair.second.ppu->_coldata.red, true);
- cr_assert_eq(pair.second.ppu->_coldata.colorIntensity, 0b11001);
+ Init()
+ snes._bus->write(0x2132, 0b10111001);
+ cr_assert_eq(snes.ppu->_coldata.blue, true);
+ cr_assert_eq(snes.ppu->_coldata.green, false);
+ cr_assert_eq(snes.ppu->_coldata.red, true);
+ cr_assert_eq(snes.ppu->_coldata.colorIntensity, 0b11001);
}
Test(PPU_write_2, setini_data_full)
{
- auto pair = Init();
- pair.first->write(0x2133, 0b10111001);
- cr_assert_eq(pair.second.ppu->_setini.externalSync, true);
- cr_assert_eq(pair.second.ppu->_setini.mode7ExtBg, false);
- cr_assert_eq(pair.second.ppu->_setini.enablePseudoHiresMode, true);
- cr_assert_eq(pair.second.ppu->_setini.overscanMode, false);
- cr_assert_eq(pair.second.ppu->_setini.objInterlace, false);
- cr_assert_eq(pair.second.ppu->_setini.screenInterlace, true);
+ Init()
+ snes._bus->write(0x2133, 0b10111001);
+ cr_assert_eq(snes.ppu->_setini.externalSync, true);
+ cr_assert_eq(snes.ppu->_setini.mode7ExtBg, false);
+ cr_assert_eq(snes.ppu->_setini.enablePseudoHiresMode, true);
+ cr_assert_eq(snes.ppu->_setini.overscanMode, false);
+ cr_assert_eq(snes.ppu->_setini.objInterlace, false);
+ cr_assert_eq(snes.ppu->_setini.screenInterlace, true);
}
\ No newline at end of file
diff --git a/tests/testMemoryBus.cpp b/tests/testMemoryBus.cpp
index 9b581cd..f1d27f8 100644
--- a/tests/testMemoryBus.cpp
+++ b/tests/testMemoryBus.cpp
@@ -7,7 +7,7 @@
#include
#include "tests.hpp"
#include "../sources/Memory/MemoryBus.hpp"
-#include "../sources/Memory/IMemory.hpp"
+#include "../sources/Memory/AMemory.hpp"
#include "../sources/SNES.hpp"
#include "../sources/Renderer/NoRenderer.hpp"
#include "../sources/Memory/MemoryShadow.hpp"
@@ -26,248 +26,237 @@ using namespace ComSquare;
Test(BusAccessor, GetWramStart)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x7E0000);
- cr_assert_eq(accessor.get(), pair.second.wram.get());
+ accessor = snes._bus->getAccessor(0x7E0000);
+ cr_assert_eq(accessor.get(), snes.wram.get());
}
Test(BusAccessor, GetWramEnd)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x7FFFFF);
- cr_assert_eq(accessor.get(), pair.second.wram.get());
+ accessor = snes._bus->getAccessor(0x7FFFFF);
+ cr_assert_eq(accessor.get(), snes.wram.get());
}
Test(BusAccessor, GetWramMirror)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x2F11FF));
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x2F11FF));
cr_assert_neq(accessor, nullptr);
- cr_assert_eq(accessor->_initial.get(), pair.second.wram.get());
+ cr_assert_eq(accessor->_initial.get(), snes.wram.get());
}
Test(BusAccessor, GetWramMirror2)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x100000));
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x100000));
cr_assert_neq(accessor, nullptr);
- cr_assert_eq(accessor->_initial.get(), pair.second.wram.get());
+ cr_assert_eq(accessor->_initial.get(), snes.wram.get());
}
Test(BusAccessor, GetWramMirror3)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x1010));
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x1010));
cr_assert_neq(accessor, nullptr);
- cr_assert_eq(accessor->_initial.get(), pair.second.wram.get());
+ cr_assert_eq(accessor->_initial.get(), snes.wram.get());
}
Test(BusAccessor, GetOpenBus)
{
- auto pair = Init();
- std::shared_ptr accessor = pair.first->getAccessor(0x897654);
+ Init()
+ std::shared_ptr accessor = snes._bus->getAccessor(0x897654);
cr_assert_eq(accessor.get(), nullptr);
}
Test(BusAccessor, GetSramStart)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x700000));
- cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x700000));
+ cr_assert_eq(accessor->_initial.get(), snes.sram.get());
}
Test(BusAccessor, GetSramEnd)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x7D7FFF));
- cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x7D7FFF));
+ cr_assert_eq(accessor->_initial.get(), snes.sram.get());
}
Test(BusAccessor, GetSramMirror)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0xF00123));
- cr_assert_eq(accessor.get(), pair.second.sram.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0xF00123));
+ cr_assert_eq(accessor.get(), snes.sram.get());
}
-//Test(BusAccessor, GetSramMirror2)
-//{
-// auto pair = Init();
-// std::shared_ptr accessor = nullptr;
-//
-// // TODO implement the SRam accessor for the FE/FF.
-// //std::cout << pair.first->getAccessor(0xFE0123) << std::endl;
-// accessor = std::static_pointer_cast(pair.first->getAccessor(0xFE0123));
-// cr_assert_eq(accessor->_initial.get(), pair.second.sram.get());
-//}
-
Test(BusAccessor, GetAPUStart)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x002140);
- cr_assert_eq(accessor.get(), pair.second.apu.get());
+ accessor = snes._bus->getAccessor(0x002140);
+ cr_assert_eq(accessor.get(), snes.apu.get());
}
Test(BusAccessor, GetAPUEnd)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x002143);
- cr_assert_eq(accessor.get(), pair.second.apu.get());
+ accessor = snes._bus->getAccessor(0x002143);
+ cr_assert_eq(accessor.get(), snes.apu.get());
}
Test(BusAccessor, GetAPUMirror)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0xAB2143));
- cr_assert_eq(accessor->_initial.get(), pair.second.apu.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0xAB2143));
+ cr_assert_eq(accessor->_initial.get(), snes.apu.get());
}
Test(BusAccessor, GetAPUMirrorFirstHalf)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x052143));
- cr_assert_eq(accessor->_initial.get(), pair.second.apu.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x052143));
+ cr_assert_eq(accessor->_initial.get(), snes.apu.get());
}
Test(BusAccessor, GetCPUStart)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x004200);
- cr_assert_eq(accessor.get(), pair.second.cpu.get());
+ accessor = snes._bus->getAccessor(0x004200);
+ cr_assert_eq(accessor.get(), snes.cpu.get());
}
Test(BusAccessor, GetCPUEnd)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x00421F);
- cr_assert_eq(accessor.get(), pair.second.cpu.get());
+ accessor = snes._bus->getAccessor(0x00421F);
+ cr_assert_eq(accessor.get(), snes.cpu.get());
}
Test(BusAccessor, GetPPU1Start)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x00213E);
- cr_assert_eq(accessor.get(), pair.second.ppu.get());
+ accessor = snes._bus->getAccessor(0x00213E);
+ cr_assert_eq(accessor.get(), snes.ppu.get());
}
Test(BusAccessor, GetPPU1End)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x00213F);
- cr_assert_eq(accessor.get(), pair.second.ppu.get());
+ accessor = snes._bus->getAccessor(0x00213F);
+ cr_assert_eq(accessor.get(), snes.ppu.get());
}
Test(BusAccessor, GetCPU)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x004212);
- cr_assert_eq(accessor.get(), pair.second.cpu.get());
+ accessor = snes._bus->getAccessor(0x004212);
+ cr_assert_eq(accessor.get(), snes.cpu.get());
}
Test(BusAccessor, GetPPU1Mirror)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x80213F));
- cr_assert_eq(accessor->_initial.get(), pair.second.ppu.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x80213F));
+ cr_assert_eq(accessor->_initial.get(), snes.ppu.get());
}
Test(BusAccessor, GetCPU2Mirror)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x804212));
- cr_assert_eq(accessor->_initial.get(), pair.second.cpu.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x804212));
+ cr_assert_eq(accessor->_initial.get(), snes.cpu.get());
}
Test(BusAccessor, GetRomStart)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0x808000);
- cr_assert_eq(accessor.get(), pair.second.cartridge.get());
+ accessor = snes._bus->getAccessor(0x808000);
+ cr_assert_eq(accessor.get(), snes.cartridge.get());
}
Test(BusAccessor, GetRomEnd)
{
- auto pair = Init();
- std::shared_ptr accessor = nullptr;
+ Init()
+ std::shared_ptr accessor = nullptr;
- accessor = pair.first->getAccessor(0xFFFFFF);
- cr_assert_eq(accessor.get(), pair.second.cartridge.get());
+ accessor = snes._bus->getAccessor(0xFFFFFF);
+ cr_assert_eq(accessor.get(), snes.cartridge.get());
}
Test(BusAccessor, GetRomMirror)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x694200));
- cr_assert_eq(accessor->_initial.get(), pair.second.cartridge.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x694200));
+ cr_assert_eq(accessor->_initial.get(), snes.cartridge.get());
}
Test(BusAccessor, GetRomMirror2)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x01FEDC));
- cr_assert_eq(accessor->_initial.get(), pair.second.cartridge.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x01FEDC));
+ cr_assert_eq(accessor->_initial.get(), snes.cartridge.get());
}
Test(BusAccessor, GetRomMirror3)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0xDE1248));
- cr_assert_eq(accessor->_initial.get(), pair.second.cartridge.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0xDE1248));
+ cr_assert_eq(accessor->_initial.get(), snes.cartridge.get());
}
Test(BusAccessor, Get0x0)
{
- auto pair = Init();
+ Init()
std::shared_ptr accessor = nullptr;
- accessor = std::static_pointer_cast(pair.first->getAccessor(0x0));
- cr_assert_eq(accessor->_initial.get(), pair.second.wram.get());
+ accessor = std::static_pointer_cast(snes._bus->getAccessor(0x0));
+ cr_assert_eq(accessor->_initial.get(), snes.wram.get());
}
///////////////////////////
@@ -278,132 +267,132 @@ Test(BusAccessor, Get0x0)
Test(BusRead, Read0x0)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.wram->_data[0] = 123;
- data = pair.first->read(0x0);
+ snes.wram->_data[0] = 123;
+ data = snes._bus->read(0x0);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadOutside, .init = cr_redirect_stdout)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.first->_openBus = 123;
- data = pair.first->read(0x002000);
+ snes._bus->_openBus = 123;
+ data = snes._bus->read(0x002000);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadOutside2, .init = cr_redirect_stdout)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.first->_openBus = 123;
- data = pair.first->read(0xBF2FFF);
+ snes._bus->_openBus = 123;
+ data = snes._bus->read(0xBF2FFF);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadOutside3, .init = cr_redirect_stdout)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.first->_openBus = 123;
- data = pair.first->read(0x127654);
+ snes._bus->_openBus = 123;
+ data = snes._bus->read(0x127654);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadAPU)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.apu->_registers.port0 = 123;
- data = pair.first->read(0x002140);
+ snes.apu->_registers.port0 = 123;
+ data = snes._bus->read(0x002140);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadROM)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.cartridge->_data[5] = 123;
- data = pair.first->read(0x808005);
+ snes.cartridge->_data[5] = 123;
+ data = snes._bus->read(0x808005);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadROMStart)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.cartridge->_data[0] = 123;
- data = pair.first->read(0x808000);
+ snes.cartridge->_data[0] = 123;
+ data = snes._bus->read(0x808000);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadCPU)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.cpu->_internalRegisters.wrio = 123;
- data = pair.first->read(0x004201);
+ snes.cpu->_internalRegisters.wrio = 123;
+ data = snes._bus->read(0x004201);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadPPU)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.ppu->mpy.mpyl = 123;
- data = pair.first->read(0x002134);
+ snes.ppu->mpy.mpyl = 123;
+ data = snes._bus->read(0x002134);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadSRAM)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.sram->_data[7] = 123;
- data = pair.first->read(0x700007);
+ snes.sram->_data[7] = 123;
+ data = snes._bus->read(0x700007);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadWRAM)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.wram->_data[3] = 123;
- data = pair.first->read(0x7E0003);
+ snes.wram->_data[3] = 123;
+ data = snes._bus->read(0x7E0003);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadWRAM2)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.wram->_data[0x1010] = 123;
- data = pair.first->read(0x7E1010);
+ snes.wram->_data[0x1010] = 123;
+ data = snes._bus->read(0x7E1010);
cr_assert_eq(data, 123);
}
Test(BusRead, ReadWRAMMirror)
{
- auto pair = Init();
+ Init()
uint8_t data;
- pair.second.wram->_data[0x1010] = 123;
- data = pair.first->read(0x1010);
+ snes.wram->_data[0x1010] = 123;
+ data = snes._bus->read(0x1010);
cr_assert_eq(data, 123);
}
@@ -415,60 +404,60 @@ Test(BusRead, ReadWRAMMirror)
Test(BusWrite, Write0x0)
{
- auto pair = Init();
+ Init()
try {
- pair.first->write(0x0, 123);
+ snes._bus->write(0x0, 123);
} catch (std::exception &ex) {
std::cout << ex.what() << std::endl;
}
- cr_assert_eq(pair.second.wram->_data[0], 123);
+ cr_assert_eq(snes.wram->_data[0], 123);
}
Test(BusWrite, WriteAPU)
{
- auto pair = Init();
+ Init()
- pair.first->write(0x002143, 123);
- cr_assert_eq(pair.second.apu->_registers.port3, 123);
+ snes._bus->write(0x002143, 123);
+ cr_assert_eq(snes.apu->_registers.port3, 123);
}
Test(BusWrite, WritePPU)
{
- auto pair = Init();
+ Init()
- pair.first->write(0x002106, 123);
- cr_assert_eq(pair.second.ppu->_mosaic.raw, 123);
+ snes._bus->write(0x002106, 123);
+ cr_assert_eq(snes.ppu->_mosaic.raw, 123);
}
Test(BusWrite, WriteCPU)
{
- auto pair = Init();
+ Init()
- pair.first->write(0x00420D, 123);
- cr_assert_eq(pair.second.cpu->_internalRegisters.memsel, 123);
+ snes._bus->write(0x00420D, 123);
+ cr_assert_eq(snes.cpu->_internalRegisters.memsel, 123);
}
Test(BusWrite, WriteROM)
{
- auto pair = Init();
+ Init()
- cr_assert_throw(pair.first->write(0x808005, 123), InvalidAction);
+ cr_assert_throw(snes._bus->write(0x808005, 123), InvalidAction);
}
Test(BusWrite, WriteWRAM)
{
- auto pair = Init();
+ Init()
- pair.first->write(0x7E0002, 123);
- cr_assert_eq(pair.second.wram->_data[2], 123);
+ snes._bus->write(0x7E0002, 123);
+ cr_assert_eq(snes.wram->_data[2], 123);
}
Test(BusWrite, WriteSRAM)
{
- auto pair = Init();
+ Init()
- pair.first->write(0x700009, 123);
- cr_assert_eq(pair.second.sram->_data[9], 123);
+ snes._bus->write(0x700009, 123);
+ cr_assert_eq(snes.sram->_data[9], 123);
}
\ No newline at end of file
diff --git a/tests/tests.cpp b/tests/tests.cpp
deleted file mode 100644
index 5864663..0000000
--- a/tests/tests.cpp
+++ /dev/null
@@ -1,24 +0,0 @@
-//
-// Created by anonymus-raccoon on 2/10/20.
-//
-
-#include
-#include
-#include
-#include "tests.hpp"
-#include "../sources/Renderer/NoRenderer.hpp"
-#include "../sources/SNES.hpp"
-
-using namespace ComSquare;
-
-std::pair, SNES> Init()
-{
- Renderer::NoRenderer norenderer(0, 0, 0);
- SNES snes("../tests/my_cartridge", norenderer);
- snes.cartridge->_size = 100;
- snes.cartridge->_data = new uint8_t[snes.cartridge->_size];
- snes.cartridge->header.mappingMode = Cartridge::LoRom;
- snes.sram->_size = 100;
- snes.sram->_data = new uint8_t[snes.cartridge->_size];
- return std::make_pair(snes._bus, snes);
-}
\ No newline at end of file
diff --git a/tests/tests.hpp b/tests/tests.hpp
index 3c33198..b37f81a 100644
--- a/tests/tests.hpp
+++ b/tests/tests.hpp
@@ -10,6 +10,20 @@
#define class struct
#include "../sources/Memory/MemoryBus.hpp"
-std::pair, ComSquare::SNES> Init();
+#include
+#include
+#include
+#include "tests.hpp"
+#include "../sources/Renderer/NoRenderer.hpp"
+#include "../sources/SNES.hpp"
+
+#define Init() \
+ Renderer::NoRenderer norenderer(0, 0, 0); \
+ SNES snes("../tests/my_cartridge", norenderer); \
+ snes.cartridge->_size = 100; \
+ snes.cartridge->_data = new uint8_t[snes.cartridge->_size]; \
+ snes.cartridge->header.mappingMode = Cartridge::LoRom; \
+ snes.sram->_size = 100; \
+ snes.sram->_data = new uint8_t[snes.cartridge->_size];
#endif //COMSQUARE_TESTS_HPP
diff --git a/ui/busView.ui b/ui/busView.ui
index 2b700d8..5185e76 100644
--- a/ui/busView.ui
+++ b/ui/busView.ui
@@ -11,363 +11,378 @@
- MainWindow
+ Memory Bus Logger
+
+
+
+ :/resources/Logo.png:/resources/Logo.png
-
-
-
- 0
- 0
- 901
- 621
-
-
-
- Qt::Horizontal
-
-
-
-
- QFrame::StyledPanel
-
-
- QFrame::Sunken
-
-
- 3
-
-
- 2
-
-
- -
-
-
- Filters
-
-
-
-
-
-
- Read from
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- false
-
-
-
-
-
-
- CPU
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- APU
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- PPU
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- ROM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- WRAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- SRAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- VRAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- OAM RAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- CG RAM
-
-
-
- -
-
-
- true
-
-
-
-
-
-
- -
-
-
- Write to
-
-
- Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
-
-
- false
-
-
-
-
-
-
- CPU
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- APU
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- PPU
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- ROM
-
-
-
- -
-
-
- false
-
-
- true
-
-
- false
-
-
- false
-
-
-
- -
-
-
- WRAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- SRAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- VRAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- OAM RAM
-
-
-
- -
-
-
- true
-
-
-
- -
-
-
- CG RAM
-
-
-
- -
-
-
- true
-
-
-
-
-
-
-
-
-
- -
-
-
-
-
-
-
-
-
-
- Clear
-
-
- false
-
-
-
- -
-
-
-
-
-
-
-
-
+
+ -
+
+
+
+ 0
+ 0
+
+
+
+ Qt::Horizontal
+
+
+
+
+ 1
+ 0
+
+
+
+
+
+ QFrame::StyledPanel
+
+
+ QFrame::Sunken
+
+
+ 3
+
+
+ 2
+
+
+
-
+
+
+ Filters
+
+
+
-
+
+
+ Read from
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+ false
+
+
+
-
+
+
+ CPU
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ APU
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ PPU
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ ROM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ WRAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ SRAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ VRAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ OAM RAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ CG RAM
+
+
+
+ -
+
+
+ true
+
+
+
+
+
+
+ -
+
+
+ Write to
+
+
+ Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter
+
+
+ false
+
+
+
-
+
+
+ CPU
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ APU
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ PPU
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ ROM
+
+
+
+ -
+
+
+ false
+
+
+ true
+
+
+ false
+
+
+ false
+
+
+
+ -
+
+
+ WRAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ SRAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ VRAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ OAM RAM
+
+
+
+ -
+
+
+ true
+
+
+
+ -
+
+
+ CG RAM
+
+
+
+ -
+
+
+ true
+
+
+
+
+
+
+
+
+
+ -
+
+
+
+
+
+
-
+
+
+ Clear
+
+
+ false
+
+
+
+ -
+
+
+
+
+
+
+
+
+
+
-
+
+
+