diff --git a/sakamoto/osu/APKBUILD b/sakamoto/osu/APKBUILD new file mode 100644 index 0000000..4e879fc --- /dev/null +++ b/sakamoto/osu/APKBUILD @@ -0,0 +1,142 @@ +# Contributor: knuxify +# Contributor: Dominika Liberda +# Maintainer: knuxify +pkgname=osu +pkgver=2022.405.0 +pkgrel=0 + +_runtime_ver=3.16 +_realmver=10.11.1 # https://github.com/realm/realm-dotnet/releases +_realmcorever=11.13.0 # https://github.com/realm/realm-core/tags + +# Taken from dotnet6-build APKBUILD +_get_arch() { + case $1 in + x86_64) local arch=x64;; + aarch64) local arch=arm64;; + armv7|armhf) local arch=arm;; + esac + echo $arch +} +_dotnet_arch=$(_get_arch $CARCH) + +pkgdesc="rhythm is just a *click* away!" +url="https://osu.ppy.sh" +arch="x86_64" # others blocked by badly linked libraries or missing dotnet6 +license="MIT AND CC-BY-NC-4.0 AND proprietary" +depends=" + dotnet6-apphost-pack + dotnet6-runtime + alsa-lib-dev + sdl2 + stbi-sharp + $pkgname-data + " +makedepends="dotnet6-sdk + bash cmake flex-dev libuv-dev lld openssl-dev zlib-dev + " +install="$pkgname.pre-install" +source="osu-lazer-$pkgver.tar.gz::https://github.com/ppy/osu/archive/refs/tags/$pkgver.tar.gz + realm-dotnet-$_realmver.tar.gz::https://github.com/realm/realm-dotnet/archive/refs/tags/$_realmver.tar.gz + realm-core-$_realmcorever.tar.gz::https://github.com/realm/realm-core/archive/refs/tags/v$_realmcorever.tar.gz + osu-launcher + osu-lazer.desktop + x-osu-lazer.xml + " +subpackages="$pkgname-lang $pkgname-data::noarch" +builddir="$srcdir/osu-$pkgver" +options="!check" # requires the game to be build in debug mode? todo + +build() { + # Build realm-dotnet wrapper lib + cd "$srcdir"/realm-dotnet-$_realmver/wrappers + rm -r realm-core + mv "$srcdir"/realm-core-$_realmcorever realm-core + + # Apply build hacks; these would probably be better off as a patch but I'm lazy + sed -i 's/dev_t/uint_fast64_t/g' realm-core/src/realm/util/file.hpp + sed -i 's/dev_t/uint_fast64_t/g' realm-core/src/realm/util/file_mapper.cpp + sed -i 's/dev_t/uint_fast64_t/g' realm-core/src/realm/util/file.cpp + sed -i 's/#if REALM_PLATFORM_APPLE || (defined(__linux__) && \!REALM_ANDROID)/\#if 0/' realm-core/src/realm/util/backtrace.cpp + sed -i 's/\#if (defined _GNU_SOURCE && !REALM_ANDROID) || REALM_PLATFORM_APPLE/\#if 0/' realm-core/src/realm/util/thread.cpp + sed -i 's/\#elif !REALM_ANDROID && _GNU_SOURCE/\#elif 0/' realm-core/src/realm/util/basic_system_errors.cpp + sed -i 's/#if defined(_POSIX_C_SOURCE) && _POSIX_C_SOURCE >= 200112L/\#if 1/' realm-core/src/realm/util/file.cpp + + ./build.sh \ + -DREALM_USE_SYSTEM_OPENSSL=true \ + -DOPENSSL_INCLUDE_DIR=/usr/include \ + -DOPENSSL_SSL_LIBRARY=/usr/lib/libssl.so \ + -DOPENSSL_CRYPTO_LIBRARY=/usr/lib/libcrypto.so + + # Build osu-lazer + cd "$builddir" + output="./osu.Desktop/bin/Release/net6.0/alpine.$_runtime_ver-$_dotnet_arch" + + DOTNET_CLI_TELEMETRY_OPTOUT=1 dotnet publish osu.Desktop \ + --framework net6.0 \ + --configuration Release \ + --runtime alpine.$_runtime_ver-$_dotnet_arch \ + --output $output \ + --no-self-contained \ + /property:Version=$pkgver +} + +check() { + dotnet test ./*.Tests/bin/Release/*/*.Tests.dll +} + +package() { + # Compiled binaries, localization files, debug info and rulesets + mkdir -p "$pkgdir"/usr/lib/$pkgname + cd "$builddir"/osu.Desktop/bin/Release/net6.0 + cp -r "alpine.$_runtime_ver-$_dotnet_arch"/* "$pkgdir"/usr/lib/$pkgname/ + + # Remove some precompiled binaries, replace incompatible ones + for lib in libSDL2.so libstbi.so; do + if [ -e "$pkgdir"/usr/lib/$pkgname/$lib ]; then + rm "$pkgdir"/usr/lib/$pkgname/$lib + fi + done + + # Replace librealm-wrappers + mv "$srcdir"/realm-dotnet-$_realmver/wrappers/cmake/Linux/src/librealm-wrappers.so \ + "$pkgdir"/usr/lib/$pkgname/librealm-wrappers.so + + # Wrapper script + install -Dm755 "$srcdir"/osu-launcher \ + "$pkgdir"/usr/bin/osu-lazer + + # Icon, desktop file and mime types + install -Dm644 "$builddir"/assets/lazer.png \ + "$pkgdir"/usr/share/pixmaps/osu-lazer.png + install -Dm644 "$srcdir"/osu-lazer.desktop \ + "$pkgdir"/usr/share/applications/osu-lazer.desktop + install -Dm644 "$srcdir"/x-osu-lazer.xml \ + "$pkgdir"/usr/share/mime/packages/x-osu-lazer.xml +} + +lang() { + for dir in "$pkgdir"/usr/lib/osu/*; do + if [ ! -d $dir ]; then continue; fi + lang=$(basename $dir) + case $lang in + 'osu'|'ref'|'linux-'*|'alpine-'*|'en') continue;; + *) amove /usr/lib/osu/$lang;; + esac + done +} + +data() { + pkgdesc="$pkgdesc (data files)" + amove /usr/lib/osu/osu.Game.Resources.dll + amove /usr/lib/osu/osu.Game.Rulesets.* +} + +sha512sums=" +e107f5c159f272bb91c73c7686b176067281ac145ab88b4ebd687234f47ffee72f1eee3148df54300a00d184670f6b7c26fabc0b32db88b65219737e896ea0e2 osu-lazer-2022.405.0.tar.gz +9565d2ff6447f889a67596fbb38602fb43e90c6f15b1da1624804e59c167b397fbe40ddb017f8b908797f33f64751e9e7ee8f4ba1f5d7ab807743fdfcf6f889b realm-dotnet-10.11.1.tar.gz +76cde6fa4e7f8b35d01b86f3e6b8824944c8033c66b17b0180c9608a4c2a67c7157d15d85a7fc3cfd2b8d2491b8cca278d418c04c99188811e4a7784d8be61c5 realm-core-11.13.0.tar.gz +faaaa02570578690f328906a4a6bbf8885374f4ffab40f333df35cfd22bf57a472b65b9dc904d69decfbe1867bf0221a1dcdc6d780254ae332f07eb3dead6643 osu-launcher +64020ebec01220cd7f4fa777c3b64ba149e8df8cc0c86613e3ad8d5c1fc0d3d88582bc460e0a581e62d58b91ecc8ac33b5712f27b3bfa1b75caa3be578468be5 osu-lazer.desktop +0f5e702f8d52425eca4eea45b40b60dc0d6a8a1c11624a2ddfd647b908e1c5e0c9c988b68dcbbf0841fedd05a35b2c7c53cc1edd5f2c509e1c527f228bf768f5 x-osu-lazer.xml +" diff --git a/sakamoto/osu/osu-launcher b/sakamoto/osu/osu-launcher new file mode 100644 index 0000000..08b6597 --- /dev/null +++ b/sakamoto/osu/osu-launcher @@ -0,0 +1,3 @@ +#!/bin/sh +export OSU_EXTERNAL_UPDATE_PROVIDER=1 +exec '/usr/lib/osu-lazer/osu!' "$@" diff --git a/sakamoto/osu/osu-lazer.desktop b/sakamoto/osu/osu-lazer.desktop new file mode 100644 index 0000000..6ad1fc1 --- /dev/null +++ b/sakamoto/osu/osu-lazer.desktop @@ -0,0 +1,13 @@ +[Desktop Entry] +Type=Application +Version=1.1 +Name=osu!lazer +Icon=osu-lazer +MimeType=application/x-osu-lazer-beatmap;application/x-osu-lazer-skin;application/zip;application/x-rar;x-scheme-handler/osu +Comment=Open source free-to-win rhythm game +Exec=/usr/bin/osu-lazer %F +Terminal=false +Categories=Game; +X-Desktop-File-Install-Version=0.24 +StartupWMClass=osu! +StartupNotify=true diff --git a/sakamoto/osu/osu.pre-install b/sakamoto/osu/osu.pre-install new file mode 100644 index 0000000..0ae1e9d --- /dev/null +++ b/sakamoto/osu/osu.pre-install @@ -0,0 +1,7 @@ +#!/bin/sh +cat << __EOF__ +* Note: if you see a warning about missing libasound2-dev on startup, +* check if the snd_seq kernel module is loaded (it's unloaded by default). +__EOF__ + +exit 0 diff --git a/sakamoto/osu/x-osu-lazer.xml b/sakamoto/osu/x-osu-lazer.xml new file mode 100644 index 0000000..9b2da11 --- /dev/null +++ b/sakamoto/osu/x-osu-lazer.xml @@ -0,0 +1,16 @@ + + + + osu! Beatmap + + osu! 譜面 + osu! 谱面 + + + + + osu! Skin + + + + diff --git a/sakamoto/qoi/APKBUILD b/sakamoto/qoi/APKBUILD new file mode 100644 index 0000000..436dc75 --- /dev/null +++ b/sakamoto/qoi/APKBUILD @@ -0,0 +1,34 @@ +# Contributor: knuxify +# Maintainer: knuxify +pkgname=qoi +pkgver=0_git20220328 +_commit=09d144f89264342901250d280b5a7905748fa66f +pkgrel=0 +pkgdesc="The 'Quite OK Image' format for fast, lossless image compression" +url="https://github.com/phoboslab/qoi" +arch="noarch" +license="MIT" +makedepends="libpng-dev stb-dev" +subpackages="$pkgname-dev ${pkgname}conv:_conv:all" +source="https://github.com/phoboslab/qoi/archive/$_commit.tar.gz + use-system-stb.patch" +builddir="$srcdir/qoi-$_commit" +options="!check" # no test suite, outside of benchmarking utility + +build() { + gcc -std=c99 $CFLAGS -o qoiconv qoiconv.c +} + +package() { + install -Dm644 "$builddir"/qoi.h "$pkgdir"/usr/include/qoi.h +} + +_conv() { + pkgdesc="PNG<>QOI conversion utility" + install -Dm755 "$builddir"/qoiconv "$subpkgdir"/usr/bin/qoiconv +} + +sha512sums=" +9b35ace11b6ce4641363e45ca462feb05b428537c4c6b2a8dd046e9f81536f421d44daca112c1124ab2e5f9eaed7bcc303df07948b9ece218316d42b7fa967ef 09d144f89264342901250d280b5a7905748fa66f.tar.gz +0a47858230111f408e0ffa7d4be905962fd8e737dcb4e4480e9ac582e155ffaec827fc452dc99620103647a21152dac9d6a9ae1d2bde4635c792795dfd21c667 use-system-stb.patch +" diff --git a/sakamoto/qoi/use-system-stb.patch b/sakamoto/qoi/use-system-stb.patch new file mode 100644 index 0000000..e7b0d47 --- /dev/null +++ b/sakamoto/qoi/use-system-stb.patch @@ -0,0 +1,47 @@ +From 88e17506846234f1d50c85ea20f9db1cd11b9c64 Mon Sep 17 00:00:00 2001 +From: knuxify +Date: Mon, 4 Apr 2022 17:27:14 +0200 +Subject: [PATCH] use system stb + +--- + qoibench.c | 4 ++-- + qoiconv.c | 4 ++-- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/qoibench.c b/qoibench.c +index cca8c14..53fe73f 100644 +--- a/qoibench.c ++++ b/qoibench.c +@@ -38,10 +38,10 @@ SOFTWARE. + #define STB_IMAGE_IMPLEMENTATION + #define STBI_ONLY_PNG + #define STBI_NO_LINEAR +-#include "stb_image.h" ++#include + + #define STB_IMAGE_WRITE_IMPLEMENTATION +-#include "stb_image_write.h" ++#include + + #define QOI_IMPLEMENTATION + #include "qoi.h" +diff --git a/qoiconv.c b/qoiconv.c +index 79aa75c..33c4e6f 100644 +--- a/qoiconv.c ++++ b/qoiconv.c +@@ -35,10 +35,10 @@ SOFTWARE. + #define STB_IMAGE_IMPLEMENTATION + #define STBI_ONLY_PNG + #define STBI_NO_LINEAR +-#include "stb_image.h" ++#include + + #define STB_IMAGE_WRITE_IMPLEMENTATION +-#include "stb_image_write.h" ++#include + + #define QOI_IMPLEMENTATION + #include "qoi.h" +-- +2.35.1 + diff --git a/sakamoto/stb/APKBUILD b/sakamoto/stb/APKBUILD new file mode 100644 index 0000000..dde4ab5 --- /dev/null +++ b/sakamoto/stb/APKBUILD @@ -0,0 +1,47 @@ +# Contributor: knuxify +# Maintainer: knuxify +pkgname=stb +pkgver=0_git20210910 +_commit=af1a5bc352164740c1cc1354942b1c6b72eacb8a +pkgrel=0 +pkgdesc="stb single-file public domain libraries for C/C++" +url="https://github.com/nothings/stb" +arch="noarch" +license="Public-Domain" +subpackages="$pkgname-dev" +source="$pkgname-$pkgver.tar.gz::https://github.com/nothings/stb/archive/$_commit.tar.gz + drop-cpp-test.patch + stb_perlin.h" +builddir="$srcdir/stb-$_commit" + +prepare() { + default_prepare + + # Manually re-add stb_perlin; it was removed due to patent infringement, + # but the patent is gone now, and the author has confirmed plans to re- + # include it: + # https://github.com/nothings/stb/commit/59e7dec3e8bb0a8d4050d03c2dc32cf71ffa87c6#commitcomment-64296536 + install "$srcdir"/stb_perlin.h "$builddir" +} + +build() { + : +} + +check() { + cd "$builddir"/tests + export CPP=g++ + make +} + +package() { + mkdir -p "$pkgdir"/usr/include/stb + install -Dm664 "$builddir"/*.h "$pkgdir"/usr/include/stb + install -Dm664 "$builddir"/*.c "$pkgdir"/usr/include/stb +} + +sha512sums=" +5937baa1a9b7342ddc0e41c37ba0ea6b0c878f670a81b55bb124681e6b5e381fdc1d9557c96637e3ba082d6d968ed67a78b47f16aa5555c1c43394d1f9e57f2d stb-0_git20210910.tar.gz +410e0ac6b3242e9f006e923e51d086a7d0472993a98de2971dbd53048522eba06d36604b759cc3d3c7bd6299dd953cfe77da3be8410947950b9a9e28b77f0d09 drop-cpp-test.patch +9dbc77a530ea368a47988393c7228ffaa8622ce5ffd83770306eaa6282bf289f7f6e55f4a4a5c746798e8c8a49e180344fd8837983ec734664abf9077e37d39f stb_perlin.h +" diff --git a/sakamoto/stb/drop-cpp-test.patch b/sakamoto/stb/drop-cpp-test.patch new file mode 100644 index 0000000..6dedfac --- /dev/null +++ b/sakamoto/stb/drop-cpp-test.patch @@ -0,0 +1,24 @@ +From 45e68a16dfb11b37100e6e54c753be6dee7d873b Mon Sep 17 00:00:00 2001 +From: knuxify +Date: Mon, 4 Apr 2022 17:46:42 +0200 +Subject: [PATCH] drop cpp test + +--- + tests/Makefile | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/tests/Makefile b/tests/Makefile +index 1782ea6..f771a19 100644 +--- a/tests/Makefile ++++ b/tests/Makefile +@@ -7,6 +7,6 @@ CPPFLAGS = -Wno-write-strings -DSTB_DIVIDE_TEST + + all: + $(CC) $(INCLUDES) $(CFLAGS) ../stb_vorbis.c test_c_compilation.c test_c_lexer.c test_dxt.c test_easyfont.c test_image.c test_image_write.c test_perlin.c test_sprintf.c test_truetype.c test_voxel.c -lm +- $(CC) $(INCLUDES) $(CPPFLAGS) -std=c++0x test_cpp_compilation.cpp -lm -lstdc++ ++ #$(CC) $(INCLUDES) $(CPPFLAGS) -std=c++0x test_cpp_compilation.cpp -lm -lstdc++ + $(CC) $(INCLUDES) $(CFLAGS) -DIWT_TEST image_write_test.c -lm -o image_write_test + $(CC) $(INCLUDES) $(CFLAGS) fuzz_main.c stbi_read_fuzzer.c -lm -o image_fuzzer +-- +2.35.1 + diff --git a/sakamoto/stb/stb_perlin.h b/sakamoto/stb/stb_perlin.h new file mode 100644 index 0000000..47cb9a4 --- /dev/null +++ b/sakamoto/stb/stb_perlin.h @@ -0,0 +1,428 @@ +// stb_perlin.h - v0.5 - perlin noise +// public domain single-file C implementation by Sean Barrett +// +// LICENSE +// +// See end of file. +// +// +// to create the implementation, +// #define STB_PERLIN_IMPLEMENTATION +// in *one* C/CPP file that includes this file. +// +// +// Documentation: +// +// float stb_perlin_noise3( float x, +// float y, +// float z, +// int x_wrap=0, +// int y_wrap=0, +// int z_wrap=0) +// +// This function computes a random value at the coordinate (x,y,z). +// Adjacent random values are continuous but the noise fluctuates +// its randomness with period 1, i.e. takes on wholly unrelated values +// at integer points. Specifically, this implements Ken Perlin's +// revised noise function from 2002. +// +// The "wrap" parameters can be used to create wraparound noise that +// wraps at powers of two. The numbers MUST be powers of two. Specify +// 0 to mean "don't care". (The noise always wraps every 256 due +// details of the implementation, even if you ask for larger or no +// wrapping.) +// +// float stb_perlin_noise3_seed( float x, +// float y, +// float z, +// int x_wrap=0, +// int y_wrap=0, +// int z_wrap=0, +// int seed) +// +// As above, but 'seed' selects from multiple different variations of the +// noise function. The current implementation only uses the bottom 8 bits +// of 'seed', but possibly in the future more bits will be used. +// +// +// Fractal Noise: +// +// Three common fractal noise functions are included, which produce +// a wide variety of nice effects depending on the parameters +// provided. Note that each function will call stb_perlin_noise3 +// 'octaves' times, so this parameter will affect runtime. +// +// float stb_perlin_ridge_noise3(float x, float y, float z, +// float lacunarity, float gain, float offset, int octaves) +// +// float stb_perlin_fbm_noise3(float x, float y, float z, +// float lacunarity, float gain, int octaves) +// +// float stb_perlin_turbulence_noise3(float x, float y, float z, +// float lacunarity, float gain, int octaves) +// +// Typical values to start playing with: +// octaves = 6 -- number of "octaves" of noise3() to sum +// lacunarity = ~ 2.0 -- spacing between successive octaves (use exactly 2.0 for wrapping output) +// gain = 0.5 -- relative weighting applied to each successive octave +// offset = 1.0? -- used to invert the ridges, may need to be larger, not sure +// +// +// Contributors: +// Jack Mott - additional noise functions +// Jordan Peck - seeded noise +// + + +#ifdef __cplusplus +extern "C" { +#endif +extern float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap); +extern float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed); +extern float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves); +extern float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves); +extern float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves); +extern float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed); +#ifdef __cplusplus +} +#endif + +#ifdef STB_PERLIN_IMPLEMENTATION + +#include // fabs() + +// not same permutation table as Perlin's reference to avoid copyright issues; +// Perlin's table can be found at http://mrl.nyu.edu/~perlin/noise/ +static unsigned char stb__perlin_randtab[512] = +{ + 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, + 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, + 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, + 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, + 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, + 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, + 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, + 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, + 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, + 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, + 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, + 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, + 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, + 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, + 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, + 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, + + // and a second copy so we don't need an extra mask or static initializer + 23, 125, 161, 52, 103, 117, 70, 37, 247, 101, 203, 169, 124, 126, 44, 123, + 152, 238, 145, 45, 171, 114, 253, 10, 192, 136, 4, 157, 249, 30, 35, 72, + 175, 63, 77, 90, 181, 16, 96, 111, 133, 104, 75, 162, 93, 56, 66, 240, + 8, 50, 84, 229, 49, 210, 173, 239, 141, 1, 87, 18, 2, 198, 143, 57, + 225, 160, 58, 217, 168, 206, 245, 204, 199, 6, 73, 60, 20, 230, 211, 233, + 94, 200, 88, 9, 74, 155, 33, 15, 219, 130, 226, 202, 83, 236, 42, 172, + 165, 218, 55, 222, 46, 107, 98, 154, 109, 67, 196, 178, 127, 158, 13, 243, + 65, 79, 166, 248, 25, 224, 115, 80, 68, 51, 184, 128, 232, 208, 151, 122, + 26, 212, 105, 43, 179, 213, 235, 148, 146, 89, 14, 195, 28, 78, 112, 76, + 250, 47, 24, 251, 140, 108, 186, 190, 228, 170, 183, 139, 39, 188, 244, 246, + 132, 48, 119, 144, 180, 138, 134, 193, 82, 182, 120, 121, 86, 220, 209, 3, + 91, 241, 149, 85, 205, 150, 113, 216, 31, 100, 41, 164, 177, 214, 153, 231, + 38, 71, 185, 174, 97, 201, 29, 95, 7, 92, 54, 254, 191, 118, 34, 221, + 131, 11, 163, 99, 234, 81, 227, 147, 156, 176, 17, 142, 69, 12, 110, 62, + 27, 255, 0, 194, 59, 116, 242, 252, 19, 21, 187, 53, 207, 129, 64, 135, + 61, 40, 167, 237, 102, 223, 106, 159, 197, 189, 215, 137, 36, 32, 22, 5, +}; + + +// perlin's gradient has 12 cases so some get used 1/16th of the time +// and some 2/16ths. We reduce bias by changing those fractions +// to 5/64ths and 6/64ths + +// this array is designed to match the previous implementation +// of gradient hash: indices[stb__perlin_randtab[i]&63] +static unsigned char stb__perlin_randtab_grad_idx[512] = +{ + 7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7, + 8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8, + 7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8, + 8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5, + 5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1, + 2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4, + 9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11, + 1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6, + 10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0, + 6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2, + 4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3, + 11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11, + 10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1, + 3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10, + 11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7, + 9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5, + + // and a second copy so we don't need an extra mask or static initializer + 7, 9, 5, 0, 11, 1, 6, 9, 3, 9, 11, 1, 8, 10, 4, 7, + 8, 6, 1, 5, 3, 10, 9, 10, 0, 8, 4, 1, 5, 2, 7, 8, + 7, 11, 9, 10, 1, 0, 4, 7, 5, 0, 11, 6, 1, 4, 2, 8, + 8, 10, 4, 9, 9, 2, 5, 7, 9, 1, 7, 2, 2, 6, 11, 5, + 5, 4, 6, 9, 0, 1, 1, 0, 7, 6, 9, 8, 4, 10, 3, 1, + 2, 8, 8, 9, 10, 11, 5, 11, 11, 2, 6, 10, 3, 4, 2, 4, + 9, 10, 3, 2, 6, 3, 6, 10, 5, 3, 4, 10, 11, 2, 9, 11, + 1, 11, 10, 4, 9, 4, 11, 0, 4, 11, 4, 0, 0, 0, 7, 6, + 10, 4, 1, 3, 11, 5, 3, 4, 2, 9, 1, 3, 0, 1, 8, 0, + 6, 7, 8, 7, 0, 4, 6, 10, 8, 2, 3, 11, 11, 8, 0, 2, + 4, 8, 3, 0, 0, 10, 6, 1, 2, 2, 4, 5, 6, 0, 1, 3, + 11, 9, 5, 5, 9, 6, 9, 8, 3, 8, 1, 8, 9, 6, 9, 11, + 10, 7, 5, 6, 5, 9, 1, 3, 7, 0, 2, 10, 11, 2, 6, 1, + 3, 11, 7, 7, 2, 1, 7, 3, 0, 8, 1, 1, 5, 0, 6, 10, + 11, 11, 0, 2, 7, 0, 10, 8, 3, 5, 7, 1, 11, 1, 0, 7, + 9, 0, 11, 5, 10, 3, 2, 3, 5, 9, 7, 9, 8, 4, 6, 5, +}; + +static float stb__perlin_lerp(float a, float b, float t) +{ + return a + (b-a) * t; +} + +static int stb__perlin_fastfloor(float a) +{ + int ai = (int) a; + return (a < ai) ? ai-1 : ai; +} + +// different grad function from Perlin's, but easy to modify to match reference +static float stb__perlin_grad(int grad_idx, float x, float y, float z) +{ + static float basis[12][4] = + { + { 1, 1, 0 }, + { -1, 1, 0 }, + { 1,-1, 0 }, + { -1,-1, 0 }, + { 1, 0, 1 }, + { -1, 0, 1 }, + { 1, 0,-1 }, + { -1, 0,-1 }, + { 0, 1, 1 }, + { 0,-1, 1 }, + { 0, 1,-1 }, + { 0,-1,-1 }, + }; + + float *grad = basis[grad_idx]; + return grad[0]*x + grad[1]*y + grad[2]*z; +} + +float stb_perlin_noise3_internal(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed) +{ + float u,v,w; + float n000,n001,n010,n011,n100,n101,n110,n111; + float n00,n01,n10,n11; + float n0,n1; + + unsigned int x_mask = (x_wrap-1) & 255; + unsigned int y_mask = (y_wrap-1) & 255; + unsigned int z_mask = (z_wrap-1) & 255; + int px = stb__perlin_fastfloor(x); + int py = stb__perlin_fastfloor(y); + int pz = stb__perlin_fastfloor(z); + int x0 = px & x_mask, x1 = (px+1) & x_mask; + int y0 = py & y_mask, y1 = (py+1) & y_mask; + int z0 = pz & z_mask, z1 = (pz+1) & z_mask; + int r0,r1, r00,r01,r10,r11; + + #define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a) + + x -= px; u = stb__perlin_ease(x); + y -= py; v = stb__perlin_ease(y); + z -= pz; w = stb__perlin_ease(z); + + r0 = stb__perlin_randtab[x0+seed]; + r1 = stb__perlin_randtab[x1+seed]; + + r00 = stb__perlin_randtab[r0+y0]; + r01 = stb__perlin_randtab[r0+y1]; + r10 = stb__perlin_randtab[r1+y0]; + r11 = stb__perlin_randtab[r1+y1]; + + n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x , y , z ); + n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x , y , z-1 ); + n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x , y-1, z ); + n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x , y-1, z-1 ); + n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y , z ); + n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y , z-1 ); + n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z ); + n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 ); + + n00 = stb__perlin_lerp(n000,n001,w); + n01 = stb__perlin_lerp(n010,n011,w); + n10 = stb__perlin_lerp(n100,n101,w); + n11 = stb__perlin_lerp(n110,n111,w); + + n0 = stb__perlin_lerp(n00,n01,v); + n1 = stb__perlin_lerp(n10,n11,v); + + return stb__perlin_lerp(n0,n1,u); +} + +float stb_perlin_noise3(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap) +{ + return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap,0); +} + +float stb_perlin_noise3_seed(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, int seed) +{ + return stb_perlin_noise3_internal(x,y,z,x_wrap,y_wrap,z_wrap, (unsigned char) seed); +} + +float stb_perlin_ridge_noise3(float x, float y, float z, float lacunarity, float gain, float offset, int octaves) +{ + int i; + float frequency = 1.0f; + float prev = 1.0f; + float amplitude = 0.5f; + float sum = 0.0f; + + for (i = 0; i < octaves; i++) { + float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i); + r = offset - (float) fabs(r); + r = r*r; + sum += r*amplitude*prev; + prev = r; + frequency *= lacunarity; + amplitude *= gain; + } + return sum; +} + +float stb_perlin_fbm_noise3(float x, float y, float z, float lacunarity, float gain, int octaves) +{ + int i; + float frequency = 1.0f; + float amplitude = 1.0f; + float sum = 0.0f; + + for (i = 0; i < octaves; i++) { + sum += stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude; + frequency *= lacunarity; + amplitude *= gain; + } + return sum; +} + +float stb_perlin_turbulence_noise3(float x, float y, float z, float lacunarity, float gain, int octaves) +{ + int i; + float frequency = 1.0f; + float amplitude = 1.0f; + float sum = 0.0f; + + for (i = 0; i < octaves; i++) { + float r = stb_perlin_noise3_internal(x*frequency,y*frequency,z*frequency,0,0,0,(unsigned char)i)*amplitude; + sum += (float) fabs(r); + frequency *= lacunarity; + amplitude *= gain; + } + return sum; +} + +float stb_perlin_noise3_wrap_nonpow2(float x, float y, float z, int x_wrap, int y_wrap, int z_wrap, unsigned char seed) +{ + float u,v,w; + float n000,n001,n010,n011,n100,n101,n110,n111; + float n00,n01,n10,n11; + float n0,n1; + + int px = stb__perlin_fastfloor(x); + int py = stb__perlin_fastfloor(y); + int pz = stb__perlin_fastfloor(z); + int x_wrap2 = (x_wrap ? x_wrap : 256); + int y_wrap2 = (y_wrap ? y_wrap : 256); + int z_wrap2 = (z_wrap ? z_wrap : 256); + int x0 = px % x_wrap2, x1; + int y0 = py % y_wrap2, y1; + int z0 = pz % z_wrap2, z1; + int r0,r1, r00,r01,r10,r11; + + if (x0 < 0) x0 += x_wrap2; + if (y0 < 0) y0 += y_wrap2; + if (z0 < 0) z0 += z_wrap2; + x1 = (x0+1) % x_wrap2; + y1 = (y0+1) % y_wrap2; + z1 = (z0+1) % z_wrap2; + + #define stb__perlin_ease(a) (((a*6-15)*a + 10) * a * a * a) + + x -= px; u = stb__perlin_ease(x); + y -= py; v = stb__perlin_ease(y); + z -= pz; w = stb__perlin_ease(z); + + r0 = stb__perlin_randtab[x0]; + r0 = stb__perlin_randtab[r0+seed]; + r1 = stb__perlin_randtab[x1]; + r1 = stb__perlin_randtab[r1+seed]; + + r00 = stb__perlin_randtab[r0+y0]; + r01 = stb__perlin_randtab[r0+y1]; + r10 = stb__perlin_randtab[r1+y0]; + r11 = stb__perlin_randtab[r1+y1]; + + n000 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z0], x , y , z ); + n001 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r00+z1], x , y , z-1 ); + n010 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z0], x , y-1, z ); + n011 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r01+z1], x , y-1, z-1 ); + n100 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z0], x-1, y , z ); + n101 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r10+z1], x-1, y , z-1 ); + n110 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z0], x-1, y-1, z ); + n111 = stb__perlin_grad(stb__perlin_randtab_grad_idx[r11+z1], x-1, y-1, z-1 ); + + n00 = stb__perlin_lerp(n000,n001,w); + n01 = stb__perlin_lerp(n010,n011,w); + n10 = stb__perlin_lerp(n100,n101,w); + n11 = stb__perlin_lerp(n110,n111,w); + + n0 = stb__perlin_lerp(n00,n01,v); + n1 = stb__perlin_lerp(n10,n11,v); + + return stb__perlin_lerp(n0,n1,u); +} +#endif // STB_PERLIN_IMPLEMENTATION + +/* +------------------------------------------------------------------------------ +This software is available under 2 licenses -- choose whichever you prefer. +------------------------------------------------------------------------------ +ALTERNATIVE A - MIT License +Copyright (c) 2017 Sean Barrett +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. +------------------------------------------------------------------------------ +ALTERNATIVE B - Public Domain (www.unlicense.org) +This is free and unencumbered software released into the public domain. +Anyone is free to copy, modify, publish, use, compile, sell, or distribute this +software, either in source code form or as a compiled binary, for any purpose, +commercial or non-commercial, and by any means. +In jurisdictions that recognize copyright laws, the author or authors of this +software dedicate any and all copyright interest in the software to the public +domain. We make this dedication for the benefit of the public at large and to +the detriment of our heirs and successors. We intend this dedication to be an +overt act of relinquishment in perpetuity of all present and future rights to +this software under copyright law. +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 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. +------------------------------------------------------------------------------ +*/ diff --git a/sakamoto/stbi-sharp/APKBUILD b/sakamoto/stbi-sharp/APKBUILD new file mode 100644 index 0000000..fcf4921 --- /dev/null +++ b/sakamoto/stbi-sharp/APKBUILD @@ -0,0 +1,35 @@ +# Contributor: knuxify +# Maintainer: knuxify +pkgname=stbi-sharp +pkgver=1.2.1 +pkgrel=0 +pkgdesc="C# wrapper around stb_image.h and qoi.h" +url="https://github.com/Tom94/stbi-sharp" +arch="all" +license="BSD-3-Clause" +makedepends="cmake stb-dev qoi-dev" +source="https://github.com/Tom94/stbi-sharp/archive/refs/tags/v$pkgver/stbi-sharp-$pkgver.tar.gz + use-system-stb.patch" +options="!check" # no test suite + +build() { + if [ "$CBUILD" != "$CHOST" ]; then + CMAKE_CROSSOPTS="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux" + fi + cd "$builddir"/libstbi + cmake -B build \ + -DCMAKE_INSTALL_PREFIX=/usr \ + -DBUILD_SHARED_LIBS=True \ + -DCMAKE_BUILD_TYPE=MinSizeRel \ + $CMAKE_CROSSOPTS . + cmake --build build +} + +package() { + DESTDIR="$pkgdir" cmake --install "$builddir"/libstbi/build +} + +sha512sums=" +cd849e73511ac0afba747e2a10fc0478c3f7eba69235a0ee3b8c8aeb33cb4a4ac56d48c7cc818c56ee0a123838e87820c7df5d045b835a2f03980b78f1b01000 stbi-sharp-1.2.1.tar.gz +0dd9c4f8dc2ddc84ef2aa307dc348194ba0e94d2f0c75898cac22729415a42dd50baefc23cfe2607ea5e73575b9b0db67739773706cf2e4b78a2edbd1d8c9daa use-system-stb.patch +" diff --git a/sakamoto/stbi-sharp/use-system-stb.patch b/sakamoto/stbi-sharp/use-system-stb.patch new file mode 100644 index 0000000..7f6dd60 --- /dev/null +++ b/sakamoto/stbi-sharp/use-system-stb.patch @@ -0,0 +1,25 @@ +From 5883dce892d00d59ceb6fa3c43de570c38e141cf Mon Sep 17 00:00:00 2001 +From: knuxify +Date: Mon, 4 Apr 2022 18:06:00 +0200 +Subject: [PATCH] use system stb + +--- + libstbi/src/stbi.cpp | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libstbi/src/stbi.cpp b/libstbi/src/stbi.cpp +index 6003d46..309879d 100644 +--- a/libstbi/src/stbi.cpp ++++ b/libstbi/src/stbi.cpp +@@ -13,7 +13,7 @@ + #define STBI_NO_STDIO + #define STBI_FAILURE_USERMSG + #define STB_IMAGE_IMPLEMENTATION +-#include ++#include + + #ifdef _WIN32 + #define EXPORT __declspec(dllexport) +-- +2.35.1 +