joncampbell123 / dosbox-x

DOSBox-X fork of the DOSBox project
GNU General Public License v2.0
2.67k stars 378 forks source link

Conditions (<>=) don't work as expected in VBDOS #3872

Closed mariobrx closed 1 year ago

mariobrx commented 1 year ago

Describe the bug Since a couple of years, I've migrated an old VisualBasic for DOS application to DOSBox-x, I managed to get it working on Debian Linux and Windows 10 instances of Dosbox-x. Now I've installed a Raspberry Pi with the Raspberry OS 64bit and installed Dosbox-x via Flathub. But: my application is not behaving as expected. I tried to adapt the config but couldn't resolve, but now I've found the root cause: when comparing single variables, it goes completely wrong, Example: print -200 > 20 --> returns FALSE as expected

print -200.0 > 20.0 --> returns TRUE --> this is causing issues all over the application

Steps to reproduce the behaviour You just download VisualBasic for DOS Professional, install it and start it like this VBDOS /H /Ah In the menu: Window / Immediate print -200.0 > 20.0

Expected behavior Should return FALSE, but it returns TRUE

What operating system(s) this bug have occurred on? Raspberry OS 64bit installation via flathub

What version(s) of DOSBox-X have this bug?

0.84.3 (2022.09.0)

Used configuration

Default config file with following changes: [dos] keyboardlayout = be

[config] set path = Z:\;Z:\SYSTEM;Z:\BIN;Z:\DOS;Z:\4DOS;Z:\DEBUG;Z:\TEXTUTIL;c:\visualb\bin;c:\visualb\lib

[autoexec] mount c: /home/pi/DOS c: vbdos /Ah /H

Have you checked that no similar bug report(s) exist? I have searched and didn't find any similar bug report.

Code of Conduct & Contributing Guidelines I agree to follow the code of conduct and the contributing guidelines.

aybe commented 1 year ago

I tested here and it works just fine.

mariobrx commented 1 year ago

Hi Aybe, did you test in the same config:

I just want to add that It has been working correctly on Windows 10 and on a Raspberry with Raspi OS 32 bit (without flathub)

If you had the same config: what would you recommend

Thanks.

aybe commented 1 year ago

No, I tested on Windows. So now we know that it only happens on PI 64-bit.

Does anyone have an idea on where this should be debugged in the sources?

mariobrx commented 1 year ago

Has someone in the meantime been able to reproduce the issue on a RaspiOS 64 bit ?

mariobrx commented 1 year ago

I've done some more reading and found this section on the main dosbox-x github page (see below). This solved my issue. In short: just add fpu=false in the CPU section of conf file

Full precision floating point emulation.

Unless using the dynamic core, DOSBox and DOSBox-X emulate the FPU registers using the "double" 64-bit floating point data type.

The Intel FPU registers are 80-bit "extended precision" floating point values, not 64-bit double precision, so this is effectively 12 bits of precision loss and 5 bits of range loss (64 to 53 mantissa bits and 16 to 11 exponent bits). This slight loss of precision is perfectly fine considering DOSBox's original goal in supporting DOS games, but may cause problems in other cases that need the full precision.

It is known at this time that this lack of precision is enough to cause otherwise straightforward comparisons against integers to fail in DOS applications originally written in QBasic or Turbo Basic. There are such DOS games written that check their file size using a floating point compare that will fail in this manner. To run these games, you will need to disable FPU emulation (fpu=false) to force the QBasic/TurboBasic runtime to use software emulation instead.

joncampbell123 commented 1 year ago

Just to confirm what is probably your issue... I recall finding a QuickBASIC compiled game way back around 2014 that checked it's own EXE file size. Even though the numbers were the same, the floating point compare failed, and the game always thought it was corrupt.