Fix float value used to calculate clock angle to prevent overshooting every hour

This commit is contained in:
Mr-Wiseguy 2025-04-28 03:11:15 -04:00
parent d766cf328f
commit 00d0d06fa7

View file

@ -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);