1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-11-26 08:49:37 +00:00

Merge pull request #948 from TomHarte/QtAspectRatio

Ensures Apple II square pixels work correctly under OpenGL
This commit is contained in:
Thomas Harte 2021-06-13 21:23:28 -04:00 committed by GitHub
commit 56c30e1651
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 31 additions and 21 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() {

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