From d7002336fae9cfbb7facbc9654d95b9741486243 Mon Sep 17 00:00:00 2001
From: AnonymusRaccoon
Date: Tue, 11 Feb 2020 14:47:56 +0100
Subject: [PATCH] Finishing the main and disabling the invalid opcode throw for
now
---
main.cpp | 3 ++-
sources/APU/APU.cpp | 2 +-
sources/APU/APU.hpp | 2 +-
sources/CPU/CPU.cpp | 3 ++-
sources/CPU/Instructions/MathematicalOperations.cpp | 2 ++
sources/Exceptions/InvalidOpcode.hpp | 6 +++---
6 files changed, 11 insertions(+), 7 deletions(-)
diff --git a/main.cpp b/main.cpp
index 61bc972..d9be8d4 100644
--- a/main.cpp
+++ b/main.cpp
@@ -4,7 +4,6 @@
#include
#include
-#include "sources/Renderer/IRenderer.hpp"
#include "sources/SNES.hpp"
#include "sources/Renderer/SFRenderer.hpp"
@@ -23,6 +22,8 @@ int main(int argc, char **argv)
unsigned cycleCount = snes.cpu->update();
snes.ppu->update(cycleCount);
snes.apu->update(cycleCount);
+
+ renderer.getEvents();
}
} catch (std::exception &e) {
std::cerr << "An error occurred: " << e.what() << std::endl;
diff --git a/sources/APU/APU.cpp b/sources/APU/APU.cpp
index a1e1f43..e46219e 100644
--- a/sources/APU/APU.cpp
+++ b/sources/APU/APU.cpp
@@ -47,7 +47,7 @@ namespace ComSquare::APU
}
}
- bool APU::update(unsigned cycles)
+ void APU::update(unsigned cycles)
{
(void)cycles;
}
diff --git a/sources/APU/APU.hpp b/sources/APU/APU.hpp
index c0bff99..bb903e3 100644
--- a/sources/APU/APU.hpp
+++ b/sources/APU/APU.hpp
@@ -125,7 +125,7 @@ namespace ComSquare::APU
//! @param data The new value of the register.
//! @throw InvalidAddress will be thrown if the address is more than $FF (the number of register).
void write(uint24_t addr, uint8_t data) override;
- bool update(unsigned cycles);
+ void update(unsigned cycles);
};
}
diff --git a/sources/CPU/CPU.cpp b/sources/CPU/CPU.cpp
index 033f117..e40669f 100644
--- a/sources/CPU/CPU.cpp
+++ b/sources/CPU/CPU.cpp
@@ -218,7 +218,8 @@ namespace ComSquare::CPU
case Instructions::ADC_ABSXl:return this->ADC(this->_getAbsoluteIndexedByXLongAddr());
default:
- throw InvalidOpcode("CPU", opcode);
+ return 0;
+ //throw InvalidOpcode("CPU", opcode);
}
}
diff --git a/sources/CPU/Instructions/MathematicalOperations.cpp b/sources/CPU/Instructions/MathematicalOperations.cpp
index 2a70d42..e1b205c 100644
--- a/sources/CPU/Instructions/MathematicalOperations.cpp
+++ b/sources/CPU/Instructions/MathematicalOperations.cpp
@@ -9,5 +9,7 @@ namespace ComSquare::CPU
int CPU::ADC(uint24_t valueAddr)
{
// this->_registers.a +=
+ (void)valueAddr;
+ return (0);
}
}
\ No newline at end of file
diff --git a/sources/Exceptions/InvalidOpcode.hpp b/sources/Exceptions/InvalidOpcode.hpp
index 6b02c29..00447c4 100644
--- a/sources/Exceptions/InvalidOpcode.hpp
+++ b/sources/Exceptions/InvalidOpcode.hpp
@@ -7,19 +7,19 @@
#include
#include
-#include
+#include
namespace ComSquare
{
//! @brief Exception thrown when someone tries to load an invalid rom.
- class InvalidOpcode : std::exception {
+ class InvalidOpcode : public std::exception {
private:
std::string _msg;
public:
explicit InvalidOpcode(const std::string &pu, unsigned opcode)
{
std::stringstream stream;
- stream << "The " + pu + ": 0x" << std::hex << opcode;
+ stream << "The " + pu + " got an invalid opcode: 0x" << std::hex << opcode;
this->_msg = stream.str();
}
const char *what() const noexcept override { return this->_msg.c_str(); }