From 01e88fbd85516630616917d4dcfe22e7572ac359 Mon Sep 17 00:00:00 2001 From: PJB3005 Date: Tue, 31 Mar 2026 01:12:21 +0200 Subject: [PATCH] Fix JUTGamePad stopPatternedRumbleAtThePeriod division by zero Happens for me when loading a save in Death Mountain Twilight. Confirmed in Dolphin with the same save file. PowerPC does not raise an exception on division by zero, so I assume this is an original game "bug" --- libs/JSystem/src/JUtility/JUTGamePad.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libs/JSystem/src/JUtility/JUTGamePad.cpp b/libs/JSystem/src/JUtility/JUTGamePad.cpp index 31b8d59f1a..091cc382d1 100644 --- a/libs/JSystem/src/JUtility/JUTGamePad.cpp +++ b/libs/JSystem/src/JUtility/JUTGamePad.cpp @@ -535,6 +535,14 @@ void JUTGamePad::CRumble::stopPatternedRumble(s16 port) { } void JUTGamePad::CRumble::stopPatternedRumbleAtThePeriod() { +#if TARGET_PC + if (mFrameCount == 0) { + // Does not trap on hardware + // PowerPC spec says result is "undefined". Let's just write zero. + mLength = 0; + return; + } +#endif u32 r31 = mFrame % mFrameCount; mLength = (mFrame + mFrameCount - 1) % mFrameCount; }