Author Topic: [SDL2] SDL_ListModes and emulation  (Read 2144 times)

Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
[SDL2] SDL_ListModes and emulation
« on: October 30, 2024, 12:29:37 pm »
You guys, something interesting here.
First of all the good news: I FINALLY got to compile a working release of FUSE, one of the best ZX Spectrum emulators available as open source https://sourceforge.net/projects/fuse-emulator/.

Configure and Make went successful but I encountered two major problems:

  • the font file fuse.font used in the SDL version got broken during compilation. I solved it replacing the broken one with a pre-compiled version from a Debian distribution. OK, I cheated, but too little time to investigate on this;
  • The executable crashed during SDL graphic mode initialization.

In the source file ui/sdl/sdldisplay.c there's a function named

uidisplay_init( int width, int height )

which calls SDL_ListModes like this:

modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_SWSURFACE);

where modes is of type SDL_Rect **modes; as per documentation.

I noticed that SDL_ListModes returns three available modes but only the first one seems somehow valid.
Trying to access modes[1] or modes[2] immediately crashed the program. SDL documentation was not helpful as I hoped.

The obvious solution was to force selecting modes[0] like this


#if defined (__OS2__)
   mn = 0; // Remove useless warning
   mw = modes[0]->w;
   mh = modes[0]->h;
   fprintf (stderr, "OS/2 system: resolution is %d x %d\n\r", mw, mh);
#else
...rest of original code follows...


I'm currently uploading everything on Hobbes, with source and utilities.
Did someone else encounter this problem? It seems almost like SDL2 under OS/2 works only in full screen mode. This may also explain why I can't start sUQLx (a Sinclair QL SDL emulator) in windowed mode, even if I try to force it.

Mentore

Pete

  • Hero Member
  • *****
  • Posts: 1352
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #1 on: October 30, 2024, 03:11:43 pm »
Hi Mentore

I have not played any ZX Spectrum games in many years, would not mind having another go at pacman as I think the Speccy version was the best.

Starfighter (downloaded from hobbes) is an SDL2 game that runs in a window so SDL2 for OS/2 should not be fullscreen only.

However, Starfighter does not work with SDL2 files installed by ANPM - currently at 2.0.18-3 -   but requires an earlier package http://hobbes.nmsu.edu/download/pub/os2/dev/SDL2-2.0.4-20160225.zip in order to run.

So, I guess the question is: Are you using the right variant of SDL2?


Regards

Pete





Dave Yeo

  • Hero Member
  • *****
  • Posts: 5095
  • Karma: +117/-1
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #2 on: October 30, 2024, 06:18:37 pm »
The SDL2 rpm also works if linked against it. Are you perhaps using a 3D (OpenGL) surface? They're not supported.

Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #3 on: October 30, 2024, 10:58:11 pm »
The SDL2 rpm also works if linked against it. Are you perhaps using a 3D (OpenGL) surface? They're not supported.

Hi Dave,
the call to SDL_ListModes is done against a SWSURFACE so I guess it's the software renderer.
Maybe the best course of action is to take a look at the SDL2 games ported on OS/2 and see what I can do with them - I used the libraries and the runtimes taken from the RPM archive.
I won't be able to get back to my OS/2 VM until the next Monday, so I guess the next few days will be silent from this side.
Still I'm really exhalted from being able to port such a nice piece of software on OS/2, even if it's for my deep love for the ZX Spectrum.

Mentore

Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #4 on: October 30, 2024, 11:00:39 pm »
Hi Mentore

I have not played any ZX Spectrum games in many years, would not mind having another go at pacman as I think the Speccy version was the best.

Starfighter (downloaded from hobbes) is an SDL2 game that runs in a window so SDL2 for OS/2 should not be fullscreen only.

However, Starfighter does not work with SDL2 files installed by ANPM - currently at 2.0.18-3 -   but requires an earlier package http://hobbes.nmsu.edu/download/pub/os2/dev/SDL2-2.0.4-20160225.zip in order to run.

So, I guess the question is: Are you using the right variant of SDL2?


Regards

Pete

Thanks Pete. Indeed I already saw some SDL2 games on OS/2 working in windowed mode so yes, I guess my SDL2 install might be the culprit.
Feel free to fetch one of my ZX Spectrum emulators and try them: the 'net is literally full of snapshots and tape images to play, including some really great gems of the past which still stand the test of time (remember Jetpac?).
I'll have a look at different SDL2 implementations and maybe - with a little luck - repack the software with the good one for my port.

Mentore

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5095
  • Karma: +117/-1
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #5 on: October 31, 2024, 01:20:03 am »
Looking at your package, fuse.exe uses SDL120.DLL

