1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-22 12:33:29 +00:00

Merge branch 'master' into Enterprise

This commit is contained in:
Thomas Harte 2021-06-13 22:22:44 -04:00
commit 333981e2a7
11 changed files with 42 additions and 28 deletions

View File

@ -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<std::thread>([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<void(void)> 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<void(void)> function) {
}
void AsyncTaskQueue::flush() {
#ifdef __APPLE__
#ifdef USE_GCD
dispatch_sync(serial_dispatch_queue_, ^{});
#else
auto flush_mutex = std::make_shared<std::mutex>();

View File

@ -16,8 +16,9 @@
#include <memory>
#include <thread>
#ifdef __APPLE__
#if defined(__APPLE__) && !defined(IGNORE_APPLE)
#include <dispatch/dispatch.h>
#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<std::thread> thread_;

View File

@ -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));
}

View File

@ -399,7 +399,7 @@ template <class BusHandler, bool is_iie> 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;

View File

@ -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));

View File

@ -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)";

View File

@ -58,7 +58,7 @@
</CommandLineArgument>
<CommandLineArgument
argument = "&quot;/Users/thomasharte/Desktop/Soft/Apple II/WOZs/Prince of Persia side A.woz&quot;"
isEnabled = "YES">
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--rompath=~/ROMs"
@ -125,12 +125,12 @@
isEnabled = "NO">
</CommandLineArgument>
<CommandLineArgument
argument = "--model=cpc6128"
isEnabled = "NO">
argument = "--model=mac512k"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--new=appleii"
isEnabled = "NO">
argument = "--new=macintosh"
isEnabled = "YES">
</CommandLineArgument>
<CommandLineArgument
argument = "--use-square-pixels"

View File

@ -21,6 +21,7 @@ linux {
# Add flags (i) to identify that this is a Qt build; and
# (ii) to disable asserts in release builds.
DEFINES += TARGET_QT
DEFINES += IGNORE_APPLE
QMAKE_CXXFLAGS_RELEASE += -DNDEBUG
# Generate warnings for any use of APIs deprecated prior to Qt 6.0.0.

View File

@ -112,11 +112,11 @@ void MainWindow::init() {
ui->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.

View File

@ -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<Analyser::Static::Target> &&);

View File

@ -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'*');