From 82565008773123158a626a3a161679e527b51723 Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 17:19:59 -0600 Subject: [PATCH 1/9] Update GitHub workflow: also build SDL UI on macOS --- .github/workflows/build.yml | 40 ++++++++++++++++++++++++++++++------- 1 file changed, 33 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 579ce3dc4..891f13c8a 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,8 +2,11 @@ name: Build on: [pull_request] jobs: build-mac: - name: Build Mac UI - runs-on: macos-latest + name: Mac UI on ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest] + runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v4 @@ -11,15 +14,38 @@ jobs: working-directory: OSBindings/Mac run: xcodebuild CODE_SIGN_IDENTITY=- build-sdl: - name: Build SDL UI - runs-on: ubuntu-latest + name: SDL UI on ${{ matrix.os }} + strategy: + matrix: + os: [macos-latest, ubuntu-latest] + runs-on: ${{ matrix.os }} steps: - name: Checkout uses: actions/checkout@v4 - name: Install dependencies + shell: bash run: | - sudo apt-get --allow-releaseinfo-change update - sudo apt-get --fix-missing install gcc-10 libsdl2-dev scons + case $RUNNER_OS in + Linux) + sudo apt-get --allow-releaseinfo-change update + sudo apt-get --fix-missing install gcc-10 libsdl2-dev scons + ;; + macOS) + brew install scons sdl2 + ;; + esac - name: Make working-directory: OSBindings/SDL - run: scons -j$(nproc --all) + shell: bash + run: | + case $RUNNER_OS in + Linux) + jobs=$(nproc --all) + ;; + macOS) + jobs=$(sysctl -n hw.activecpu) + ;; + *) + jobs=1 + esac + scons -j"$jobs" From 2352b4e6d856169613418b57df7ac469b25540b5 Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 18:25:56 -0600 Subject: [PATCH 2/9] Import PATH into scons environment Fixes "/bin/sh: sdl2-config: command not found" when sdl2-config is not in a standard system bin directory. --- OSBindings/SDL/SConstruct | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/OSBindings/SDL/SConstruct b/OSBindings/SDL/SConstruct index f8c614a18..0a8eb2537 100644 --- a/OSBindings/SDL/SConstruct +++ b/OSBindings/SDL/SConstruct @@ -1,4 +1,5 @@ import glob +import os import sys # Establish UTF-8 encoding for Python 2. @@ -7,7 +8,7 @@ if sys.version_info < (3, 0): sys.setdefaultencoding('utf-8') # Create build environment. -env = Environment() +env = Environment(ENV = {'PATH' : os.environ['PATH']}) # Determine compiler and linker flags for SDL. env.ParseConfig('sdl2-config --cflags') From dc657bdd5129d52dcbaeb45d2dce86156af93a2f Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 18:28:43 -0600 Subject: [PATCH 3/9] Use the right include path for SDL.h Fixes "main.cpp:22:10: fatal error: 'SDL2/SDL.h' file not found" when SDL2 is not in a standard system include directory. --- OSBindings/SDL/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OSBindings/SDL/main.cpp b/OSBindings/SDL/main.cpp index 226cb7c41..d0c253d30 100644 --- a/OSBindings/SDL/main.cpp +++ b/OSBindings/SDL/main.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include "../../Analyser/Static/StaticAnalyser.hpp" #include "../../Machines/Utility/MachineForTarget.hpp" From 778544b36e2366e951c8bba0abda1c99b0fab7fb Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 18:38:52 -0600 Subject: [PATCH 4/9] Link with Accelerate framework on macOS Fixes "Undefined symbols for architecture x86_64: '_vDSP_dotpr_s1_15'" --- OSBindings/SDL/SConstruct | 3 +++ 1 file changed, 3 insertions(+) diff --git a/OSBindings/SDL/SConstruct b/OSBindings/SDL/SConstruct index 0a8eb2537..4a7d227f8 100644 --- a/OSBindings/SDL/SConstruct +++ b/OSBindings/SDL/SConstruct @@ -142,5 +142,8 @@ env.Append(CCFLAGS = ['--std=c++17', '--std=c++1z', '-Wall', '-O2', '-DNDEBUG']) # Add additional libraries to link against. env.Append(LIBS = ['libz', 'pthread', 'GL']) +if env['PLATFORM'] == 'darwin': + env.Append(FRAMEWORKS = ['Accelerate']) + # Build target. env.Program(target = 'clksignal', source = SOURCES) From bb030fc1414e4d38e3ab51a18d95fd02204144e8 Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 18:46:28 -0600 Subject: [PATCH 5/9] Silence macOS OpenGL deprecation warnings --- OSBindings/SDL/SConstruct | 1 + 1 file changed, 1 insertion(+) diff --git a/OSBindings/SDL/SConstruct b/OSBindings/SDL/SConstruct index 4a7d227f8..56d8e7904 100644 --- a/OSBindings/SDL/SConstruct +++ b/OSBindings/SDL/SConstruct @@ -143,6 +143,7 @@ env.Append(CCFLAGS = ['--std=c++17', '--std=c++1z', '-Wall', '-O2', '-DNDEBUG']) env.Append(LIBS = ['libz', 'pthread', 'GL']) if env['PLATFORM'] == 'darwin': + env.Append(CCFLAGS = ['-DGL_SILENCE_DEPRECATION']) env.Append(FRAMEWORKS = ['Accelerate']) # Build target. From d31ecd8986bea0e9ab7aaacaf213113e50ad0951 Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 18:58:15 -0600 Subject: [PATCH 6/9] Link with OpenGL framework on macOS Fixes "ld: library not found for -lGL" --- OSBindings/SDL/SConstruct | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/OSBindings/SDL/SConstruct b/OSBindings/SDL/SConstruct index 56d8e7904..094b0df6f 100644 --- a/OSBindings/SDL/SConstruct +++ b/OSBindings/SDL/SConstruct @@ -140,11 +140,14 @@ SOURCES += glob.glob('../../Storage/Tape/Parsers/*.cpp') env.Append(CCFLAGS = ['--std=c++17', '--std=c++1z', '-Wall', '-O2', '-DNDEBUG']) # Add additional libraries to link against. -env.Append(LIBS = ['libz', 'pthread', 'GL']) +env.Append(LIBS = ['libz', 'pthread']) +# Add additional platform-specific compiler flags, libraries, and frameworks. if env['PLATFORM'] == 'darwin': env.Append(CCFLAGS = ['-DGL_SILENCE_DEPRECATION']) - env.Append(FRAMEWORKS = ['Accelerate']) + env.Append(FRAMEWORKS = ['Accelerate', 'OpenGL']) +else: + env.Append(LIBS = ['GL']) # Build target. env.Program(target = 'clksignal', source = SOURCES) From cd4498a36add69d5ac6cc25bb09c3d3337f6e612 Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Thu, 14 Dec 2023 19:03:45 -0600 Subject: [PATCH 7/9] Improve macOS SDL Macintosh video & Apple II colors Hacks in AppleII/Video.cpp, AppleII/Video.hpp, and Macintosh/Video.cpp assume that building on macOS means building for Metal unless IGNORE_APPLE is defined. By defining this in the macOS SDL build, Macintosh video is now sized and positioned correctly and Apple II colors are now just as wrong as they are on other OpenGL builds instead of being wrong in a unique way. See #872 --- OSBindings/SDL/SConstruct | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/OSBindings/SDL/SConstruct b/OSBindings/SDL/SConstruct index 094b0df6f..02f9893b1 100644 --- a/OSBindings/SDL/SConstruct +++ b/OSBindings/SDL/SConstruct @@ -144,7 +144,7 @@ env.Append(LIBS = ['libz', 'pthread']) # Add additional platform-specific compiler flags, libraries, and frameworks. if env['PLATFORM'] == 'darwin': - env.Append(CCFLAGS = ['-DGL_SILENCE_DEPRECATION']) + env.Append(CCFLAGS = ['-DGL_SILENCE_DEPRECATION', '-DIGNORE_APPLE']) env.Append(FRAMEWORKS = ['Accelerate', 'OpenGL']) else: env.Append(LIBS = ['GL']) From 81ad8646596321215840c33675b0cfb9644ea549 Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Fri, 15 Dec 2023 04:28:18 -0600 Subject: [PATCH 8/9] Fix OpenGL Apple II colors Adjust phase by 90 degress. Closes #872 --- Machines/Apple/AppleII/Video.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index 9cd75093c..6346bc699 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -471,7 +471,7 @@ template class Video: public VideoBase { #if defined(__APPLE__) && !defined(IGNORE_APPLE) constexpr int phase = 224; #else - constexpr int phase = 0; + constexpr int phase = 192; #endif crt_.output_colour_burst((colour_burst_end - colour_burst_start) * 14, phase); From d12316dfcf4ae4b0943dd07bd19a29fe964c783d Mon Sep 17 00:00:00 2001 From: Ryan Carsten Schmidt Date: Fri, 15 Dec 2023 04:38:30 -0600 Subject: [PATCH 9/9] Change phase from int to uint8_t output_colour_burst expects a uint8_t so may as well make that clear. --- Machines/Apple/AppleII/Video.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Machines/Apple/AppleII/Video.hpp b/Machines/Apple/AppleII/Video.hpp index 6346bc699..c5e07dfe3 100644 --- a/Machines/Apple/AppleII/Video.hpp +++ b/Machines/Apple/AppleII/Video.hpp @@ -469,9 +469,9 @@ template class Video: public VideoBase { // Supply the real phase value if this is an Apple build. // TODO: eliminate UGLY HACK. #if defined(__APPLE__) && !defined(IGNORE_APPLE) - constexpr int phase = 224; + constexpr uint8_t phase = 224; #else - constexpr int phase = 192; + constexpr uint8_t phase = 192; #endif crt_.output_colour_burst((colour_burst_end - colour_burst_start) * 14, phase);