Friday, 23 January 2015

Install Wolf4SDL

In this tutorial, I will show how to download and install the Wolfenstein 3D port, wolf4sdl as well as how to integrate it into Retropie.



A Quick Word about the Versions of Wolfenstein 3D


Wolf4sdl came already installed on my Retropie 1.9 build but is no longer included in version 2.x.  It's easy to see why. When I installed wolf4sdl on my desktop, five binaries were installed, one each for the different versions of the game. On the pi, there is one binary, wolf3d, for all versions of the games. As a result, the Retropie 1.9 pre-compiled binary would only work for one (unspecified) version of the game.

Compiling the wolf3d binary takes less than five minutes and to do so is straightforward. The short compile times means it can be repeated until the right one for your version of Wolfenstein 3D is obtained.

Build Wolf4sdl binary for your version


If you are not using Retropie, then it's likely that you will need to install the SDL development libraries by running the command below.

sudo apt-get install libsdl1.2-dev libsdl-image1.2-dev libsdl-mixer1.2-dev libsdl-ttf2.0-dev

Obtain the source code and unzip the data with following commands.

wget https://sites.google.com/site/dosonthepi/master.zip
unzip master.zip


Before you compile, you need to edit the source code to create a binary for the version of your game data. The file to edit is version.h in the wolf4sdl-master folder. To do this, run the following commands.

cd wolf4sdl-master
sudo nano version.h

The lines to edit are 10 to 12. If you brought the full version of Wolfenstein 3D 1.4 from 3D Realms, then you need to leave line 16 uncommented as below.
 
//#define UPLOAD
//#define GOODTIMES
#define CARMACIZED

If you have the full version 1.4 from GT interactive, ID or Activision, then you need to leave line 15 uncomment as well.

//#define UPLOAD
#define GOODTIMES
#define CARMACIZED

If you have shareware version, have versions other than 1.4 or wish to create a binary for Spear of Destiny, then refer to lines 22 to 31 in version.h to find which lines to leave uncommented.

Save your changes to version.h. To compile, run the following command.

make

As mentioned earlier, the compile will take no more than five minutes. Once done, there will be a binary called wolf3d in the wolf4sdl-master folder.

Set up and Run Wolf4sdl


The source data is no longer required so to keep things tidy, create a new folder, wolf3d, in the home directory and copy the wolf3d binary to this folder.

cd ~
mkdir wolf3d
cp /home/pi/wolf4sdl-master/wolf3d /home/pi/wolf3d/wolf3d

The game data needs to be in the same folder as the binary so copy the game data to the wolf3d folder. The game data needs to be placed in /usr/share/games/wolf3d folder. If you are using the full version, the file extensions will be *.WL6. Change the working directory to the one containing the game data and run the following command.

sudo cp -r *.wl6 /usr/share/games/wolf3d/

For shareware versions,  the game extensions are *.WL1 so change *.wl6 to *.wl1 in the command above.

Before you can run the game, all filenames need to be changed to lowercase. As a check, the data files required are:

  • audiohed.wl6
  • audiot.wl6
  • config.wl6
  • gamemaps.wl6
  • maphead.wl6
  • vgadict.wl6
  • vgagraph.wl6
  • vgahead.wl6
  • vswap.wl6

Now run the following commands to check that Wolfenstein 3D runs.

cd wolf3d
./wolf3d --res 640 480
 
If the game runs fine, then you can now delete the source code in the wolf4sdl-master folder if you wish.

Troubleshooting


It's likely that you will have to play around with both versions of the version.h file described above before you get the right binary.

NO WOLFENSTEIN 3-D DATA FILES to be found!

Check that the *.wl6 data files are in the same directory as the wolf3d binary and their names are in lowercase. If they are and you are still getting this error, then re-edit the version.h file (see above) and recompile.

ps you forgot to update NUMCHUNKS

If you receive this error, then it's likely that you have a binary for the wrong version. Re-edit the version.h file (see above) and recompile.

 If this does not resolve the problem, then try again with a different source for your game data.

Integration into Retropie


