@@ -172,18 +172,14 @@ s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
172172 } else {
173173 if (fo_curve == 1 ) {
174174 return volume;
175- } else if (fo_curve == 9 ) {
175+ } else if (fo_curve == 9 || fo_curve == 11 ) {
176176 xdiff = gEarTrans [1 ].x - pos->x ;
177177 ydiff = gEarTrans [1 ].y - pos->y ;
178178 zdiff = gEarTrans [1 ].z - pos->z ;
179179 } else if (fo_curve == 10 ) {
180180 xdiff = 0 ;
181181 ydiff = gEarTrans [0 ].y - pos->y ;
182182 zdiff = 0 ;
183- } else if (fo_curve == 11 ) {
184- xdiff = gEarTrans [1 ].x - pos->x ;
185- ydiff = gEarTrans [1 ].y - pos->y ;
186- zdiff = gEarTrans [1 ].z - pos->z ;
187183 } else {
188184 xdiff = gEarTrans [0 ].x - pos->x ;
189185 ydiff = gEarTrans [0 ].y - pos->y ;
@@ -213,37 +209,35 @@ s32 CalculateFalloffVolume(Vec3w* pos, s32 volume, s32 fo_curve, s32 fo_min, s32
213209 ydiff >>= 1 ;
214210 zdiff >>= 1 ;
215211 }
216- s32 dist_squared = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
212+ u32 dist_squared = xdiff * xdiff + ydiff * ydiff + zdiff * zdiff;
217213 s32 dist_steps = 0 ;
218214 if (dist_squared != 0 ) {
219215 while ((dist_squared & 0xc0000000 ) == 0 ) {
220- dist_steps = dist_steps + 1 ;
216+ ++dist_steps ;
221217 dist_squared <<= 2 ;
222218 }
223219 dist_steps = sqrt_table[dist_squared >> 24 ] >> (dist_steps & 0x1f );
224220 }
225221 new_vol = volume;
226222 if (min < dist_steps) {
227- s32 voldiff = dist_steps - min;
223+ u32 voldiff = dist_steps - min;
228224 if (dist_steps < max) {
229225 dist_steps = max - min;
230- while (0xffff < voldiff ) {
226+ while (voldiff > 0xffff ) {
231227 dist_steps >>= 1 ;
232228 voldiff >>= 1 ;
233229 }
234230 voldiff = (voldiff << 0x10 ) / dist_steps;
235231 if (voldiff != 0x10000 ) {
236- new_vol = voldiff * voldiff >> 0x10 ;
237- new_vol = gCurves [fo_curve].unk4 * 0x10000 + gCurves [fo_curve].unk3 * voldiff +
238- gCurves [fo_curve].unk2 * new_vol +
239- gCurves [fo_curve].unk1 * ((new_vol * voldiff) >> 0x10 ) >>
232+ new_vol = ( voldiff * voldiff) >> 0x10 ;
233+ new_vol = ( gCurves [fo_curve].unk4 * 0x10000 + gCurves [fo_curve].unk3 * voldiff +
234+ gCurves [fo_curve].unk2 * new_vol +
235+ gCurves [fo_curve].unk1 * ((new_vol * voldiff) >> 0x10 ) ) >>
240236 0xc ;
241237 if (new_vol < 0 ) {
242238 new_vol = 0 ;
243- } else {
244- if (0x10000 < new_vol) {
245- new_vol = 0x10000 ;
246- }
239+ } else if (0x10000 < new_vol) {
240+ new_vol = 0x10000 ;
247241 }
248242 new_vol = (new_vol * volume) >> 0x10 ;
249243 }
0 commit comments