From 459e46cfddb35444dc91758001eb587a6acc0088 Mon Sep 17 00:00:00 2001 From: robojumper Date: Thu, 17 Jul 2025 22:46:51 +0200 Subject: [PATCH] weird bugged float harp mgr functions --- config/SOUE01/symbols.txt | 4 ++-- include/d/snd/d_snd_harp_song_mgr.h | 3 ++- src/d/snd/d_snd_harp_song_mgr.cpp | 36 +++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+), 3 deletions(-) diff --git a/config/SOUE01/symbols.txt b/config/SOUE01/symbols.txt index 5ec9f24f..3ddf7de7 100644 --- a/config/SOUE01/symbols.txt +++ b/config/SOUE01/symbols.txt @@ -20913,8 +20913,8 @@ fn_803814B0 = .text:0x803814B0; // type:function size:0x8C fn_80381540 = .text:0x80381540; // type:function size:0x1C fn_80381560 = .text:0x80381560; // type:function size:0x14 fn_80381580 = .text:0x80381580; // type:function size:0x78 -fn_80381600 = .text:0x80381600; // type:function size:0xA0 -fn_803816A0 = .text:0x803816A0; // type:function size:0xC0 +shiftFloat1__17dSndHarpSongMgr_cFf = .text:0x80381600; // type:function size:0xA0 +shiftFloat2__17dSndHarpSongMgr_cFf = .text:0x803816A0; // type:function size:0xC0 resetFloatArr1__17dSndHarpSongMgr_cFv = .text:0x80381760; // type:function size:0x60 resetFloatArr2__17dSndHarpSongMgr_cFv = .text:0x803817C0; // type:function size:0x80 fn_80381840 = .text:0x80381840; // type:function size:0x28 diff --git a/include/d/snd/d_snd_harp_song_mgr.h b/include/d/snd/d_snd_harp_song_mgr.h index 2ffca321..67868858 100644 --- a/include/d/snd/d_snd_harp_song_mgr.h +++ b/include/d/snd/d_snd_harp_song_mgr.h @@ -24,7 +24,8 @@ public: } private: - + void shiftFloat1(f32 val); + void shiftFloat2(f32 val); void resetFloatArr1(); void resetFloatArr2(); diff --git a/src/d/snd/d_snd_harp_song_mgr.cpp b/src/d/snd/d_snd_harp_song_mgr.cpp index 54598591..6861b67e 100644 --- a/src/d/snd/d_snd_harp_song_mgr.cpp +++ b/src/d/snd/d_snd_harp_song_mgr.cpp @@ -73,6 +73,42 @@ void dSndHarpSongMgr_c::setupState0() { mDataLoaded = true; } +void dSndHarpSongMgr_c::shiftFloat1(f32 val) { + if (val < 0.0f) { + val = 0.0f; + } + if (val > 150.0f) { + val = 150.0f; + } + + // @bug (?) this loop ends up copying the value of field_0x07C[0] + // to all array elements when surely the intention was to + // move each of them back by one position. TODO: are array entries + // other than [0] read anywhere? + for (int i = 1; i < 300; i++) { + field_0x07C[i] = field_0x07C[i - 1]; + } + field_0x07C[0] = val; +} + +void dSndHarpSongMgr_c::shiftFloat2(f32 val) { + if (val < 0.0f) { + val = 0.0f; + } + if (val > 240.0f) { + val = 240.0f; + } + + // @bug (?) this loop ends up copying the value of field_0x52C[0] + // to all array elements when surely the intention was to + // move each of them back by one position. TODO: are array entries + // other than [0] read anywhere? + for (int i = 1; i < 30; i++) { + field_0x52C[i] = field_0x52C[i - 1]; + } + field_0x52C[0] = val; +} + void dSndHarpSongMgr_c::resetFloatArr1() { for (int i = 0; i < 300; i++) { field_0x07C[i] = 0.0f;