diff --git a/Concurrency/AsyncTaskQueue.cpp b/Concurrency/AsyncTaskQueue.cpp index a88fbf4ac..d4f2f84a5 100644 --- a/Concurrency/AsyncTaskQueue.cpp +++ b/Concurrency/AsyncTaskQueue.cpp @@ -11,11 +11,11 @@ using namespace Concurrency; AsyncTaskQueue::AsyncTaskQueue() -#ifndef __APPLE__ +#ifndef USE_GCD : should_destruct_(false) #endif { -#ifdef __APPLE__ +#ifdef USE_GCD serial_dispatch_queue_ = dispatch_queue_create("com.thomasharte.clocksignal.asyntaskqueue", DISPATCH_QUEUE_SERIAL); #else thread_ = std::make_unique([this]() { @@ -44,7 +44,7 @@ AsyncTaskQueue::AsyncTaskQueue() } AsyncTaskQueue::~AsyncTaskQueue() { -#ifdef __APPLE__ +#ifdef USE_GCD flush(); dispatch_release(serial_dispatch_queue_); serial_dispatch_queue_ = nullptr; @@ -57,7 +57,7 @@ AsyncTaskQueue::~AsyncTaskQueue() { } void AsyncTaskQueue::enqueue(std::function function) { -#ifdef __APPLE__ +#ifdef USE_GCD dispatch_async(serial_dispatch_queue_, ^{function();}); #else std::lock_guard lock(queue_mutex_); @@ -67,7 +67,7 @@ void AsyncTaskQueue::enqueue(std::function function) { } void AsyncTaskQueue::flush() { -#ifdef __APPLE__ +#ifdef USE_GCD dispatch_sync(serial_dispatch_queue_, ^{}); #else auto flush_mutex = std::make_shared(); diff --git a/Concurrency/AsyncTaskQueue.hpp b/Concurrency/AsyncTaskQueue.hpp index 599fa7c74..7e48a404e 100644 --- a/Concurrency/AsyncTaskQueue.hpp +++ b/Concurrency/AsyncTaskQueue.hpp @@ -16,8 +16,9 @@ #include #include -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(IGNORE_APPLE) #include +#define USE_GCD #endif namespace Concurrency { @@ -47,7 +48,7 @@ class AsyncTaskQueue { void flush(); private: -#ifdef __APPLE__ +#ifdef USE_GCD dispatch_queue_t serial_dispatch_queue_; #else std::unique_ptr thread_; diff --git a/Machines/Apple/AppleII/Video.cpp b/Machines/Apple/AppleII/Video.cpp index ae358c0ab..6ed67553c 100644 --- a/Machines/Apple/AppleII/Video.cpp +++ b/Machines/Apple/AppleII/Video.cpp @@ -29,11 +29,11 @@ void VideoBase::set_use_square_pixels(bool use_square_pixels) { use_square_pixels_ = use_square_pixels; // HYPER-UGLY HACK. See correlated hack in the Macintosh. -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(IGNORE_APPLE) crt_.set_visible_area(Outputs::Display::Rect(0.128f, 0.122f, 0.75f, 0.77f)); #else if(use_square_pixels) { - crt_.set_visible_area(Outputs::Display::Rect(0.128f, 0.112f, 0.75f, 0.73f)); + crt_.set_visible_area(Outputs::Display::Rect(0.128f, 0.09f, 0.75f, 0.77f)); } else { crt_.set_visible_area(Outputs::Display::Rect(0.128f, 0.12f, 0.75f, 0.77f)); } diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index ba414c83e..1e66d1cc2 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -399,7 +399,7 @@ template class Video: public VideoBase { // The OpenGL scan target introduces a phase error of 1/8th of a wave. The Metal one does not. // Supply the real phase value if this is an Apple build. // TODO: eliminate UGLY HACK. -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(IGNORE_APPLE) constexpr int phase = 224; #else constexpr int phase = 0; diff --git a/Machines/Apple/Macintosh/Video.cpp b/Machines/Apple/Macintosh/Video.cpp index 3c98374f0..85849469e 100644 --- a/Machines/Apple/Macintosh/Video.cpp +++ b/Machines/Apple/Macintosh/Video.cpp @@ -35,7 +35,7 @@ Video::Video(DeferredAudio &audio, DriveSpeedAccumulator &drive_speed_accumulato // The [newer] Metal scan target has no such issue. So assume that Apple => Metal, // and set a visible area to work around the OpenGL issue if required. // TODO: eliminate UGLY HACK. -#ifdef __APPLE__ +#if defined(__APPLE__) && !defined(IGNORE_APPLE) crt_.set_visible_area(Outputs::Display::Rect(0.08f, 10.0f / 368.0f, 0.82f, 344.0f / 368.0f)); #else crt_.set_visible_area(Outputs::Display::Rect(0.08f, -0.025f, 0.82f, 0.82f)); diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj index 60a7ae8c2..5bdace657 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj +++ b/OSBindings/Mac/Clock Signal.xcodeproj/project.pbxproj @@ -5892,6 +5892,11 @@ "$(USER_LIBRARY_DIR)/Frameworks", ); GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + IGNORE_APPLE, + ); MACOSX_DEPLOYMENT_TARGET = 10.13; PRODUCT_NAME = "$(TARGET_NAME)"; }; @@ -5913,7 +5918,10 @@ ); GCC_C_LANGUAGE_STANDARD = gnu11; GCC_OPTIMIZATION_LEVEL = 2; - GCC_PREPROCESSOR_DEFINITIONS = NDEBUG; + GCC_PREPROCESSOR_DEFINITIONS = ( + NDEBUG, + IGNORE_APPLE, + ); MACOSX_DEPLOYMENT_TARGET = 10.13; ONLY_ACTIVE_ARCH = YES; PRODUCT_NAME = "$(TARGET_NAME)"; diff --git a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme index 263537208..2b77bafce 100644 --- a/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme +++ b/OSBindings/Mac/Clock Signal.xcodeproj/xcshareddata/xcschemes/Clock Signal Kiosk.xcscheme @@ -58,7 +58,7 @@ + isEnabled = "NO"> + argument = "--model=mac512k" + isEnabled = "YES"> + argument = "--new=macintosh" + isEnabled = "YES"> setupUi(this); romRequestBaseText = ui->missingROMsBox->toPlainText(); - createActions(); - restoreSelections(); - // TEMPORARY: remove the Apple IIgs tab; this machine isn't ready yet. ui->machineSelectionTabs->removeTab(ui->machineSelectionTabs->indexOf(ui->appleIIgsTab)); + + createActions(); + restoreSelections(); } void MainWindow::createActions() { @@ -207,14 +207,15 @@ QString MainWindow::getFilename(const char *title) { return fileName; } -void MainWindow::insertFile(const QString &fileName) { - if(!machine) return; +bool MainWindow::insertFile(const QString &fileName) { + if(!machine) return false; auto mediaTarget = machine->media_target(); - if(!mediaTarget) return; + if(!mediaTarget) return false; - Analyser::Static::Media media = Analyser::Static::GetMedia(fileName.toStdString()); - mediaTarget->insert_media(media); + const Analyser::Static::Media media = Analyser::Static::GetMedia(fileName.toStdString()); + if(media.empty()) return false; + return mediaTarget->insert_media(media); } bool MainWindow::launchFile(const QString &fileName) { @@ -732,7 +733,10 @@ void MainWindow::dropEvent(QDropEvent* event) { case UIPhase::RunningMachine: { // Attempt to insert into the running machine. const auto fileName = event->mimeData()->urls()[0].toLocalFile(); - insertFile(fileName); + if(!insertFile(fileName)) { + deleteMachine(); + launchFile(fileName); + } } break; // TODO: permit multiple files dropped at once in both of the above cases. diff --git a/OSBindings/Qt/mainwindow.h b/OSBindings/Qt/mainwindow.h index ab02f14e9..24f3593e1 100644 --- a/OSBindings/Qt/mainwindow.h +++ b/OSBindings/Qt/mainwindow.h @@ -104,7 +104,7 @@ class MainWindow : public QMainWindow, public Outputs::Speaker::Speaker::Delegat } keyboardInputMode; QAction *insertAction = nullptr; - void insertFile(const QString &fileName); + bool insertFile(const QString &fileName); bool launchFile(const QString &fileName); void launchTarget(std::unique_ptr &&); diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 6034207aa..1573a2887 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -774,7 +774,7 @@ int main(int argc, char *argv[]) { default: break; case ::Machine::Error::MissingROM: { std::cerr << "Could not find system ROMs; please install to /usr/local/share/CLK/ or /usr/share/CLK/, or provide a --rompath, e.g. --rompath=~/ROMs." << std::endl; - std::cerr << "Needed — but didn't find —"; + std::cerr << "Needed but didn't find"; using DescriptionFlag = ROM::Description::DescriptionFlag; std::wcerr << missing_roms.description(DescriptionFlag::Filename | DescriptionFlag::CRC, L'*');