Dave Yeo

  • Hero Member
  • *****
  • Posts: 5095
  • Karma: +117/-1
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #6 on: October 31, 2024, 04:04:56 am »
So I tried building fuse. For spectrum I used these configure arguments,
Code: [Select]
--without-libgcrypt --prefix=/@unixroot/usr/local LDFLAGS="-Zomf -Zhigh-mem -lcx"
and for Fuse,
Code: [Select]
--prefix=/Fuse-160 --without-x --without-gtk --disable-gtk3 --with-sdl  LDFLAGS="-Zomf -Zhigh-mem -lcx" LIBS="-lbz2 -lz"  LIBSPECTRUM_CFLAGS=-I/@unixroot/usr/local/include LIBSPECTRUM_LIBS=-l/@unixroot/usr/local/lib/spectrum.a 2>&1 | tee configure.log
and had to add to peripherals/ttx2000s.c, in the include area around line 37,
Code: [Select]
#ifdef __OS2__
#include <libcx/net.h>
#endif

I see configure output,
Code: [Select]
checking whether SDL UI requested... yes
configure: WARNING: SDL 2 not supported for the UI, using SDL 1 instead
checking for sdl-config... /@unixroot/usr/bin/sdl-config
checking for SDL - version >= 1.2.4... yes
and at the end,
Code: [Select]
****************************
*** Libspectrum features ***
****************************

Internal GLib replacement: no
zlib support: yes
bzip2 support: yes
audiofile support: no

********************
*** Fuse options ***
********************

User interface: sdl
Using SDL 2: no
Joystick support: yes
Using libjsw for joystick support: no
zlib support: yes
libxml2 support: yes
libpng support: yes
Available audio drivers: sdl  null
Selected audio driver: sdl
Spectranet support: yes
SpeccyBoot support: no
TTX2000 S support: yes
Desktop integration: no

Type 'make' to compile Fuse

Unluckily, it crashes while, I think, trying to show the settings. fuse --help does work. Perhaps due to lack of utilities? All I feel like doing right now as I'm not really interested in the emulator.


Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #7 on: October 31, 2024, 09:11:30 am »
So I tried building fuse. For spectrum I used these configure arguments,
Code: [Select]
--without-libgcrypt --prefix=/@unixroot/usr/local LDFLAGS="-Zomf -Zhigh-mem -lcx"
and for Fuse,
Code: [Select]
--prefix=/Fuse-160 --without-x --without-gtk --disable-gtk3 --with-sdl  LDFLAGS="-Zomf -Zhigh-mem -lcx" LIBS="-lbz2 -lz"  LIBSPECTRUM_CFLAGS=-I/@unixroot/usr/local/include LIBSPECTRUM_LIBS=-l/@unixroot/usr/local/lib/spectrum.a 2>&1 | tee configure.log
and had to add to peripherals/ttx2000s.c, in the include area around line 37,
Code: [Select]
#ifdef __OS2__
#include <libcx/net.h>
#endif

I see configure output,
Code: [Select]
checking whether SDL UI requested... yes
configure: WARNING: SDL 2 not supported for the UI, using SDL 1 instead
checking for sdl-config... /@unixroot/usr/bin/sdl-config
checking for SDL - version >= 1.2.4... yes
and at the end,
Code: [Select]
****************************
*** Libspectrum features ***
****************************

Internal GLib replacement: no
zlib support: yes
bzip2 support: yes
audiofile support: no

********************
*** Fuse options ***
********************

User interface: sdl
Using SDL 2: no
Joystick support: yes
Using libjsw for joystick support: no
zlib support: yes
libxml2 support: yes
libpng support: yes
Available audio drivers: sdl  null
Selected audio driver: sdl
Spectranet support: yes
SpeccyBoot support: no
TTX2000 S support: yes
Desktop integration: no

Type 'make' to compile Fuse

Unluckily, it crashes while, I think, trying to show the settings. fuse --help does work. Perhaps due to lack of utilities? All I feel like doing right now as I'm not really interested in the emulator.

Thanks a lot Dave, I skipped the network support and some other things in order to obtain something working.
Quite possibly you are experiencing my same problem - SDL initialization fails due to SDL_LoadModes returning a 3 value array but with only one mode valid (the other two crash initialization).
I'll surely take your work into account as soon as I can.

Mentore

Lars

  • Hero Member
  • *****
  • Posts: 1367
  • Karma: +70/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #8 on: October 31, 2024, 07:28:27 pm »
Hi Mentore

