Closed zelurker closed 4 years ago
Oh yuck... Well, it works, which is better than it not working :P
From the 040UM.pdf section 9-11, it says: "When theMC68040 performs an operation, the calculation is carried out using extended-precision inputs, and the intermediate result is calculated as if to produce infinite precision. After the calculation is complete, the intermediate result is rounded to the selected precision and stored in the destination."
... which means that in future we can probably improve on this immensely by just doing the calculations in 128 bit precision (supported by the compiler) and then rounding down to whatever format is required. The 96-bit extended floating point format will then just be a last-mile conversion problem rather than a central part of all calculations (only the NaN representations might be an issue, but it's rare that anyone actually relies on NaN encoding behavior, Javascript notwithstanding). The BCD format also looks like it's not too terrible to convert to. We could probably replace all the sprintf-based BCD code in there with table lookups.
Still, this is definitely an improvement :) Thanks!
the biggest part here is the usage of softfloat, from a lib found on the web. But it's better to use the mame version because the one from the web has 1 makefile + some headers / target platform, + the latest version has a ton of files, here this version is much smaller and compiles assuming you just change the basic types in softload/mamesf.h (I changed the file to use the current basic types from musashi). I changed the define for the basic types to typedef but it was useless after all, I can revert to the old defines if you prefer but softfloat is using typedefs anyway so you need a compiler supporting that.
The softfloat lib allows to have some support for the special formats which were not supported before, the surprise is that it seems as fast as before, it's less readable though but I guess you get used to it...
mame has added some prototype functions using the c++ & as parameter in softfloat.h, which makes an error with gcc, you need g++ for that, so I just commented them out for now, they are not used for now here, probably later (it's about fsin, fcos and ftan). That should be all, I think I'll take another break after that !