mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-09 04:24:58 +00:00
Making the debugger available on demand with a macro
This commit is contained in:
+7
-1
@@ -121,7 +121,13 @@ add_executable(ComSquare
|
|||||||
sources/Ram/ExtendedRam.hpp
|
sources/Ram/ExtendedRam.hpp
|
||||||
sources/Debugger/DebugCpu.cpp
|
sources/Debugger/DebugCpu.cpp
|
||||||
sources/Debugger/DebugCpu.hpp
|
sources/Debugger/DebugCpu.hpp
|
||||||
sources/Renderer/QtRenderer/QtSFML.cpp sources/Renderer/QtRenderer/QtSFML.h sources/Renderer/QtRenderer/QtWidgetSFML.cpp sources/Renderer/QtRenderer/QtWidgetSFML.h)
|
sources/Renderer/QtRenderer/QtSFML.cpp
|
||||||
|
sources/Renderer/QtRenderer/QtSFML.hpp
|
||||||
|
sources/Renderer/QtRenderer/QtWidgetSFML.cpp
|
||||||
|
sources/Renderer/QtRenderer/QtWidgetSFML.hpp
|
||||||
|
)
|
||||||
|
|
||||||
|
target_compile_definitions(ComSquare PUBLIC DEBUGGER_ENABLED)
|
||||||
|
|
||||||
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
find_package(Qt5 COMPONENTS Widgets REQUIRED)
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <QtWidgets/QFrame>
|
#include <QtWidgets/QFrame>
|
||||||
#include "sources/SNES.hpp"
|
#include "sources/SNES.hpp"
|
||||||
#include "sources/Renderer/SFRenderer.hpp"
|
#include "sources/Renderer/SFRenderer.hpp"
|
||||||
#include "sources/Renderer/QtRenderer/QtSFML.h"
|
#include "sources/Renderer/QtRenderer/QtSFML.hpp"
|
||||||
|
|
||||||
using namespace ComSquare;
|
using namespace ComSquare;
|
||||||
|
|
||||||
@@ -22,6 +22,6 @@ int main(int argc, char **argv)
|
|||||||
Renderer::QtSFML renderer(app, 600, 800);
|
Renderer::QtSFML renderer(app, 600, 800);
|
||||||
SNES snes(std::make_shared<Memory::MemoryBus>(), argv[1], renderer);
|
SNES snes(std::make_shared<Memory::MemoryBus>(), argv[1], renderer);
|
||||||
renderer.createWindow(snes, 60);
|
renderer.createWindow(snes, 60);
|
||||||
snes.enableCPUDebugging();
|
//snes.enableCPUDebugging();
|
||||||
return QApplication::exec();
|
return QApplication::exec();
|
||||||
}
|
}
|
||||||
+42
-22
@@ -3,6 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
|
#include <bitset>
|
||||||
#include "PPU.hpp"
|
#include "PPU.hpp"
|
||||||
#include "../Exceptions/NotImplementedException.hpp"
|
#include "../Exceptions/NotImplementedException.hpp"
|
||||||
#include "../Exceptions/InvalidAddress.hpp"
|
#include "../Exceptions/InvalidAddress.hpp"
|
||||||
@@ -40,7 +41,7 @@ namespace ComSquare::PPU
|
|||||||
break;
|
break;
|
||||||
case ppuRegisters::oamdata:
|
case ppuRegisters::oamdata:
|
||||||
this->_oamdata = data;
|
this->_oamdata = data;
|
||||||
throw InvalidAddress("oamdata", addr);
|
//throw InvalidAddress("oamdata", addr);
|
||||||
std::cout << "oamdata" << std::endl;
|
std::cout << "oamdata" << std::endl;
|
||||||
// the oamAddress have to be calculated if fblank or not (not implemented)
|
// the oamAddress have to be calculated if fblank or not (not implemented)
|
||||||
_oamram.write(this->_oamadd.oamAddress, this->_oamdata);
|
_oamram.write(this->_oamadd.oamAddress, this->_oamdata);
|
||||||
@@ -88,6 +89,7 @@ namespace ComSquare::PPU
|
|||||||
case 0b11:
|
case 0b11:
|
||||||
this->_incrementAmount = 128;
|
this->_incrementAmount = 128;
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case ppuRegisters::vmaddl:
|
case ppuRegisters::vmaddl:
|
||||||
this->_vmadd.vmaddl = data;
|
this->_vmadd.vmaddl = data;
|
||||||
break;
|
break;
|
||||||
@@ -95,7 +97,7 @@ namespace ComSquare::PPU
|
|||||||
this->_vmadd.vmaddh = data;
|
this->_vmadd.vmaddh = data;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::vmdatal:
|
case ppuRegisters::vmdatal:
|
||||||
throw InvalidAddress("vmdata", addr);
|
//throw InvalidAddress("vmdata", addr);
|
||||||
std::cout << "vmdatal" << std::endl;
|
std::cout << "vmdatal" << std::endl;
|
||||||
if (!this->_inidisp.fblank) {
|
if (!this->_inidisp.fblank) {
|
||||||
this->_vmdata.vmdatal = data;
|
this->_vmdata.vmdatal = data;
|
||||||
@@ -121,19 +123,20 @@ namespace ComSquare::PPU
|
|||||||
this->_isLowByte = true;
|
this->_isLowByte = true;
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::cgdata:
|
case ppuRegisters::cgdata:
|
||||||
throw InvalidAddress("cgdata", addr);
|
//throw InvalidAddress("cgdata", addr);
|
||||||
if (this->_isLowByte) {
|
if (this->_isLowByte) {
|
||||||
std::cout << "cgadatal" << std::endl;
|
//std::cout << "cgadatal" << std::endl;
|
||||||
this->_cgdata.cgdatal = data;
|
this->_cgdata.cgdatal = data;
|
||||||
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
//this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
||||||
|
//this->_cgadd++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
std::cout << "cgadatah" << std::endl;
|
//std::cout << "cgadatah" << std::endl;
|
||||||
this->_cgdata.cgdatah = data;
|
this->_cgdata.cgdatah = data;
|
||||||
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
this->_cgram.write(this->_cgadd, this->_cgdata.raw);
|
||||||
|
this->_cgadd++;
|
||||||
}
|
}
|
||||||
this->_isLowByte = !this->_isLowByte;
|
this->_isLowByte = !this->_isLowByte;
|
||||||
this->_cgadd++;
|
|
||||||
break;
|
break;
|
||||||
case ppuRegisters::w12sel:
|
case ppuRegisters::w12sel:
|
||||||
case ppuRegisters::w34sel:
|
case ppuRegisters::w34sel:
|
||||||
@@ -203,28 +206,45 @@ namespace ComSquare::PPU
|
|||||||
void PPU::update(unsigned cycles)
|
void PPU::update(unsigned cycles)
|
||||||
{
|
{
|
||||||
(void)cycles;
|
(void)cycles;
|
||||||
int inc = 0;
|
this->_bus->write(0x2121, 0);
|
||||||
uint32_t pixelTmp = 0xFFFFFFFF;
|
for (uint16_t value = 0; value <= 256; value++) {
|
||||||
pixelTmp |= this->_inidisp.brightness;
|
this->_bus->write(0x2122, 0b11100000);
|
||||||
std::cout << "update" << std::endl;
|
this->_bus->write(0x2122, 0b00000011);
|
||||||
if (!this->_inidisp.fblank) {
|
}
|
||||||
for (int x = 0; x < 448; x++) {
|
uint16_t tmp;
|
||||||
for (int y = 0; y < 512; y++) {
|
uint8_t red;
|
||||||
if (inc == 0xFA00)
|
uint8_t green;
|
||||||
inc = 0;
|
uint8_t blue;
|
||||||
//std::cout << "holy" << std::endl;
|
uint32_t pixelTmp = 0x000000FF;
|
||||||
this->_renderer.putPixel(x, y, (uint32_t)this->_vram.read(inc++));
|
//std::cout << "update" << std::endl;
|
||||||
}
|
if (!this->_inidisp.fblank) {
|
||||||
}
|
for (int y = 0; y <= 255; y++) {
|
||||||
|
tmp = this->_cgram.read(y);
|
||||||
|
|
||||||
|
//std::cout << "tmp " << std::bitset<16>(tmp) << std::endl;
|
||||||
|
blue = (tmp & 0x7D00U) >> 10U;
|
||||||
|
green = (tmp & 0x03E0U) >> 5U;
|
||||||
|
red = (tmp & 0x001FU);
|
||||||
|
|
||||||
|
//std::cout << "red " << std::bitset<8>(red) << std::endl;
|
||||||
|
//std::cout << "green " << std::bitset<8>(green) << std::endl;
|
||||||
|
//std::cout << "blue " << std::bitset<8>(blue) << std::endl;
|
||||||
|
pixelTmp += (red * 256U / 32U) << 24U;
|
||||||
|
pixelTmp += (green * 256U / 32U) << 16U;
|
||||||
|
pixelTmp += (blue * 256U / 32U) << 8U;
|
||||||
|
//std::cout << "value of pixel " << std::hex << pixelTmp << " pour inc " << std::dec << y << std::endl;
|
||||||
|
for (int x = 0; x < 100; x++)
|
||||||
|
this->_renderer.putPixel(x, y, pixelTmp);
|
||||||
|
pixelTmp = 0xFF;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
//std::cout << "cgadata2" << std::endl;
|
|
||||||
this->_renderer.drawScreen();
|
this->_renderer.drawScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
PPU::PPU(const std::shared_ptr<Memory::MemoryBus> &bus, Renderer::IRenderer &renderer):
|
PPU::PPU(const std::shared_ptr<Memory::MemoryBus> &bus, Renderer::IRenderer &renderer):
|
||||||
_renderer(renderer),
|
_renderer(renderer),
|
||||||
_bus(std::move(bus)),
|
_bus(std::move(bus)),
|
||||||
_vram(64000),
|
_vram(65536),
|
||||||
_oamram(544),
|
_oamram(544),
|
||||||
_cgram(512)
|
_cgram(512)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -29,8 +29,9 @@ namespace ComSquare::Renderer
|
|||||||
(void)maxFPS;
|
(void)maxFPS;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NoRenderer::createWindow(int maxFPS)
|
void NoRenderer::createWindow(SNES &snes, int maxFPS)
|
||||||
{
|
{
|
||||||
(void)maxFPS.
|
(void)snes;
|
||||||
|
(void)maxFPS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -26,7 +26,7 @@ namespace ComSquare::Renderer
|
|||||||
void getEvents();
|
void getEvents();
|
||||||
//! @brief Use this function to create the window.
|
//! @brief Use this function to create the window.
|
||||||
//! @param maxFPS The number of FPS you aim to run on.
|
//! @param maxFPS The number of FPS you aim to run on.
|
||||||
void createWindow(int maxFPS) override;
|
void createWindow(SNES &snes, int maxFPS) override;
|
||||||
//! @brief Constructor that return the window component of the SFML.
|
//! @brief Constructor that return the window component of the SFML.
|
||||||
//! @param height height of the window.
|
//! @param height height of the window.
|
||||||
//! @param width width of the window.
|
//! @param width width of the window.
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
#include <QtWidgets/QFrame>
|
#include <QtWidgets/QFrame>
|
||||||
#include <QCloseEvent>
|
#include <QCloseEvent>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "QtSFML.h"
|
#include "QtSFML.hpp"
|
||||||
|
|
||||||
#ifdef Q_WS_X11
|
#ifdef Q_WS_X11
|
||||||
#include <Qt/qx11info_x11.h>
|
#include <Qt/qx11info_x11.h>
|
||||||
|
|||||||
@@ -2,15 +2,15 @@
|
|||||||
// Created by anonymus-raccoon on 2/15/20.
|
// Created by anonymus-raccoon on 2/15/20.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef COMSQUARE_QTSFML_H
|
#ifndef COMSQUARE_QTSFML_HPP
|
||||||
#define COMSQUARE_QTSFML_H
|
#define COMSQUARE_QTSFML_HPP
|
||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
#include <QtCore/QTimer>
|
#include <QtCore/QTimer>
|
||||||
#include "../IRenderer.hpp"
|
#include "../IRenderer.hpp"
|
||||||
#include "../SFRenderer.hpp"
|
#include "../SFRenderer.hpp"
|
||||||
#include "QtWidgetSFML.h"
|
#include "QtWidgetSFML.hpp"
|
||||||
|
|
||||||
namespace ComSquare::Renderer
|
namespace ComSquare::Renderer
|
||||||
{
|
{
|
||||||
@@ -45,4 +45,4 @@ namespace ComSquare::Renderer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //COMSQUARE_QTSFML_H
|
#endif //COMSQUARE_QTSFML_HPP
|
||||||
@@ -2,7 +2,7 @@
|
|||||||
// Created by anonymus-raccoon on 2/16/20.
|
// Created by anonymus-raccoon on 2/16/20.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "QtWidgetSFML.h"
|
#include "QtWidgetSFML.hpp"
|
||||||
|
|
||||||
namespace ComSquare::Renderer
|
namespace ComSquare::Renderer
|
||||||
{
|
{
|
||||||
|
|||||||
+3
-3
@@ -2,8 +2,8 @@
|
|||||||
// Created by anonymus-raccoon on 2/16/20.
|
// Created by anonymus-raccoon on 2/16/20.
|
||||||
//
|
//
|
||||||
|
|
||||||
#ifndef COMSQUARE_QTWIDGETSFML_H
|
#ifndef COMSQUARE_QTWIDGETSFML_HPP
|
||||||
#define COMSQUARE_QTWIDGETSFML_H
|
#define COMSQUARE_QTWIDGETSFML_HPP
|
||||||
|
|
||||||
#include <QtWidgets/QWidget>
|
#include <QtWidgets/QWidget>
|
||||||
#include <SFML/Graphics/RenderWindow.hpp>
|
#include <SFML/Graphics/RenderWindow.hpp>
|
||||||
@@ -30,4 +30,4 @@ namespace ComSquare::Renderer
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif //COMSQUARE_QTWIDGETSFML_H
|
#endif //COMSQUARE_QTWIDGETSFML_HPP
|
||||||
+3
-1
@@ -23,7 +23,9 @@ namespace ComSquare
|
|||||||
|
|
||||||
void SNES::enableCPUDebugging()
|
void SNES::enableCPUDebugging()
|
||||||
{
|
{
|
||||||
this->cpu = std::make_shared<Debugger::CPUDebug>(*this->cpu, *this);
|
#ifdef DEBUGGER_ENABLED
|
||||||
|
this->cpu = std::make_shared<Debugger::CPUDebug>(*this->cpu, *this);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void SNES::disableCPUDebugging()
|
void SNES::disableCPUDebugging()
|
||||||
|
|||||||
Reference in New Issue
Block a user