Fixing unit tests compilation

This commit is contained in:
Zoe Roux
2021-07-05 20:46:48 +02:00
parent cb6fb8a240
commit 6693c30df2
11 changed files with 81 additions and 120 deletions

View File

@@ -19,11 +19,6 @@ namespace ComSquare::APU
this->reset();
}
bool APU::isDebugger() const
{
return false;
}
std::string APU::getName() const
{
return "APU";

View File

@@ -2,16 +2,15 @@
// Created by Melefo on 24/01/2020.
//
#ifndef COMSQUARE_APU_HPP
#define COMSQUARE_APU_HPP
#pragma once
#include <memory>
#include "DSP/DSP.hpp"
#include "../Memory/AMemory.hpp"
#include "../Ram/Ram.hpp"
#include "Memory/AMemory.hpp"
#include "Ram/Ram.hpp"
#include "IPL/IPL.hpp"
#include "../Renderer/IRenderer.hpp"
#include "../Cartridge/Cartridge.hpp"
#include "Renderer/IRenderer.hpp"
#include "Cartridge/Cartridge.hpp"
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.
//! @throw InvalidAddress will be thrown if the address is more than $FFFF (the number of register).
//! @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.
//! @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:
explicit APU(Renderer::IRenderer &renderer);
APU(const APU &) = default;
APU &operator=(const APU &) = default;
APU &operator=(const APU &) = delete;
~APU() override = default;
//! @brief Read from the APU ram.
@@ -385,10 +384,10 @@ namespace ComSquare::APU
void write(uint24_t addr, uint8_t data) override;
//! @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)
Component getComponent() const override;
[[nodiscard]] Component getComponent() const override;
//! @brief Get the name of the data at the address
//! @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.
//! @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
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.
void reset();
//! @brief Return true if the CPU is overloaded with debugging features.
virtual bool isDebugger() const;
};
}
#endif //COMSQUARE_APU_HPP

View File

@@ -10,16 +10,12 @@ using namespace ComSquare::APU;
namespace ComSquare::Debugger
{
APUDebug::APUDebug(APU &apu, SNES &snes) :
APU(apu),
_window(new ClosableWindow<APUDebug>(*this, &APUDebug::disableDebugger)),
APUDebug::APUDebug(APU &apu, SNES &snes)
: APU(apu),
_window(new ClosableWindow([&snes] { snes.disableAPUDebugging(); })),
_ui(),
_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);
QMainWindow::connect(this->_ui.resumeButton, &QPushButton::clicked, this, &APUDebug::pause);
QMainWindow::connect(this->_ui.stepButton, &QPushButton::clicked, this, &APUDebug::step);
@@ -396,17 +392,6 @@ namespace ComSquare::Debugger
this->_ui.resumeButton->setText("Pause");
}
void APUDebug::disableDebugger()
{
this->_snes.disableAPUDebugging();
}
bool APUDebug::isDebugger() const
{
return true;
}
void APUDebug::focus()
{
this->_window->activateWindow();

View File

@@ -2,12 +2,11 @@
// Created by Melefo on 19/02/2020.
//
#ifndef COMSQUARE_APUDEBUG_HPP
#define COMSQUARE_APUDEBUG_HPP
#pragma once
#include "../APU/APU.hpp"
#include "../SNES.hpp"
#include "../../ui/ui_apuView.h"
#include "APU/APU.hpp"
#include "SNES.hpp"
#include "ui/ui_apuView.h"
namespace ComSquare::Debugger
{
@@ -43,11 +42,11 @@ namespace ComSquare::Debugger
std::tuple<Operand, Operand> operands;
};
class APUDebug : public APU::APU, public QObject
class APUDebug : public QObject
{
private:
//! @brief List of instructions and their information
std::array<Instruction, 0x100> _instructions {{
const std::array<Instruction, 0x100> _instructions {{
{"NOP", 1, {None, None}},
{"TCALL", 1, {None, None}},
{"SET1", 2, {DirectAddr, None}},
@@ -313,7 +312,7 @@ namespace ComSquare::Debugger
int _appendInstruction(int row);
//! @brief The QT window for this debugger.
ClosableWindow<APUDebug> *_window;
ClosableWindow *_window;
//! @brief A widget that contain the whole UI.
Ui::APUView _ui;
@@ -358,12 +357,7 @@ namespace ComSquare::Debugger
//! @brief Override the apu's update to disable debugging.
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.
void focus();
};
}
#endif //COMSQUARE_APUDEBUG_HPP

View File

@@ -470,11 +470,6 @@ namespace ComSquare::PPU
return Ppu;
}
bool PPU::isDebugger() const
{
return false;
}
uint16_t PPU::cgramRead(uint16_t addr)
{
return this->cgram.read(addr);

View File

@@ -607,8 +607,6 @@ namespace ComSquare::PPU
uint16_t getVramAddress() const;
//! @brief Give the name of the Address register (used for debug)
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
uint16_t cgramRead(uint16_t addr);
//! @brief get the bpp depending of the bgNumber and the Bgmode

View File

@@ -90,7 +90,7 @@ namespace ComSquare::Renderer
void QtFullSFML::enableDebugAPU()
{
// this->_snes.enableAPUDebugging();
this->_snes.enableAPUDebugging();
}
void QtFullSFML::enableDebugBus()

View File

@@ -101,21 +101,21 @@ namespace ComSquare
this->_headerViewer = std::nullopt;
}
// void SNES::enableAPUDebugging()
// {
void SNES::enableAPUDebugging()
{
// if (this->apu->isDebugger())
// std::static_pointer_cast<Debugger::APUDebug>(this->apu)->focus();
// else {
// this->apu = std::make_shared<Debugger::APUDebug>(*this->apu, *this);
// this->bus.mapComponents(*this);
// }
// }
//
// void SNES::disableAPUDebugging()
// {
}
void SNES::disableAPUDebugging()
{
// this->apu = std::make_shared<APU::APU>(*this->apu);
// this->bus.mapComponents(*this);
// }
}
void SNES::enableMemoryBusDebugging()
{

View File

@@ -102,10 +102,10 @@ namespace ComSquare
void disableHeaderViewer();
//! @brief Enable the Header's debugging window.
void enableHeaderViewer();
// //! @brief Disable the APU's debugging window.
// void disableAPUDebugging();
// //! @brief Enable the APU's debugging window.
// void enableAPUDebugging();
//! @brief Disable the APU's debugging window.
void disableAPUDebugging();
//! @brief Enable the APU's debugging window.
void enableAPUDebugging();
//! @brief Disable the Memory Bus's debugging window.
void disableMemoryBusDebugging();
//! @brief Enable the Memory Bus's debugging window.

View File

@@ -52,7 +52,7 @@ TEST_CASE("RomToVRAM DMA", "[DMA]")
REQUIRE(snes.cpu._dmaChannels[0]._port == 0x18);
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2400);
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(snes.cpu._dmaChannels[0].enabled == false);
@@ -69,7 +69,7 @@ TEST_CASE("VramWrite DMA", "[DMA]")
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2001 + 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);
}
}
@@ -86,7 +86,7 @@ TEST_CASE("VramWriteInvertedOrder DMA", "[DMA]")
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x2001 + 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);
}
}
@@ -133,7 +133,7 @@ TEST_CASE("WRamToVRAM DMA", "[DMA]")
REQUIRE(snes.cpu._dmaChannels[0]._port == 0x18);
REQUIRE(snes.ppu._registers._vmadd.vmadd == 0x0400);
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(snes.cpu._dmaChannels[0].enabled == false);

View File

@@ -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(0x2119, 0xFF);
REQUIRE(snes.ppu._registers._vmadd.vmadd == 3);
REQUIRE(snes.ppu.vram->read(4) == 0xFF);
REQUIRE(snes.ppu.vram->read(5) == 0xF);
REQUIRE(snes.ppu.vram.read(4) == 0xFF);
REQUIRE(snes.ppu.vram.read(5) == 0xF);
}
TEST_CASE("vmadd_full_high_byte_null PPU_write_2", "[PPU_write_2]")