-
-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FreeBoy - Division by zero #5734
Comments
It's possible to turn the floating point exceptions off temporarily.
I'm not sure about this case though but I'm sure there are a lot of places where things like division with zero doesn't matter. For instance when you already test for infinites and discard them. |
|
Here's where the values are used in the game-music-emu code: https://bitbucket.org/mpyne/game-music-emu/src/013d4676c689dc49f363f99dcfb8b88f22278236/gme/Gb_Oscs.cpp#lines-194 static unsigned char const table [8] = { 8, 16, 32, 48, 64, 80, 96, 112 };
int period = table [regs [3] & 7] << (regs [3] >> 4);
|
@DomClark Nice catch! I think we can even more optimize calcuating |
Also, |
Added comments and used more descriptive variable names for noise channel initialization block. Also indented the nested for loop to improve code clarity. The reasons for doing this can be found in this answer: https://softwareengineering.stackexchange.com/a/362796
* Fixed issue #5734 (FreeBoy Division by zero). Added comments and used more descriptive variable names for noise channel initialization block. Also indented the nested for loop to improve code clarity. The reasons for doing this can be found in this answer: https://softwareengineering.stackexchange.com/a/362796 * Better initial div_ratio guess Allows us to skip r = 0 and a conditional in the loop below. --------- Co-authored-by: Spekular <[email protected]>
Division by zero. Debugging with the fpe flag
-DCMAKE_BUILD_TYPE=Debug -DWANT_DEBUG_FPE=True
gives a division by zero error in FreeBoy.This is on stable-1.2 and master as of 7808e0b. It's probably introduced with the original FreeBoy(papu) commit.
Logs
Click to expand
lmms/plugins/FreeBoy/FreeBoy.cpp
Lines 370 to 377 in 7808e0b
We set 'r' to 0 in the second for loop and this gives
f = 524288.0 / 0
on line 374.Something like this for line 374 could work:
f = 524288.0 / std::max( r * pow( 2.0, s + 1.0 ), 0.000001 );
It plays back similar on this demo project.
freeboy.mmp.zip
The text was updated successfully, but these errors were encountered: