This commit is contained in:
Anonymus Raccoon
2020-02-18 00:46:48 +01:00
6 changed files with 46 additions and 12 deletions
+1 -1
View File
@@ -1,4 +1,4 @@
<p align="center"><img src="resources/Black.svg" _width="400"></p>
<p align="center"><img src="./resources/Black.svg" width="400"></p>
<p align="center">
<a href="./LICENSE"><img src="https://img.shields.io/github/license/AnonymusRaccoon/ComSquare?style=flat-square" alt="License"></a>
+34 -1
View File
@@ -4,21 +4,54 @@
#include <iostream>
#include <QtWidgets/QApplication>
#include <getopt.h>
#include "sources/SNES.hpp"
#include "sources/Renderer/SFRenderer.hpp"
#include "sources/Renderer/QtRenderer/QtSFML.hpp"
using namespace ComSquare;
void usage(char *bin)
{
std::cout << "ComSquare:" << std::endl << "\tUsage: " << bin << " rom_path" << std::endl;
}
void parseArguments(int argc, char **argv, SNES &snes)
{
while (true) {
int this_option_optind = optind ? optind : 1;
int option_index = 0;
static struct option long_options[] = {
{"cpu-debug", no_argument, 0, 'c' },
{0, 0, 0, 0 }
};
char c = getopt_long(argc, argv, "c:pu-debug", long_options, &option_index);
if (c == -1)
break;
switch (c) {
case 0:
usage(argv[0]);
break;
case 'c':
snes.enableCPUDebugging();
break;
default:
break;
}
}
}
int main(int argc, char **argv)
{
if (argc < 2) {
std::cout << "ComSquare:" << std::endl << "\tUsage: " << argv[0] << " rom_path" << std::endl;
usage(argv[0]);
return 1;
}
QApplication app(argc, argv);
Renderer::QtSFML renderer(600, 800);
SNES snes(std::make_shared<Memory::MemoryBus>(), argv[1], renderer);
renderer.createWindow(snes, 60);
parseArguments(argc, argv, snes);
return QApplication::exec();
}
+1 -1
View File
File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 6.4 KiB

After

Width:  |  Height:  |  Size: 6.4 KiB

@@ -12,7 +12,7 @@ namespace ComSquare::CPU
unsigned value = this->_bus->read(valueAddr) + this->_registers.p.c;
if (this->_registers.p.m)
value += this->_bus->read(valueAddr + 1) << 8u;
unsigned negativeMask = this->_isEmulationMode ? 0xF0u : 0xF000u;
unsigned negativeMask = this->_isEmulationMode ? 0x80u : 0x8000u;
unsigned maxValue = this->_isEmulationMode ? UINT8_MAX : UINT16_MAX;
this->_registers.p.c = static_cast<unsigned>(this->_registers.a) + value > maxValue;
+6 -1
View File
@@ -70,7 +70,12 @@ namespace ComSquare::Renderer
void QtFullSFML::_onUpdate()
{
this->_snes.update();
try {
this->_snes.update();
} catch (std::exception &e) {
std::cerr << "An error occurred: " << e.what() << std::endl;
QApplication::quit();
}
}
void QtFullSFML::enableDebugCPU()
+3 -7
View File
@@ -52,12 +52,8 @@ namespace ComSquare
void SNES::update()
{
try {
unsigned cycleCount = this->cpu->update();
this->ppu->update(cycleCount);
this->apu->update(cycleCount);
} catch (std::exception &e) {
std::cerr << "An error occurred: " << e.what() << std::endl;
}
unsigned cycleCount = this->cpu->update();
this->ppu->update(cycleCount);
this->apu->update(cycleCount);
}
}