dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Compiling Error JFSW, Shadow Warrior port

Sat Nov 18, 2017 1:31 pm

I am trying to compile the source code for jsfw, a source port of Shadow Warrior on my Raspberry Pi 2 running RetroPie 4.3. These are the commands I have tried.

1. Get Dependencies

Code: Select all

sudo apt-get install build-essential libgl1-mesa-dev libgtk2.0-dev libsdl1.2-dev libvorbis-dev nasm timidity freepats git

2. Get Source

Code: Select all

git clone https://github.com/jonof/jfsw.git
cd jfsw
git clone https://github.com/jonof/jfbuild.git
git clone https://github.com/jonof/jfaudiolib.git
git clone https://github.com/jonof/jfmact.git
3. Compile Source Code

Code: Select all

make

When I try to compile the code, I get the error message below:

Code: Select all

/usr/bin/ld: jfbuild/src/libengine.a(a.o): Relocations in generic ELF (EM: 3)
jfbuild/src/libengine.a: error adding symbols: File in wrong format
collect2: error: ld returned 1 exit status
Makefile:225: recipe for target 'sw' failed
make: *** [sw] Error 1
Any advice on how this can be fixed would be appreciated. Thanks.

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Mon Nov 19, 2018 3:53 am

(Exactly one year later)

If you look at the source for a.nasm, it's x86 assembly which certainly won't work on the Pi. The solution is to remove a.o + libengine.a and continue building with make NOASM=1

I came across and had to fix other build annoyances like a conflicting declaration for startwin_run(), undefined joynumhats, missing the LIBS setting on the final link step, and for data files you've got to make sure sw.{grp,rts} are named in lowercase.

Can't complain too much though. Thanks to you, I can play Shadow Warrior on my Pi 3B+.

dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Re: Compiling Error JFSW, Shadow Warrior port

Mon Nov 19, 2018 12:34 pm

Thanks for the reply!

I tried building JFSW but I got the following error:

Code: Select all

src/game.c:934:12: error: conflicting types for ‘startwin_run’
 extern int startwin_run(void);
            ^~~~~~~~~~~~
In file included from src/game.c:45:0:
jfbuild/include/baselayer.h:30:12: note: previous declaration of ‘startwin_run’ was here
 extern int startwin_run(struct startwin_settings *);
            ^~~~~~~~~~~~
Makefile:238: recipe for target 'src/game.o' failed
make: *** [src/game.o] Error 1

I presume this relates to the startwin_run error you mention. I don't have the expertise to fix these type of errors, and the others you mentioned. I am not 100% certain what you mean by removing a.o + libengine.a but I was prepared to give it a go.

I was wondering if it was possible to fork the Github repos with fixes put in to make building JFSW on the Pi more straightforward, particularly for general users like myself, who carry out the fixes whilst compiling.

In the meantime, I was wondering if you would kind enough to share your JFSW binary for me to test.

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Mon Nov 19, 2018 5:09 pm

Okay, pushed my changes! https://github.com/jdonald/jfsw/commit/ ... 7db5c45fc6 New instructions:

Code: Select all

sudo apt-get remove nasm # because you won't need it
sudo apt-get install build-essential libgl1-mesa-dev libgtk2.0-dev libsdl2-dev libvorbis-dev timidity freepats git
git clone https://github.com/jdonald/jfsw.git
cd jfsw
git submodule init
git submodule update
make
If you immediately run ./sw you may see the error about missing TABLES.DAT and the game data. To obtain sw.grp (which embeds TABLES.DAT) and sw.rts, I did sudo apt install dosbox and used that to run INSTALL.EXE from the freely available 3dsw12.zip

I saw jonov updated the jfbuild repo in just the last two days, so I'll see if I can get these fixes pushed upstream.
dudleydes wrote:
Mon Nov 19, 2018 12:34 pm
In the meantime, I was wondering if you would kind enough to share your JFSW binary for me to test.
Here you go: https://github.com/jdonald/jfsw/releases
Last edited by jdonald on Mon Nov 19, 2018 9:04 pm, edited 3 times in total.

dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Re: Compiling Error JFSW, Shadow Warrior port

