Merge branch 'dev' into comments

This commit is contained in:
white-axe 2024-01-22 15:21:29 -05:00
commit 073c294e12
No known key found for this signature in database
GPG key ID: 7901753DB465B711
37 changed files with 1099 additions and 32 deletions

View file

@ -83,8 +83,8 @@ jobs:
build/artifact/scripts/ build/artifact/scripts/
build/artifact/stdlib/ build/artifact/stdlib/
build-linux: build-linux-native:
name: Ubuntu 22.04 name: Ubuntu 22.04 x86_64
runs-on: ubuntu-22.04 runs-on: ubuntu-22.04
steps: steps:
- uses: benjlevesque/short-sha@v2.2 - uses: benjlevesque/short-sha@v2.2
@ -100,7 +100,7 @@ jobs:
path: | path: |
linux/build-x86_64 linux/build-x86_64
linux/downloads linux/downloads
key: lin-${{ hashFiles('linux/Makefile') }} key: lin-x86_64-${{ hashFiles('linux/Makefile') }}
- name: Install apt dependencies - name: Install apt dependencies
run: | run: |
@ -133,7 +133,112 @@ jobs:
- uses: actions/upload-artifact@v3 - uses: actions/upload-artifact@v3
with: with:
name: mkxp-z.linux.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}} name: mkxp-z.linux.x86_64.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}}
path: build/local.zip
build-linux-cross:
name: Ubuntu 22.04 ${{matrix.arch_mkxpz}}
runs-on: ubuntu-22.04
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
include:
- arch_mkxpz: armv6
arch_debian: armhf
arch_gcc: arm-linux-gnueabihf
# GCC doesn't like the -mcpu flags, TODO investigate.
experimental: true
- arch_mkxpz: armv7
arch_debian: armhf
arch_gcc: arm-linux-gnueabihf
# GCC doesn't like the -mcpu flags, TODO investigate.
experimental: true
- arch_mkxpz: armv7-neon
arch_debian: armhf
arch_gcc: arm-linux-gnueabihf
experimental: false
- arch_mkxpz: arm64
arch_debian: arm64
arch_gcc: aarch64-linux-gnu
experimental: false
- arch_mkxpz: power8le
arch_debian: ppc64el
arch_gcc: powerpc64le-linux-gnu
experimental: false
- arch_mkxpz: power9le
arch_debian: ppc64el
arch_gcc: powerpc64le-linux-gnu
experimental: false
- arch_mkxpz: riscv64
arch_debian: riscv64
arch_gcc: riscv64-linux-gnu
# libjxl/highway compatibility issue, TODO check if fixed in later SDL_image.
# Also probably an OpenSSL arch name issue.
experimental: true
steps:
- uses: benjlevesque/short-sha@v2.2
id: short-sha
with:
length: 7
- name: Checkout repository
uses: actions/checkout@v3
- uses: actions/cache@v3
with:
path: |
linux/build-${{matrix.arch_mkxpz}}
linux/downloads
key: lin-${{matrix.arch_mkxpz}}-${{ hashFiles('linux/Makefile', 'linux/target*', 'linux/toolchain*') }}
- name: Install apt dependencies
run: |
sudo sed -i "s/deb /deb [arch=amd64] /g" /etc/apt/sources.list
sudo dpkg --add-architecture ${{matrix.arch_debian}}
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy-updates main restricted" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy-updates universe" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy-updates multiverse" | sudo tee -a /etc/apt/sources.list
echo "deb [arch=${{matrix.arch_debian}}] http://ports.ubuntu.com/ jammy-backports main restricted universe multiverse" | sudo tee -a /etc/apt/sources.list
sudo apt update
sudo apt install git build-essential cmake meson autoconf automake libtool pkg-config ruby bison -y
sudo apt install libdmx-dev:${{matrix.arch_debian}} libfontenc-dev:${{matrix.arch_debian}} libfs-dev:${{matrix.arch_debian}} libice-dev:${{matrix.arch_debian}} libsm-dev:${{matrix.arch_debian}} libx11-dev:${{matrix.arch_debian}} libxau-dev:${{matrix.arch_debian}} libxaw7-dev:${{matrix.arch_debian}} libxcomposite-dev:${{matrix.arch_debian}} libxcursor-dev:${{matrix.arch_debian}} libxdamage-dev:${{matrix.arch_debian}} libxdmcp-dev:${{matrix.arch_debian}} libxext-dev:${{matrix.arch_debian}} libxfixes-dev:${{matrix.arch_debian}} libxfont-dev:${{matrix.arch_debian}} libxft-dev:${{matrix.arch_debian}} libxi-dev:${{matrix.arch_debian}} libxinerama-dev:${{matrix.arch_debian}} libxkbfile-dev:${{matrix.arch_debian}} libxmu-dev:${{matrix.arch_debian}} libxmuu-dev:${{matrix.arch_debian}} libxpm-dev:${{matrix.arch_debian}} libxrandr-dev:${{matrix.arch_debian}} libxrender-dev:${{matrix.arch_debian}} libxres-dev:${{matrix.arch_debian}} libxss-dev:${{matrix.arch_debian}} libxt-dev:${{matrix.arch_debian}} libxtst-dev:${{matrix.arch_debian}} libxv-dev:${{matrix.arch_debian}} libxvmc-dev:${{matrix.arch_debian}} libxxf86dga-dev:${{matrix.arch_debian}} libxxf86vm-dev:${{matrix.arch_debian}} x11proto-dev:${{matrix.arch_debian}} xserver-xorg-dev:${{matrix.arch_debian}} xtrans-dev:${{matrix.arch_debian}} -y
sudo apt install gcc-${{matrix.arch_gcc}} g++-${{matrix.arch_gcc}} zlib1g-dev:${{matrix.arch_debian}} libbz2-dev:${{matrix.arch_debian}} libgl1-mesa-dev:${{matrix.arch_debian}} libasound2-dev:${{matrix.arch_debian}} libpulse-dev:${{matrix.arch_debian}} -y
- name: Build everything else
run: |
cd linux
source target-${{matrix.arch_mkxpz}}.sh
make
- name: Build executable
run: |
source linux/target-${{matrix.arch_mkxpz}}.sh
source linux/vars.sh
meson setup --cross-file linux/$ARCH_MESON_TOOLCHAIN build --bindir=. --prefix=$GITHUB_WORKSPACE/build/local
cd build
ninja
ninja install
cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib*/
cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib*/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib*/
- name: Prepare archive
run: |
cd build/local
cp -r ../../linux/build-${{matrix.arch_mkxpz}}/lib/ruby/3.1.0 .
mv ./3.1.0 ./stdlib
cp ../../mkxp.json .
cp -r ../../scripts .
cp ../../assets/LICENSE.mkxp-z-with-https.txt .
cd ..
zip -r local.zip local
- uses: actions/upload-artifact@v3
with:
name: mkxp-z.linux.${{matrix.arch_mkxpz}}.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}}
path: build/local.zip path: build/local.zip
build-macos: build-macos:

View file

@ -23,7 +23,7 @@ This is a fork of mkxp intended to be a little more than just a barebones recrea
Despite the fact that it was made with Essentials games in mind, there is nothing connected to it contained in this repository, and it should still be compatible with anything that runs in the upstream version of MKXP. You can think of it as MKXP but a bit supercharged -- it should be able to run all but the most demanding of RGSS projects, given a bit of porting work. Despite the fact that it was made with Essentials games in mind, there is nothing connected to it contained in this repository, and it should still be compatible with anything that runs in the upstream version of MKXP. You can think of it as MKXP but a bit supercharged -- it should be able to run all but the most demanding of RGSS projects, given a bit of porting work.
It supports Windows, Linux and both Intel and Apple Silicon versions of macOS. It supports Windows, Linux (x86, ARM, and POWER), and both Intel and Apple Silicon versions of macOS.
mkxp-z is licensed under the GNU General Public License v2+. However, if you build mkxp-z with the `enable-https` option turned on (which is the default), you will also need to comply with OpenSSL's Apache v2 license, which in practice means that the resulting binaries are licensed under GPLv3. mkxp-z is licensed under the GNU General Public License v2+. However, if you build mkxp-z with the `enable-https` option turned on (which is the default), you will also need to comply with OpenSSL's Apache v2 license, which in practice means that the resulting binaries are licensed under GPLv3.

View file

@ -1,10 +1,13 @@
ARCH := $(shell uname -m) ARCH ?= $(shell uname -m)
ARCH_OPENSSL ?= $(ARCH)
ARCH_CFLAGS ?=
ARCH_CONFIGURE ?= $(shell gcc -dumpmachine)
SDL_FLAGS := ${SDL_FLAGS} SDL_FLAGS := ${SDL_FLAGS}
SDL2_IMAGE_FLAGS := ${SDL2_IMAGE_FLAGS} SDL2_IMAGE_FLAGS := ${SDL2_IMAGE_FLAGS}
SDL2_TTF_FLAGS := ${SDL2_TTF_FLAGS} SDL2_TTF_FLAGS := ${SDL2_TTF_FLAGS}
OPENAL_FLAGS := -DALSOFT_CPUEXT_NEON=no ${OPENAL_FLAGS} OPENAL_FLAGS := -DALSOFT_CPUEXT_NEON=no ${OPENAL_FLAGS}
OPENSSL_FLAGS := linux-$(ARCH) ${OPENSSL_FLAGS} OPENSSL_FLAGS := linux-$(ARCH_OPENSSL) ${OPENSSL_FLAGS}
RUBY_FLAGS := ${RUBY_FLAGS} RUBY_FLAGS := ${RUBY_FLAGS}
BUILD_PREFIX := ${PWD}/build-$(ARCH) BUILD_PREFIX := ${PWD}/build-$(ARCH)
@ -12,9 +15,9 @@ LIBDIR := $(BUILD_PREFIX)/lib
INCLUDEDIR := $(BUILD_PREFIX)/include INCLUDEDIR := $(BUILD_PREFIX)/include
DOWNLOADS := ${PWD}/downloads/$(ARCH) DOWNLOADS := ${PWD}/downloads/$(ARCH)
NPROC := $(shell nproc) NPROC := $(shell nproc)
CFLAGS := -I$(INCLUDEDIR) -flax-vector-conversions -O3 CFLAGS := -I$(INCLUDEDIR) -flax-vector-conversions -O3 $(ARCH_CFLAGS)
LDFLAGS := -L$(LIBDIR) LDFLAGS := -L$(LIBDIR)
CC := gcc CC ?= gcc
PKG_CONFIG_LIBDIR := $(BUILD_PREFIX)/lib/pkgconfig PKG_CONFIG_LIBDIR := $(BUILD_PREFIX)/lib/pkgconfig
GIT := git GIT := git
CLONE := $(GIT) clone -q CLONE := $(GIT) clone -q
@ -24,14 +27,19 @@ CONFIGURE_ENV := \
PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) \ PKG_CONFIG_LIBDIR=$(PKG_CONFIG_LIBDIR) \
CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" CC="$(CC)" CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)"
CONFIGURE_ARGS := --prefix="$(BUILD_PREFIX)" CONFIGURE_ARGS := --prefix="$(BUILD_PREFIX)" --host="$(ARCH_CONFIGURE)"
ifdef ARCH_CMAKE_TOOLCHAIN
ARCH_CMAKE_ARGS := -DCMAKE_TOOLCHAIN_FILE="${PWD}/$(ARCH_CMAKE_TOOLCHAIN)"
endif
CMAKE_ARGS := \ CMAKE_ARGS := \
-DCMAKE_INSTALL_PREFIX="$(BUILD_PREFIX)" \ -DCMAKE_INSTALL_PREFIX="$(BUILD_PREFIX)" \
-DCMAKE_PREFIX_PATH="$(BUILD_PREFIX)" \ -DCMAKE_PREFIX_PATH="$(BUILD_PREFIX)" \
-DCMAKE_C_FLAGS="$(CFLAGS)" \ -DCMAKE_C_FLAGS="$(CFLAGS)" \
-DCMAKE_BUILD_TYPE=Release -DCMAKE_BUILD_TYPE=Release \
$(ARCH_CMAKE_ARGS)
# TODO: Check if we can disable rubygems, remove prefixes.
RUBY_CONFIGURE_ARGS := \ RUBY_CONFIGURE_ARGS := \
--enable-install-static-library \ --enable-install-static-library \
--enable-shared \ --enable-shared \
@ -316,7 +324,7 @@ ruby: init_dirs openssl $(LIBDIR)/libruby.so.3.1
$(LIBDIR)/libruby.so.3.1: $(DOWNLOADS)/ruby/Makefile $(LIBDIR)/libruby.so.3.1: $(DOWNLOADS)/ruby/Makefile
cd $(DOWNLOADS)/ruby; \ cd $(DOWNLOADS)/ruby; \
make -j$(NPROC); make install make -j$(NPROC); make install DESTDIR="$(BUILD_PREFIX)"
$(DOWNLOADS)/ruby/Makefile: $(DOWNLOADS)/ruby/configure $(DOWNLOADS)/ruby/Makefile: $(DOWNLOADS)/ruby/configure
cd $(DOWNLOADS)/ruby; \ cd $(DOWNLOADS)/ruby; \

13
linux/meson-arm64.txt Normal file
View file

@ -0,0 +1,13 @@
[binaries]
c = 'aarch64-linux-gnu-gcc'
cpp = 'aarch64-linux-gnu-g++'
ar = 'aarch64-linux-gnu-ar'
strip = 'aarch64-linux-gnu-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'aarch64'
cpu = 'generic-armv8-a'
endian = 'little'

13
linux/meson-armv6.txt Normal file
View file

@ -0,0 +1,13 @@
[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-g++'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'generic-armv6+fp'
endian = 'little'

View file

@ -0,0 +1,13 @@
[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-g++'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'generic-armv7-a+neon'
endian = 'little'

13
linux/meson-armv7.txt Normal file
View file

@ -0,0 +1,13 @@
[binaries]
c = 'arm-linux-gnueabihf-gcc'
cpp = 'arm-linux-gnueabihf-g++'
ar = 'arm-linux-gnueabihf-ar'
strip = 'arm-linux-gnueabihf-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'arm'
cpu = 'generic-armv7-a+fp'
endian = 'little'

13
linux/meson-power8le.txt Normal file
View file

@ -0,0 +1,13 @@
[binaries]
c = 'powerpc64le-linux-gnu-gcc'
cpp = 'powerpc64le-linux-gnu-g++'
ar = 'powerpc64le-linux-gnu-ar'
strip = 'powerpc64le-linux-gnu-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'ppc64'
cpu = 'power8'
endian = 'little'

13
linux/meson-power9le.txt Normal file
View file

@ -0,0 +1,13 @@
[binaries]
c = 'powerpc64le-linux-gnu-gcc'
cpp = 'powerpc64le-linux-gnu-g++'
ar = 'powerpc64le-linux-gnu-ar'
strip = 'powerpc64le-linux-gnu-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'ppc64'
cpu = 'power9'
endian = 'little'

13
linux/meson-riscv64.txt Normal file
View file

@ -0,0 +1,13 @@
[binaries]
c = 'riscv64-linux-gnu-gcc'
cpp = 'riscv64-linux-gnu-g++'
ar = 'riscv64-linux-gnu-ar'
strip = 'riscv64-linux-gnu-strip'
pkgconfig = 'pkg-config'
cmake = 'cmake'
[host_machine]
system = 'linux'
cpu_family = 'riscv64'
cpu = 'rv64gc'
endian = 'little'

28
linux/target-arm64.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture arm64
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:arm64 libfontenc-dev:arm64 libfs-dev:arm64 libice-dev:arm64 libsm-dev:arm64 libx11-dev:arm64 libxau-dev:arm64 libxaw7-dev:arm64 libxcomposite-dev:arm64 libxcursor-dev:arm64 libxdamage-dev:arm64 libxdmcp-dev:arm64 libxext-dev:arm64 libxfixes-dev:arm64 libxfont-dev:arm64 libxft-dev:arm64 libxi-dev:arm64 libxinerama-dev:arm64 libxkbfile-dev:arm64 libxmu-dev:arm64 libxmuu-dev:arm64 libxpm-dev:arm64 libxrandr-dev:arm64 libxrender-dev:arm64 libxres-dev:arm64 libxss-dev:arm64 libxt-dev:arm64 libxtst-dev:arm64 libxv-dev:arm64 libxvmc-dev:arm64 libxxf86dga-dev:arm64 libxxf86vm-dev:arm64 x11proto-dev:arm64 xserver-xorg-dev:arm64 xtrans-dev:arm64
# sudo apt install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu zlib1g-dev:arm64 libbz2-dev:arm64 libgl1-mesa-dev:arm64 libasound2-dev:arm64 libpulse-dev:arm64
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=arm64
export ARCH_OPENSSL=aarch64
export ARCH_CFLAGS=""
export ARCH_CONFIGURE=aarch64-linux-gnu
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-arm64.cmake
export ARCH_MESON_TOOLCHAIN=meson-arm64.txt

28
linux/target-armv6.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture armhf
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:armhf libfontenc-dev:armhf libfs-dev:armhf libice-dev:armhf libsm-dev:armhf libx11-dev:armhf libxau-dev:armhf libxaw7-dev:armhf libxcomposite-dev:armhf libxcursor-dev:armhf libxdamage-dev:armhf libxdmcp-dev:armhf libxext-dev:armhf libxfixes-dev:armhf libxfont-dev:armhf libxft-dev:armhf libxi-dev:armhf libxinerama-dev:armhf libxkbfile-dev:armhf libxmu-dev:armhf libxmuu-dev:armhf libxpm-dev:armhf libxrandr-dev:armhf libxrender-dev:armhf libxres-dev:armhf libxss-dev:armhf libxt-dev:armhf libxtst-dev:armhf libxv-dev:armhf libxvmc-dev:armhf libxxf86dga-dev:armhf libxxf86vm-dev:armhf x11proto-dev:armhf xserver-xorg-dev:armhf xtrans-dev:armhf
# sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf zlib1g-dev:armhf libbz2-dev:armhf libgl1-mesa-dev:armhf libasound2-dev:armhf libpulse-dev:armhf
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=armv6
export ARCH_OPENSSL=armv4
export ARCH_CFLAGS="-mcpu=generic-armv6+fp -mtune=generic-armv6+fp"
export ARCH_CONFIGURE=arm-linux-gnueabihf
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-arm32.cmake
export ARCH_MESON_TOOLCHAIN=meson-armv6.txt

28
linux/target-armv7-neon.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture armhf
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:armhf libfontenc-dev:armhf libfs-dev:armhf libice-dev:armhf libsm-dev:armhf libx11-dev:armhf libxau-dev:armhf libxaw7-dev:armhf libxcomposite-dev:armhf libxcursor-dev:armhf libxdamage-dev:armhf libxdmcp-dev:armhf libxext-dev:armhf libxfixes-dev:armhf libxfont-dev:armhf libxft-dev:armhf libxi-dev:armhf libxinerama-dev:armhf libxkbfile-dev:armhf libxmu-dev:armhf libxmuu-dev:armhf libxpm-dev:armhf libxrandr-dev:armhf libxrender-dev:armhf libxres-dev:armhf libxss-dev:armhf libxt-dev:armhf libxtst-dev:armhf libxv-dev:armhf libxvmc-dev:armhf libxxf86dga-dev:armhf libxxf86vm-dev:armhf x11proto-dev:armhf xserver-xorg-dev:armhf xtrans-dev:armhf
# sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf zlib1g-dev:armhf libbz2-dev:armhf libgl1-mesa-dev:armhf libasound2-dev:armhf libpulse-dev:armhf
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=armv7-neon
export ARCH_OPENSSL=armv4
export ARCH_CFLAGS="-mcpu=generic-armv7-a+neon -mtune=generic-armv7-a+neon"
export ARCH_CONFIGURE=arm-linux-gnueabihf
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-arm32.cmake
export ARCH_MESON_TOOLCHAIN=meson-armv7-neon.txt

28
linux/target-armv7.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture armhf
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:armhf libfontenc-dev:armhf libfs-dev:armhf libice-dev:armhf libsm-dev:armhf libx11-dev:armhf libxau-dev:armhf libxaw7-dev:armhf libxcomposite-dev:armhf libxcursor-dev:armhf libxdamage-dev:armhf libxdmcp-dev:armhf libxext-dev:armhf libxfixes-dev:armhf libxfont-dev:armhf libxft-dev:armhf libxi-dev:armhf libxinerama-dev:armhf libxkbfile-dev:armhf libxmu-dev:armhf libxmuu-dev:armhf libxpm-dev:armhf libxrandr-dev:armhf libxrender-dev:armhf libxres-dev:armhf libxss-dev:armhf libxt-dev:armhf libxtst-dev:armhf libxv-dev:armhf libxvmc-dev:armhf libxxf86dga-dev:armhf libxxf86vm-dev:armhf x11proto-dev:armhf xserver-xorg-dev:armhf xtrans-dev:armhf
# sudo apt install gcc-arm-linux-gnueabihf g++-arm-linux-gnueabihf zlib1g-dev:armhf libbz2-dev:armhf libgl1-mesa-dev:armhf libasound2-dev:armhf libpulse-dev:armhf
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=armv7
export ARCH_OPENSSL=armv4
export ARCH_CFLAGS="-mcpu=generic-armv7-a+fp -mtune=generic-armv7-a+fp"
export ARCH_CONFIGURE=arm-linux-gnueabihf
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-arm32.cmake
export ARCH_MESON_TOOLCHAIN=meson-armv7.txt

28
linux/target-power8le.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture ppc64el
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:ppc64el libfontenc-dev:ppc64el libfs-dev:ppc64el libice-dev:ppc64el libsm-dev:ppc64el libx11-dev:ppc64el libxau-dev:ppc64el libxaw7-dev:ppc64el libxcomposite-dev:ppc64el libxcursor-dev:ppc64el libxdamage-dev:ppc64el libxdmcp-dev:ppc64el libxext-dev:ppc64el libxfixes-dev:ppc64el libxfont-dev:ppc64el libxft-dev:ppc64el libxi-dev:ppc64el libxinerama-dev:ppc64el libxkbfile-dev:ppc64el libxmu-dev:ppc64el libxmuu-dev:ppc64el libxpm-dev:ppc64el libxrandr-dev:ppc64el libxrender-dev:ppc64el libxres-dev:ppc64el libxss-dev:ppc64el libxt-dev:ppc64el libxtst-dev:ppc64el libxv-dev:ppc64el libxvmc-dev:ppc64el libxxf86dga-dev:ppc64el libxxf86vm-dev:ppc64el x11proto-dev:ppc64el xserver-xorg-dev:ppc64el xtrans-dev:ppc64el
# sudo apt install gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu zlib1g-dev:ppc64el libbz2-dev:ppc64el libgl1-mesa-dev:ppc64el libasound2-dev:ppc64el libpulse-dev:ppc64el
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=power8le
export ARCH_OPENSSL=ppc64le
export ARCH_CFLAGS="-mcpu=power8 -mtune=power8"
export ARCH_CONFIGURE=powerpc64le-linux-gnu
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-ppc64le.cmake
export ARCH_MESON_TOOLCHAIN=meson-power8le.txt

28
linux/target-power9le.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture ppc64el
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:ppc64el libfontenc-dev:ppc64el libfs-dev:ppc64el libice-dev:ppc64el libsm-dev:ppc64el libx11-dev:ppc64el libxau-dev:ppc64el libxaw7-dev:ppc64el libxcomposite-dev:ppc64el libxcursor-dev:ppc64el libxdamage-dev:ppc64el libxdmcp-dev:ppc64el libxext-dev:ppc64el libxfixes-dev:ppc64el libxfont-dev:ppc64el libxft-dev:ppc64el libxi-dev:ppc64el libxinerama-dev:ppc64el libxkbfile-dev:ppc64el libxmu-dev:ppc64el libxmuu-dev:ppc64el libxpm-dev:ppc64el libxrandr-dev:ppc64el libxrender-dev:ppc64el libxres-dev:ppc64el libxss-dev:ppc64el libxt-dev:ppc64el libxtst-dev:ppc64el libxv-dev:ppc64el libxvmc-dev:ppc64el libxxf86dga-dev:ppc64el libxxf86vm-dev:ppc64el x11proto-dev:ppc64el xserver-xorg-dev:ppc64el xtrans-dev:ppc64el
# sudo apt install gcc-powerpc64le-linux-gnu g++-powerpc64le-linux-gnu zlib1g-dev:ppc64el libbz2-dev:ppc64el libgl1-mesa-dev:ppc64el libasound2-dev:ppc64el libpulse-dev:ppc64el
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=power9le
export ARCH_OPENSSL=ppc64le
export ARCH_CFLAGS="-mcpu=power9 -mtune=power9"
export ARCH_CONFIGURE=powerpc64le-linux-gnu
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-ppc64le.cmake
export ARCH_MESON_TOOLCHAIN=meson-power9le.txt

28
linux/target-riscv64.sh Executable file
View file

@ -0,0 +1,28 @@
#!/usr/bin/env bash
# Deps instructions:
# sudo dpkg --add-architecture riscv64
# (Target versions of xorg-dev; removes native versions of: libxfont-dev xorg-dev xserver-xorg-dev) sudo apt install libdmx-dev:riscv64 libfontenc-dev:riscv64 libfs-dev:riscv64 libice-dev:riscv64 libsm-dev:riscv64 libx11-dev:riscv64 libxau-dev:riscv64 libxaw7-dev:riscv64 libxcomposite-dev:riscv64 libxcursor-dev:riscv64 libxdamage-dev:riscv64 libxdmcp-dev:riscv64 libxext-dev:riscv64 libxfixes-dev:riscv64 libxfont-dev:riscv64 libxft-dev:riscv64 libxi-dev:riscv64 libxinerama-dev:riscv64 libxkbfile-dev:riscv64 libxmu-dev:riscv64 libxmuu-dev:riscv64 libxpm-dev:riscv64 libxrandr-dev:riscv64 libxrender-dev:riscv64 libxres-dev:riscv64 libxss-dev:riscv64 libxt-dev:riscv64 libxtst-dev:riscv64 libxv-dev:riscv64 libxvmc-dev:riscv64 libxxf86dga-dev:riscv64 libxxf86vm-dev:riscv64 x11proto-dev:riscv64 xserver-xorg-dev:riscv64 xtrans-dev:riscv64
# sudo apt install gcc-riscv64-linux-gnu g++-riscv64-linux-gnu zlib1g-dev:riscv64 libbz2-dev:riscv64 libgl1-mesa-dev:riscv64 libasound2-dev:riscv64 libpulse-dev:riscv64
# Build instructions
# cd linux
# source target-whatever.sh
# make
# source vars.sh
# cd ../
# meson setup --cross-file ./linux/$ARCH_MESON_TOOLCHAIN build
# cd build
# ninja
# meson configure --bindir=. --prefix=$PWD/local
# ninja install
# cp "$MKXPZ_PREFIX/lib/$("$ARCH_CONFIGURE-objdump" -p local/mkxp-z* | grep -i NEEDED | grep -Eo 'libruby.so.[0-9\.]+')" local/lib64/
# cp "/usr/lib/$ARCH_CONFIGURE/$("$ARCH_CONFIGURE-objdump" -p local/lib64/libruby.so* | grep -i NEEDED | grep -Eo 'libcrypt.so.[0-9\.]+')" local/lib64/
export ARCH=riscv64
export ARCH_OPENSSL=riscv64
export ARCH_CFLAGS=""
export ARCH_CONFIGURE=riscv64-linux-gnu
export CC="$ARCH_CONFIGURE-gcc"
export ARCH_CMAKE_TOOLCHAIN=toolchain-riscv64.cmake
export ARCH_MESON_TOOLCHAIN=meson-riscv64.txt

View file

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR arm)
set(CMAKE_C_COMPILER ${tools}/bin/arm-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/arm-linux-gnueabihf-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View file

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR aarch64)
set(CMAKE_C_COMPILER ${tools}/bin/aarch64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/aarch64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View file

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR ppc64le)
set(CMAKE_C_COMPILER ${tools}/bin/powerpc64le-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/powerpc64le-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View file

@ -0,0 +1,8 @@
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSTEM_PROCESSOR riscv64)
set(CMAKE_C_COMPILER ${tools}/bin/riscv64-linux-gnu-gcc)
set(CMAKE_CXX_COMPILER ${tools}/bin/riscv64-linux-gnu-g++)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)

View file

@ -1,12 +1,24 @@
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
MKXPZ_PREFIX=$(uname -m) MKXPZ_PREFIX="$ARCH"
if [ "$MKXPZ_PREFIX" = "" ]
then
MKXPZ_PREFIX=$(uname -m)
fi
export LDFLAGS="-L$DIR/build-${MKXPZ_PREFIX}/lib" export LDFLAGS="-L$DIR/build-${MKXPZ_PREFIX}/lib"
export CFLAGS="-I$DIR/build-${MKXPZ_PREFIX}/include" export CFLAGS="-I$DIR/build-${MKXPZ_PREFIX}/include"
MKXPZ_OLD_PC=$(pkg-config --variable pc_path pkg-config) MKXPZ_OLD_PC=$(pkg-config --variable pc_path pkg-config)
if [ "$ARCH_CONFIGURE" != "" ]
then
MKXPZ_OLD_PC="/usr/lib/$ARCH_CONFIGURE/pkgconfig"
fi
# Try to load the stuff we built first # Try to load the stuff we built first
export PKG_CONFIG_LIBDIR="$DIR/build-${MKXPZ_PREFIX}/lib/pkgconfig:$DIR/build-${MKXPZ_PREFIX}/lib64/pkgconfig:${MKXPZ_OLD_PC}" export PKG_CONFIG_LIBDIR="$DIR/build-${MKXPZ_PREFIX}/lib/pkgconfig:$DIR/build-${MKXPZ_PREFIX}/lib64/pkgconfig:${MKXPZ_OLD_PC}"
export PATH="$DIR/build-${MKXPZ_PREFIX}/bin:$PATH" export PATH="$DIR/build-${MKXPZ_PREFIX}/bin:$PATH"
export LD_LIBRARY_PATH="$DIR/build-${MKXPZ_PREFIX}/lib:${LD_LIBRARY_PATH}" export LD_LIBRARY_PATH="$DIR/build-${MKXPZ_PREFIX}/lib:${LD_LIBRARY_PATH}"
export MKXPZ_PREFIX="$DIR/build-${MKXPZ_PREFIX}" export MKXPZ_PREFIX="$DIR/build-${MKXPZ_PREFIX}"
# Horrifying Ruby cross-compile bug workaround
MKXPZ_RUBY_PREFIX="$MKXPZ_PREFIX/$MKXPZ_PREFIX"
cp -a "$MKXPZ_RUBY_PREFIX"/* "$MKXPZ_PREFIX/"

View file

@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */ /* Begin PBXBuildFile section */
02054AB6B60F49E3DF366CBD /* libjxl_dec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 672947DA8FC50921A7ED814A /* libjxl_dec.a */; }; 02054AB6B60F49E3DF366CBD /* libjxl_dec.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 672947DA8FC50921A7ED814A /* libjxl_dec.a */; };
21B74169A8853D63648093D5 /* xbrz.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = 88734C4B8039751FD0A59FA7 /* xbrz.frag */; };
319D403193F13F7989325EEA /* bicubic.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */; }; 319D403193F13F7989325EEA /* bicubic.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */; };
3389416F9825F408A40824F3 /* libbrotlicommon-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8AA4AE49BB66C97EFAE3055 /* libbrotlicommon-static.a */; }; 3389416F9825F408A40824F3 /* libbrotlicommon-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = A8AA4AE49BB66C97EFAE3055 /* libbrotlicommon-static.a */; };
3B10EC5C2568D40500372D13 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; }; 3B10EC5C2568D40500372D13 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BE081562568D3A60006849F /* CoreGraphics.framework */; };
@ -505,6 +506,7 @@
3BF5B4BD2685881D00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BC2685881C00A3B240 /* libSDL2_sound.a */; }; 3BF5B4BD2685881D00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BC2685881C00A3B240 /* libSDL2_sound.a */; };
3BF5B4BF2685883B00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BE2685883B00A3B240 /* libSDL2_sound.a */; }; 3BF5B4BF2685883B00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BE2685883B00A3B240 /* libSDL2_sound.a */; };
3BF5B4C02685883B00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BE2685883B00A3B240 /* libSDL2_sound.a */; }; 3BF5B4C02685883B00A3B240 /* libSDL2_sound.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3BF5B4BE2685883B00A3B240 /* libSDL2_sound.a */; };
3D094509A210271690AF48F7 /* xbrz.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = 88734C4B8039751FD0A59FA7 /* xbrz.frag */; };
3E2542219A9FD2B16781B1F5 /* libbrotlidec-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4B4BA780D4407F24279700 /* libbrotlidec-static.a */; }; 3E2542219A9FD2B16781B1F5 /* libbrotlidec-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 3C4B4BA780D4407F24279700 /* libbrotlidec-static.a */; };
3F7F41D98CEDE6F418AAB0D2 /* bicubic.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */; }; 3F7F41D98CEDE6F418AAB0D2 /* bicubic.frag in CopyFiles */ = {isa = PBXBuildFile; fileRef = CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */; };
74E9471FB1A876B0D9F2ABFF /* libbrotlidec-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C254B088D8B18C7E957DE30 /* libbrotlidec-static.a */; }; 74E9471FB1A876B0D9F2ABFF /* libbrotlidec-static.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 5C254B088D8B18C7E957DE30 /* libbrotlidec-static.a */; };
@ -766,6 +768,7 @@
3B10ECE92568E83D00372D13 /* trans.frag in CopyFiles */, 3B10ECE92568E83D00372D13 /* trans.frag in CopyFiles */,
3B10ECEA2568E83D00372D13 /* transSimple.frag in CopyFiles */, 3B10ECEA2568E83D00372D13 /* transSimple.frag in CopyFiles */,
3F7F41D98CEDE6F418AAB0D2 /* bicubic.frag in CopyFiles */, 3F7F41D98CEDE6F418AAB0D2 /* bicubic.frag in CopyFiles */,
3D094509A210271690AF48F7 /* xbrz.frag in CopyFiles */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -777,6 +780,7 @@
files = ( files = (
3B10ECF52568E86B00372D13 /* liberation.ttf in CopyFiles */, 3B10ECF52568E86B00372D13 /* liberation.ttf in CopyFiles */,
319D403193F13F7989325EEA /* bicubic.frag in CopyFiles */, 319D403193F13F7989325EEA /* bicubic.frag in CopyFiles */,
21B74169A8853D63648093D5 /* xbrz.frag in CopyFiles */,
); );
runOnlyForDeploymentPostprocessing = 0; runOnlyForDeploymentPostprocessing = 0;
}; };
@ -1128,6 +1132,7 @@
5C254B088D8B18C7E957DE30 /* libbrotlidec-static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libbrotlidec-static.a"; path = "Dependencies/build-macosx-x86_64/lib/libbrotlidec-static.a"; sourceTree = "<group>"; }; 5C254B088D8B18C7E957DE30 /* libbrotlidec-static.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = "libbrotlidec-static.a"; path = "Dependencies/build-macosx-x86_64/lib/libbrotlidec-static.a"; sourceTree = "<group>"; };
667B4E3FBC5B03611D5C334E /* libhwy.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libhwy.a; path = "Dependencies/build-macosx-universal/lib/libhwy.a"; sourceTree = "<group>"; }; 667B4E3FBC5B03611D5C334E /* libhwy.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libhwy.a; path = "Dependencies/build-macosx-universal/lib/libhwy.a"; sourceTree = "<group>"; };
672947DA8FC50921A7ED814A /* libjxl_dec.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjxl_dec.a; path = "Dependencies/build-macosx-universal/lib/libjxl_dec.a"; sourceTree = "<group>"; }; 672947DA8FC50921A7ED814A /* libjxl_dec.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libjxl_dec.a; path = "Dependencies/build-macosx-universal/lib/libjxl_dec.a"; sourceTree = "<group>"; };
88734C4B8039751FD0A59FA7 /* xbrz.frag */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.glsl; name = xbrz.frag; path = ../shader/xbrz.frag; sourceTree = "<group>"; };
96563581279A5ABD003D6A75 /* libtheora.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtheora.a; path = "Dependencies/build-macosx-x86_64/lib/libtheora.a"; sourceTree = "<group>"; }; 96563581279A5ABD003D6A75 /* libtheora.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtheora.a; path = "Dependencies/build-macosx-x86_64/lib/libtheora.a"; sourceTree = "<group>"; };
96563584279A5ADA003D6A75 /* libtheora.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtheora.a; path = "Dependencies/build-macosx-universal/lib/libtheora.a"; sourceTree = "<group>"; }; 96563584279A5ADA003D6A75 /* libtheora.a */ = {isa = PBXFileReference; lastKnownFileType = archive.ar; name = libtheora.a; path = "Dependencies/build-macosx-universal/lib/libtheora.a"; sourceTree = "<group>"; };
9656358E279A5B74003D6A75 /* theoraplay_cvtrgb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = theoraplay_cvtrgb.h; sourceTree = "<group>"; }; 9656358E279A5B74003D6A75 /* theoraplay_cvtrgb.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = theoraplay_cvtrgb.h; sourceTree = "<group>"; };
@ -1392,6 +1397,7 @@
3B10ECA02568E7B600372D13 /* tilemap.vert */, 3B10ECA02568E7B600372D13 /* tilemap.vert */,
3B10EC962568E7B500372D13 /* tilemapvx.vert */, 3B10EC962568E7B500372D13 /* tilemapvx.vert */,
CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */, CBEA4C45BE737EE0FF5A8A4C /* bicubic.frag */,
88734C4B8039751FD0A59FA7 /* xbrz.frag */,
); );
name = Shaders; name = Shaders;
sourceTree = "<group>"; sourceTree = "<group>";

View file

@ -83,6 +83,7 @@
// 1: Bilinear // 1: Bilinear
// 2: Bicubic // 2: Bicubic
// 3: Lanczos3 // 3: Lanczos3
// 4: xBRZ
// (default: 0) // (default: 0)
// //
// "smoothScaling": 0, // "smoothScaling": 0,
@ -96,6 +97,14 @@
// "bicubicSharpness": 100, // "bicubicSharpness": 100,
// Scaling factor for xBRZ interpolation
// (set to at least the ratio of your window size
// to the game's native resolution)
// (default: 1.0)
//
// "xbrzScalingFactor": 4.0,
// Replace the game's Bitmap files with external high-res files // Replace the game's Bitmap files with external high-res files
// provided in the "Hires" directory. // provided in the "Hires" directory.
// (You'll also need to set the below Scaling Factors.) // (You'll also need to set the below Scaling Factors.)

View file

@ -29,6 +29,11 @@ embedded_shaders = [
'simpleMatrix.vert' 'simpleMatrix.vert'
] ]
# xBRZ shader is GPLv3.
if get_option('enable-https') == true
embedded_shaders += 'xbrz.frag'
endif
embedded_shaders_f = files(embedded_shaders) embedded_shaders_f = files(embedded_shaders)
count = 0 count = 0

393
shader/xbrz.frag Normal file
View file

