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

Enables Win9x support on a Pentium3 PC #4612

Merged
merged 13 commits into from
Dec 1, 2023
Merged

Conversation

crazii
Copy link
Contributor

@crazii crazii commented Nov 18, 2023

Enables Win9x support on a Pentium3 PC.

  • Add _WIN32_WINDOWS macro to detect win9x target platform
  • Add OpenCOW (static lib) to support Unicode functions
    Unicode functions (e.g. GetOpenFileNameW to choose dosbox-x.conf) which is not originally supported on Win9x, it just fails silently with no error code. (similar found in code: FindFirstFileW/FindNextFileW, GetFileAttributeExW, InsertMenuItemW)
    For MSVCRT it is the same, e.g. wstat/wopen won't work. mounted drive in DOSBox-X will fail getting file information and result in empty mounted disks.
    The OpenCOW lib will translate *W calls to *A calls: adjust wide strings to ANSI string with current system code page and call the corresponding ANSI function, and make the win9x build compatible with Unicode functions.
  • Use 32bit file offsets
    Win9x uses FAT32 which doesn't need 64bit file offset, so it is not supported.
  • New build script: build-mingw-lowend9x (SDL1), no SDL2 support.

Additional information

A custom toolchain that targeted to pentium3 is needed (https://github.com/crazii/MINGW-toolchains-w9x/releases/tag/v1.0),
otherwise the built binary can not run.
Tested working on a real Pentium3 Win98SE laptop.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changing from SSE to SSE3 should be incorrect, at least it should be SSE2. if uses SSE the dynamic branch of SSE2 is OK but it still got compiled, when targeting to pentium3 it failed to compile.
add target specific _WIN32_WINDOWS should be OK.

@Torinde
Copy link
Contributor

Torinde commented Nov 19, 2023

Related: #3577

  • will this build also run on NT4 or NT3.x?
  • I assume it won't be able to run under Win3.1x/Win32S? That would've also allowed to run under OS/2 or ArcaOS...

Is there a Github Actions .yml file in this PR - for automatically making those builds? That would help to catch if some future change affects the tweaks here.

@crazii
Copy link
Contributor Author

crazii commented Nov 19, 2023

NT4 has similar API set to Win9x, so at least It's possible to make it run, with a few changes if needed. But I didn't test it yet, I don't have legacy PCs that run NT4.
But NT3.x and Win3.x don't.

Also I need correct my previous statement about the custom toolchain, it is essential because the original MSYS2 mingw32-crt startup routine will call some inline NT functions and corrupt the memory. Maybe an older mingw32 will help. What edition of Mingw32 is used to build DOSBox-X lowend exactly?

And I've found some new problems and still been testing, for sometimes the build exe fails with page error on start, and it always does. but another build will always run. This only happens on my Penntium3 laptop, but works well in VMWare Player (with modern CPU features, which indicate the problem lays on instruction sets). - So it is not ready for PR yet.

I don't know about Github Actions, but I can try to make one when the build is stable.

@Torinde
Copy link
Contributor

Torinde commented Nov 19, 2023

call some inline NT functions and corrupt the memory. Maybe an older mingw32 will help.

I don't know what's used for the MinGW-lowend build, but there is also a HX DOS build, which I think doesn't use any NT functions.

I don't have legacy PCs that run NT4.

I can test in VirtualBox - when you have an executable ready.

@crazii
Copy link
Contributor Author

crazii commented Nov 19, 2023

the executable is here: https://github.com/crazii/dosbox-x-w9x/releases/tag/beta

@joncampbell123
Copy link
Owner

Ready for me to merge your pull request or should I wait for some testing to complete first?

@Torinde
Copy link
Contributor

Torinde commented Nov 21, 2023

I did some tests - results are in #3577, basically the 9x build works under 98/Me/2000/11 and ReactOS.

Doesn't work under 95 or NT4 (so I haven't tested NT3.x and Win32S) - can that be corrected?

Would be nice to default into video output surface and to get the debugger enabled.

Besides Github Actions, would be good if it gets an Installer (the NSIS used for XP/Vista installers supports down to Win95/NT) and added to the DOSbox-X Release scripts

@joncampbell123
Copy link
Owner

joncampbell123 commented Nov 22, 2023

I did some tests - results are in #3577, basically the 9x build works under 98/Me/2000/11 and ReactOS.

Doesn't work under 95 or NT4 (so I haven't tested NT3.x and Win32S) - can that be corrected?

Would be nice to default into video output surface and to get the debugger enabled.

Besides Github Actions, would be good if it gets an Installer (the NSIS used for XP/Vista installers supports down to Win95/NT) and added to the DOSbox-X Release scripts

I suppose an #ifdef could be added to default to surface output if compiling the lowend version for systems below XP. Not sure if pdcurses can run on an OS that low. Is the missing component that prevents Windows 95/NT4 MSVCRT.DLL? That seems to be a common thing with MinGW compiled binaries in that they require MSVCRT.DLL which is provided by default on Windows 98/2000 on up.

Another idea is that if pdcurses can't compile for Windows that old, perhaps the SDL interface itself could provide the debugger interface. In the same way that when you switch to the mapper interface the SDL window changes to an 8bpp mode to render the mapper buttons and such. Then the debugger interface could call some code that does very minimal ncurses emulation on the SDL window when active.

If you can find a version of the NullSoft installer system that runs on Windows 95/NT4, that could be used for those systems, sure.

@Torinde
Copy link
Contributor

Torinde commented Nov 23, 2023