Mon Nov 19, 2018 8:39 pm

Thank you for your prompt response.

I am testing on the RetroPie 4.4 image which runs on Raspbian Lite (Stretch 9.4 Linux 4.14.30-v7+) so is missing the desktop environment.

When I run ./sw from the terminal, I get an error message regarding being unable to create GLES window surface. I'm thinking jfsw needs to be run from the desktop?

I tried to build from source following your new instructions but this too failed. These are the last few lines of the output:

Code: Select all

src/startgtk.game.c: In function ‘startwin_run’:
src/startgtk.game.c:720:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.fullscreen = ScreenMode;
             ^
             ->
src/startgtk.game.c:721:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.xdim3d = ScreenWidth;
             ^
             ->
src/startgtk.game.c:722:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.ydim3d = ScreenHeight;
             ^
             ->
src/startgtk.game.c:723:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.bpp3d = ScreenBPP;
             ^
             ->
src/startgtk.game.c:724:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.forcesetup = ForceSetup;
             ^
             ->
src/startgtk.game.c:725:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.usemouse = UseMouse;
             ^
             ->
src/startgtk.game.c:726:13: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     settings.usejoy = UseJoystick;
             ^
             ->
In file included from /usr/include/string.h:630:0,
                 from src/startgtk.game.c:9:
src/startgtk.game.c:727:21: error: ‘settings’ is a pointer; did you mean to use ‘->’?
     strncpy(settings.selectedgrp, grpfile, BMAX_PATH);
                     ^
     ->
src/startgtk.game.c:734:30: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         ScreenMode = settings.fullscreen;
                              ^
                              ->
src/startgtk.game.c:735:31: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         ScreenWidth = settings.xdim3d;
                               ^
                               ->
src/startgtk.game.c:736:32: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         ScreenHeight = settings.ydim3d;
                                ^
                                ->
src/startgtk.game.c:737:29: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         ScreenBPP = settings.bpp3d;
                             ^
                             ->
src/startgtk.game.c:738:30: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         ForceSetup = settings.forcesetup;
                              ^
                              ->
src/startgtk.game.c:739:28: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         UseMouse = settings.usemouse;
                            ^
                            ->
src/startgtk.game.c:740:31: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         UseJoystick = settings.usejoy;
                               ^
                               ->
src/startgtk.game.c:741:27: error: ‘settings’ is a pointer; did you mean to use ‘->’?
         grpfile = settings.selectedgrp;
                           ^
                           ->
Makefile:247: recipe for target 'src/startgtk.game.o' failed
make: *** [src/startgtk.game.o] Error 1

There's no need to install DOSBox as the sw.grp and sw.rts files can be extracted using unzip and renamed to lower case as below:

Code: Select all

unzip 3dsw12.zip SWSW12.SHR
unzip SWSW12.SHR SW.RTS SW.GRP
rm 3dsw12.zip SWSW12.SHR
rename 'y/A-Z/a-z/' *

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Mon Nov 19, 2018 9:39 pm

dudleydes wrote:
Mon Nov 19, 2018 8:39 pm

Code: Select all

unzip 3dsw12.zip SWSW12.SHR
unzip SWSW12.SHR SW.RTS SW.GRP
rm 3dsw12.zip SWSW12.SHR
rename 'y/A-Z/a-z/' *
Awesome, and now I'm glad to learn the proper idiom to change files to lowercase.

I think I messed up an earlier commit and got the settings variable name conflict when I tried on gcc 5. I just pushed a fix so you can pull and try the latest.
dudleydes wrote:
Mon Nov 19, 2018 8:39 pm
When I run ./sw from the terminal, I get an error message regarding being unable to create GLES window surface.
If you're talking to the Pi via ssh or other headless connection, you can try DISPLAY=:0 ./sw

dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Re: Compiling Error JFSW, Shadow Warrior port

Thu Nov 22, 2018 10:40 am

Thanks for the update. I have managed to compile a binary and successfully launched JFSW in Raspbian. If I try to launch from the CLI, I can only do so by using sudo xinit ./sw. If xinit is not used, then I get a no available video device error. It's apparent that the desktop is required.

On my Pi 2, I could only get JFSW running at a decent rate in 320x240 windowed mode. Running in full screen was impossible. This surprised me as Shadow Warrior was playable using RetroPie's DOSBox SVN build with the frameskip set to 1.

I thought the advantage of source ports is that they could run old games smoothly at higher resolutions than what's possible in DOSBox. This is certainly the case with the ones I tried so far, such as Crispy Doom, eDuke32 and DXX-Rebirth, which even ran pretty well on a Pi 1. All of these run from the command line so would running JFSW in similar fashion, without the overhead of the desktop, improve performance?

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Thu Nov 22, 2018 10:27 pm

I don't have a Pi 2 on hand to test with, but some of those other ports you've named have been specially targeted for the Pi and rely on the legacy Broadcom GLES driver. When I switch to the legacy driver on a Pi 3B+ I get extreme slowdowns similar to what you're describing, plus brcmEGL is the default for RetroPie so I suspect this could be the problem.

Could you make sure to run sudo raspi-config, select the full OpenGL driver with KMS, reboot, sudo apt install mesa-utils, run glxgears and confirm that OpenGL renders at close to 60 fps? Then try Shadow Warrior again.

The drawback of enabling full OpenGL is that it breaks many games on Retropie, but if it turns out we're on the right track it may be possible to use a fork of SDL2 that renders via brcmEGL. That would also solve the desktop requirement inherent in SDL2's default SDL_VIDEODRIVER=x11

dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Re: Compiling Error JFSW, Shadow Warrior port

Sun Nov 25, 2018 11:37 am

After enabling the full OpenGL driver with KMS and rebooting, I can get JFSW running smoothly, even at a resolution of 1024x768 fullscreen though the audio isn't great. In addition, when I run glxgears, I am getting a consistent 60fps.

It would be great if we could get JFSW rendering via brcmEGL so that I can include it in my RetroPie build, though not necessarily at 1024x768. If you have any code modifications, then I would be happy to test.

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Sun Nov 25, 2018 10:05 pm

It turns out SDL2 (main repo, not a fork) can be compiled with --enable-video-rpi while disabling the other video modes. That's enough for games like Duke Nukem to launch without a DISPLAY variable set.

However, unlike eduke32, jfsw does not readily build with OpenGL disabled. From what I can tell JonoF isn't testing that configuration and may have dropped support for USE_OPENGL=0 a long time ago. It would take a lot of effort to restore this in both jfsw and jfbuild. The software renderer + brcmEGL also wouldn't perform as well as we're currently seeing with OpenGL, although hypothetically it would still be smoother than dosbox.

It bothers me too that the sound cuts out. The sound quality is fine with jfsw on Linux x86 plus eduke32's audio works on the Pi, so I don't have an explanation.

edit: JonoF just replied on the GitHub ticket. The project is active and planned to have support for both GLES2 and USE_OPENGL=0! In theory the GLES2 branch of jfbuild will make a performant Retropie build more viable with the legacy driver.

User avatar
jonof
Posts: 3
Joined: Mon Dec 03, 2018 10:16 pm
Contact: Website

Re: Compiling Error JFSW, Shadow Warrior port

Wed Dec 05, 2018 7:50 am

Folks, the Pi I have ordered is currently on its way, so once I get acquainted with it and test the changes, I'll post an update here. If you're particularly impatient, there's the jfbuild-update branch in the jfsw repository which should get you a non-OpenGL, non-Polymost (non-assembly-code) variant built. It cross-compiles for me for armhf and arm64 on Debian 9.

Jonathon

dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Re: Compiling Error JFSW, Shadow Warrior port

Thu Dec 06, 2018 10:48 am

Thank you, Jonathon, for a quick update. I have successfully built jfsw on my Pi 3 running RetroPie and I have been able run the shareware and full version of Shadow Warrior smoothly, even at the higher resolutions. There are a couple of minor issues though.

Is it possible to launch the sw binary in quiet mode, suppressing the output, mainly relating to available resolutions? Many RetroPie users, myself included, prefer a console-like experience. I tried launching with ./sw >/dev/null without luck.

I cannot get my PS3 controller to work either in the menu or in-game. It's detected by the binary but I'm not getting any input from it. Maybe I'm missing something. Also, some of the default keymappings - move, turn, fire - were not assigned though I was able to do so in the options menu.

For those interested in building jfsw, these are the commands I used:

Code: Select all

git clone -b jfbuild-update https://github.com/jonof/jfsw.git
cd jfsw
git submodule init
git submodule update
make USE_POLYMOST=0 USE_OPENGL=0
PS. Thanks also @jdonald for reviving this thread and submitting your fixes.

EDIT: I have managed to get my controller working. While setting the directory containing the OGG music files in the config file /home/pi/.jfsw/sw.cfg, I found the setting UseJoystick which I changed from 0 to 1. The analog sticks were far too sensitive so I have reduced the joystick scales in the config file to 32767, the value obtained when running jstest.

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Sun Dec 09, 2018 7:43 am

Welcome to the Pi forums, Jonathon!
dudleydes wrote:
Thu Dec 06, 2018 10:48 am
I tried launching with ./sw >/dev/null without luck.
Strange, the redirect works for me whether to /dev/null or a file. There are only a few remaining prints to stderr regarding SDL/ALSA so you can suppress both stdout+stderr with ./sw >& /dev/null

I see the sound quality is fine in this config. That leaves me wondering why the sound cuts out only in the OpenGL build.

dudleydes
Posts: 51
Joined: Sun May 18, 2014 12:19 pm

Re: Compiling Error JFSW, Shadow Warrior port

Sun Dec 09, 2018 9:42 am

I have revisited the launching of jfsw and, after a reboot, the redirect seems to be working fine.

User avatar
jonof
Posts: 3
Joined: Mon Dec 03, 2018 10:16 pm
Contact: Website

Re: Compiling Error JFSW, Shadow Warrior port

Tue Dec 11, 2018 11:28 am

After some playing around, I've determined that I have a lot more work to do on the OpenGL side of JFBuild. The Pi's GPU really doesn't like the kind of rendering I'm asking of it at the moment, so Polymost on the Pi appears hopeless for the moment. However, I've tested a number of combinations of Pi config and compile options and it seems that these are the ideal choices:
  • With the vc4 driver disabled: make USE_OPENGL=0 USE_POLYMOST=0 CFLAGS="-march=native"
  • With the vc4 driver enabled: make USE_OPENGL=0 USE_POLYMOST=0 CFLAGS="-march=native -DSDLAYER_USE_RENDERER"
For rendering 8-bit modes with the GL driver enabled, the GLES branch is faster again, but I don't want to merge that code until I come up with a better implementation that's more suited to a tile-based GPU.

Also, I enabled the JFSW joystick option by default. The master branches of the jfbuild and jfsw repos are updated with the work done so far. I haven't got audio connected to my Pi yet so I don't know how well/badly it works.

Jonathon

User avatar
jonof
Posts: 3
Joined: Mon Dec 03, 2018 10:16 pm
Contact: Website

Re: Compiling Error JFSW, Shadow Warrior port

Wed Dec 19, 2018 5:50 am

Folks, this branch should give you a decently playable OpenGL ES Polymost experience at 1280x720 in a VT with the non-Gallium-based video driver using a non-X11-enabled SDL2 build.

You can build it with:

Code: Select all

make USE_OPENGL=USE_GLES2 USE_POLYMOST=1 SDL2CONFIG=/path/to/other/sdl2-config CFLAGS=-march=native
After I've done some more testing, I'll merge it into the master branch.

Cheers
Jonathon

Edit: voxels are now working properly in GL mode.

jdonald
Posts: 133
Joined: Fri Nov 03, 2017 4:36 pm

Re: Compiling Error JFSW, Shadow Warrior port

Thu Dec 20, 2018 6:26 pm

That build works smoothly for me with the legacy driver, and with OpenGL enabled it seems to work well on that branch built as:

Code: Select all

make USE_OPENGL=1 USE_POLYMOST=1 CFLAGS="-march=native -DSDLAYER_USE_RENDERER"
The sound issues seem to be fixed as well.

Great work, Jonathon.

Return to “Gaming”