Ports in Retropie 2.x now use shell scripts to launch games in emulationstation. Do the same for Wolf4sdl by using the commands below to create a script, wolf3d.sh.

cd ~/RetroPie/roms/ports
sudo nano wolf3d.sh

Copy and paste the code below.

#!/bin/bash
cd /home/pi/wolf3d
/opt/retropie/supplementary/runcommand/runcommand.sh 0 "./wolf3d --res 640 480"

Save and exit. Next make the wolf3d.sh executable so it can be launched from emulationstation.

sudo chmod +x wolf3d.sh

Restart emulationstation and Wolfenstein 3D will appear in the Ports category.

If you are running Retropie version 2.3 or earlier, then it's probable that you will see a black screen on game exit and the pi can only be rebooted through a power cycle. In which case, you can fix this by either getting the latest Retropie image or carrying out the following updates on your existing image:
  • Update the Retropie binaries by choosing option 6 in the Retropie setup script;
  • Update the runcommand.sh script.

25 comments:

  1. I have a problem with the command "make":

    SDL_mixer.h: no such file or directory.....

    ReplyDelete
    Replies
    1. It appears that you may not have the SDL development libraries installed on your system. I've updated the tutorial. Apologies, I assumed most folk would be using Retropie which has the libraries pre-installed.

      Delete
  2. I tested wolf3D and it works now!
    Can you explain me how to configure the joypad please??

    ReplyDelete
  3. Thanks for posting! My installation stops when I try to install the SDL dev libraries. It can't find the file libflac-dev_1.2.1-6_armhf.deb (404 Not found). Although there is a libflac-dev_1.3.0-3_armhf.deb on mirrordirector. How can I use this file instead?

    ReplyDelete
    Replies
    1. I'm not a Linux expert so I can't give a definitive solution.

      As far I understand, libflac-dev is a dependency of the libsdl-mixer1.2-dev package. I think the dependency required is libflac8_1.2.1-6+deb7u1_armhf.deb. I have just installed it on my system with without issue.

      Maybe you could check your /etc/apt/sources.list file. It should have one line:

      deb http://mirrordirector.raspbian.org/raspbian/ wheezy main contrib non-free rpi

      If it doesn't, then you should update your packages list with sudo apt-get update. If that doesn't help, then you can try apt-get install --fix-missing to download and install any missing packages on your system.

      If this doesn't help, you could try this thread on apt-get 404 errors at the raspberry pi forum to see if you find anything useful.

      If you're happy installing a .deb package, you could use gdebi. Install using sudo apt-get install gdebi and use with command: sudo debi package.deb.

      Delete
    2. Here's the URL to the apt-get 404 errors thread at the Raspberry Pi forum.

      http://www.raspberrypi.org/forums/viewtopic.php?f=28&t=71998

      Still getting used to posting Blogger comments!

      Delete
    3. I know, I'm having trouble with blogger too. I had to reply 3 times to get it right. Thanks for the info. Once I did...

      sudo apt-get update

      ...everything compiled like it should have. Although I did have to run it at a lower resolution or I'd get a blank screen.

      ./wolf3d --res 320 200

      Just curious if there are any other useful command line switches to use?

      Delete
    4. I think a resolution of 320 x 200 is default. I suppose it depends on your video output as what the best resolution will be.

      You can find the command line options in the README.txt file or at the Wolf4SDL github.

      https://raw.githubusercontent.com/mozzwald/wolf4sdl/master/README.txt

      Delete
  4. If I play wolf3D with your script in retropie a red screen appers when I exit the game. And I have to reboot my raspberry every time. Do you have the same problem?

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. This comment has been removed by the author.

      Delete
    3. I still had the problem though it was a black screen rather than a red one. It was strange because if Wolf3D was the first game I played after booting, then I'd get the black screen. If it wasn't, then I could return to ES without a problem.

      I have updated the Integration into Retropie section above with a new shell script and the updates you need to do to make sure the script will work. I have tested it on my system and everything is working fine.

      Delete
    4. Thanks. Now it works!!

      Delete
  5. I think you should add a post for games like Doom, Hexen and Heretic in your blog.
    In this page there is the script to install crispy-doom...

    http://www.raspberrypi.org/forums/viewtopic.php?f=78&t=96732

    ReplyDelete
    Replies
    1. Thanks, alb. I shall put it on my list.

      Delete
  6. I have tried both settings and about 5 different versions, but cant get it to work, always says "NO GAME DATA FOUND"

    someone please help me :(

    ReplyDelete
    Replies
    1. Even with my official version from 3drealms says the same...im running BETA2 for raspberry pi2 if any help...

      Delete
  7. The options in editing the version.f file I have given above are not the only ones available. You need to refer to lines 22 to 31 for a full list. I have Wolf3d shareware v1.4 so I needed to define CARMACIZED and UPLOAD, i.e. leave them uncommented.

    I would remove your wolf3d binary and recompile a fresh one by defining CARMACIZED for the official 3d realms version. Then you need to make sure that the game data is in the same folder as the wolf3d binary and has been renamed in lower case.

    If this is unsuccessful, you can try using DOSBox. As you have the Rpi2, I don't think you should any issues with performance.

    ReplyDelete
  8. Im going out of my mind trying to get this working...

    I have recompiled it with -

    /* Defines used for different versions */

    //#define SPEAR
    //#define SPEARDEMO
    #define UPLOAD
    //#define GOODTIMES
    #define CARMACIZED
    //#define APOGEE_1_0
    //#define APOGEE_1_1
    //#define APOGEE_1_2

    /*
    Wolf3d Full v1.1 Apogee (with ReadThis) - define CARMACIZED and APOGEE_1_1
    Wolf3d Full v1.4 Apogee (with ReadThis) - define CARMACIZED
    Wolf3d Full v1.4 GT/ID/Activision - define CARMACIZED and GOODTIMES
    Wolf3d Shareware v1.0 - define UPLOAD and APOGEE_1_0
    Wolf3d Shareware v1.1 - define CARMACIZED and UPLOAD and APOGEE_1_1
    Wolf3d Shareware v1.2 - define CARMACIZED and UPLOAD and APOGEE_1_2
    Wolf3d Shareware v1.4 - define CARMACIZED and UPLOAD
    Spear of Destiny Full and Mission Disks - define CARMACIZED and SPEAR
    (and GOODTIMES for no FormGen quiz)
    Spear of Destiny Demo - define CARMACIZED and SPEAR and SPEARDEMO

    and have the 1.4 shareware version, and all the files are in the .wolf3d (home folder) and it still doesn't work...

    Can someone try this on their pi and let me know if it works?
    https://www.dropbox.com/s/m5vw3m2bj2yf47m/wolf.rar?dl=0

    its the wolf3d binary that was created for me and all the data files im using from the 1.4 shareware version..

    thanks

    ReplyDelete
    Replies
    1. Do you want to try this binary for the 1.4 shareware version? I'll try to compile a new binary myself over the weekend to see if there have been any changes in source code..

      Have you tried running your versions of wolf3d in DOSBox? It's a lot more straightforward. There's no need to worry about the version of the game you have or whether you have a working binary. Just run it as you would any other DOS game.

      Delete
    2. mate that worked, I don't know what it is I am doing wrong...

      Can you possibly build me a version for the full 3drealms version?

      Thanks

      Karl

      Delete
    3. Hi Karl

      I have noticed that there have been recent changes to the source code. The binary now requires the game data to be placed in the /usr/share/games/wolf3d folder. Do you want to test this with the shareware version before trying to compile a binary for the 3drealms version?

      I'm going to try to fork the wolf4sdl repo so that it is consistent with the RetroPie file structure. It may take some time as I've never done something like this before!

      Delete
    4. Recomplied the full version and put data files in /usr/share/games/wolf3d ... No game data found again :(

      Delete
    5. I also compiled a shareware version again, and placed the data files that worked with your binary into usr/share/games/wolf3d, but that didn't work either...so something is not right somewhere....

      Delete
  9. This comment has been removed by a blog administrator.

    ReplyDelete