- --
Viewing Issue Advanced Details
ID | Category [?] | Severity [?] | Reproducibility | Date Submitted | Last Update |
---|---|---|---|---|---|
08793 | Core | Minor | Always | Nov 22, 2023, 21:17 | Jul 6, 2024, 02:50 |
Tester | Wismi | View Status | Public | Platform | MAME (Official Binary) |
Assigned To | R. Belmont | Resolution | Fixed | OS | Linux (64-bit) |
Status [?] | Resolved | Driver | |||
Version | 0.260 | Fixed in Version | 0.267 | Build | 64-bit |
Fixed in Git Commit | 6957c46 | 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
|
Mac-BII-Mame.png (993,971 bytes) Nov 22, 2023, 21:17 Uploaded by Wismi Jigsaw Puzzle Mame vs. Basilisk II
| ||||
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
| |||||
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)
| |||||
Relationships
Notes
15
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? |
---|---|
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? |
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. |
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. |
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. |
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? |
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. |
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. |
No.22108
R. Belmont Developer
May 20, 2024, 03:29
edited on: May 20, 2024, 11:41 |
Thanks, the Extended Calculator example is helpful. It indicates the problem isn't with the math, it's with the loading and storing of FP numbers to memory, I think. Here is the complete operations log. The "load source type 2"s are suspect, although some of them are clearly right. Load source type 2 = 1.000000 FMOVE: FPR0 = 1.000000 Load source type 2 = 1.570796 FMOVE: FPR1 = 1.570796 Load source from FPR 1 = 1.570796 FREM: 1.000000 REM 1.570796 = -0.570796 (FPR 0) Load source from FPR 0 = -0.570796 FMOVE: FPR3 = -0.570796 Load source from FPR 0 = -0.570796 FMUL: -0.570796 * -0.570796 = 0.325808 (FPR 0) Load source type 2 = -0.759041 FMOVE: FPR1 = -0.759041 Load source from FPR 0 = 0.325808 FMUL: -0.759041 * 0.325808 = -0.247302 (FPR 1) Load source type 2 = 158.464545 FADD: -0.247302 + 158.464545 = 158.217243 (FPR 1) Load source from FPR 0 = 0.325808 FMUL: 158.217243 * 0.325808 = 51.548514 (FPR 1) Load source type 2 = -11220.408046 FADD: 51.548514 + -11220.408046 = -11168.859532 (FPR 1) Load source from FPR 0 = 0.325808 FMUL: -11168.859532 * 0.325808 = -3638.908775 (FPR 1) Load source type 2 = 342239.961507 FADD: -3638.908775 + 342239.961507 = 338601.052731 (FPR 1) Load source from FPR 1 = 338601.052731 FMOVE: FPR2 = 338601.052731 Load source type 2 = 1.000000 FMOVE: FPR1 = 1.000000 Load source from FPR 0 = 0.325808 FMUL: 1.000000 * 0.325808 = 0.325808 (FPR 1) Load source type 2 = 273.693123 FADD: 0.325808 + 273.693123 = 274.018932 (FPR 1) Load source from FPR 0 = 0.325808 FMUL: 274.018932 * 0.325808 = 89.277683 (FPR 1) Load source type 2 = 35349.540177 FADD: 89.277683 + 35349.540177 = 35438.817860 (FPR 1) Load source from FPR 0 = 0.325808 FMUL: 35438.817860 * 0.325808 = 11546.266199 (FPR 1) Load source type 2 = 2053439.769040 FADD: 11546.266199 + 2053439.769040 = 2064986.035239 (FPR 1) Load source from FPR 1 = 2064986.035239 FDIV: 338601.052731 / 2064986.035239 = 0.163973 Load source from FPR 3 = -0.570796 FMUL: 0.325808 * -0.570796 = -0.185970 (FPR 0) Load source from FPR 0 = -0.185970 FMUL: 0.163973 * -0.185970 = -0.030494 (FPR 2) Load source from FPR 2 = -0.030494 FSUB: -0.570796 - -0.030494 = -0.540302 (FPR 3) |
No.22111
R. Belmont Developer
May 21, 2024, 14:09
edited on: May 21, 2024, 14:11 |
It's more esoteric than I thought, FREM and FMOD are intended to generate specific results in one field of the status register. Conveniently WinUAE commented in their code that not doing that "breaks free rotation in ClarisWorks", which I know is a Mac reference :-) I'm going to upgrade the FPU emulation to Softfloat 3E plus the Bochs extensions, which should solve this and many other problems (notably Wolfenstein 3D being all garbled, which is funny because the PC original is all integer but Burger Becky's Mac port heavily uses SANE and the FPU). I will also look into why systems that had the FPU optional will Sad Mac on startup when it's not present. |
No.22131
R. Belmont Developer
May 25, 2024, 17:25
|
Some work in progress news here: I have the 680x0 FPU converted to SoftFloat 3E and I've fixed the status register error with FREM and FMOD. Extended Calculator now computes sin(1) identically to Basilisk, and Wolfenstein 3D is now fully playable instead of showing a screen full of pseudo-random garbage. So SANE is now computing sine correctly when FPU-accelerated. Weirdly the odd one out is Jigsaw Puzzle, which is still wrong, but differently wrong. Go figure. |
No.22133
R. Belmont Developer
May 27, 2024, 02:26
|
Making exception flag generation work and fixing some major issues with how FMOVEM was being decoded allows SANE (via Extended Calculator) to compute square roots, And that fixed Jigsaw Puzzle! |
No.22135
R. Belmont Developer
May 28, 2024, 00:58
edited on: May 28, 2024, 01:00 |
Maelstrom also works fine now. This has been submitted and will not be in the 0.266 release this week, but will be in 0.267 at the end of June. |
No.22214
Wismi Tester
Jul 6, 2024, 01:08
|
I thought I would check in on this. This was the best result possible! Thank you! I'm going to get the latest and try it out. With the better sound emulation, and the ability to play certain other games well, this might outright replace my use of Basilisk II. Crossing my fingers! |
No.22215
Wismi Tester
Jul 6, 2024, 02:50
|
I can confirm these fixes, as well as SpectreVR. |