mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 14:15:11 +00:00
Fixing unit tests compilation
This commit is contained in:
@@ -19,11 +19,6 @@ namespace ComSquare::APU
|
|||||||
this->reset();
|
this->reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool APU::isDebugger() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string APU::getName() const
|
std::string APU::getName() const
|
||||||
{
|
{
|
||||||
return "APU";
|
return "APU";
|
||||||
|
|||||||
@@ -2,16 +2,15 @@
|
|||||||
// Created by Melefo on 24/01/2020.
|
// Created by Melefo on 24/01/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef COMSQUARE_APU_HPP
|
#pragma once
|
||||||
#define COMSQUARE_APU_HPP
|
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
#include "DSP/DSP.hpp"
|
#include "DSP/DSP.hpp"
|
||||||
#include "../Memory/AMemory.hpp"
|
#include "Memory/AMemory.hpp"
|
||||||
#include "../Ram/Ram.hpp"
|
#include "Ram/Ram.hpp"
|
||||||
#include "IPL/IPL.hpp"
|
#include "IPL/IPL.hpp"
|
||||||
#include "../Renderer/IRenderer.hpp"
|
#include "Renderer/IRenderer.hpp"
|
||||||
#include "../Cartridge/Cartridge.hpp"
|
#include "Cartridge/Cartridge.hpp"
|
||||||
|
|
||||||
namespace ComSquare::APU
|
namespace ComSquare::APU
|
||||||
{
|
{
|
||||||
@@ -154,7 +153,7 @@ namespace ComSquare::APU
|
|||||||
//! @param addr The address to read from. The address 0x0000 should refer to the first byte of the register.
|
//! @param addr The address to read from. The address 0x0000 should refer to the first byte of the register.
|
||||||
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
|
||||||
//! @return Return the data.
|
//! @return Return the data.
|
||||||
uint8_t _internalRead(uint24_t addr) const;
|
[[nodiscard]] uint8_t _internalRead(uint24_t addr) const;
|
||||||
|
|
||||||
//! @brief Write data to the APU ram.
|
//! @brief Write data to the APU ram.
|
||||||
//! @param addr The address to write to. The address 0x0000 should refer to the first byte of register.
|
//! @param addr The address to write to. The address 0x0000 should refer to the first byte of register.
|
||||||
@@ -369,7 +368,7 @@ namespace ComSquare::APU
|
|||||||
public:
|
public:
|
||||||
explicit APU(Renderer::IRenderer &renderer);
|
explicit APU(Renderer::IRenderer &renderer);
|
||||||
APU(const APU &) = default;
|
APU(const APU &) = default;
|
||||||
APU &operator=(const APU &) = default;
|
APU &operator=(const APU &) = delete;
|
||||||
~APU() override = default;
|
~APU() override = default;
|
||||||
|
|
||||||
//! @brief Read from the APU ram.
|
//! @brief Read from the APU ram.
|
||||||
@@ -385,10 +384,10 @@ namespace ComSquare::APU
|
|||||||
void write(uint24_t addr, uint8_t data) override;
|
void write(uint24_t addr, uint8_t data) override;
|
||||||
|
|
||||||
//! @brief Get the name of this accessor (used for debug purpose)
|
//! @brief Get the name of this accessor (used for debug purpose)
|
||||||
std::string getName() const override;
|
[[nodiscard]] std::string getName() const override;
|
||||||
|
|
||||||
//! @brief Get the component of this accessor (used for debug purpose)
|
//! @brief Get the component of this accessor (used for debug purpose)
|
||||||
Component getComponent() const override;
|
[[nodiscard]] Component getComponent() const override;
|
||||||
|
|
||||||
//! @brief Get the name of the data at the address
|
//! @brief Get the name of the data at the address
|
||||||
//! @param addr The address (in local space)
|
//! @param addr The address (in local space)
|
||||||
@@ -396,7 +395,7 @@ namespace ComSquare::APU
|
|||||||
|
|
||||||
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
//! @brief Get the size of the data. This size can be lower than the mapped data.
|
||||||
//! @return The number of bytes inside this memory.
|
//! @return The number of bytes inside this memory.
|
||||||
uint24_t getSize() const override;
|
[[nodiscard]] uint24_t getSize() const override;
|
||||||
|
|
||||||
//! @brief Parses rom data to uploads directly into RAM and corresponding registers
|
//! @brief Parses rom data to uploads directly into RAM and corresponding registers
|
||||||
void loadFromSPC(Cartridge::Cartridge &cartridge);
|
void loadFromSPC(Cartridge::Cartridge &cartridge);
|
||||||
@@ -407,10 +406,5 @@ namespace ComSquare::APU
|
|||||||
|
|
||||||
//! @brief This function is executed when the SNES is powered on or the reset button is pushed.
|
//! @brief This function is executed when the SNES is powered on or the reset button is pushed.
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
|
||||||
virtual bool isDebugger() const;
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //COMSQUARE_APU_HPP
|
|
||||||
|
|||||||
@@ -10,16 +10,12 @@ using namespace ComSquare::APU;
|
|||||||
|
|
||||||
namespace ComSquare::Debugger
|
namespace ComSquare::Debugger
|
||||||
{
|
{
|
||||||
APUDebug::APUDebug(APU &apu, SNES &snes) :
|
APUDebug::APUDebug(APU &apu, SNES &snes)
|
||||||
APU(apu),
|
: APU(apu),
|
||||||
_window(new ClosableWindow<APUDebug>(*this, &APUDebug::disableDebugger)),
|
_window(new ClosableWindow([&snes] { snes.disableAPUDebugging(); })),
|
||||||
_ui(),
|
_ui(),
|
||||||
_snes(snes)
|
_snes(snes)
|
||||||
{
|
{
|
||||||
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.setupUi(this->_window);
|
||||||
QMainWindow::connect(this->_ui.resumeButton, &QPushButton::clicked, this, &APUDebug::pause);
|
QMainWindow::connect(this->_ui.resumeButton, &QPushButton::clicked, this, &APUDebug::pause);
|
||||||
QMainWindow::connect(this->_ui.stepButton, &QPushButton::clicked, this, &APUDebug::step);
|
QMainWindow::connect(this->_ui.stepButton, &QPushButton::clicked, this, &APUDebug::step);
|
||||||
@@ -396,17 +392,6 @@ namespace ComSquare::Debugger
|
|||||||
this->_ui.resumeButton->setText("Pause");
|
this->_ui.resumeButton->setText("Pause");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void APUDebug::disableDebugger()
|
|
||||||
{
|
|
||||||
this->_snes.disableAPUDebugging();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool APUDebug::isDebugger() const
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void APUDebug::focus()
|
void APUDebug::focus()
|
||||||
{
|
{
|
||||||
this->_window->activateWindow();
|
this->_window->activateWindow();
|
||||||
|
|||||||
@@ -2,12 +2,11 @@
|
|||||||
// Created by Melefo on 19/02/2020.
|
// Created by Melefo on 19/02/2020.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef COMSQUARE_APUDEBUG_HPP
|
#pragma once
|
||||||
#define COMSQUARE_APUDEBUG_HPP
|
|
||||||
|
|
||||||
#include "../APU/APU.hpp"
|
#include "APU/APU.hpp"
|
||||||
#include "../SNES.hpp"
|
#include "SNES.hpp"
|
||||||
#include "../../ui/ui_apuView.h"
|
#include "ui/ui_apuView.h"
|
||||||
|
|
||||||
namespace ComSquare::Debugger
|
namespace ComSquare::Debugger
|
||||||
{
|
{
|
||||||
@@ -43,11 +42,11 @@ namespace ComSquare::Debugger
|
|||||||
std::tuple<Operand, Operand> operands;
|
std::tuple<Operand, Operand> operands;
|
||||||
};
|
};
|
||||||
|
|
||||||
class APUDebug : public APU::APU, public QObject
|
class APUDebug : public QObject
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
//! @brief List of instructions and their information
|
//! @brief List of instructions and their information
|
||||||
std::array<Instruction, 0x100> _instructions {{
|
const std::array<Instruction, 0x100> _instructions {{
|
||||||
{"NOP", 1, {None, None}},
|
{"NOP", 1, {None, None}},
|
||||||
{"TCALL", 1, {None, None}},
|
{"TCALL", 1, {None, None}},
|
||||||
{"SET1", 2, {DirectAddr, None}},
|
{"SET1", 2, {DirectAddr, None}},
|
||||||
@@ -313,7 +312,7 @@ namespace ComSquare::Debugger
|
|||||||
int _appendInstruction(int row);
|
int _appendInstruction(int row);
|
||||||
|
|
||||||
//! @brief The QT window for this debugger.
|
//! @brief The QT window for this debugger.
|
||||||
ClosableWindow<APUDebug> *_window;
|
ClosableWindow *_window;
|
||||||
|
|
||||||
//! @brief A widget that contain the whole UI.
|
//! @brief A widget that contain the whole UI.
|
||||||
Ui::APUView _ui;
|
Ui::APUView _ui;
|
||||||
@@ -358,12 +357,7 @@ namespace ComSquare::Debugger
|
|||||||
//! @brief Override the apu's update to disable debugging.
|
//! @brief Override the apu's update to disable debugging.
|
||||||
void update(unsigned cycles) override;
|
void update(unsigned cycles) override;
|
||||||
|
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
|
||||||
bool isDebugger() const override;
|
|
||||||
|
|
||||||
//! @brief Focus the debugger's window.
|
//! @brief Focus the debugger's window.
|
||||||
void focus();
|
void focus();
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //COMSQUARE_APUDEBUG_HPP
|
|
||||||
@@ -470,11 +470,6 @@ namespace ComSquare::PPU
|
|||||||
return Ppu;
|
return Ppu;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PPU::isDebugger() const
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint16_t PPU::cgramRead(uint16_t addr)
|
uint16_t PPU::cgramRead(uint16_t addr)
|
||||||
{
|
{
|
||||||
return this->cgram.read(addr);
|
return this->cgram.read(addr);
|
||||||
|
|||||||
@@ -607,8 +607,6 @@ namespace ComSquare::PPU
|
|||||||
uint16_t getVramAddress() const;
|
uint16_t getVramAddress() const;
|
||||||
//! @brief Give the name of the Address register (used for debug)
|
//! @brief Give the name of the Address register (used for debug)
|
||||||
std::string getValueName(uint24_t addr) const;
|
std::string getValueName(uint24_t addr) const;
|
||||||
//! @brief Return true if the CPU is overloaded with debugging features.
|
|
||||||
virtual bool isDebugger() const;
|
|
||||||
//! @brief Allow others components to read the CGRAM
|
//! @brief Allow others components to read the CGRAM
|
||||||
uint16_t cgramRead(uint16_t addr);
|
uint16_t cgramRead(uint16_t addr);
|
||||||
//! @brief get the bpp depending of the bgNumber and the Bgmode
|
//! @brief get the bpp depending of the bgNumber and the Bgmode
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ namespace ComSquare::Renderer
|
|||||||
|
|
||||||
void QtFullSFML::enableDebugAPU()
|
void QtFullSFML::enableDebugAPU()
|
||||||
{
|
{
|
||||||
// this->_snes.enableAPUDebugging();
|
this->_snes.enableAPUDebugging();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtFullSFML::enableDebugBus()
|
void QtFullSFML::enableDebugBus()
|
||||||
|
|||||||
@@ -101,21 +101,21 @@ namespace ComSquare
|
|||||||
this->_headerViewer = std::nullopt;
|
this->_headerViewer = std::nullopt;
|
||||||
}
|
}
|
||||||
|
|
||||||
// void SNES::enableAPUDebugging()
|
void SNES::enableAPUDebugging()
|
||||||
// {
|
{
|
||||||
// if (this->apu->isDebugger())
|
// if (this->apu->isDebugger())
|
||||||
// std::static_pointer_cast<Debugger::APUDebug>(this->apu)->focus();
|
// std::static_pointer_cast<Debugger::APUDebug>(this->apu)->focus();
|
||||||
// else {
|
// else {
|
||||||
// this->apu = std::make_shared<Debugger::APUDebug>(*this->apu, *this);
|
// this->apu = std::make_shared<Debugger::APUDebug>(*this->apu, *this);
|
||||||
// this->bus.mapComponents(*this);
|
// this->bus.mapComponents(*this);
|
||||||
// }
|
// }
|
||||||
// }
|
}
|
||||||
//
|
|
||||||
// void SNES::disableAPUDebugging()
|
void SNES::disableAPUDebugging()
|
||||||
// {
|
{
|
||||||
// this->apu = std::make_shared<APU::APU>(*this->apu);
|
// this->apu = std::make_shared<APU::APU>(*this->apu);
|
||||||
// this->bus.mapComponents(*this);
|
// this->bus.mapComponents(*this);
|
||||||
// }
|
}
|
||||||
|
|
||||||
void SNES::enableMemoryBusDebugging()
|
void SNES::enableMemoryBusDebugging()
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,10 +102,10 @@ namespace ComSquare
|
|||||||
void disableHeaderViewer();
|
void disableHeaderViewer();
|
||||||
//! @brief Enable the Header's debugging window.
|
//! @brief Enable the Header's debugging window.
|
||||||
void enableHeaderViewer();
|
void enableHeaderViewer();
|
||||||
// //! @brief Disable the APU's debugging window.
|
//! @brief Disable the APU's debugging window.
|
||||||
// void disableAPUDebugging();
|
void disableAPUDebugging();
|
||||||
// //! @brief Enable the APU's debugging window.
|
//! @brief Enable the APU's debugging window.
|
||||||
// void enableAPUDebugging();
|
void enableAPUDebugging();
|
||||||
//! @brief Disable the Memory Bus's debugging window.
|
//! @brief Disable the Memory Bus's debugging window.
|
||||||
void disableMemoryBusDebugging();
|
void disableMemoryBusDebugging();
|
||||||
//! @brief Enable the Memory Bus's debugging window.
|
//! @brief Enable the Memory Bus's debugging window.
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ TEST_CASE("RomToVRAM DMA", "[DMA]")
|
|||||||
REQUIRE(snes.cpu._dmaChannels[0]._port == 0x18);
|
REQUIRE(snes.cpu._dmaChannels[0]._port == 0x18);
|
||||||
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2400);
|
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2400);
|
||||||
for(unsigned i = 0; i < 0x400; i++) {
|
for(unsigned i = 0; i < 0x400; i++) {
|
||||||
uint16_t value = snes.ppu.vram->_data[0x2000 * 2 + i * 2] | (snes.ppu.vram->_data[0x2000 * 2 + i * 2 + 1] << 8);
|
uint16_t value = snes.ppu.vram._data[0x2000 * 2 + i * 2] | (snes.ppu.vram._data[0x2000 * 2 + i * 2 + 1] << 8);
|
||||||
REQUIRE(value == i);
|
REQUIRE(value == i);
|
||||||
}
|
}
|
||||||
REQUIRE(snes.cpu._dmaChannels[0].enabled == false);
|
REQUIRE(snes.cpu._dmaChannels[0].enabled == false);
|
||||||
@@ -69,7 +69,7 @@ TEST_CASE("VramWrite DMA", "[DMA]")
|
|||||||
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2001 + i);
|
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2001 + i);
|
||||||
}
|
}
|
||||||
for(unsigned i = 0; i < 0x400; i++) {
|
for(unsigned i = 0; i < 0x400; i++) {
|
||||||
uint16_t value = snes.ppu.vram->_data[0x2000 * 2 + i * 2] | (snes.ppu.vram->_data[0x2000 * 2 + i * 2 + 1] << 8);
|
uint16_t value = snes.ppu.vram._data[0x2000 * 2 + i * 2] | (snes.ppu.vram._data[0x2000 * 2 + i * 2 + 1] << 8);
|
||||||
REQUIRE(value == (uint16_t)i);
|
REQUIRE(value == (uint16_t)i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -86,7 +86,7 @@ TEST_CASE("VramWriteInvertedOrder DMA", "[DMA]")
|
|||||||
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2001 + i);
|
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2001 + i);
|
||||||
}
|
}
|
||||||
for(unsigned i = 0; i < 0x400; i++) {
|
for(unsigned i = 0; i < 0x400; i++) {
|
||||||
uint16_t value = snes.ppu.vram->_data[0x2000 * 2 + i * 2] | (snes.ppu.vram->_data[0x2000 * 2 + i * 2 + 1] << 8);
|
uint16_t value = snes.ppu.vram._data[0x2000 * 2 + i * 2] | (snes.ppu.vram._data[0x2000 * 2 + i * 2 + 1] << 8);
|
||||||
REQUIRE(value == (uint16_t)i);
|
REQUIRE(value == (uint16_t)i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +133,7 @@ TEST_CASE("WRamToVRAM DMA", "[DMA]")
|
|||||||
REQUIRE(snes.cpu._dmaChannels[0]._port == 0x18);
|
REQUIRE(snes.cpu._dmaChannels[0]._port == 0x18);
|
||||||
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x0400);
|
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x0400);
|
||||||
for(unsigned i = 0; i < 0x400; i++) {
|
for(unsigned i = 0; i < 0x400; i++) {
|
||||||
uint16_t value = snes.ppu.vram->_data[i * 2] | (snes.ppu.vram->_data[i * 2 + 1] << 8);
|
uint16_t value = snes.ppu.vram._data[i * 2] | (snes.ppu.vram._data[i * 2 + 1] << 8);
|
||||||
REQUIRE(value == i);
|
REQUIRE(value == i);
|
||||||
}
|
}
|
||||||
REQUIRE(snes.cpu._dmaChannels[0].enabled == false);
|
REQUIRE(snes.cpu._dmaChannels[0].enabled == false);
|
||||||
|
|||||||
@@ -64,8 +64,8 @@ TEST_CASE("vmadd_full_data_check_ram PPU_write_2", "[PPU_write_2]")
|
|||||||
snes.bus.write(0x2118, 0xFF);
|
snes.bus.write(0x2118, 0xFF);
|
||||||
snes.bus.write(0x2119, 0xFF);
|
snes.bus.write(0x2119, 0xFF);
|
||||||
REQUIRE(snes.ppu._registers._vmadd.vmadd == 3);
|
REQUIRE(snes.ppu._registers._vmadd.vmadd == 3);
|
||||||
REQUIRE(snes.ppu.vram->read(4) == 0xFF);
|
REQUIRE(snes.ppu.vram.read(4) == 0xFF);
|
||||||
REQUIRE(snes.ppu.vram->read(5) == 0xF);
|
REQUIRE(snes.ppu.vram.read(5) == 0xF);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("vmadd_full_high_byte_null PPU_write_2", "[PPU_write_2]")
|
TEST_CASE("vmadd_full_high_byte_null PPU_write_2", "[PPU_write_2]")
|
||||||
|
|||||||
Reference in New Issue
Block a user