Huge refactor: Make Core a singleton

This commit is contained in:
irisz64
2025-07-29 11:08:05 +02:00
parent e0e887ce90
commit 3061334004
56 changed files with 426 additions and 594 deletions

View File

@@ -2,12 +2,13 @@
#include <EmuThread.hpp>
#include <KaizenGui.hpp>
EmuThread::EmuThread(const std::shared_ptr<n64::Core> &core, double &fps, RenderWidget &renderWidget,
EmuThread::EmuThread(double &fps, RenderWidget &renderWidget,
SettingsWindow &settings) noexcept :
renderWidget(renderWidget), core(core), settings(settings), fps(fps) {}
renderWidget(renderWidget), settings(settings), fps(fps) {}
void EmuThread::run() const noexcept {
if(!core->romLoaded) return;
n64::Core& core = n64::Core::GetInstance();
if(!core.romLoaded) return;
auto lastSample = std::chrono::high_resolution_clock::now();
auto avgFps = 16.667;
@@ -17,8 +18,8 @@ void EmuThread::run() const noexcept {
fps = 1000.0 / avgFps;
const auto startFrameTime = std::chrono::high_resolution_clock::now();
if (!core->pause) {
core->Run(settings.getVolumeL(), settings.getVolumeR());
if (!core.pause) {
core.Run(settings.getVolumeL(), settings.getVolumeR());
}
const auto endFrameTime = std::chrono::high_resolution_clock::now();
@@ -40,15 +41,17 @@ void EmuThread::run() const noexcept {
}
void EmuThread::TogglePause() const noexcept {
core->TogglePause();
n64::Core::GetInstance().TogglePause();
}
void EmuThread::Reset() const noexcept {
core->Stop();
core->LoadROM(core->rom);
n64::Core& core = n64::Core::GetInstance();
core.Stop();
core.LoadROM(core.rom);
}
void EmuThread::Stop() const noexcept {
core->Stop();
core->rom = {};
n64::Core& core = n64::Core::GetInstance();
core.Stop();
core.rom = {};
}