I have not played any ZX Spectrum games in many years, would not mind having another go at pacman as I think the Speccy version was the best.

Starfighter (downloaded from hobbes) is an SDL2 game that runs in a window so SDL2 for OS/2 should not be fullscreen only.

However, Starfighter does not work with SDL2 files installed by ANPM - currently at 2.0.18-3 -   but requires an earlier package http://hobbes.nmsu.edu/download/pub/os2/dev/SDL2-2.0.4-20160225.zip in order to run.

So, I guess the question is: Are you using the right variant of SDL2?


Regards

Pete

Hi Pete,

1) I downloaded "Project_Starfigher_1-6.zip" from Hobbes
2) I have SDL2 version 2.28.1-1 installed, so that is newer than what you have. I got this either from Netlabs or Netlabs experimental as an RPM, you should be able to also install it.

That works just fine with USB audio as well as on board audio (UNIAUD). I can switch back and forth the default audio device and that also works just fine.

Pete

  • Hero Member
  • *****
  • Posts: 1352
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #9 on: October 31, 2024, 08:28:45 pm »
Hi Lars

I deleted the sdl2*.dll files that starfighter definitely uses and updated SDL2 to 2.28.1-1 then tried running Starfighter.
Result: Error window displayed stating Cannot start J:\Games.eCS\StarFighter\starfighter.exe ...

Dropped starfighter.exe onto the PMdll object which shows starfighter needs the following files to run
sdl2.dll
sdl2mix.dll
sdl2img.dll

The above are not included in SDL2 2.28.1-1
Maybe you already have those somewhere on the libpath? - Or am I missing some sort of "forwarder" dll file where calls to sdl2*.dll files get passed to sdl2200.dll?


Regards

Pete




David McKenna

  • Hero Member
  • *****
  • Posts: 814
  • Karma: +25/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #10 on: October 31, 2024, 09:12:44 pm »
Pete,

  You could try Digi's SDL ports found here: http://os2.snc.ru/product-SDL.html. Pretty sure they use the DLL names you list...

Regards,

Pete

  • Hero Member
  • *****
  • Posts: 1352
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #11 on: November 01, 2024, 01:16:01 am »
Hi David

Yes, have the latest of those already, Thanks. They work.


Regards

Pete

Lars

  • Hero Member
  • *****
  • Posts: 1367
  • Karma: +70/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #12 on: November 01, 2024, 09:41:02 am »
Hi Lars

I deleted the sdl2*.dll files that starfighter definitely uses and updated SDL2 to 2.28.1-1 then tried running Starfighter.
Result: Error window displayed stating Cannot start J:\Games.eCS\StarFighter\starfighter.exe ...

Dropped starfighter.exe onto the PMdll object which shows starfighter needs the following files to run
sdl2.dll
sdl2mix.dll
sdl2img.dll

The above are not included in SDL2 2.28.1-1
Maybe you already have those somewhere on the libpath? - Or am I missing some sort of "forwarder" dll file where calls to sdl2*.dll files get passed to sdl2200.dll?


Regards

Pete

Ah, ok. I was mislead by you stating that the SDL2 package installed by ANPM "does not work". I thought that that would trap your system or some such.
Now I see that the game uses a completely different SDL2 implementation (thanks OS/2 for being such a mess).
I found the mentioned SDL2 files in my \ecs\dll directory and they are from 2016. Likely the package that you also have installed. So no, you are not missing anything.

By the way, I find this newer package:
http://www.hobbesarchive.com/Home/Download?path=/Hobbes/pub/os2/dev/libraries/graphics/SDL2_2-0-4_2020-09-07.zip

Have you tried that or is it better to stick to the package from 2016 ?
« Last Edit: November 01, 2024, 09:45:00 am by Lars »

Pete

  • Hero Member
  • *****
  • Posts: 1352
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #13 on: November 02, 2024, 04:05:03 am »
Hi Lars

Installed the sdl2*.dll files from SDL2_2-0-4_2020-09-07 which work at least as well as the SDL2_2-0-4_20160225 files they replaced.
Going by file sizes and dates only sdl2.dll has changed.


Regards

Pete

Mentore

  • Full Member
  • ***
  • Posts: 224
  • Karma: +11/-0
    • View Profile
Re: [SDL2] SDL_ListModes and emulation
« Reply #14 on: November 05, 2024, 11:09:09 am »
Looking at your package, fuse.exe uses SDL120.DLL

Checked. Indeed it is as you say.
Funnily, I tried to re-configure and make and, lo and behold, the configure script expects SDL 1.2.4 and reports an error. So it seems I can't compile it this time (the only difference being trying to include network support).

Mentore