From ccb50c6021b57e3257a3a5aaed0eceda9e73f9cb Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 23 Nov 2024 20:45:16 +0100 Subject: [PATCH 1/9] readme: update supported platforms --- README.md | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 4437a7a05..b9b15dba5 100644 --- a/README.md +++ b/README.md @@ -35,9 +35,11 @@ There are minor graphics- and gameplay-related issues, and possibly occasional c * in practice the game will have issues running faster than ~165 FPS, so use VSync or `Video.FramerateLimit` to cap it. * emulate the Transfer Pak functionality the game has on the Nintendo 64 to unlock some cheats automatically. -Currently both 32-bit and 64-bit platforms should be supported. -The port is tested on i686 and x86_64, both on Windows and on Linux. -ARM platforms might be supported, but are mostly untested. +The following platforms are officially supported and tested: +* Windows: x86_64, i686 +* Linux: x86_64, i686 +* Mac: x86_64, arm64 +* Nintendo Switch: arm64 ## Download @@ -68,7 +70,7 @@ Optionally, you can also put your Perfect Dark for GameBoy Color ROM named `pd.g Additional information can be found in the [wiki](https://github.com/fgsfdsfgs/perfect_dark/wiki). -A GPU supporting OpenGL 3.0 or above is required to run the port. +A GPU supporting OpenGL 3.0/ES3.0 or above is required to run the port. ### Installing the Nintendo Switch version @@ -165,7 +167,7 @@ Alternate compilers or toolchains can be specified by passing `-DCMAKE_TOOLCHAIN You will need to provide a `jpn-final` or `pal-final` ROM to run executables built for those regions, named `pd.jpn-final.z64` or `pd.pal-final.z64`. -It might be possible to build and run the game on an ARM/AArch64 platform, but this has not been tested. +It might be possible to build and run the game on platforms that are not specified in the supported platforms list (e.g. Linux on armv7), but this has not been tested. ## Credits From 13a3e0a0eaef13da8e42ce78d21fb4871c043934 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 23 Nov 2024 20:46:17 +0100 Subject: [PATCH 2/9] readme: specify OS versions --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index b9b15dba5..e403d7dff 100644 --- a/README.md +++ b/README.md @@ -36,9 +36,9 @@ There are minor graphics- and gameplay-related issues, and possibly occasional c * emulate the Transfer Pak functionality the game has on the Nintendo 64 to unlock some cheats automatically. The following platforms are officially supported and tested: -* Windows: x86_64, i686 +* Windows: x86_64, i686 (should work on Windows 7 and above) * Linux: x86_64, i686 -* Mac: x86_64, arm64 +* MacOS: x86_64 (OS 10.9+), arm64 (OS 11.0+) * Nintendo Switch: arm64 ## Download From 5c5c33c116fe4f3bf70519283d5530ccfda8eb25 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 23 Nov 2024 20:46:59 +0100 Subject: [PATCH 3/9] readme: small style edit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index e403d7dff..1a8f3245f 100644 --- a/README.md +++ b/README.md @@ -36,8 +36,8 @@ There are minor graphics- and gameplay-related issues, and possibly occasional c * emulate the Transfer Pak functionality the game has on the Nintendo 64 to unlock some cheats automatically. The following platforms are officially supported and tested: -* Windows: x86_64, i686 (should work on Windows 7 and above) -* Linux: x86_64, i686 +* Windows 7+: i686, x86_64 +* Linux: i686, x86_64 * MacOS: x86_64 (OS 10.9+), arm64 (OS 11.0+) * Nintendo Switch: arm64 From 37e69cb83d5d228030ccc6a7d1b75aa8823a4a2c Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 23 Nov 2024 21:07:21 +0100 Subject: [PATCH 4/9] readme: add osx build instructions --- README.md | 38 +++++++++++++++++++++++++++++++++----- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1a8f3245f..807bb598f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ There are minor graphics- and gameplay-related issues, and possibly occasional c * in practice the game will have issues running faster than ~165 FPS, so use VSync or `Video.FramerateLimit` to cap it. * emulate the Transfer Pak functionality the game has on the Nintendo 64 to unlock some cheats automatically. -The following platforms are officially supported and tested: +**The following platforms are officially supported and tested:** * Windows 7+: i686, x86_64 * Linux: i686, x86_64 * MacOS: x86_64 (OS 10.9+), arm64 (OS 11.0+) @@ -136,6 +136,32 @@ Controls can be rebound in `pd.ini`. Default control scheme is as follows: 4. Run `cmake --build build -j4`. 5. The resulting executable will be at `build/pd.` (for example `build/pd.x86_64`). +### MacOS + +1. Set up Homebrew. +2. Install dependencies: + * Execute command: `brew install cmake gcc python3 zlib git` +3. Install SDL2: + * Execute commands: + ``` + wget http://libsdl.org/release/SDL2-2.30.9.dmg -O SDL2.dmg + hdiutil mount SDL2.dmg + sudo cp -vr /Volumes/SDL2/SDL2.framework /Library/Frameworks + hdiutil detach /Volumes/SDL2 + ``` + * This installs SDL2 system-wide and this is how the automatic builds are done. The game will also look for it in the executable path, so you could + download it locally instead. +4. Get the source code: + `git clone --recursive https://github.com/fgsfdsfgs/perfect_dark.git && cd perfect_dark` +5. Configure: + * Execute command: `cmake -G"Unix Makefiles" -Bbuild -DCMAKE_OSX_ARCHITECTURES=x86_64 .` + * Replace `x86_64` with `arm64` if building for an ARM64 Mac. + * Add ` -DROMID=pal-final` or ` -DROMID=jpn-final` at the end of the command if you want to build a PAL or JPN executable respectively. +6. Build: + * Execute command: `cmake --build build --target pd -j4 --clean-first` +7. The resulting executable will be at `build/pd.` (for example `build/pd.x86_64`). + * You might need to execute `chmod +x build/pd.x86-64` before you can run it. + ### Nintendo Switch 1. Set up the [devkitA64 environment](https://devkitpro.org/wiki/Getting_Started). @@ -151,15 +177,17 @@ Controls can be rebound in `pd.ini`. Default control scheme is as follows: dkp-pacman -S devkitA64 libnx switch-zlib switch-sdl2 switch-cmake dkp-toolchain-vars ``` * If in MSYS2 or `dkp-pacman` doesn't work, replace it with just `pacman`. -4. Ensure devkitA64 environment variables are set: +4. Get the source code: + `git clone --recursive https://github.com/fgsfdsfgs/perfect_dark.git && cd perfect_dark` +5. Ensure devkitA64 environment variables are set: * Execute command: `source /opt/devkitpro/switchvars.sh` * If your `$DEVKITPRO` path is different, substitute that instead or set the variables manually. -5. Configure: +6. Configure: * Execute command: `aarch64-none-elf-cmake -G"Unix Makefiles" -Bbuild .` * Add ` -DROMID=pal-final` or ` -DROMID=jpn-final` at the end of the command if you want to build a PAL or JPN executable respectively. -6. Build: +7. Build: * Execute command: `make -C build -j4` -7. The resulting executable will be at `build/pd.arm64.nro`. +8. The resulting executable will be at `build/pd.arm64.nro`. ### Notes From 33efd36278338ee34d68e0ac11528bb77368b392 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 23 Nov 2024 21:11:38 +0100 Subject: [PATCH 5/9] readme: add note about save folder --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 807bb598f..00485eebb 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,8 @@ If you want to use a PAL or JPN ROM instead, put them into the `data` directory Optionally, you can also put your Perfect Dark for GameBoy Color ROM named `pd.gbc` in the `data` directory if you want to emulate having the Nintendo 64's Transfer Pak and unlock some cheats automatically. +Optionally, you can move the data folder to `~/.local/share/perfectdark` on Linux or `~/Library/Application Support/perfectdark` on MacOS. + Additional information can be found in the [wiki](https://github.com/fgsfdsfgs/perfect_dark/wiki). A GPU supporting OpenGL 3.0/ES3.0 or above is required to run the port. From 0ad4492ff665982d9330d2cb791a3132543090de Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 24 Nov 2024 00:25:19 +0100 Subject: [PATCH 6/9] port: default to home directory for saves on OSX as well --- port/src/fs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/src/fs.c b/port/src/fs.c index cbcec8782..40335a3fa 100644 --- a/port/src/fs.c +++ b/port/src/fs.c @@ -149,7 +149,7 @@ s32 fsInit(void) if (portable) { path = "$E"; } else { -#ifdef PLATFORM_LINUX +#if defined(PLATFORM_LINUX) || defined(PLATFORM_OSX) // check if there's a config in the working directory, otherwise default to homeDir if (fsFileSize("./" CONFIG_FNAME) >= 0) { path = "."; From 92e1c4aa0b535b8c2dfe4f85c595f15d9a154c7a Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 24 Nov 2024 00:31:31 +0100 Subject: [PATCH 7/9] port: osx: temporarily bump target version to 10.13 to test something --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 440e899e0..cb55c494e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum OS X deployment version") else() # SDL2 requires at least this version for everything to work properly. - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") endif() endif() From 9c4aded403976a90ca9641fb5fb989dd7c80ad7a Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sun, 24 Nov 2024 01:05:18 +0100 Subject: [PATCH 8/9] port: osx: restore 10.9 target version --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cb55c494e..440e899e0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,7 @@ if(APPLE) set(CMAKE_OSX_DEPLOYMENT_TARGET "11.0" CACHE STRING "Minimum OS X deployment version") else() # SDL2 requires at least this version for everything to work properly. - set(CMAKE_OSX_DEPLOYMENT_TARGET "10.13" CACHE STRING "Minimum OS X deployment version") + set(CMAKE_OSX_DEPLOYMENT_TARGET "10.9" CACHE STRING "Minimum OS X deployment version") endif() endif() From 67675d89809516f2eac079f36830b03967b5367a Mon Sep 17 00:00:00 2001 From: fgsfds Date: Fri, 29 Nov 2024 09:46:46 +0100 Subject: [PATCH 9/9] port: fix #541 --- src/game/chraicommands.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/game/chraicommands.c b/src/game/chraicommands.c index d09decd94..efcbf5ecf 100644 --- a/src/game/chraicommands.c +++ b/src/game/chraicommands.c @@ -2114,14 +2114,18 @@ bool aiIfGunUnclaimed(void) g_Vars.aioffset += 5; } } else { - struct weaponobj *weapon = g_Vars.chrdata->gunprop->weapon; + struct prop *prop = g_Vars.chrdata->gunprop; - if (weapon && weapon->base.prop) { - weapon->base.flags |= OBJFLAG_FORCENOBOUNCE; - g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); - } else { - g_Vars.aioffset += 5; + if (prop && prop->weapon && prop->parent == NULL && prop->type == PROPTYPE_WEAPON) { + struct weaponobj *weapon = prop->weapon; + if (weapon->base.prop) { + weapon->base.flags |= OBJFLAG_FORCENOBOUNCE; + g_Vars.aioffset = chraiGoToLabel(g_Vars.ailist, g_Vars.aioffset, cmd[4]); + return false; + } } + + g_Vars.aioffset += 5; } return false;