CUzeBox - The new official Uzebox emulator

The Uzebox now have a fully functional emulator! Download and discuss it here.
User avatar
Artcfox
Posts: 990
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Artcfox » Sun Jun 21, 2020 12:48 pm

Jubatian wrote:
Sun Jun 21, 2020 12:35 pm
Hi Artcfox,

Taking a look at the Windows Audio issue, trying to understand the causes and why the particular solution would solve it. Do I get it right that the introduction of WASAPI support is the culprit?

https://discourse.libsdl.org/t/sdl-2-0-8-released/23957

Which is introduced in 2.0.8, and indeed I see complaints that it doesn't work. So in case of 2.0.8 and above, CUzeBox would have to force selecting directsound as default (unless the user had set up the environment variable already for something) which I presume was the default before 2.0.8.
That sounds right. I've never used anything higher than Windows 7, so the whole WASAPI UWP (Universal Windows Platform) is foreign to me, but I looked at how other game emulators solved it, and my proposed solution incorporates what I think is the best solution, only setting it if the user hasn't already overridden it.

Perhaps there is someone here who can test to make sure this works on Windows 10? My guess is it would, since all the old games would still have to run with DirectSound, but we should get confirmation.

User avatar
Jubatian
Posts: 1447
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian » Sun Jun 21, 2020 1:03 pm

Looking at the patch I can see one significant problem: The SDL version check as you put it is evaluated compile time. This doesn't look right to me as you might have a global SDL installation (although on Windows it isn't that likely as on Linux), which might be anything. The current CUzeBox binary packages should work I think as they are packaged together with a version of SDL for Windows, but of course if you are compiling yourself, then you might match it with a different version.

The good solution would be I think either skipping the version check (older versions defaulted to directsound anyway I guess, so there it wouldn't really change anything), or query the version at runtime from the SDL library using https://wiki.libsdl.org/SDL_GetVersion .

User avatar
Artcfox
Posts: 990
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Artcfox » Sun Jun 21, 2020 1:15 pm

When we package cuzebox, we package it alongside the SDL2.dll (in the same directory) so I don't think we have to worry about the difference between what it was compiled against vs. linked against.

I guess it's easy enough to do either way.

User avatar
Artcfox
Posts: 990
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Artcfox » Mon Jun 22, 2020 5:54 am

Now I remember why the version check is needed!

The Win32 default for SDL2 is called "DirectSound", but in SDL1 that default is called "dsound".

The drivers available depend on the platform and SDL compile-time options, so that is why I think we should go with the compile time check.

https://wiki.libsdl.org/FAQUsingSDL

shockdesign
Posts: 27
Joined: Mon Jan 06, 2014 12:20 pm

Re: CUzeBox - The new official Uzebox emulator

Post by shockdesign » Wed Jun 24, 2020 5:07 pm

Hey @Jubatian

Just wanted to say thanks, this compiles perfectly on a Mac as well (using Linux as the TSYS)...Awesome work.

User avatar
Jubatian
Posts: 1447
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian » Fri Jun 26, 2020 11:45 am

shockdesign wrote:
Wed Jun 24, 2020 5:07 pm
Hey @Jubatian

Just wanted to say thanks, this compiles perfectly on a Mac as well (using Linux as the TSYS)...Awesome work.
Thank you! Great to hear it works! :)
Artcfox wrote:
Mon Jun 22, 2020 5:54 am
Now I remember why the version check is needed!

The Win32 default for SDL2 is called "DirectSound", but in SDL1 that default is called "dsound".

The drivers available depend on the platform and SDL compile-time options, so that is why I think we should go with the compile time check.

https://wiki.libsdl.org/FAQUsingSDL
SDL1 and SDL2 are different libraries, a game compiled against one won't run with the other. You can compile CUzeBox for either since it has conditionally compiled code to address the specifics of each, but once having the binary, it will only run with the variant (1 or 2) of SDL it is compiled against.

Compile time distinction between minor versions I think isn't a good idea at all. The emulator binary would run with any version of SDL 2. So then depending on whether you compiled it with a header set for 2.0.8 or later or before, different behaviours would be the result! Notably if you happen to have a binary compiled with pre 2.0.8 SDL headers, and you happen to have a 2.0.8 or later SDL library installed, it would have no sound (if also affected by the WASAPI problem), while if the emulator was compiled against 2.0.8 or later headers, it would work. Such things are just awful regarding maintenance (if someone reported to have no sound, then what could be it? Might he happen to use a build compiled against pre 2.0.8 SDL headers, or a legitimate other issue? If he only has the binary of the emulator then, about impossible to figure out).

User avatar
Artcfox
Posts: 990
Joined: Thu Jun 04, 2015 5:35 pm
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Artcfox » Sat Jun 27, 2020 7:40 am

You had mentioned skipping the level check entirely and unconditionally setting that variable to "DirectSound". I was trying to point out that SDL 1 uses direct sound by default, but that environment variable would need to be set to "dsound" for SDL 1 according to the faq, so setting it unconditionally to "directsound" seems bad.

User avatar
Jubatian
Posts: 1447
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian » Sat Jun 27, 2020 12:46 pm

Artcfox wrote:
Sat Jun 27, 2020 7:40 am
You had mentioned skipping the level check entirely and unconditionally setting that variable to "DirectSound". I was trying to point out that SDL 1 uses direct sound by default, but that environment variable would need to be set to "dsound" for SDL 1 according to the faq, so setting it unconditionally to "directsound" seems bad.
It would still be an SDL2 specific element, not both (so the USE_SDL1 flag still used to add this for SDL2 builds only). SDL1 and SDL2 are two different libraries, CUzeBox only can be compiled against either, but not both simultaneously. The distinction is that CUzeBox compiled for SDL2 won't run with any version of SDL1, CUzeBox compiled for SDL1 won't run with any version of SDL2, while across different minor versions of the same major SDL library, it will run.

Probably I would add the runtime version check for it. If (with CUzeBox compiled for SDL2 and Windows) SDL2 version is less than 2.0.8, use whatever SDL2 provides as default, if 2.0.8 or later, enforce directsound if the environment variable is unset, but it seems not quite necessary as SDL2 < 2.0.8 would use directsound by default anyway (I guess).

User avatar
Jubatian
Posts: 1447
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian » Sun Jun 28, 2020 3:52 pm

Hi Artcfox, does it work with current (2.0.12) SDL on your system?

Would like to get an idea of the scope. Reading after it found that WASAPI was introduced with 2.0.6, so presumably a version check's bottom bound should be 2.0.6. Even if it works with 2.0.12, I might add the workaround with a dynamic version check, just in case, there could be situations when on Windows a global SDL2 library is used, affected by the problem.

User avatar
Jubatian
Posts: 1447
Joined: Thu Oct 01, 2015 9:44 pm
Location: Hungary
Contact:

Re: CUzeBox - The new official Uzebox emulator

Post by Jubatian » Sat Jul 04, 2020 11:21 am

I added a case for this audio issue for tracking: https://github.com/Jubatian/cuzebox/issues/3

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests