ref: b21b62079cfd4541f7735b38af6e5922d1da58e4
parent: 62b110bc3b91bad4dfdc1c280440a02fc2cbd7f7
author: allkern <lisandroaalarcon@gmail.com>
date: Mon Jun 19 20:07:26 EDT 2023
Merge GitHub Actions work
--- /dev/null
+++ b/.github/workflows/macos.yml
@@ -1,0 +1,25 @@
+name: macOS CI
+
+on:
+ push:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ runs-on: macos-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install SDL2 and dylibbundler
+ run: |
+ brew install sdl2
+ brew install dylibbundler
+ - name: Build and pack PSXE
+ run: |
+ ./build.sh
+ mkdir -p psxe
+ mv psxe.app psxe
+ - uses: actions/upload-artifact@v3
+ with:
+ name: psxe-macos-latest
+ path: psxe/
--- /dev/null
+++ b/.github/workflows/ubuntu.yml
@@ -1,0 +1,22 @@
+name: Ubuntu CI
+
+on:
+ push:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install SDL2
+ run: |
+ sudo apt update
+ sudo apt install libsdl2-dev
+ - name: make
+ run: make
+ - uses: actions/upload-artifact@v3
+ with:
+ name: psxe-ubuntu-latest
+ path: bin/psxe
\ No newline at end of file
--- /dev/null
+++ b/.github/workflows/windows.yml
@@ -1,0 +1,35 @@
+name: Windows CI
+
+on:
+ push:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ runs-on: windows-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Run build-deps
+ run: ./build-deps.ps1
+ - name: 64-bit build
+ run: |
+ ./build-win64.ps1
+ New-Item -Path "psxe" -ItemType Directory
+ Copy-Item -Recurse "bin" -Destination "psxe"
+ - uses: actions/upload-artifact@v3
+ with:
+ name: psxe-win64-latest
+ path: psxe/
+ - name: Cleanup
+ run: ./build-clean
+ - name: 32-bit build
+ run: |
+ Remove-Item -Path psxe -Recurse
+ ./build-win32.ps1
+ New-Item -Path "psxe" -ItemType Directory
+ Copy-Item -Recurse "bin" -Destination "psxe"
+ - uses: actions/upload-artifact@v3
+ with:
+ name: psxe-win32-latest
+ path: psxe/
\ No newline at end of file
--- a/.gitignore
+++ b/.gitignore
@@ -5,9 +5,12 @@
res/
sdl2/
SDL2-2.26.5/
+sdl2-win32/
+sdl2-win64/
test/
*.bin
*.dll
*.exe
*.out
-*.toml
\ No newline at end of file
+*.toml
+*.zip
\ No newline at end of file
--- /dev/null
+++ b/Info.plist
@@ -1,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
+<plist version="1.0">
+ <dict>
+ <key>CFBundleDevelopmentRegion</key>
+ <string>en</string>
+ <key>CFBundleExecutable</key>
+ <string>psxe</string>
+ <key>CFBundleIdentifier</key>
+ <string>psxe.app.0</string>
+ <key>CFBundleInfoDictionaryVersion</key>
+ <string>6.0</string>
+ <key>CFBundleName</key>
+ <string>psxe</string>
+ <key>CFBundlePackageType</key>
+ <string>APPL</string>
+ <key>CFBundleShortVersionString</key>
+ <string>0.1-alpha</string>
+ <key>CFBundleSignature</key>
+ <string>psxe</string>
+ <key>CFBundleVersion</key>
+ <string>0.1-alpha</string>
+ <key>LSApplicationCategoryType</key>
+ <string>public.app-category.games</string>
+ <key>LSMinimumSystemVersion</key>
+ <string>10.6</string>
+ <key>NSHighResolutionCapable</key>
+ <true/>
+ <key>NSPrincipalClass</key>
+ <string>NSApplication</string>
+ </dict>
+</plist>
--- a/Makefile
+++ b/Makefile
@@ -17,7 +17,8 @@
-DREP_VERSION="$(VERSION_TAG)" \
-DREP_COMMIT_HASH="$(COMMIT_HASH)" \
-g -DLOG_USE_COLOR -lSDL2 -lSDL2main \
- -Ofast -Wno-overflow -Wall -pedantic
+ -Ofast -Wno-overflow -Wall -pedantic \
+ -Wno-newline-eof
clean:
rm -rf "bin"
--- a/build-deps.ps1
+++ b/build-deps.ps1
@@ -2,11 +2,19 @@
Remove-Item -Recurse "SDL2-2.26.5"
}
-$URL = "https://github.com/libsdl-org/SDL/releases/download/release-2.26.5/SDL2-devel-2.26.5-mingw.zip"
+$SDL2_URL = "https://github.com/libsdl-org/SDL/releases/download/release-2.26.5/SDL2-devel-2.26.5-mingw.zip"
+$WIN32_URL = "https://github.com/libsdl-org/SDL/releases/download/release-2.26.5/SDL2-2.26.5-win32-x86.zip"
+$WIN64_URL = "https://github.com/libsdl-org/SDL/releases/download/release-2.26.5/SDL2-2.26.5-win32-x64.zip"
-Invoke-WebRequest -URI $URL -OutFile "sdl2.zip"
-Expand-Archive "sdl2.zip" -DestinationPath "."
+Invoke-WebRequest -URI $SDL2_URL -OutFile "sdl2.zip"
+Expand-Archive "sdl2.zip" -DestinationPath "." -Force
-Remove-Item "sdl2.zip"
+Invoke-WebRequest -URI $WIN32_URL -OutFile "sdl2-win32.zip"
+Expand-Archive "sdl2-win32.zip" -DestinationPath "sdl2-win32" -Force
-Copy-Item -Path "SDL2-2.26.5\x86_64-w64-mingw32\bin\SDL2.dll" -Destination .
\ No newline at end of file
+Invoke-WebRequest -URI $WIN64_URL -OutFile "sdl2-win64.zip"
+Expand-Archive "sdl2-win64.zip" -DestinationPath "sdl2-win64" -Force
+
+Remove-Item "sdl2.zip"
+Remove-Item "sdl2-win32.zip"
+Remove-Item "sdl2-win64.zip"
\ No newline at end of file
--- /dev/null
+++ b/build-win32.ps1
@@ -1,0 +1,25 @@
+$VERSION_TAG = git describe --always --tags --abbrev=0
+$COMMIT_HASH = git rev-parse --short HEAD
+$OS_INFO = (Get-WMIObject win32_operatingsystem).caption + " " + (Get-WMIObject win32_operatingsystem).version + " " + (Get-WMIObject win32_operatingsystem).OSArchitecture
+
+$SDL2_DIR = "SDL2-2.26.5\x86_64-w64-mingw32"
+$PSX_DIR = "."
+
+mkdir -Force -Path bin > $null
+
+gcc -I"`"$($PSX_DIR)`"" `
+ -I"`"$($SDL2_DIR)\include`"" `
+ -I"`"$($SDL2_DIR)\include\SDL2`"" `
+ "psx\*.c" `
+ "psx\dev\*.c" `
+ "frontend\*.c" `
+ -o "bin\psxe.exe" `
+ -DREP_VERSION="`"$($VERSION_TAG)`"" `
+ -DREP_COMMIT_HASH="`"$($COMMIT_HASH)`"" `
+ -DOS_INFO="`"$($OS_INFO)`"" `
+ -L"`"$($SDL2_DIR)\lib`"" `
+ -lSDL2main -lSDL2 -Wno-overflow `
+ -Wall -pedantic -DLOG_USE_COLOR `
+ -ffast-math -Ofast
+
+Copy-Item -Path "sdl2-win32/SDL2.dll" -Destination "bin"
\ No newline at end of file
--- /dev/null
+++ b/build-win64.ps1
@@ -1,0 +1,25 @@
+$VERSION_TAG = git describe --always --tags --abbrev=0
+$COMMIT_HASH = git rev-parse --short HEAD
+$OS_INFO = (Get-WMIObject win32_operatingsystem).caption + " " + (Get-WMIObject win32_operatingsystem).version + " " + (Get-WMIObject win32_operatingsystem).OSArchitecture
+
+$SDL2_DIR = "SDL2-2.26.5\x86_64-w64-mingw32"
+$PSX_DIR = "."
+
+mkdir -Force -Path bin > $null
+
+gcc -I"`"$($PSX_DIR)`"" `
+ -I"`"$($SDL2_DIR)\include`"" `
+ -I"`"$($SDL2_DIR)\include\SDL2`"" `
+ "psx\*.c" `
+ "psx\dev\*.c" `
+ "frontend\*.c" `
+ -o "bin\psxe.exe" `
+ -DREP_VERSION="`"$($VERSION_TAG)`"" `
+ -DREP_COMMIT_HASH="`"$($COMMIT_HASH)`"" `
+ -DOS_INFO="`"$($OS_INFO)`"" `
+ -L"`"$($SDL2_DIR)\lib`"" `
+ -m64 -lSDL2main -lSDL2 -Wno-overflow `
+ -Wall -pedantic -DLOG_USE_COLOR `
+ -ffast-math -Ofast
+
+Copy-Item -Path "sdl2-win64/SDL2.dll" -Destination "bin"
\ No newline at end of file
--- /dev/null
+++ b/build.sh
@@ -1,0 +1,19 @@
+#!/bin/sh
+
+# Build emulator
+make clean && make
+
+# Create bundle filesystem
+mkdir -p psxe.app/Contents/MacOS/Libraries
+
+# Move executable to folder
+mv bin/psxe psxe.app/Contents/MacOS
+
+# Make executable
+chmod 777 psxe.app/Contents/MacOS/psxe
+
+# Bundle required dylibs
+dylibbundler -b -x ./psxe.app/Contents/MacOS/psxe -d ./psxe.app/Contents/Libraries/ -p @executable_path/../Libraries/ -cd
+
+# Move plist to Contents folder
+mv Info.plist psxe.app/Contents/Info.plist
\ No newline at end of file
--- a/frontend/screen.c
+++ b/frontend/screen.c
@@ -21,9 +21,13 @@
screen->psx = psx;
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS);
+
+ SDL_SetHint("SDL_HINT_RENDER_SCALE_QUALITY", "2");}
void psxe_screen_reload(psxe_screen_t* screen) {+ SDL_SetHint("SDL_HINT_RENDER_SCALE_QUALITY", "2");+
if (screen->texture) SDL_DestroyTexture(screen->texture);
if (screen->renderer) SDL_DestroyRenderer(screen->renderer);
if (screen->window) SDL_DestroyWindow(screen->window);
@@ -33,7 +37,7 @@
SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
screen->width * screen->scale,
screen->height * screen->scale,
- SDL_WINDOW_OPENGL
+ SDL_WINDOW_OPENGL | SDL_WINDOW_ALLOW_HIGHDPI
);
screen->renderer = SDL_CreateRenderer(
@@ -48,6 +52,18 @@
SDL_TEXTUREACCESS_STREAMING,
PSX_GPU_FB_WIDTH, PSX_GPU_FB_HEIGHT
);
+
+ // Check for retina displays
+ int width = 0, height = 0;
+
+ SDL_GetRendererOutputSize(screen->renderer, &width, &height);
+
+ if (width != (screen->width * screen->scale)) {+ float width_scale = (float)width / (float)(screen->width * screen->scale);
+ float height_scale = (float)height / (float)(screen->height * screen->scale);
+
+ SDL_RenderSetScale(screen->renderer, width_scale, height_scale);
+ }
screen->open = 1;
}
--
⑨