Win 95 error messages are for IPHLPAPI.DLL (resolved by taking it from WinME), DHCPCSVC.DLL (resolved by taking it from WinME), NTDLL.DLL (resolved by replacing the one in WINDOWS\SYSTEM with one from WinME), unresolved for KERNEL32.DLL (Windows can't boot if the file is replaced with the one from WinME)

Win NT4 first error is about IMM32.DLL (resolved by placing it in the DOSbox-X folder), then user32.dll (couldn't resolve)

Error message sometimes mention specific function inside the DLL that's required. I will make screenshots of those later.

@Torinde
Copy link
Contributor

Torinde commented Nov 23, 2023

NSIS installer - from the link above (which I think is the official/regular one used already by DOSBox-X) it seems to already support Win95/NT (maybe even NT3.x, because number isn't mentioned):
image

@Torinde
Copy link
Contributor

Torinde commented Nov 23, 2023

Win 95 RTM + Winsock2 + OpenGL95 + IE4SP2 + DirectX:
image

image

image

image

I haven't tested with Microsoft Layer for Unicode, but it's not expected to help since the 9x build already has OpenCOW, correct?

Win NT4 SP6a
image

image

@crazii
Copy link
Contributor Author

crazii commented Nov 24, 2023

Ready for me to merge your pull request or should I wait for some testing to complete first?

No yet, it needs more tests.

@crazii
Copy link
Contributor Author

crazii commented Nov 24, 2023

I haven't tested with Microsoft Layer for Unicode, but it's not expected to help since the 9x build already has OpenCOW, correct?

Yes. Thanks for the testing, I will try to fix it on win95 in VM first. Can you "at" someone who's familiar with the toochains used to build the lowend binary? I could check if that helps.

@Torinde
Copy link
Contributor

Torinde commented Nov 26, 2023

@joncampbell123 @maron2000, can you please tell:

What edition of Mingw32 is used to build DOSBox-X lowend exactly?

@joncampbell123
Copy link
Owner

@joncampbell123 @maron2000, can you please tell:

What edition of Mingw32 is used to build DOSBox-X lowend exactly?

This would be the original 32-bit MinGW (not the MinGW x64 which seems to support only Windows Vista and up).
The original MinGW 32-bit compiler, last I checked sometime around 2017, is still able to target as low as Windows 98 (Windows 95 if you install MSVCRT.DLL).

@joncampbell123
Copy link
Owner

joncampbell123 commented Nov 27, 2023

I suspect the IPHLPAPI dependency might be the SDLNet library, which is not required by DOSBox-X unless you want the IPX tunnel code or the ability to connect a serial port to a TCP socket, and it might have something to do with the WinPCAP support.

https://en.cppreference.com/w/cpp/types/offsetof

@joncampbell123
Copy link
Owner

joncampbell123 commented Nov 27, 2023

You should be able to comment out a #define to disable the IMM32.DLL dependency. Some contributors have added IME support especially where it concerns Japanese/Chinese keyboard input and/or PC-98 mode.

You could also comment out the "multiple monitor" support code to eliminate the USER32.DLL dependency error. DOSBox-X is only trying to use that to determine your monitor's DPI and which monitor it's on. To my recollection, the multiple monitor API didn't appear in Windows 9x until Windows 98 when it was one of the Big New Features added by Microsoft. Not sure about when Windows NT added it (maybe it was added in Windows 2000?).

@joncampbell123
Copy link
Owner

joncampbell123 commented Nov 27, 2023

Come to think of it, I already have plenty of LoadLibrary and GetProcAddress() for more recent Windows APIs like the one in Windows 7 to add buttons and define the portion of your window shown when you hover over the app icon on the taskbar, perhaps I should LoadLibrary/GetProcAddress IME support and multiple monitor support too when targeting Windows.

If done right you could do that well enough to run on Windows 95 while using all the newer APIs you could ever want.

@crazii
Copy link
Contributor Author

crazii commented Nov 28, 2023

OK, I was using the customized 32bit toolchain of MINGW-w64, I'll try to build a new binary with the legacy toolchain from SF.

@dbjh
Copy link
Contributor

dbjh commented Nov 28, 2023

OK, I was using the customized 32bit toolchain of MINGW-w64, I'll try to build a new binary with the legacy toolchain from SF.

You can use that, or a slightly more recent version from the official site https://mingw.osdn.io/. However, for me the official site is unreachable at the moment. As an alternative you can also use https://osdn.net/projects/mingw/.

@joncampbell123
Copy link
Owner

OK, I was using the customized 32bit toolchain of MINGW-w64, I'll try to build a new binary with the legacy toolchain from SF.

You can use that, or a slightly more recent version from the official site https://mingw.osdn.io/. However, for me the official site is unreachable at the moment. As an alternative you can also use https://osdn.net/projects/mingw/.

It seems like the original MinGW site has gotten more and more inaccessible since about 2017 when I noticed the GUI to install it's packages stopped working.

@maron2000
Copy link
Contributor

FYI, the mingw32 environment used to build the x86 lowend builds is found here

@crazii
Copy link
Contributor Author

crazii commented Nov 29, 2023

Thank you guys, I've finished the build (with extra modifications of the source code) using toolchains from both SF and OSDN, tested good in win95, 98 and NT4.
Now I'm gonna try the mingw32 that maron2000 mentioned.

@crazii
Copy link
Contributor Author

crazii commented Nov 29, 2023

I ran a simple & fast test on the toolchain used to build lowend target (it seems a i686-w64-mingw32 for ming-w64), under win98 there's a missing function AddVectoredExceptionHandler in kernel32.dll, which is XP(or maybe 2k) only.
That seems to be fixed in latest mingw32 which uses LoadLibrary last time I checked, when customizing the i686-w64-mingw32 toolchain.
Conclusion: no luck.

For now the legacy MinGW from SF/OSDN is a sound choice. The built binary runs on win98 p3 real pc or win98/95osr2.5/nt4sp1 in VirtualBox. But I have to use Pentium instruction instead of p3, for win95 will fail on a invalid instruction of SSE1 (win98 works fine), didn't figure out why, but it shouldn't happen - Virtualbox won't limit such CPU caps on guest OS.

@crazii
Copy link
Contributor Author

crazii commented Dec 1, 2023

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

@joncampbell123
Copy link
Owner

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

It can't find the ".in" file 😆 because it forgot that "configure" is part of it.

@crazii
Copy link
Contributor Author

crazii commented Dec 1, 2023

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

It can't find the ".in" file 😆 because it forgot that "configure" is part of it.

Yes I can see that in the check log, only a .in, but why?
Is this related to my changes?

@crazii
Copy link
Contributor Author

crazii commented Dec 1, 2023

The source code itself is ready. There's my questions about CI workflow

I checked the yml for build lowend, it runs under msys2, while the legacy MinGW runs on msys1, I don't know whether it works if the shell is changed to MinGW or msys, and the package installing part, should a pre-made zip be used (like mingw lowend zip) or install packages on the fly? I should test it on my fork to make sure everything works. But I don't know how.

Should I enable the workflow on my fork and add a new one to test? The original workflows are disable by github, and I don't know the consequences if it is enabled.

Anyone can help with this?

@joncampbell123
Copy link
Owner

The source code itself is ready. There's my questions about CI workflow

I checked the yml for build lowend, it runs under msys2, while the legacy MinGW runs on msys1, I don't know whether it works if the shell is changed to MinGW or msys, and the package installing part, should a pre-made zip be used (like mingw lowend zip) or install packages on the fly? I should test it on my fork to make sure everything works. But I don't know how.

Should I enable the workflow on my fork and add a new one to test? The original workflows are disable by github, and I don't know the consequences if it is enabled.

Anyone can help with this?

If you do that, please make it a separate pull request.

@joncampbell123 joncampbell123 merged commit 4709f86 into joncampbell123:master Dec 1, 2023
@maron2000
Copy link
Contributor

You can take a look at .github/workflows/mingw32.yml
Lowend builds now replace the mingw environment.
You can follow that or make a workflow to tweak the latest mingw as you already did in order to build your own executables.

@dbjh
Copy link
Contributor

dbjh commented Dec 2, 2023

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

You converted configure.ac to DOS text format (\r\n). If you convert it back to UNIX format (\n) the problem will be solved.

@crazii
Copy link
Contributor Author

crazii commented Dec 2, 2023

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

You converted configure.ac to DOS text format (\r\n). If you convert it back to UNIX format (\n) the problem will be solved.

Thanks. I didn't remember doing that. Doesn't git always use LF in remote? I've seen articles about that, there's a auto CRLF option for windows local clones.

@Torinde
Copy link
Contributor

Torinde commented Dec 3, 2023

WfW 3.11 + Win32s 1.30c: goes trough IMM32.DLL, MSVCRT.DLL, OPENGL32.DLL, GLU32.DLL, DCIMAN32.DLL, OLE32.DLL and then reaches unresolvable 'system component out of date' and w32scomb.dll (see at #3577 (comment))

So, it seems NT 3.51 is much closer to working (IMM32.DLL, then USER32.DLL). Would you be able to adapt the 9x/NT4 to build to work on NT 3.x?

@dbjh
Copy link
Contributor

dbjh commented Dec 3, 2023

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

You converted configure.ac to DOS text format (\r\n). If you convert it back to UNIX format (\n) the problem will be solved.

Thanks. I didn't remember doing that. Doesn't git always use LF in remote? I've seen articles about that, there's a auto CRLF option for windows local clones.

Could you create a pull request with the fix? It appears no one else will do that and the issue breaks the build on at least Linux and macOS (for everyone, not just for CI).

@crazii
Copy link
Contributor Author

crazii commented Dec 3, 2023

What's the problem of the Linux/MacOS CI build check? I've no idea what happens, probably due to some changes on the configure.ac?

You converted configure.ac to DOS text format (\r\n). If you convert it back to UNIX format (\n) the problem will be solved.

Thanks. I didn't remember doing that. Doesn't git always use LF in remote? I've seen articles about that, there's a auto CRLF option for windows local clones.

Could you create a pull request with the fix? It appears no one else will do that and the issue breaks the build on at least Linux and macOS (for everyone, not just for CI).

Sorry for the inconvenience. #4651

@crazii
Copy link
Contributor Author

crazii commented Dec 3, 2023

WfW 3.11 + Win32s 1.30c: goes trough IMM32.DLL, MSVCRT.DLL, OPENGL32.DLL, GLU32.DLL, DCIMAN32.DLL, OLE32.DLL and then reaches unresolvable 'system component out of date' and w32scomb.dll (see at #3577 (comment))

So, it seems NT 3.51 is much closer to working (IMM32.DLL, then USER32.DLL). Would you be able to adapt the 9x/NT4 to build to work on NT 3.x?

Not for now probably. I wonder how many users in real world runs DOSBox-X under a pre 2k era machine. Me for instance, I've a win98 laptop with HW SBPro and soft FM emulation by the vxd driver, but a few games have problem with the FM emulation and they have no sound, and after they exit, the system get muted. After test them on DOSBox in win98 I got a satisfied result, then I want to see what happens if with the OPL hardware passthrough of DOSBox-X? But it fails to run. That's my initial intention of the fork. Those games runs with sound in DOSBox-X with sound in hardware OPL mode, but after exit DOSBox-X, the system still got muted. it's the bad driver of the host.
DOSBox-X is more powerful than DOSBox especially running win9x guests, but on a Win9x system, there's no need of that, and most games runs OK natively (except for some early DOS games). and the need of running DOSBox-X on NT3.51 is little.

@crazii
Copy link
Contributor Author

crazii commented Dec 3, 2023

You can take a look at .github/workflows/mingw32.yml Lowend builds now replace the mingw environment. You can follow that or make a workflow to tweak the latest mingw as you already did in order to build your own executables.

Thanks. I'm trying to add a new job in mingw32.yml to build the 9x binary, I don't want to put the toolchain pack (90mega) into the repo so I tried use wget to download it. But I got a error that wget: command not found, even if I added wget to the packages to install.
It's weird that wget is already installed as I got warning: wget-1.21.4-1 is up to date -- skipping but still it is not found, any ideas?

-The error logs are here: https://github.com/crazii/dosbox-x-w9x/actions/runs/7073571460/job/19253760479

@crazii
Copy link
Contributor Author

crazii commented Dec 3, 2023

OK, after reading the yml carefully, I get that the setup step uses a bash shell which is separated from msys2 shell, so msys2 has wget but bash env hasn't.

@dbjh
Copy link
Contributor

dbjh commented Dec 3, 2023

WfW 3.11 + Win32s 1.30c: goes trough IMM32.DLL, MSVCRT.DLL, OPENGL32.DLL, GLU32.DLL, DCIMAN32.DLL, OLE32.DLL and then reaches unresolvable 'system component out of date' and w32scomb.dll (see at #3577 (comment))
So, it seems NT 3.51 is much closer to working (IMM32.DLL, then USER32.DLL). Would you be able to adapt the 9x/NT4 to build to work on NT 3.x?

Not for now probably. I wonder how many users in real world runs DOSBox-X under a pre 2k era machine. Me for instance, I've a win98 laptop with HW SBPro and soft FM emulation by the vxd driver, but a few games have problem with the FM emulation and they have no sound, and after they exit, the system get muted. After test them on DOSBox in win98 I got a satisfied result, then I want to see what happens if with the OPL hardware passthrough of DOSBox-X? But it fails to run. That's my initial intention of the fork. Those games runs with sound in DOSBox-X with sound in hardware OPL mode, but after exit DOSBox-X, the system still got muted. it's the bad driver of the host. DOSBox-X is more powerful than DOSBox especially running win9x guests, but on a Win9x system, there's no need of that, and most games runs OK natively (except for some early DOS games). and the need of running DOSBox-X on NT3.51 is little.

The OPL pass-through code is not enabled by default, but your use-case may be a reason to change that. In order to enable the code change line 6 of src/hardware/hardopl.h as indicated in the comment (https://github.com/joncampbell123/dosbox-x/blob/master/src/hardware/hardopl.h#L6C12-L6C12).

Edit: I was not reading carefully. Sorry. You already stated you ran the games with hardware OPL pass-through enabled.

@crazii
Copy link
Contributor Author

crazii commented Dec 3, 2023

Yes, I checked the source that it is not enabled, I've enabled it on my local builds (didn't want to commit to the repo).
Funny that the hardware OPL passthrough has worse quality than emulated by DOSBox-X, since the "hardware" OPL on host is a poor emulation by the driver (on VT82C868 southbridge), worse that DBOPL emulation. But still way better than the ESS allegro/maestro or some other wavetable emulation like Ensoniq AudioPCI.

@joncampbell123
Copy link
Owner

WfW 3.11 + Win32s 1.30c: goes trough IMM32.DLL, MSVCRT.DLL, OPENGL32.DLL, GLU32.DLL, DCIMAN32.DLL, OLE32.DLL and then reaches unresolvable 'system component out of date' and w32scomb.dll (see at #3577 (comment))

So, it seems NT 3.51 is much closer to working (IMM32.DLL, then USER32.DLL). Would you be able to adapt the 9x/NT4 to build to work on NT 3.x?

Here's an article from IBM who, unlike Microsoft, doesn't throw away their old Knowledge Base articles:

https://web.archive.org/web/20231203070203/https://www.ibm.com/support/pages/win32s-errors

Apparently something to do with OLE32.DLL?

@Torinde
Copy link
Contributor

Torinde commented Mar 12, 2024

I wonder how many users in real world runs DOSBox-X under a pre 2k era machine.
the need of running DOSBox-X on NT3.51 is little.

There's a community of NT3.51 enthusiasts, for example Running NT 3.51 on real new hardware (Ryzen 3900X), Gaming on Windows NT 3.51 and VOGONS

DOSBox 0.65 is reported as the last version working under NT3.51, so those users would benefit greatly if latest DOSbox-X lowend9x can be made to run there.

(I also wonder if NewShell patches will help or allow NT4 Internet Explorer to be installed, which may also help)

@crazii
Copy link
Contributor Author

crazii commented Mar 19, 2024

I wonder how many users in real world runs DOSBox-X under a pre 2k era machine.
the need of running DOSBox-X on NT3.51 is little.

There's a community of NT3.51 enthusiasts, for example Running NT 3.51 on real new hardware (Ryzen 3900X), Gaming on Windows NT 3.51 and VOGONS

DOSBox 0.65 is reported as the last version working under NT3.51, so those users would benefit greatly if latest DOSbox-X lowend9x can be made to run there.

(I also wonder if NewShell patches will help or allow NT4 Internet Explorer to be installed, which may also help)

OK, cool.
I can figure out a time to test it on NT3.51, when I've finished my work at hand, it might take long, please wait :)

I'll mark this as unread in case I forget about that.

@Torinde
Copy link
Contributor

Torinde commented Jun 19, 2024

@crazii, at DOSBox Compilation Guides (by @DosFreak) there are instructions for building NT3.50 and NT3.51 DOSbox SVN - probably similar procedure can applied here?

Also, in some of the comments they discuss a use-case for DOSbox on Win3.1 (although it seems more difficult than for NT3.50).

What I tried is your lowend9x build on NT3.51 + newshell2 - doesn't work.
Installing IE4 4.01 SP2 (4.72.3612.1707) with active desktop (for 9x/NT4) on NT3.51 - installer says NT4 is required.
Installing IE4 4.01 (4.01.2111) for Windows 3.1 (I assume that's 16-bit IE4) on NT3.51 - installer hangs the Windows, but anyway without active desktop I don't think it would've helped.

@Torinde
Copy link
Contributor

Torinde commented Jun 20, 2024

SDL 1.2 working on Windows 3.1 with Win32s and WinG: https://github.com/ccawley2011/SDL-1.2/tree/win32s (from this discussion)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants