diff --git a/patches/required_patches.c b/patches/required_patches.c index 8fbb140..7c1b15d 100644 --- a/patches/required_patches.c +++ b/patches/required_patches.c @@ -2,6 +2,7 @@ #include "misc_funcs.h" #include "transform_ids.h" #include "loadfragment.h" +#include "libc/math.h" void Main_ClearMemory(void* begin, void* end); void Main_InitMemory(void); @@ -40,6 +41,13 @@ RECOMP_PATCH void Main_Init(void) { gDmaMgrDmaBuffSize = prevSize; Main_ClearMemory(SEGMENT_BSS_START(code), SEGMENT_BSS_END(code)); + + // @recomp Patch a float that's used to render the clock into the correct value. + // This is done this way instead of patching the function to avoid conflicts with mods that need to patch the function. + // The original code is `Matrix_RotateZF(-(timeInSeconds * 0.0175f) / 10.0f, MTXMODE_APPLY);`, where 0.0175f is being used + // to convert degrees to radians. However, the correct value is PI/180 which is approximately 0.0174533f, and the difference is enough + // to cause the clock to overshoot when reaching an hour mark. + *(f32*)0x801DDBBC = ((f32)M_PI) / 180.0f; } void Overlay_Relocate(void* allocatedRamAddr, OverlayRelocationSection* ovlRelocs, uintptr_t vramStart);