From a9a90b1b58f2bd227df7fd2a681c5931b64459b7 Mon Sep 17 00:00:00 2001 From: Luke Wilde Date: Wed, 13 Apr 2022 17:22:56 +0100 Subject: [PATCH] Ports: Add mGBA --- Ports/AvailablePorts.md | 1 + Ports/mgba/package.sh | 16 +++++++++++++ Ports/mgba/patches/ReadMe.md | 23 +++++++++++++++++++ ...does-not-support-futimens-or-futimes.patch | 14 +++++++++++ ...-sdl-software-renderer-with-no-vsync.patch | 11 +++++++++ 5 files changed, 65 insertions(+) create mode 100755 Ports/mgba/package.sh create mode 100644 Ports/mgba/patches/ReadMe.md create mode 100644 Ports/mgba/patches/serenity-does-not-support-futimens-or-futimes.patch create mode 100644 Ports/mgba/patches/use-sdl-software-renderer-with-no-vsync.patch diff --git a/Ports/AvailablePorts.md b/Ports/AvailablePorts.md index 3e378c9c23..147458ac6f 100644 --- a/Ports/AvailablePorts.md +++ b/Ports/AvailablePorts.md @@ -132,6 +132,7 @@ Please make sure to keep this list up to date when adding and updating ports. :^ | [`mawk`](mawk/) | mawk | 1.3.4-20200120 | https://invisible-island.net/mawk/ | | [`mbedtls`](mbedtls/) | Mbed TLS | 2.16.2 | https://tls.mbed.org/ | | [`mc`](mc/) | Midnight Commander | 4.8.27 | http://midnight-commander.org/ | +| [`mgba`](mgba/) | Game Boy, Game Boy Color and Game Boy Advance emulator | 0.9.3 | https://mgba.io/ | | [`milkytracker`](milkytracker/) | milkytracker | 1.03.00 | https://github.com/milkytracker/MilkyTracker | | [`mold`](mold/) | A Modern Linker | 1.0.2 | https://github.com/rui314/mold | | [`mpc`](mpc/) | GNU Multiple Precision Complex Library (MPC) | 1.2.1 | http://www.multiprecision.org/mpc/ | diff --git a/Ports/mgba/package.sh b/Ports/mgba/package.sh new file mode 100755 index 0000000000..94a62c569c --- /dev/null +++ b/Ports/mgba/package.sh @@ -0,0 +1,16 @@ +#!/usr/bin/env -S bash ../.port_include.sh +port=mgba +version=0.9.3 +files="https://github.com/mgba-emu/mgba/archive/refs/tags/${version}.tar.gz mgba-${version}.tar.gz 692ff0ac50e18380df0ff3ee83071f9926715200d0dceedd9d16a028a59537a0" +auth_type=sha256 +configopts=("-DCMAKE_TOOLCHAIN_FILE=${SERENITY_BUILD_DIR}/CMakeToolchain.txt") +useconfigure=true +depends=("SDL2" "zlib" "sqlite" "libpng" "libzip") + +configure() { + run cmake "${configopts[@]}" +} + +install() { + run make install +} diff --git a/Ports/mgba/patches/ReadMe.md b/Ports/mgba/patches/ReadMe.md new file mode 100644 index 0000000000..018aca7f49 --- /dev/null +++ b/Ports/mgba/patches/ReadMe.md @@ -0,0 +1,23 @@ +# Patches for mGBA on SerenityOS + +## `serenity-does-not-support-futimens-or-futimes.patch` + +We do not currently support futimens or futimes. [futimens is a POSIX function,](https://pubs.opengroup.org/onlinepubs/9699919799/) +so this is an issue on our side. + +### Status +- [ ] Local? +- [ ] Should be merged to upstream? +- [X] Resolves issue(s) with our side of things +- [ ] Hack + +## `use-sdl-software-renderer-with-no-vsync.patch` + +This makes us use the SDL software renderer with no vsync, as our SDL2 port does not currently support accelerated rendering +or vsync. + +### Status +- [ ] Local? +- [ ] Should be merged to upstream? +- [X] Resolves issue(s) with our side of things +- [ ] Hack diff --git a/Ports/mgba/patches/serenity-does-not-support-futimens-or-futimes.patch b/Ports/mgba/patches/serenity-does-not-support-futimens-or-futimes.patch new file mode 100644 index 0000000000..694dc9f8ba --- /dev/null +++ b/Ports/mgba/patches/serenity-does-not-support-futimens-or-futimes.patch @@ -0,0 +1,14 @@ +--- mgba-0.9.3/src/util/vfs/vfs-fd.c 2021-12-18 01:56:32.000000000 +0000 ++++ mgba-0.9.3.serenity/src/util/vfs/vfs-fd.c 2022-04-13 02:50:08.792765951 +0100 +@@ -200,11 +200,6 @@ + UNUSED(size); + struct VFileFD* vfd = (struct VFileFD*) vf; + #ifndef _WIN32 +-#ifdef __HAIKU__ +- futimens(vfd->fd, NULL); +-#else +- futimes(vfd->fd, NULL); +-#endif + if (buffer && size) { + return msync(buffer, size, MS_ASYNC) == 0; + } diff --git a/Ports/mgba/patches/use-sdl-software-renderer-with-no-vsync.patch b/Ports/mgba/patches/use-sdl-software-renderer-with-no-vsync.patch new file mode 100644 index 0000000000..a53dcbc9bb --- /dev/null +++ b/Ports/mgba/patches/use-sdl-software-renderer-with-no-vsync.patch @@ -0,0 +1,11 @@ +--- mgba-0.9.3/src/platform/sdl/sw-sdl2.c 2021-12-18 01:56:32.000000000 +0000 ++++ mgba-0.9.3.serenity/src/platform/sdl/sw-sdl2.c 2022-04-13 02:50:08.760766286 +0100 +@@ -25,7 +25,7 @@ + renderer->window = SDL_CreateWindow(projectName, SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, renderer->viewportWidth, renderer->viewportHeight, SDL_WINDOW_OPENGL | (SDL_WINDOW_FULLSCREEN_DESKTOP * renderer->player.fullscreen)); + SDL_GetWindowSize(renderer->window, &renderer->viewportWidth, &renderer->viewportHeight); + renderer->player.window = renderer->window; +- renderer->sdlRenderer = SDL_CreateRenderer(renderer->window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_PRESENTVSYNC); ++ renderer->sdlRenderer = SDL_CreateRenderer(renderer->window, -1, SDL_RENDERER_SOFTWARE); + #ifdef COLOR_16_BIT + #ifdef COLOR_5_6_5 + renderer->sdlTex = SDL_CreateTexture(renderer->sdlRenderer, SDL_PIXELFORMAT_RGB565, SDL_TEXTUREACCESS_STREAMING, width, height);