Wine and the WINEPREFIX variable

## DESCRIPTION ##

I've installed a lot of Wine-based applications...games mostly. To name just a few, I've succesfully installed/played the following: Doom3, Jedi Knight 2 Outcast, Jedi Knight: Jedi Academy, Max Payne, Max Payne2, Return To Castle Wolfenstein, Quake4, StarCraft and WarCarft 3. Each of those, I installed in a very similar way. I thought it would be good to document how I did it. Keep in mind, most of the games are pretty self-contained, and didn't require any 3rd party dependencies. Also, I'm pretty sure all of this is NOT required to do. I simply chose to do it this way, because I like having everything all in it's own little sub-directory, and didn't want to worry about apps conflicting with apps. The other HUGE benefit of doing it this way, is once you are all done....you can tar up the directory and easily have a "ready-to-play" backup/copy of the game :exmark:

 

## PROCEDURE ##
(I'll use Jedi Academy as an example, so just change the name where necessary)

1.) First, I create a directory where I want the game to be installed:

mkdir /home/lupine/Games/JediAcademy

2.) Next, prep this directory for Wine

export WINEPREFIX=/home/lupine/Games/JediAcademy
winecfg

When you launch winecfg, the Wine configuration window should pop up. Under the "Drives" tab I click Autodetect. And then I switch over to the "Audio" tab and make sure that ALSA Driver is the only one checked. Sometimes "Full" Hardware Acceleration won't work, so I have to switch it over to "Emulation". That sometimes causes a crackling noise though, so try out Full first. Another good option to select is the "Graphics" tab and enable the "Emulate a virtual desktop" and set the resolution.  Once you are done with all that, click OK to save the changes.

3.) Now it's time to mount the CD and install the game

sudo mount -o loop cd1.iso /media/cdrom
wine /media/cdrom/JediAcademy.exe

From here just follow the instructions to install the game normally. However, I would suggest one TIP. When it asks you where to install the game, I suggest installing it to a customized place. I always do so on the root of the "C:\" drive in a one-word folder. (e.g. c:\JediAcademy) This will make the launcher script we'll write later, easier.

4.) Once the installation is done, dismount the ISO:

sudo umount /media/cdrom

5.) For some of us, that don't have the original CD anymore, or just like to use ISOs all the time....like I do...you'll need to write a little script to launch the game. For the rest of you, you can stop here and look under you application list. You should have a new menu called "Wine" and within that, you'll find you newly installed application.

For us ISO users, I'll continue on with the following. First, I cd into the game directory:

cd $WINEPREFIX

6.) I then copied the ISO into this directory:

cp /path/to/cd1.iso ./

7.) Next I went out and found whatever "no-cd patch" I needed to get the game to work with a loop mounted ISO file

8.) Finally, I wrote a little script to automatically loop-mount the ISO, launch the game and then dismount the ISO when I was all done:

#!/bin/sh

SCRIPT=$0
GAME_DIR=`dirname $SCRIPT`
cd $GAME_DIR
WINEPREFIX=`pwd`

##JediAcademy
sudo mount -o loop cd1.iso /media/cdrom
EXE="JediAcademy.exe"
DIR=$GAME_DIR"/drive_c/JediAcademy"
cd $DIR
WINEPREFIX="$WINEPREFIX"
wine $EXE
sudo umount /media/cdrom

 

9.) Save this script in the root of the $WINEPREFIX direcotry, and make sure you make it executable.

10.) From there, I usually just make a launcher that points to my script....and give it an icon that I rip from the executable, and I'm good to go

 

## CONCLUSION ##

This is a pretty straight forward process, and like I said it has worked for me on all those games listed up top. The most difficult part sometimes, is just finding the correct no-cd patch Wink