@ -0,0 +1,393 @@
// From https://github.com/bsnes-emu/bsnes/tree/c0c60c83a84a49d4a2b822a0491cb258a3c5b98a/shaders/xBRZ.shader
// Copyright bsnes contributors.
// mkxp-z modifications Copyright 2022-2023 Splendide Imaginarius.
// GPLv3+ license.
// xBRZ freescale
// based on :
// 4xBRZ shader - Copyright (C) 2014-2016 DeSmuME team
//
// This file is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 2 of the License, or
// (at your option) any later version.
//
// This file is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with the this software. If not, see <http://www.gnu.org/licenses/>.
/*
Hyllian's xBR-vertex code and texel mapping
Copyright (C) 2011/2016 Hyllian - sergiogdb@gmail.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
#ifdef GLSLES
precision highp float;
#endif
uniform sampler2D texture;
uniform vec2 sourceSize;
uniform vec2 texSizeInv;
uniform vec2 targetScale;
varying vec2 v_texCoord;
#define BLEND_NONE 0
#define BLEND_NORMAL 1
#define BLEND_DOMINANT 2
#define LUMINANCE_WEIGHT 1.0
#define EQUAL_COLOR_TOLERANCE 30.0/255.0
#define STEEP_DIRECTION_THRESHOLD 2.2
#define DOMINANT_DIRECTION_THRESHOLD 3.6
float DistYCbCr(vec3 pixA, vec3 pixB)
{
const vec3 w = vec3(0.2627, 0.6780, 0.0593);
const float scaleB = 0.5 / (1.0 - w.b);
const float scaleR = 0.5 / (1.0 - w.r);
vec3 diff = pixA - pixB;
float Y = dot(diff.rgb, w);
float Cb = scaleB * (diff.b - Y);
float Cr = scaleR * (diff.r - Y);
return sqrt(((LUMINANCE_WEIGHT * Y) * (LUMINANCE_WEIGHT * Y)) + (Cb * Cb) + (Cr * Cr));
}
bool IsPixEqual(const vec3 pixA, const vec3 pixB)
{
return (DistYCbCr(pixA, pixB) < EQUAL_COLOR_TOLERANCE);
}
float get_left_ratio(vec2 center, vec2 origin, vec2 direction, vec2 scale)
{
vec2 P0 = center - origin;
vec2 proj = direction * (dot(P0, direction) / dot(direction, direction));
vec2 distv = P0 - proj;
vec2 orth = vec2(-direction.y, direction.x);
float side = sign(dot(P0, orth));
float v = side * length(distv * scale);
// return step(0, v);
return smoothstep(-sqrt(2.0)/2.0, sqrt(2.0)/2.0, v);
}
#define eq(a,b) (a == b)
#define neq(a,b) (a != b)
// TODO: replace P with P4
#define P(x,y) texture2D(texture, coord + texSizeInv * vec2(x, y)).rgb
#define P4(x,y) texture2D(texture, coord + texSizeInv * vec2(x, y))
vec4 pass0(vec2 p0_texCoord) {
vec4 fragColor;
//---------------------------------------
// Input Pixel Mapping: -|x|x|x|-
// x|A|B|C|x
// x|D|E|F|x
// x|G|H|I|x
// -|x|x|x|-
vec2 pos = fract(p0_texCoord * sourceSize) - vec2(0.5, 0.5);
vec2 coord = p0_texCoord - pos * texSizeInv;
vec3 A = P(-1,-1);
vec3 B = P( 0,-1);
vec3 C = P( 1,-1);
vec3 D = P(-1, 0);
vec3 E = P( 0, 0);
vec3 F = P( 1, 0);
vec3 G = P(-1, 1);
vec3 H = P( 0, 1);
vec3 I = P( 1, 1);
// blendResult Mapping: x|y|
// w|z|
ivec4 blendResult = ivec4(BLEND_NONE,BLEND_NONE,BLEND_NONE,BLEND_NONE);
// Preprocess corners
// Pixel Tap Mapping: -|-|-|-|-
// -|-|B|C|-
// -|D|E|F|x
// -|G|H|I|x
// -|-|x|x|-
if (!((eq(E,F) && eq(H,I)) || (eq(E,H) && eq(F,I))))
{
float dist_H_F = DistYCbCr(G, E) + DistYCbCr(E, C) + DistYCbCr(P(0,2), I) + DistYCbCr(I, P(2,0)) + (4.0 * DistYCbCr(H, F));
float dist_E_I = DistYCbCr(D, H) + DistYCbCr(H, P(1,2)) + DistYCbCr(B, F) + DistYCbCr(F, P(2,1)) + (4.0 * DistYCbCr(E, I));
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_H_F) < dist_E_I;
blendResult.z = ((dist_H_F < dist_E_I) && neq(E,F) && neq(E,H)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
}
// Pixel Tap Mapping: -|-|-|-|-
// -|A|B|-|-
// x|D|E|F|-
// x|G|H|I|-
// -|x|x|-|-
if (!((eq(D,E) && eq(G,H)) || (eq(D,G) && eq(E,H))))
{
float dist_G_E = DistYCbCr(P(-2,1) , D) + DistYCbCr(D, B) + DistYCbCr(P(-1,2), H) + DistYCbCr(H, F) + (4.0 * DistYCbCr(G, E));
float dist_D_H = DistYCbCr(P(-2,0) , G) + DistYCbCr(G, P(0,2)) + DistYCbCr(A, E) + DistYCbCr(E, I) + (4.0 * DistYCbCr(D, H));
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_D_H) < dist_G_E;
blendResult.w = ((dist_G_E > dist_D_H) && neq(E,D) && neq(E,H)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
}
// Pixel Tap Mapping: -|-|x|x|-
// -|A|B|C|x
// -|D|E|F|x
// -|-|H|I|-
// -|-|-|-|-
if (!((eq(B,C) && eq(E,F)) || (eq(B,E) && eq(C,F))))
{
float dist_E_C = DistYCbCr(D, B) + DistYCbCr(B, P(1,-2)) + DistYCbCr(H, F) + DistYCbCr(F, P(2,-1)) + (4.0 * DistYCbCr(E, C));
float dist_B_F = DistYCbCr(A, E) + DistYCbCr(E, I) + DistYCbCr(P(0,-2), C) + DistYCbCr(C, P(2,0)) + (4.0 * DistYCbCr(B, F));
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_B_F) < dist_E_C;
blendResult.y = ((dist_E_C > dist_B_F) && neq(E,B) && neq(E,F)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
}
// Pixel Tap Mapping: -|x|x|-|-
// x|A|B|C|-
// x|D|E|F|-
// -|G|H|-|-
// -|-|-|-|-
if (!((eq(A,B) && eq(D,E)) || (eq(A,D) && eq(B,E))))
{
float dist_D_B = DistYCbCr(P(-2,0), A) + DistYCbCr(A, P(0,-2)) + DistYCbCr(G, E) + DistYCbCr(E, C) + (4.0 * DistYCbCr(D, B));
float dist_A_E = DistYCbCr(P(-2,-1), D) + DistYCbCr(D, H) + DistYCbCr(P(-1,-2), B) + DistYCbCr(B, F) + (4.0 * DistYCbCr(A, E));
bool dominantGradient = (DOMINANT_DIRECTION_THRESHOLD * dist_D_B) < dist_A_E;
blendResult.x = ((dist_D_B < dist_A_E) && neq(E,D) && neq(E,B)) ? ((dominantGradient) ? BLEND_DOMINANT : BLEND_NORMAL) : BLEND_NONE;
}
fragColor = vec4(blendResult);
// Pixel Tap Mapping: -|-|-|-|-
// -|-|B|C|-
// -|D|E|F|x
// -|G|H|I|x
// -|-|x|x|-
if(blendResult.z == BLEND_DOMINANT || (blendResult.z == BLEND_NORMAL &&
!((blendResult.y != BLEND_NONE && !IsPixEqual(E, G)) || (blendResult.w != BLEND_NONE && !IsPixEqual(E, C)) ||
(IsPixEqual(G, H) && IsPixEqual(H, I) && IsPixEqual(I, F) && IsPixEqual(F, C) && !IsPixEqual(E, I)))))
{
fragColor.z += 4.0;
float dist_F_G = DistYCbCr(F, G);
float dist_H_C = DistYCbCr(H, C);
if((STEEP_DIRECTION_THRESHOLD * dist_F_G <= dist_H_C) && neq(E,G) && neq(D,G))
fragColor.z += 16.0;
if((STEEP_DIRECTION_THRESHOLD * dist_H_C <= dist_F_G) && neq(E,C) && neq(B,C))
fragColor.z += 64.0;
}
// Pixel Tap Mapping: -|-|-|-|-
// -|A|B|-|-
// x|D|E|F|-
// x|G|H|I|-
// -|x|x|-|-
if(blendResult.w == BLEND_DOMINANT || (blendResult.w == BLEND_NORMAL &&
!((blendResult.z != BLEND_NONE && !IsPixEqual(E, A)) || (blendResult.x != BLEND_NONE && !IsPixEqual(E, I)) ||
(IsPixEqual(A, D) && IsPixEqual(D, G) && IsPixEqual(G, H) && IsPixEqual(H, I) && !IsPixEqual(E, G)))))
{
fragColor.w += 4.0;
float dist_H_A = DistYCbCr(H, A);
float dist_D_I = DistYCbCr(D, I);
if((STEEP_DIRECTION_THRESHOLD * dist_H_A <= dist_D_I) && neq(E,A) && neq(B,A))
fragColor.w += 16.0;
if((STEEP_DIRECTION_THRESHOLD * dist_D_I <= dist_H_A) && neq(E,I) && neq(F,I))
fragColor.w += 64.0;
}
// Pixel Tap Mapping: -|-|x|x|-
// -|A|B|C|x
// -|D|E|F|x
// -|-|H|I|-
// -|-|-|-|-
if(blendResult.y == BLEND_DOMINANT || (blendResult.y == BLEND_NORMAL &&
!((blendResult.x != BLEND_NONE && !IsPixEqual(E, I)) || (blendResult.z != BLEND_NONE && !IsPixEqual(E, A)) ||
(IsPixEqual(I, F) && IsPixEqual(F, C) && IsPixEqual(C, B) && IsPixEqual(B, A) && !IsPixEqual(E, C)))))
{
fragColor.y += 4.0;
float dist_B_I = DistYCbCr(B, I);
float dist_F_A = DistYCbCr(F, A);
if((STEEP_DIRECTION_THRESHOLD * dist_B_I <= dist_F_A) && neq(E,I) && neq(H,I))
fragColor.y += 16.0;
if((STEEP_DIRECTION_THRESHOLD * dist_F_A <= dist_B_I) && neq(E,A) && neq(D,A))
fragColor.y += 64.0;
}
// Pixel Tap Mapping: -|x|x|-|-
// x|A|B|C|-
// x|D|E|F|-
// -|G|H|-|-
// -|-|-|-|-
if(blendResult.x == BLEND_DOMINANT || (blendResult.x == BLEND_NORMAL &&
!((blendResult.w != BLEND_NONE && !IsPixEqual(E, C)) || (blendResult.y != BLEND_NONE && !IsPixEqual(E, G)) ||
(IsPixEqual(C, B) && IsPixEqual(B, A) && IsPixEqual(A, D) && IsPixEqual(D, G) && !IsPixEqual(E, A)))))
{
fragColor.x += 4.0;
float dist_D_C = DistYCbCr(D, C);
float dist_B_G = DistYCbCr(B, G);
if((STEEP_DIRECTION_THRESHOLD * dist_D_C <= dist_B_G) && neq(E,C) && neq(F,C))
fragColor.x += 16.0;
if((STEEP_DIRECTION_THRESHOLD * dist_B_G <= dist_D_C) && neq(E,G) && neq(H,G))
fragColor.x += 64.0;
}
fragColor /= 255.0;
return fragColor;
}
vec4 pass1(vec2 p1_texCoord) {
vec4 fragColor;
//---------------------------------------
// Input Pixel Mapping: -|B|-
// D|E|F
// -|H|-
vec2 scale = targetScale;
vec2 pos = fract(p1_texCoord * sourceSize) - vec2(0.5, 0.5);
vec2 coord = p1_texCoord - pos * texSizeInv;
vec4 B = P4( 0,-1);
vec4 D = P4(-1, 0);
vec4 E = P4( 0, 0);
vec4 F = P4( 1, 0);
vec4 H = P4( 0, 1);
vec4 info = floor(pass0(coord) * 255.0 + 0.5);
// info Mapping: x|y|
// w|z|
vec4 blendResult = floor(mod(info, 4.0));
vec4 doLineBlend = floor(mod(info / 4.0, 4.0));
vec4 haveShallowLine = floor(mod(info / 16.0, 4.0));
vec4 haveSteepLine = floor(mod(info / 64.0, 4.0));
vec4 res = E;
// Pixel Tap Mapping: -|-|-
// -|E|F
// -|H|-
if(blendResult.z > float(BLEND_NONE))
{
vec2 origin = vec2(0.0, 1.0 / sqrt(2.0));
vec2 direction = vec2(1.0, -1.0);
if(doLineBlend.z > 0.0)
{
origin = haveShallowLine.z > 0.0? vec2(0.0, 0.25) : vec2(0.0, 0.5);
direction.x += haveShallowLine.z;
direction.y -= haveSteepLine.z;
}
// TODO: replace the rest of these with vec4
vec4 blendPix = mix(H,F, step(DistYCbCr(E.rgb, F.rgb), DistYCbCr(E.rgb, H.rgb)));
res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale));
}
// Pixel Tap Mapping: -|-|-
// D|E|-
// -|H|-
if(blendResult.w > float(BLEND_NONE))
{
vec2 origin = vec2(-1.0 / sqrt(2.0), 0.0);
vec2 direction = vec2(1.0, 1.0);
if(doLineBlend.w > 0.0)
{
origin = haveShallowLine.w > 0.0? vec2(-0.25, 0.0) : vec2(-0.5, 0.0);
direction.y += haveShallowLine.w;
direction.x += haveSteepLine.w;
}
// TODO: replace the rest of these with vec4
vec4 blendPix = mix(H,D, step(DistYCbCr(E.rgb, D.rgb), DistYCbCr(E.rgb, H.rgb)));
res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale));
}
// Pixel Tap Mapping: -|B|-
// -|E|F
// -|-|-
if(blendResult.y > float(BLEND_NONE))
{
vec2 origin = vec2(1.0 / sqrt(2.0), 0.0);
vec2 direction = vec2(-1.0, -1.0);
if(doLineBlend.y > 0.0)
{
origin = haveShallowLine.y > 0.0? vec2(0.25, 0.0) : vec2(0.5, 0.0);
direction.y -= haveShallowLine.y;
direction.x -= haveSteepLine.y;
}
// TODO: replace the rest of these with vec4
vec4 blendPix = mix(F,B, step(DistYCbCr(E.rgb, B.rgb), DistYCbCr(E.rgb, F.rgb)));
res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale));
}
// Pixel Tap Mapping: -|B|-
// D|E|-
// -|-|-
if(blendResult.x > float(BLEND_NONE))
{
vec2 origin = vec2(0.0, -1.0 / sqrt(2.0));
vec2 direction = vec2(-1.0, 1.0);
if(doLineBlend.x > 0.0)
{
origin = haveShallowLine.x > 0.0? vec2(0.0, -0.25) : vec2(0.0, -0.5);
direction.x -= haveShallowLine.x;
direction.y += haveSteepLine.x;
}
// TODO: replace the rest of these with vec4
vec4 blendPix = mix(D,B, step(DistYCbCr(E.rgb, B.rgb), DistYCbCr(E.rgb, D.rgb)));
res = mix(res, blendPix, get_left_ratio(pos, origin, direction, scale));
}
fragColor = res;
return fragColor;
}
void main() {
gl_FragColor = pass1(v_texCoord);
}

View file

@ -136,6 +136,9 @@ void Config::read(int argc, char *argv[]) {
{"fixedAspectRatio", true}, {"fixedAspectRatio", true},
{"smoothScaling", 0}, {"smoothScaling", 0},
{"bicubicSharpness", 100}, {"bicubicSharpness", 100},
#ifdef MKXPZ_SSL
{"xbrzScalingFactor", 1.},
#endif
{"enableHires", false}, {"enableHires", false},
{"textureScalingFactor", 1.}, {"textureScalingFactor", 1.},
{"framebufferScalingFactor", 1.}, {"framebufferScalingFactor", 1.},
@ -267,6 +270,9 @@ try { exp } catch (...) {}
SET_OPT(fixedAspectRatio, boolean); SET_OPT(fixedAspectRatio, boolean);
SET_OPT(smoothScaling, integer); SET_OPT(smoothScaling, integer);
SET_OPT(bicubicSharpness, integer); SET_OPT(bicubicSharpness, integer);
#ifdef MKXPZ_SSL
SET_OPT(xbrzScalingFactor, integer);
#endif
SET_OPT(enableHires, boolean); SET_OPT(enableHires, boolean);
SET_OPT(textureScalingFactor, number); SET_OPT(textureScalingFactor, number);
SET_OPT(framebufferScalingFactor, number); SET_OPT(framebufferScalingFactor, number);

View file

@ -45,6 +45,9 @@ struct Config {
bool fixedAspectRatio; bool fixedAspectRatio;
int smoothScaling; int smoothScaling;
int bicubicSharpness; int bicubicSharpness;
#ifdef MKXPZ_SSL
double xbrzScalingFactor;
#endif
bool enableHires; bool enableHires;
double textureScalingFactor; double textureScalingFactor;
double framebufferScalingFactor; double framebufferScalingFactor;

View file

@ -927,30 +927,94 @@ IntRect Bitmap::rect() const
} }
void Bitmap::blt(int x, int y, void Bitmap::blt(int x, int y,
const Bitmap &source, IntRect rect, const Bitmap &source, const IntRect &rect,
int opacity) int opacity)
{ {
if (source.isDisposed()) if (source.isDisposed())
return; return;
// FIXME: RGSS allows the source rect to both lie outside
// the bitmap rect and be inverted in both directions;
// clamping only covers a subset of these cases (and
// doesn't fix anything for a direct stretch_blt call).
/* Clamp rect to source bitmap size */
if (rect.x + rect.w > source.width())
rect.w = source.width() - rect.x;
if (rect.y + rect.h > source.height())
rect.h = source.height() - rect.y;
stretchBlt(IntRect(x, y, rect.w, rect.h), stretchBlt(IntRect(x, y, rect.w, rect.h),
source, rect, opacity); source, rect, opacity);
} }
void Bitmap::stretchBlt(const IntRect &destRect, static bool shrinkRects(float &sourcePos, float &sourceLen, const int &sBitmapLen,
const Bitmap &source, const IntRect &sourceRect, float &destPos, float &destLen, const int &dBitmapLen, bool normalize = false)
{
float sStart = sourceLen > 0 ? sourcePos : sourceLen + sourcePos;
float sEnd = sourceLen > 0 ? sourceLen + sourcePos : sourcePos;
float sLength = sEnd - sStart;
if (sStart >= 0 && sEnd < sBitmapLen)
return false;
if (sStart >= sBitmapLen || sEnd < 0)
return true;
float dStart = destLen > 0 ? destPos: destLen + destPos;
float dEnd = destLen > 0 ? destLen + destPos : destPos;
float dLength = dEnd - dStart;
float delta = sEnd - sBitmapLen;
float dDelta;
if (delta > 0)
{
dDelta = (delta / sLength) * dLength;
sLength -= delta;
sEnd = sBitmapLen;
dEnd -= dDelta;
dLength -= dDelta;
}
if (sStart < 0)
{
dDelta = (sStart / sLength) * dLength;
sLength += sStart;
sStart = 0;
dStart -= dDelta;
dLength += dDelta;
}
if (!normalize)
{
sourcePos = sourceLen > 0 ? sStart : sEnd;
sourceLen = sourceLen > 0 ? sLength : -sLength;
destPos = destLen > 0 ? dStart : dEnd;
destLen = destLen > 0 ? dLength : -dLength;
}
else
{
// Ensure the source rect has positive dimensions, for blitting from mega surfaces
destPos = (destLen > 0 == sourceLen > 0) ? dStart : dEnd;
destLen = (destLen > 0 == sourceLen > 0) ? dLength : -dLength;
sourcePos = sStart;
sourceLen = sLength;
}
return false;
}
static bool shrinkRects(int &sourcePos, int &sourceLen, const int &sBitmapLen,
int &destPos, int &destLen, const int &dBitmapLen)
{
float fSourcePos = sourcePos;
float fSourceLen = sourceLen;
float fDestPos = destPos;
float fDestLen = destLen;
bool ret = shrinkRects(fSourcePos, fSourceLen, sBitmapLen, fDestPos, fDestLen, dBitmapLen, true);
if (!ret)
ret = shrinkRects(fDestPos, fDestLen, dBitmapLen, fSourcePos, fSourceLen, sBitmapLen);
sourcePos = round(fSourcePos);
sourceLen = round(fSourceLen);
destPos = round(fDestPos);
destLen = round(fDestLen);
return ret || sourceLen == 0 || destLen == 0;
}
void Bitmap::stretchBlt(IntRect destRect,
const Bitmap &source, IntRect sourceRect,
int opacity) int opacity)
{ {
guardDisposed(); guardDisposed();
@ -988,6 +1052,11 @@ void Bitmap::stretchBlt(const IntRect &destRect,
if (opacity == 0) if (opacity == 0)
return; return;
if(shrinkRects(sourceRect.x, sourceRect.w, source.width(), destRect.x, destRect.w, width()))
return;
if(shrinkRects(sourceRect.y, sourceRect.h, source.height(), destRect.y, destRect.h, height()))
return;
SDL_Surface *srcSurf = source.megaSurface(); SDL_Surface *srcSurf = source.megaSurface();
if (srcSurf && shState->config().subImageFix) if (srcSurf && shState->config().subImageFix)

View file

@ -63,11 +63,11 @@ public:
IntRect rect() const; IntRect rect() const;
void blt(int x, int y, void blt(int x, int y,
const Bitmap &source, IntRect rect, const Bitmap &source, const IntRect &rect,
int opacity = 255); int opacity = 255);
void stretchBlt(const IntRect &destRect, void stretchBlt(IntRect destRect,
const Bitmap &source, const IntRect &sourceRect, const Bitmap &source, IntRect sourceRect,
int opacity = 255); int opacity = 255);
void fillRect(int x, int y, void fillRect(int x, int y,

View file

@ -175,6 +175,19 @@ static void _blitBegin(FBO::ID fbo, const Vec2i &size)
} }
break; break;
#ifdef MKXPZ_SSL
case xBRZ:
{
XbrzShader &shader = shState->shaders().xbrz;
shader.bind();
shader.applyViewportProj();
shader.setTranslation(Vec2i());
shader.setTexSize(Vec2i(size.x, size.y));
shader.setTargetScale(Vec2(1., 1.));
}
break;
#endif
default: default:
{ {
SimpleShader &shader = shState->shaders().simple; SimpleShader &shader = shState->shaders().simple;
@ -261,6 +274,16 @@ void blitSource(TEXFBO &source)
} }
break; break;
#ifdef MKXPZ_SSL
case xBRZ:
{
XbrzShader &shader = shState->shaders().xbrz;
shader.bind();
shader.setTexSize(Vec2i(blitSrcWidthHires, blitSrcHeightHires));
}
break;
#endif
default: default:
{ {
SimpleShader &shader = shState->shaders().simple; SimpleShader &shader = shState->shaders().simple;
@ -306,6 +329,13 @@ void blitRectangle(const IntRect &src, const IntRect &dst, bool smooth)
} }
else else
{ {
#ifdef MKXPZ_SSL
if (shState->config().smoothScaling == xBRZ)
{
XbrzShader &shader = shState->shaders().xbrz;
shader.setTargetScale(Vec2((float)(shState->config().xbrzScalingFactor), (float)(shState->config().xbrzScalingFactor)));
}
#endif
if (smooth) if (smooth)
TEX::setSmooth(true); TEX::setSmooth(true);

View file

@ -48,6 +48,9 @@
#include "flashMap.frag.xxd" #include "flashMap.frag.xxd"
#include "bicubic.frag.xxd" #include "bicubic.frag.xxd"
#include "lanczos3.frag.xxd" #include "lanczos3.frag.xxd"
#ifdef MKXPZ_SSL
#include "xbrz.frag.xxd"
#endif
#include "minimal.vert.xxd" #include "minimal.vert.xxd"
#include "simple.vert.xxd" #include "simple.vert.xxd"
#include "simpleColor.vert.xxd" #include "simpleColor.vert.xxd"
@ -799,3 +802,21 @@ void Lanczos3Shader::setTexSize(const Vec2i &value)
ShaderBase::setTexSize(value); ShaderBase::setTexSize(value);
gl.Uniform2f(u_sourceSize, (float)value.x, (float)value.y); gl.Uniform2f(u_sourceSize, (float)value.x, (float)value.y);
} }
#ifdef MKXPZ_SSL
XbrzShader::XbrzShader()
{
INIT_SHADER(simple, xbrz, XbrzShader);
ShaderBase::init();
GET_U(texOffsetX);
GET_U(sourceSize);
GET_U(targetScale);
}
void XbrzShader::setTargetScale(const Vec2 &value)
{
gl.Uniform2f(u_targetScale, value.x, value.y);
}
#endif

View file

@ -352,6 +352,19 @@ protected:
GLint u_bc; GLint u_bc;
}; };
#ifdef MKXPZ_SSL
class XbrzShader : public Lanczos3Shader
{
public:
XbrzShader();
void setTargetScale(const Vec2 &value);
protected:
GLint u_targetScale;
};
#endif
/* Global object containing all available shaders */ /* Global object containing all available shaders */
struct ShaderSet struct ShaderSet
{ {
@ -375,6 +388,9 @@ struct ShaderSet
TilemapVXShader tilemapVX; TilemapVXShader tilemapVX;
BicubicShader bicubic; BicubicShader bicubic;
Lanczos3Shader lanczos3; Lanczos3Shader lanczos3;
#ifdef MKXPZ_SSL
XbrzShader xbrz;
#endif
}; };
#endif // SHADER_H #endif // SHADER_H

View file

@ -206,6 +206,9 @@ enum InterpolationMethod
Bilinear = 1, Bilinear = 1,
Bicubic = 2, Bicubic = 2,
Lanczos3 = 3, Lanczos3 = 3,
#ifdef MKXPZ_SSL
xBRZ = 4,
#endif
}; };
/* For internal use. /* For internal use.

Binary file not shown.

View file

@ -0,0 +1,62 @@
# Test suite for mkxp-z stretch_blt.
# Copyright 2024 Splendide Imaginarius.
# License GPLv2+.
# Test images are from https://github.com/xinntao/Real-ESRGAN/
#
# Run the suite via the "customScript" field in mkxp.json.
# Use RGSS v3 for best results.
def dump(bmp, spr, desc)
spr.bitmap = bmp
Graphics.wait(1)
bmp.to_file("test-results/" + desc + ".png")
System::puts("Finished " + desc)
end
# Setup graphics
Graphics.resize_screen(1920, 1080)
# Setup font
fnt = Font.new("Liberation Sans", 100)
# Setup splash screen
bmp = Bitmap.new(1920, 1080)
bmp.fill_rect(0, 0, 1920, 1080, Color.new(0, 0, 0))
bmp.font = fnt
bmp.draw_text(0, 0, 1920, 540, "stretch_blt Test Suite", 1)
bmp.draw_text(0, 540, 1920, 540, "Starting Now", 1)
spr = Sprite.new()
spr.bitmap = bmp
Graphics.wait(1 * 60)
# Tests start here
foreground = Bitmap.new("Graphics/Pictures/OST_009")
dump(foreground, spr, "foreground")
background = Bitmap.new(1920, 1080)
background.clear
dump(background, spr, "background")
composite = background.dup
composite.stretch_blt(Rect.new(0, 0, 1920, 1080), foreground, Rect.new(0, 0, 1920, 1080))
dump(composite, spr, "composite")
# Tests are finished, show exit screen
bmp = Bitmap.new(1920, 1080)
bmp.fill_rect(0, 0, 1920, 1080, Color.new(0, 0, 0))
fnt = Font.new("Liberation Sans", 100)
bmp.font = fnt
bmp.draw_text(0, 0, 1920, 540, "stretch_blt Test Suite", 1)
bmp.draw_text(0, 540, 1920, 540, "Has Finished", 1)
spr.bitmap = bmp
Graphics.wait(1 * 60)
exit