Skip to content
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

MDK2 fade bug #3

Closed
leilei- opened this issue May 17, 2021 · 3 comments
Closed

MDK2 fade bug #3

leilei- opened this issue May 17, 2021 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@leilei-
Copy link
Contributor

leilei- commented May 17, 2021

Describe the bug
The scene fading function in the game cannot fade in the scene from black, causing MDK2 to not render anything. This also affects results for the benchmark funcitonality.

To Reproduce
Multiple ways:

  • Start any level, it's black until you zoom-in (as Kurt) or access the main menu.
  • Save/load any game.
  • Start the benchmark.

Expected behavior
The scene fading in.

Screenshots

Emulator configuration

  • HOT-557
  • CPU: Pentium, K6/2, Winchip
  • Graphics/sound cards: 3dfx Voodoo3, S3 ViRGE, Mystique, etc
  • Installed OS: Windows 98SE

Host machine

  • OS: Windows 7
  • Emulator version: v17

Additional context
I believe it is a CPU bug, as the problem also occurs with SGI software OpenGL, Techland MSI, etc.

@sarah-walker-pcem sarah-walker-pcem added the bug Something isn't working label May 18, 2021
@sarah-walker-pcem sarah-walker-pcem self-assigned this May 31, 2021
@sarah-walker-pcem
Copy link
Owner

Initial investigation reveals curious behaviour - MDK2 isn't failing to fade in, it's failing to draw the scene at all.

@sarah-walker-pcem
Copy link
Owner

Quite a curious bug in the end. MDK2 is executing an FSCALE instruction with input parameters of 0.0 and 1536.0, this should perform 0.0 * (2 ^ 1536.0), which is obviously zero. 2 ^ 1536.0 is out of the range of any floating point format, and therefore resolves to infinity. On x87, 0.0 * infinity = NaN, which then propagates itself through numerous subsequent instructions. However this only seems to apply to explicit multiplies, this does not seem to occur to the multiply in FSCALE, and the end result should instead be 0.0. Adding special case code for FSCALE fixes MDK2.

@sarah-walker-pcem
Copy link
Owner

Fixed in commit 2e037b5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants