From e65f46d081b83ded445248efbf8ea9304a2760f6 Mon Sep 17 00:00:00 2001 From: peerchemist Date: Tue, 18 Mar 2025 08:47:29 +0100 Subject: [PATCH 01/14] Update c-cpp.yml It hardly makes sense to use 32bit binary for flatpak. --- .github/workflows/c-cpp.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/c-cpp.yml b/.github/workflows/c-cpp.yml index 6ae34ca94..94989b5ba 100644 --- a/.github/workflows/c-cpp.yml +++ b/.github/workflows/c-cpp.yml @@ -266,7 +266,7 @@ jobs: build-flatpak-bundle: name: "Build flatpak bundle" runs-on: ubuntu-latest - needs: [build-i686-linux, build-x86_64-linux] + needs: [build-x86_64-linux] container: image: bilelmoussaoui/flatpak-github-actions:freedesktop-23.08 options: --privileged @@ -274,7 +274,7 @@ jobs: - uses: actions/checkout@v4 - uses: actions/download-artifact@v4 with: - name: pd-i686-linux + name: pd-x86_64-linux path: dist/linux/bin/ - uses: flatpak/flatpak-github-actions/flatpak-builder@v6 From 6c29e7ecc817689ebcebf354c65ba3dda199d9ba Mon Sep 17 00:00:00 2001 From: peerchemist Date: Tue, 18 Mar 2025 09:00:38 +0100 Subject: [PATCH 02/14] Update io.github.fgsfdsfgs.perfect_dark.sh --- dist/linux/io.github.fgsfdsfgs.perfect_dark.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh b/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh index 9269fbd70..719a7fbee 100644 --- a/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh +++ b/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh @@ -11,14 +11,14 @@ done # Default to pd as executable but switch to jpn/pal if the NTSC rom # is missing but JPN/PAL are present. # TODO: Other arch -executable="pd.i686" +executable="pd.x86_64" if [ -f ${XDG_DATA_HOME}/roms/pd.ntsc-final.z64 ] | \ [ -f ${XDG_DATA_HOME}/roms/pd.ntsc-1.0.z64 ]; then - executable="pd.i686" + executable="pd.x86_64" elif [ -f ${XDG_DATA_HOME}/roms/pd.jpn-final.z64 ]; then - executable="pd.jpn.i686" + executable="pd.jpn.x" elif [ -f ${XDG_DATA_HOME}/roms/pd.pal-final.z64 ]; then - executable="pd.pal.i686" + executable="pd.pal.x86_64" fi # If first parameter passed to this script is one of the pd executables, From 4019bd59cf6466a8bcea9ace9f946e6931dc29b4 Mon Sep 17 00:00:00 2001 From: peerchemist Date: Tue, 18 Mar 2025 09:13:23 +0100 Subject: [PATCH 03/14] Update io.github.fgsfdsfgs.perfect_dark.yaml --- .../io.github.fgsfdsfgs.perfect_dark.yaml | 62 ++----------------- 1 file changed, 6 insertions(+), 56 deletions(-) diff --git a/dist/linux/io.github.fgsfdsfgs.perfect_dark.yaml b/dist/linux/io.github.fgsfdsfgs.perfect_dark.yaml index c9d1d4f1d..213f146d3 100644 --- a/dist/linux/io.github.fgsfdsfgs.perfect_dark.yaml +++ b/dist/linux/io.github.fgsfdsfgs.perfect_dark.yaml @@ -1,13 +1,11 @@ app-id: io.github.fgsfdsfgs.perfect_dark runtime: org.freedesktop.Platform -runtime-version: &runtime-version '23.08' +runtime-version: "23.08" sdk: org.freedesktop.Sdk command: io.github.fgsfdsfgs.perfect_dark.sh finish-args: - # hardware 3D and controller access - --device=all - # X11 + XShm access - --share=ipc - --socket=x11 # Audio @@ -15,59 +13,16 @@ finish-args: # Enable network for multiplayer - --share=network -# Parameters for 32-bit extensions -x-gl-version: &gl-version '1.4' -x-gl-versions: &gl-versions 23.08;1.4 -x-gl-merge-dirs: &gl-merge-dirs vulkan/icd.d;glvnd/egl_vendor.d;egl/egl_external_platform.d;OpenCL/vendors;lib/dri;lib/d3d;lib/gbm;vulkan/explicit_layer.d;vulkan/implicit_layer.d - -add-extensions: - org.freedesktop.Platform.Compat.i386: - directory: lib/i386-linux-gnu - version: '23.08' - - org.freedesktop.Platform.GL32: - directory: lib/i386-linux-gnu/GL - version: *gl-version - versions: *gl-versions - subdirectories: true - no-autodownload: true - autodelete: false - add-ld-path: lib - merge-dirs: *gl-merge-dirs - download-if: active-gl-driver - enable-if: active-gl-driver - autoprune-unless: active-gl-driver - - org.freedesktop.Platform.GL32.Debug: - directory: lib/debug/lib/i386-linux-gnu/GL - version: *gl-version - versions: *gl-versions - subdirectories: true - no-autodownload: true - merge-dirs: *gl-merge-dirs - enable-if: active-gl-driver - autoprune-unless: active-gl-driver - - org.freedesktop.Platform.VAAPI.Intel.i386: - directory: lib/i386-linux-gnu/dri/intel-vaapi-driver - version: *runtime-version - versions: *runtime-version - autodelete: false - no-autodownload: true - add-ld-path: lib - download-if: have-intel-gpu - autoprune-unless: have-intel-gpu - modules: - name: perfect_dark buildsystem: simple sources: - type: file - path: bin/pd.i686 + path: bin/pd.x86_64 - type: file - path: bin/pd.jpn.i686 + path: bin/pd.jpn.x86_64 - type: file - path: bin/pd.pal.i686 + path: bin/pd.pal.x86_64 - type: file path: io.github.fgsfdsfgs.perfect_dark.sh - type: file @@ -78,13 +33,8 @@ modules: path: io.github.fgsfdsfgs.perfect_dark.desktop build-commands: [] post-install: - # create extension mountpoints - - mkdir -p /app/lib/i386-linux-gnu - - mkdir -p /app/lib/i386-linux-gnu/GL - - mkdir -p /app/lib/debug/lib/i386-linux-gnu/GL - - mkdir -p /app/lib/i386-linux-gnu/dri/intel-vaapi-driver - # port - - install -Dm 755 -t /app/bin/ pd* + # Install the binaries + - install -Dm 755 -t /app/bin/ pd.* - install -Dm 755 ${FLATPAK_ID}.sh /app/bin/${FLATPAK_ID}.sh - install -Dm 644 ${FLATPAK_ID}.desktop /app/share/applications/${FLATPAK_ID}.desktop - install -Dm 644 ${FLATPAK_ID}.metainfo.xml /app/share/metainfo/${FLATPAK_ID}.metainfo.xml From 355f0ed0eedcfda50c5e77990947fe5bfb052425 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Sun, 24 Nov 2024 17:51:53 -0800 Subject: [PATCH 04/14] IR Goggle support for 4player and 1-2p draw fixes - allocate memory for 4player's IR goggle scanlines - fixes IR goggle alignment - fixes IR lens for players 2 and 4 - fixes off-by-one rendering error for top two players (bottom of screen) - fixes off-by-one rendering error for right-side players (right side of semicircle thing) - fixes dark area flickering; use resolved shading for props if not wearing goggles - port: fix IR goggle off-by-one draw issues --- src/game/bondview.c | 31 +++++++++++++++++++++++++++++-- src/game/propobj.c | 4 ++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/src/game/bondview.c b/src/game/bondview.c index ed527006c..9dbae8e06 100644 --- a/src/game/bondview.c +++ b/src/game/bondview.c @@ -31,7 +31,7 @@ char var800a41c0[26]; char var800a41c0[24]; #endif -u8 g_IrScanlines[2][480]; +u8 g_IrScanlines[4][480]; #if VERSION < VERSION_NTSC_1_0 u8 var800a8b58nb[0x1c0]; @@ -2356,6 +2356,10 @@ Gfx *bviewDrawIrLens(Gfx *gdl) gSPSetExtraGeometryModeEXT(gdl++, G_MODULATE_EXT); #endif + // fixes off by one error w/ two top players + if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 1) { + scanbottom++; + } for (i = scantop; i < scanbottom; i++) { #if VERSION >= VERSION_NTSC_1_0 if (i & 1) { @@ -2392,6 +2396,10 @@ Gfx *bviewDrawIrLens(Gfx *gdl) s32 semicirclewidth = sqrtf(sqinnerradius - (s32) (f0 * f0)) * (viewwidth / (f32) SCREEN_WIDTH_LO); s32 semicircleright = viewcentrex + semicirclewidth; s32 rightsidewidth = viewwidth - semicircleright; + // if playernum is 1 or 3, shift to the right by viewwidth + if (g_Vars.currentplayernum == 1 || g_Vars.currentplayernum == 3) { + rightsidewidth += viewwidth; + } #ifdef PLATFORM_N64 // Left and right of semicircle @@ -2405,14 +2413,22 @@ Gfx *bviewDrawIrLens(Gfx *gdl) gdl = bviewCopyPixels(gdl, fb, i, 5, i, 1.0f, viewleft, viewwidth); } #else - // Left and right of semicircle + + // Scanlines to the left and right of the semicircle gDPFillRectangle(gdl++, viewleft, i, viewcentrex, i + 1); + if (PLAYERCOUNT() <= 2 && g_Vars.currentplayernum == 0 && i == viewcentrey) { + semicircleright -= 1; + } + else if (PLAYERCOUNT() > 2 && (g_Vars.currentplayernum == 1 || g_Vars.currentplayernum == 3 ) && i == viewcentrey) { + semicircleright -= 1; + } gDPFillRectangle(gdl++, semicircleright, i, semicircleright + rightsidewidth, i + 1); // The semicircle itself has a static colour gDPSetPrimColorViaWord(gdl++, 0, 0, 0xee0000ff); gDPFillRectangle(gdl++, viewcentrex, i, viewcentrex + semicirclewidth, i + 1); } else { + // scanlines above and below the semicircle gDPFillRectangle(gdl++, viewleft, i, viewleft + viewwidth, i + 1); } #endif @@ -2781,6 +2797,10 @@ Gfx *bviewDrawIrBinoculars(Gfx *gdl) s32 viewleft = viGetViewLeft(); s32 viewright = viewleft + viewwidth; s32 viewbottom = viewtop + viewheight; + // fixes off by one error w/ two top players + if (g_Vars.currentplayernum == 0 || g_Vars.currentplayernum == 1) { + viewbottom++; + } s32 leftx = viewleft + viewwidth / 3; s32 rightx = viewleft + (viewwidth * 2) / 3; s32 centrey = (viewtop + viewbottom) / 2; @@ -2798,6 +2818,13 @@ Gfx *bviewDrawIrBinoculars(Gfx *gdl) for (y = viewtop; y < viewbottom; y++) { s32 ytocentre = centrey - y; s32 sqytocentre = ytocentre * ytocentre; + if (PLAYERCOUNT() <= 2) { + sqytocentre += 1; + } else if (PLAYERCOUNT() > 2) { + if (g_Vars.currentplayernum == 1 || g_Vars.currentplayernum == 3) { + sqytocentre += 1; + } + } if (sqytocentre < sqradius) { s32 xoffset = (viewwidth / (f32) SCREEN_WIDTH_LO) * sqrtf(sqradius - sqytocentre); diff --git a/src/game/propobj.c b/src/game/propobj.c index 01687817e..9c6c8d864 100644 --- a/src/game/propobj.c +++ b/src/game/propobj.c @@ -1616,9 +1616,9 @@ void propCalculateShadeColour(struct prop *prop, u8 *nextcol, u16 floorcol) { s32 shade = func0f068fc8(prop, 0); - // fix props flickering in split screen when one of the players has night vision on + // fix props flickering in split screen when one of the players has night vision or IR Goggles on if (prop->type != PROPTYPE_PLAYER || g_Vars.currentplayer->prop != prop) { - if (USINGDEVICE(DEVICE_NIGHTVISION)) { + if (USINGDEVICE(DEVICE_NIGHTVISION) || USINGDEVICE(DEVICE_IRSCANNER)) { if (prop->rooms[0] >= 0) { shade = g_Rooms[prop->rooms[0]].br_settled_regional; } From 4f55a41d99660f6cec2da883515f9cc26d335a46 Mon Sep 17 00:00:00 2001 From: Catherine Reprobate Date: Fri, 21 Mar 2025 10:22:09 -0700 Subject: [PATCH 05/14] add NVGs and IRGs to CS - fixes n64-bug: NVGs and IR goggles should not be dual-wieldable --- src/game/invitems.c | 4 ++-- src/game/mplayer/mplayer.c | 28 +++++++++++++++------------- src/include/constants.h | 2 +- 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/src/game/invitems.c b/src/game/invitems.c index 89c7b0ed4..7597195bf 100644 --- a/src/game/invitems.c +++ b/src/game/invitems.c @@ -5118,7 +5118,7 @@ struct weapon invitem_nightvision = { L_GUN_059, // name L_GUN_000, // manufacturer L_GUN_191, // description - WEAPONFLAG_ONEHANDED | WEAPONFLAG_AICANUSE | WEAPONFLAG_00000080 | WEAPONFLAG_DUALWIELD | WEAPONFLAG_UNDROPPABLE, + WEAPONFLAG_ONEHANDED | WEAPONFLAG_AICANUSE | WEAPONFLAG_00000080 | WEAPONFLAG_UNDROPPABLE, }; struct weaponfunc invfunc_horizonscanner_primary = { @@ -5344,7 +5344,7 @@ struct weapon invitem_irscanner = { L_GUN_069, // name L_GUN_000, // manufacturer L_GUN_194, // description - WEAPONFLAG_ONEHANDED | WEAPONFLAG_AICANUSE | WEAPONFLAG_00000040 | WEAPONFLAG_DUALWIELD | WEAPONFLAG_UNDROPPABLE, + WEAPONFLAG_ONEHANDED | WEAPONFLAG_AICANUSE | WEAPONFLAG_00000040 | WEAPONFLAG_UNDROPPABLE, }; struct weaponfunc invfunc_disguise_primary = { diff --git a/src/game/mplayer/mplayer.c b/src/game/mplayer/mplayer.c index b329f51db..9d9c73b53 100644 --- a/src/game/mplayer/mplayer.c +++ b/src/game/mplayer/mplayer.c @@ -100,23 +100,25 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = { #ifndef PLATFORM_N64 // fix X-Ray Scanner model /*0x22*/ { WEAPON_XRAYSCANNER, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_XRAYSCANNER, MODEL_XRAYSPECS, 256 }, + /*0x23*/ { WEAPON_NIGHTVISION, 0, 0, 0, 0, 1, 0, MODEL_CHRNIGHTSIGHT, 256 }, + /*0x24*/ { WEAPON_IRSCANNER, 0, 0, 0, 0, 1, 0, MODEL_MISC_IRSPECS, 256 }, #else /*0x22*/ { WEAPON_XRAYSCANNER, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_XRAYSCANNER, MODEL_CHRNIGHTSIGHT, 256 }, #endif - /*0x23*/ { WEAPON_CLOAKINGDEVICE, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_CLOAKINGDEVICE, MODEL_CHRCLOAKER, 256 }, - /*0x24*/ { WEAPON_COMBATBOOST, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_COMBATBOOST, MODEL_CHRSPEEDPILL, 256 }, + /*0x25*/ { WEAPON_CLOAKINGDEVICE, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_CLOAKINGDEVICE, MODEL_CHRCLOAKER, 256 }, + /*0x26*/ { WEAPON_COMBATBOOST, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_COMBATBOOST, MODEL_CHRSPEEDPILL, 256 }, #ifndef PLATFORM_N64 - /*0x25*/ { WEAPON_PP9I, AMMOTYPE_PISTOL, 80, 0, 0, 1, 0, MODEL_CHRWPPK, 256 }, - /*0x26*/ { WEAPON_CC13, AMMOTYPE_PISTOL, 80, 0, 0, 1, 0, MODEL_CHRTT33, 256 }, - /*0x27*/ { WEAPON_KL01313, AMMOTYPE_SMG, 100, 0, 0, 1, 0, MODEL_CHRSKORPION, 256 }, - /*0x28*/ { WEAPON_KF7SPECIAL, AMMOTYPE_RIFLE, 100, 0, 0, 1, 0, MODEL_CHRKALASH, 256 }, - /*0x29*/ { WEAPON_ZZT, AMMOTYPE_SMG, 100, 0, 0, 1, 0, MODEL_CHRUZI, 256 }, - /*0x2a*/ { WEAPON_DMC, AMMOTYPE_SMG, 100, 0, 0, 1, 0, MODEL_CHRMP5K, 256 }, - /*0x2b*/ { WEAPON_AR53, AMMOTYPE_RIFLE, 150, 0, 0, 1, 0, MODEL_CHRM16, 256 }, - /*0x2c*/ { WEAPON_RCP45, AMMOTYPE_SMG, 150, 0, 0, 1, 0, MODEL_CHRFNP90, 256 }, + /*0x27*/ { WEAPON_PP9I, AMMOTYPE_PISTOL, 80, 0, 0, 1, 0, MODEL_CHRWPPK, 256 }, + /*0x28*/ { WEAPON_CC13, AMMOTYPE_PISTOL, 80, 0, 0, 1, 0, MODEL_CHRTT33, 256 }, + /*0x29*/ { WEAPON_KL01313, AMMOTYPE_SMG, 100, 0, 0, 1, 0, MODEL_CHRSKORPION, 256 }, + /*0x2a*/ { WEAPON_KF7SPECIAL, AMMOTYPE_RIFLE, 100, 0, 0, 1, 0, MODEL_CHRKALASH, 256 }, + /*0x2b*/ { WEAPON_ZZT, AMMOTYPE_SMG, 100, 0, 0, 1, 0, MODEL_CHRUZI, 256 }, + /*0x2c*/ { WEAPON_DMC, AMMOTYPE_SMG, 100, 0, 0, 1, 0, MODEL_CHRMP5K, 256 }, + /*0x2d*/ { WEAPON_AR53, AMMOTYPE_RIFLE, 150, 0, 0, 1, 0, MODEL_CHRM16, 256 }, + /*0x2e*/ { WEAPON_RCP45, AMMOTYPE_SMG, 150, 0, 0, 1, 0, MODEL_CHRFNP90, 256 }, #endif - /*0x2d*/ { WEAPON_MPSHIELD, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_SHIELD, MODEL_CHRSHIELD, 256 }, - /*0x2e*/ { WEAPON_DISABLED }, // 0x25 on N64 + /*0x2f*/ { WEAPON_MPSHIELD, 0, 0, 0, 0, 1, MPFEATURE_WEAPON_SHIELD, MODEL_CHRSHIELD, 256 }, + /*0x30*/ { WEAPON_DISABLED }, // 0x25 on N64 }; #ifndef PLATFORM_N64 @@ -138,7 +140,7 @@ struct mpweapon g_MpWeapons[NUM_MPWEAPONS] = { .usereloads = false, \ } -struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS] = { +struct extplayerconfig g_PlayerExtCfg[MAX_PLAYERS] = { PLAYER_EXT_CFG_DEFAULT, PLAYER_EXT_CFG_DEFAULT, PLAYER_EXT_CFG_DEFAULT, diff --git a/src/include/constants.h b/src/include/constants.h index 110e88f5b..32452ddab 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -3016,7 +3016,7 @@ #define MPWEAPON_RCP45 0x2c #define MPWEAPON_SHIELD 0x2d #define MPWEAPON_DISABLED 0x2e -#define NUM_MPWEAPONS 0x2f +#define NUM_MPWEAPONS 0x31 #endif #define MUSICEVENTTYPE_PLAY 1 From a26260e9328d438b80f36f417af0050196015948 Mon Sep 17 00:00:00 2001 From: AL2009man <67606569+AL2009man@users.noreply.github.com> Date: Thu, 27 Mar 2025 01:47:49 -0400 Subject: [PATCH 06/14] added SDL Hints field For some reason: this sourceport isn't using SDL Hints. this is very crucial inorder to implement features sets like Gyro Aiming. Thus: most of the important hints will be forcefully enabled while improving Contorller compatibility when using RawInput --- port/src/input.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/port/src/input.c b/port/src/input.c index cfee620a5..6c00f829c 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -678,6 +678,19 @@ s32 inputInit(void) SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC); } + // Set SDL hints before loading controller mappings + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); // This hint will enable PlayStation's more advanced feature sets when using Bluetooth connecivity, this includes Motion Sensors. + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); // same case as PS4_Rumble hint. + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, "1"); + // try to load controller db from an external file in the save folder if (fsFileSize("$S/" CONTROLLERDB_FNAME)) { const char *dbpath = fsFullPath("$S/" CONTROLLERDB_FNAME); From 1a5e42e55f3fda6e7ca3e543ce9cf71a06eadea6 Mon Sep 17 00:00:00 2001 From: AL2009man <67606569+AL2009man@users.noreply.github.com> Date: Thu, 27 Mar 2025 01:49:28 -0400 Subject: [PATCH 07/14] changed note --- port/src/input.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/port/src/input.c b/port/src/input.c index 6c00f829c..ed953dc28 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -683,7 +683,7 @@ s32 inputInit(void) SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); // This hint will enable PlayStation's more advanced feature sets when using Bluetooth connecivity, this includes Motion Sensors. + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); // Enables Rumble and Motion Sensor functionality when under Bluetooth connectivity. SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); // same case as PS4_Rumble hint. SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); From c44704e2af1b0af6fa3ba9094ef5a945d9763c82 Mon Sep 17 00:00:00 2001 From: AL2009man <67606569+AL2009man@users.noreply.github.com> Date: Thu, 27 Mar 2025 01:55:25 -0400 Subject: [PATCH 08/14] added SDL Hint for Wii Controllers --- port/src/input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/port/src/input.c b/port/src/input.c index ed953dc28..7475c2b2b 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -688,6 +688,7 @@ s32 inputInit(void) SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, "1"); From dace9fd634ff2f2c117e3eb18b04c3223292a42a Mon Sep 17 00:00:00 2001 From: peerchemist Date: Sat, 29 Mar 2025 11:02:55 +0100 Subject: [PATCH 09/14] x86_64 --- dist/linux/io.github.fgsfdsfgs.perfect_dark.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh b/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh index 719a7fbee..28ff8213b 100644 --- a/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh +++ b/dist/linux/io.github.fgsfdsfgs.perfect_dark.sh @@ -16,7 +16,7 @@ if [ -f ${XDG_DATA_HOME}/roms/pd.ntsc-final.z64 ] | \ [ -f ${XDG_DATA_HOME}/roms/pd.ntsc-1.0.z64 ]; then executable="pd.x86_64" elif [ -f ${XDG_DATA_HOME}/roms/pd.jpn-final.z64 ]; then - executable="pd.jpn.x" + executable="pd.jpn.x86_64" elif [ -f ${XDG_DATA_HOME}/roms/pd.pal-final.z64 ]; then executable="pd.pal.x86_64" fi From 9a853077a0b87bd9c057b5905edc755b889a49e0 Mon Sep 17 00:00:00 2001 From: peerchemist Date: Sat, 29 Mar 2025 11:15:57 +0100 Subject: [PATCH 10/14] correct Exec name --- dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop b/dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop index 663933b7e..94c45ca9c 100755 --- a/dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop +++ b/dist/linux/io.github.fgsfdsfgs.perfect_dark.desktop @@ -1,7 +1,7 @@ [Desktop Entry] Name=Perfect Dark Comment=Modern source port of Perfect Dark -Exec=pd +Exec=io.github.fgsfdsfgs.perfect_dark.sh Icon=io.github.fgsfdsfgs.perfect_dark Terminal=false Type=Application From be4d8330bd32a490ad58b9e90c85a67a280fb28a Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 29 Mar 2025 12:29:14 +0100 Subject: [PATCH 11/14] port: add settings for HIDAPI and raw input --- port/src/input.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index 7475c2b2b..ce6f4b5b9 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -74,6 +74,9 @@ static s32 connectedMask = 0; static s32 numJoysticks = 0; +static s32 useHIDAPI = 1; +static s32 useRawInput = 1; + static s32 mouseEnabled = 1; static s32 mouseX, mouseY; static s32 mouseDX, mouseDY; @@ -674,24 +677,29 @@ static inline void inputLoadBinds(void) s32 inputInit(void) { + // Set SDL hints before initializing the controller subsystem. + if (useHIDAPI) { + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); + // the two hints below enable Rumble and Motion Sensor for PS4/5 pads connected via bluetooth + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); + } + if (useRawInput) { + SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, "1"); + } + if (!SDL_WasInit(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC)) { SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_HAPTIC); } - // Set SDL hints before loading controller mappings - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); // Enables Rumble and Motion Sensor functionality when under Bluetooth connectivity. - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); // same case as PS4_Rumble hint. - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT_CORRELATE_XINPUT, "1"); - // try to load controller db from an external file in the save folder if (fsFileSize("$S/" CONTROLLERDB_FNAME)) { const char *dbpath = fsFullPath("$S/" CONTROLLERDB_FNAME); @@ -1496,6 +1504,8 @@ PD_CONSTRUCTOR static void inputConfigInit(void) configRegisterFloat("Input.MouseSpeedY", &mouseSensY, -10.f, 10.f); configRegisterInt("Input.FakeGamepads", &fakeControllers, 0, 4); configRegisterInt("Input.FirstGamepadNum", &firstController, 0, 3); + configRegisterInt("Input.UseHIDAPI", &useHIDAPI, 0, 1); + configRegisterInt("Input.UseRawInput", &useRawInput, 0, 1); char secname[] = "Input.Player1.Binds"; char keyname[256] = { 0 }; From e32d719c16cbd487d460aab0944b1548c8ee3ed6 Mon Sep 17 00:00:00 2001 From: fgsfds Date: Sat, 29 Mar 2025 12:48:38 +0100 Subject: [PATCH 12/14] port: only enable SDL hints on SDL versions that support them --- port/src/input.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/port/src/input.c b/port/src/input.c index ce6f4b5b9..2bacbd646 100644 --- a/port/src/input.c +++ b/port/src/input.c @@ -679,17 +679,30 @@ s32 inputInit(void) { // Set SDL hints before initializing the controller subsystem. if (useHIDAPI) { - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); +#if SDL_VERSION_ATLEAST(2, 0, 12) + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); +#endif +#if SDL_VERSION_ATLEAST(2, 0, 14) SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5, "1"); +#endif +#if SDL_VERSION_ATLEAST(2, 0, 22) + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI, "1"); + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_SWITCH, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_JOY_CONS, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_GAMECUBE, "1"); - SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); // the two hints below enable Rumble and Motion Sensor for PS4/5 pads connected via bluetooth SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS4_RUMBLE, "1"); SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS5_RUMBLE, "1"); +#endif +#if SDL_VERSION_ATLEAST(2, 23, 2) + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_COMBINE_JOY_CONS, "1"); +#endif +#if SDL_VERSION_ATLEAST(2, 25, 1) + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_PS3, "1"); +#endif +#if SDL_VERSION_ATLEAST(2, 26, 0) + SDL_SetHint(SDL_HINT_JOYSTICK_HIDAPI_WII, "1"); +#endif } if (useRawInput) { SDL_SetHint(SDL_HINT_JOYSTICK_RAWINPUT, "1"); From edd58c8925946b28e3b771b2b5eb8e92e9197197 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Sun, 30 Mar 2025 22:31:51 +0900 Subject: [PATCH 13/14] Fix offset in weapon set by adding IR Scanner and Night Vision --- port/src/preprocess/misc.c | 12 ++++++++++-- src/include/constants.h | 28 +++++++++++++++------------- 2 files changed, 25 insertions(+), 15 deletions(-) diff --git a/port/src/preprocess/misc.c b/port/src/preprocess/misc.c index c3361e90b..23e345266 100644 --- a/port/src/preprocess/misc.c +++ b/port/src/preprocess/misc.c @@ -57,18 +57,26 @@ u8 *preprocessMpConfigs(u8* data, u32 size, u32* outSize) for (s32 j = 0; j < ARRAYCOUNT(cfg->setup.weapons); ++j) { #if VERSION == VERSION_JPN_FINAL /* TODO: replace with runtime check */ if (cfg->setup.weapons[j] >= 0x24) { - // weapons after and including the shield need to be shifted + // weapons after and including the shield need to be shifted (for classic weapons) cfg->setup.weapons[j] += (MPWEAPON_SHIELD - MPWEAPON_PP9I); } + if (cfg->setup.weapons[j] >= 0x22) { + // weapons after and including the cloaking device need to be shifted (for IR Scanner and Night Vision) + cfg->setup.weapons[j] += (MPWEAPON_CLOAKINGDEVICE - MPWEAPON_NIGHTVISION); + } if (cfg->setup.weapons[j] >= 0x19) { // weapons after the combat knife also need to be shifted up in JPN cfg->setup.weapons[j]++; } #else - // in other versions we only care about the shield and above if (cfg->setup.weapons[j] >= 0x25) { + // weapons after and including the shield need to be shifted (for classic weapons) cfg->setup.weapons[j] += (MPWEAPON_SHIELD - MPWEAPON_PP9I); } + if (cfg->setup.weapons[j] >= 0x23) { + // weapons after and including the cloaking device need to be shifted (for IR Scanner and Night Vision) + cfg->setup.weapons[j] += (MPWEAPON_CLOAKINGDEVICE - MPWEAPON_NIGHTVISION); + } #endif } } diff --git a/src/include/constants.h b/src/include/constants.h index 32452ddab..2ff7b0658 100644 --- a/src/include/constants.h +++ b/src/include/constants.h @@ -2993,7 +2993,7 @@ #define MPWEAPON_SHIELD (VERSION == VERSION_JPN_FINAL ? 0x24 : 0x25) #define MPWEAPON_DISABLED (VERSION == VERSION_JPN_FINAL ? 0x25 : 0x26) #define NUM_MPWEAPONS (VERSION == VERSION_JPN_FINAL ? 0x26 : 0x27) -#else // add all classic weapons to multiplayer and allow combat knife in JPN +#else // add all classic weapons to multiplayer and allow combat knife in JPN and add IR Scanner and Night Vision #define MPWEAPON_COMBATKNIFE 0x19 #define MPWEAPON_CROSSBOW 0x1a #define MPWEAPON_TRANQUILIZER 0x1b @@ -3004,18 +3004,20 @@ #define MPWEAPON_REMOTEMINE 0x20 #define MPWEAPON_LASER 0x21 #define MPWEAPON_XRAYSCANNER 0x22 -#define MPWEAPON_CLOAKINGDEVICE 0x23 -#define MPWEAPON_COMBATBOOST 0x24 -#define MPWEAPON_PP9I 0x25 -#define MPWEAPON_CC13 0x26 -#define MPWEAPON_KL01313 0x27 -#define MPWEAPON_KF7SPECIAL 0x28 -#define MPWEAPON_ZZT 0x29 -#define MPWEAPON_DMC 0x2a -#define MPWEAPON_AR53 0x2b -#define MPWEAPON_RCP45 0x2c -#define MPWEAPON_SHIELD 0x2d -#define MPWEAPON_DISABLED 0x2e +#define MPWEAPON_NIGHTVISION 0x23 +#define MPWEAPON_IRSCANNER 0x24 +#define MPWEAPON_CLOAKINGDEVICE 0x25 +#define MPWEAPON_COMBATBOOST 0x26 +#define MPWEAPON_PP9I 0x27 +#define MPWEAPON_CC13 0x28 +#define MPWEAPON_KL01313 0x29 +#define MPWEAPON_KF7SPECIAL 0x2a +#define MPWEAPON_ZZT 0x2b +#define MPWEAPON_DMC 0x2c +#define MPWEAPON_AR53 0x2d +#define MPWEAPON_RCP45 0x2e +#define MPWEAPON_SHIELD 0x2f +#define MPWEAPON_DISABLED 0x30 #define NUM_MPWEAPONS 0x31 #endif From 33c5194a1bf4be610155d56f5d7b30b8f2d7f560 Mon Sep 17 00:00:00 2001 From: Jonaeru Date: Sun, 30 Mar 2025 22:48:14 +0900 Subject: [PATCH 14/14] Fix "Select Dark" in Select Random Weapons feature to not select IR Scanner and Night Vision --- src/game/mplayer/setup.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/game/mplayer/setup.c b/src/game/mplayer/setup.c index cae26d3c7..962d05392 100644 --- a/src/game/mplayer/setup.c +++ b/src/game/mplayer/setup.c @@ -1214,7 +1214,10 @@ MenuItemHandlerResult mpSelectRandomWeaponListHandler(s32 operation, struct menu case 0: // Select Dark for (i = 0; i < ARRAYCOUNT(g_MpWeapons); i++) { - if ((i >= MPWEAPON_NONE && i <= MPWEAPON_COMBATBOOST) || i >= MPWEAPON_SHIELD) { + if ((i >= MPWEAPON_NONE && i <= MPWEAPON_XRAYSCANNER) + || i == MPWEAPON_CLOAKINGDEVICE + || i == MPWEAPON_COMBATBOOST + || i >= MPWEAPON_SHIELD) { g_MpWeaponSetRandomFilters[i] = 1; } else { g_MpWeaponSetRandomFilters[i] = 0;