From b28ffa7a1f1d8ca9906326bd5c0d786dce97bf1f Mon Sep 17 00:00:00 2001 From: UnrealPowerz Date: Mon, 1 Jun 2026 12:25:53 +0200 Subject: [PATCH] Fix macOS build --- core/soc/rtc/rtc.cpp | 4 ++++ core/soc/sci3/sci3.h | 1 + core/utils/h8300h_ptr.h | 2 ++ desktop/src/main.cpp | 7 +++++++ desktop/src/qt/audio/qt_audio_system.cpp | 6 ++++++ desktop/src/qt/emulator/emulator_context.cpp | 11 +++++++++++ 6 files changed, 31 insertions(+) diff --git a/core/soc/rtc/rtc.cpp b/core/soc/rtc/rtc.cpp index 908a69d..91fc660 100644 --- a/core/soc/rtc/rtc.cpp +++ b/core/soc/rtc/rtc.cpp @@ -48,7 +48,11 @@ void RTC::Cycle(uint8_t cycles) const time_t now = std::time(nullptr); std::tm current_time = {}; +#ifdef _WIN32 localtime_s(¤t_time, &now); +#else + localtime_r(&now, ¤t_time); +#endif RSECDR = BCD(current_time.tm_sec); RMINDR = BCD(current_time.tm_min); diff --git a/core/soc/sci3/sci3.h b/core/soc/sci3/sci3.h index 6128a61..484e678 100644 --- a/core/soc/sci3/sci3.h +++ b/core/soc/sci3/sci3.h @@ -1,6 +1,7 @@ #pragma once #include +#include #include #include "core/soc/memory/regions/io.h" diff --git a/core/utils/h8300h_ptr.h b/core/utils/h8300h_ptr.h index 40d38ac..41ab7b0 100644 --- a/core/utils/h8300h_ptr.h +++ b/core/utils/h8300h_ptr.h @@ -1,6 +1,8 @@ #pragma once #include #include +#include +#include // provides an h8/300h big endian byte swap ptr for u16 and u32 // holy moly this is ugly diff --git a/desktop/src/main.cpp b/desktop/src/main.cpp index a560da6..4c89ad8 100644 --- a/desktop/src/main.cpp +++ b/desktop/src/main.cpp @@ -1,6 +1,7 @@ #include #include #include +#include #include "argparse/argparse.hpp" @@ -9,6 +10,12 @@ int main(int argc, char* argv[]) { + QSurfaceFormat fmt; + fmt.setVersion(3, 3); + fmt.setProfile(QSurfaceFormat::CoreProfile); + fmt.setRenderableType(QSurfaceFormat::OpenGL); + QSurfaceFormat::setDefaultFormat(fmt); + argparse::ArgumentParser arguments("pocketwalker"); arguments.add_argument("rom") diff --git a/desktop/src/qt/audio/qt_audio_system.cpp b/desktop/src/qt/audio/qt_audio_system.cpp index 96eaa0f..669ad47 100644 --- a/desktop/src/qt/audio/qt_audio_system.cpp +++ b/desktop/src/qt/audio/qt_audio_system.cpp @@ -1,5 +1,6 @@ #include "qt_audio_system.h" #include +#include #include "desktop/src/qt/settings/app_settings.h" @@ -20,7 +21,12 @@ QtAudioSystem::QtAudioSystem(QObject* parent) : QObject(parent) QtAudioSystem::~QtAudioSystem() { Flush(); + sink->disconnect(); sink->stop(); + device = nullptr; + QThread::msleep(50); + delete sink; + sink = nullptr; } void QtAudioSystem::PushSample(BuzzerInformation info) diff --git a/desktop/src/qt/emulator/emulator_context.cpp b/desktop/src/qt/emulator/emulator_context.cpp index 9e17144..64cbb20 100644 --- a/desktop/src/qt/emulator/emulator_context.cpp +++ b/desktop/src/qt/emulator/emulator_context.cpp @@ -48,6 +48,17 @@ EmulatorContext::~EmulatorContext() if (emulator_thread && emulator_thread->joinable()) emulator_thread->join(); + audio.reset(); + + if (network && network_thread && network_thread->isRunning()) + { + QThread* main_thread = QThread::currentThread(); + QMetaObject::invokeMethod( + network.get(), + [n = network.get(), main_thread]() { n->moveToThread(main_thread); }, + Qt::BlockingQueuedConnection); + } + if (network_thread) { network_thread->quit();