Viewing Issue Advanced Details
ID Category [?] Severity [?] Reproducibility Date Submitted Last Update
08793 Core Minor Always Nov 22, 2023, 21:17 Mar 11, 2024, 15:46
Tester Wismi View Status Public Platform MAME (Official Binary)
Assigned To Resolution Open OS Linux (64-bit)
Status [?] Acknowledged Driver
Version 0.260 Fixed in Version Build 64-bit
Fixed in Git Commit Github Pull Request #
Summary 08793: Mac II FPU Errors: Mac 68881 Emulation returning bad results.
Description On a Mac (II) emulation, certain games such as Maelstrom (most obvious), Spectre VR, and the Desktop Accessory Jigsaw puzzle the FPU is generating a bad result when the Apple SANE library is asked to perform a sine function.
Steps To Reproduce For Maelstrom, shooting and moving (a vector) is in the wrong direction from where you are pointing. From what I can find, newer versions of this application build a 32 item array (by degrees or radians or something) ahead of time by using the Apple Package Manager's SANE library. The SANE library without a FPU would calculate everything in pure 68k without any FPU mnemonics. If the FPU is available, as it seems to always be in Mame, then SANE will use if for what it considers compatible (the real FPU isn't entirely IEEE-754 compatible). The sin function in SANE does use the FPU when present, but it does not call the FPU's FSIN function or other "transcendental" functions. So, some other FPU mnemonic is returning an incorrect result. I chose to test on maclc /maciivx because they didn't come with a FPU out of the box, but Mame provides it anyway.

For Spectre VR, the symptom is the level change text as you enter a new level. It's usually smooth, but in Mame does not work properly - the points do not correctly draw the characters of the intended text. I compared to real macs and Basilisk II and it is readable. The animation would have to use sin/cos to function.

For the Jigsaw Puzzle Desk Accessory, the Puzzle pieces are jagged rather than looking like puzzle pieces with rounded cuts. This is the easiest to reproduce I think, and I've included a snapshot from 256b_64

There are probably games that rely heavily on FPU acceleration, but these three programs do not and seem to all use the SANE package from ROM.

mame maciivx -hard "..\mac755.chd" -ramsize 64M -nojoy -window

I've compiled, and tried to debug the Softfloat and 68881 implementation in the Mac driver. I couldn't get it to work with GDB so I could step through the implementation of the FPU.
Additional Information Is not specific to host OS. Is not specific to any version of Mame that included the Mac II driver.
Github Commit
Flags
Regression Version
Affected Sets / Systems Mac II FPU Errors
Attached Files
png file icon Mac-BII-Mame.png (993,971 bytes) Nov 22, 2023, 21:17 Uploaded by Wismi
Jigsaw Puzzle Mame vs. Basilisk II
png file icon Maelstrom SANE Math Issue with 68881 Mame Emulation.png (11,541 bytes) Nov 24, 2023, 16:37 Uploaded by Wismi
Maelstrom example of math issue
Wismi
png file icon Screenshot at 2023-11-27 17-56-45.png (266,308 bytes) Nov 27, 2023, 23:57 Uploaded by Wismi
Mame vs Basilisk II Sin (via SANE)
Wismi
Relationships
related to 05411Confirmed  maclc3: Jigsaw Puzzle is glitched out 
Notes
8
User avatar
No.21865
Wismi
Tester
Nov 28, 2023, 00:05
I'm updating with a simpler example, the Sine function via SANE on MacIIvx, On the right is Basilisk II with the correct result, on the left is MAME with the incorrect result. The program is Extended Calculator 2.01.

Was able to get this running on Linux under GDB. Found that this program internally used FREM, FMUL, FADD, FDIV to implement Sine (I didn't look for the exact trap, but probably was SANE)

I'm figuring the parameters passed into m68000_musashi_device::fpgen_rm_reg may narrow down the exact reproducible error or something with how the numbers are converted.

Does anyone know if there are any docs on how FPUs are implemented in MAME? Or a place where devs hang out that I can pick a brain or two?
User avatar
No.21909
Wismi
Tester
Jan 13, 2024, 18:35
Are there any recent builds of Mame that still run 32 bit? The 68k emulation is provided by Musashi, which in turn used Softfloat 2.b. 2.b is known to have 64 bit issues (I don't know the nature of them) which apparently were fixed in 2.c. 2.c (and softfloat3) had so many changes it appears that upgrading it in Mame isn't trivial. So I'd like to know if anyone has a recent version that runs in 32 bit mode?
User avatar
No.21911
Robbbert
Senior Tester
Jan 13, 2024, 20:46
There's unofficial current Windows 32-bit builds, but it looks like you're after a build for a mac.
User avatar
No.21912
AJR
Developer
Jan 15, 2024, 16:25
edited on: Jan 15, 2024, 16:29
The situation with softfloat is even worse than it appears, since MAME's softfloat2 includes a few unofficial extensions (from the Bochs x86 emulator) that can't be converted to softfloat3 because its license is also incompatible.
User avatar
No.21991
Wismi
Tester
Mar 2, 2024, 03:34
I wouldn't mind a windows 32 bit build of 256 or greater if anyone has a recommendation. It would tell me if it's the 64 bit issue reported by SoftFloat (Berkley I think) or something else.
User avatar
No.21994
Wismi
Tester
Mar 2, 2024, 23:22
I'm just curious, how can I just remove softfloat from the Mac driver. It is presented on all Mac II drivers, but not all of them came with a FPU. I'm wondering how to just disable it?
User avatar
No.21995
Robbbert
Senior Tester
Mar 3, 2024, 07:37
edited on: Mar 3, 2024, 07:38
I wouldn't mind a windows 32 bit build of 256 or greater if anyone has a recommendation.

https://retrodanuart.com/mamexp/

Even though the target machine is XP, I understand they will work on later OS's as well.
Hope this helps you.
User avatar
No.22001
Wismi
Tester
Mar 11, 2024, 15:46
I gave the 32 bit build of Mame a try. The problem remained. So this is beyond the 64 bit issue of SoftFloat 2.b. Maybe that explains the massive changes to 2.c.

The underlying project, Mushashi, probably would have the same issue if called in the same exact way.

There may be some benefit to FPU emulation for 68030 & 68040, but I believe it would be best if the FPU could be turned off, especially for the hardware that did not include a FPU.

Meanwhile, I am going to see how SANE determines there is an FPU and modify my local code to cause it to fail.