Linuxdoc Linux Questions
Click here to ask our community of linux experts!
Custom Search

10. Emulation and Virtual Machines

Linux gets ragged on a lot because we don't have the wealth of games that other platforms have. Frankly, there's enough games for me, although it would be really nice to have some of the bleeding edge games and classics like Half-life and Carmageddon. Fortunately, we have more emulators than you can shake a stick at. Although playing an emulated game is sometimes not quite as fun as playing it on the native machine, and getting some of the emulators to work well can be a difficult task, they're here, and there's alot of them!

10.1. What is a virtual machine?

A "real computer" provides an operating system many things, including a CPU, I/O channels, memory, a BIOS to provide low level access to motherboard and I/O resources, etc. When an operating system wants to write to a hard drive, it communicates through a device driver that interfaces directly with the hardware device memory.

However, it's possible to give a program all the hardware resources it needs. When it wants to access a hard drive, give it some memory to write to. When it wants to set an IRQ, give it some bogus instructions that lets it think it set an IRQ. If you do this correctly, then in principle, there's no way for the poor application to know whether it's really accessing hardware or tricked by being given resources which simulate hardware. A virtual machine is the environment which tricks applications into believing they're running on a real computer. It provides all the services that a real computer would provide.

VM's were used initially in the 1960's to emulate time shared operating systems, but these days we use them to run software which was written for foreign operating systems, or more commonly, an entire operating system. Because of the nature of the VM, the foreign OS can't tell the difference between operating in a VM or in a "real" machine.

10.2. Apple 8-bit

All the 8-bit Apple ][ emulators require a copy of the original ROM, for whichever system you want to emulate, in a file. If you search hard enough, you can find file copies of the ROMs for the Apple ][, ][+, ][e, ][c and //gs. They are still copyrighted by Apple, and you can only use them legally if you actually own one of these computers.

10.2.1. KEGS

KEGS is an Apple II emulator written by Kent Dickey which was originally written for HP-UX, but improved and customized for Linux. It runs under X at any color depth, and supports changeable memory sizes, joysticks, and sound. KEGS boots all Apple II variants, and supports all of the Apple ]['s graphics modes. I can't find a working homepage for this application.

10.2.2. apple2 and xapple2

The SVGAlib based apple2 and X based xapple2 can emulate any Apple ][ variant except for the //gs. The interface is a bit funky, but usable. Configuration is also a bit funky; this emulator would benefit from an SVGA or X based configuration tool. It supports the undocumented portion of the 6502 instruction set which some games rely on. apple2 is currently being maintained by Michael Deutschmann and seems to be developed at a slow but constant pace. I don't think this application has a homepage.

10.3. DOS

10.3.1. dosemu

dosemu <http://www.dosemu.org> is the canonical DOS emulator on Linux. When you think of DOS, don't think of things like PROCOM PLUS OR OTHER PROGRA~1 WHICH HAVE SHORT NAMES AND ARE IN ALL CAPS. There are some real classics that were written for DOS like Carmageddon, Redneck Rampage and Tomb Raider. dosemu can run these. Unfortunately, it can take alot of effort to get dosemu to work, and of Jan 2002, the sound code is somewhat broken. Not a big deal when you're trying to run Wordperfect or an old database application. It's an absolute show stopper for gaming. Getting dosemu to work well is not easy, but unfortunately, for DOS games it's the best avenue. Good luck. If you have success using dosemu, I would like to hear from you.

10.4. Win16

10.4.1. Wabi

Wabi is a commercial Win16 emulator. That is, it'll run Windows 16-bit applications from a Windows 3.1, Windows 3.11 or Windows for Workgroups 3.11 environment. Wabi was originally created by SCO Unix a long time ago and then was purchased by Caldera sometime in mid year 2001.

Wabi is fast and does a good job for what it does, although I've heard it said that wabi for Solaris is more stable than Linux. It might be useful for playing older Win16 games, but there are three problems:

  • You must have a licensed copy of Windows 3.1/3.11 or WfW 3.11.

  • Wabi is awfully expensive for what it does.

  • Wabi doesn't work under 32bpp or 24bpp color.

Wabi does NOT do DOS itself, but it looks like it can use a DOS emulator as a backend for running DOS programs. There was talk about Wabi 3.0 which would've done Win32 emulation, but AFAIK, this project was shelved indefinitely. I think Wabi will run under Linux on all architectures (can someone verify this?)

10.5. Win32

10.5.1. wine

Wine <http://www.winehq.com>, which bears the GNUish acronym "Wine Is Not An Emulator" is a non-commercial implementation of the Win32 API. The reason why it's not an emulator is subtle and not of much interest to most non computer scientists, so we'll call it an emulator here (it really does run-time translation of calls to the Win32 API to POSIX/X11 calls). Wine has come a long way, and is capable of emulating many important programs, which is great news for Linux users who want this sort of stuff.

Wine does not provide the DOS API, so you can't use it to run DOS applications. For that, you should look at dosemu (Section 10.3.1). Wine has never been too good at implementing DirectX, although a number of games are known to work under wine. For gaming you might want to look at winex (Section 10.5.3).

In addition to run-time translation of the Win32 API to POSIX/X11 (it runs Windows applications on Linux), wine also does compile-time tranlation of the Win32 API to POSIX/X11 (it compiles Windows application source code on Linux). In this sense, wine is a Windows-to-Linux porting utility. The x86 architecture isn't required, but is recommended since it allows actual x86 binary execution as well as direct DLL usage).

You can use wine `with Windows', which means that wine uses libraries that actually come with Microsoft Windows itself. This is legal only if you own a copy of Windows which isn't currently being used on a computer. It's said that wine has the best success when run with Windows. You can also run wine without Windows. The people at winehq are writing their own set of libraries called libwine which implements the Win32 API with no Microsoft code at all.

Wine was originally licenced under the MIT/X11 license, so it could be used for both commercial and non-commercial purposes. In mid 2002, parts of wine were re-licensed under the LGPL so that it could only be used for non-commercial puposes. This presents a problem for companies like Transgaming (Section 10.5.3) and prompted a fork of wine called ReWind (Section 10.5.2).

10.5.2. rewind

Rewind <http://rewind.sourceforge.net/> was started by Eric Pouech (a wine developer) and Ove Kåven (a winex developer) in response to wine's license change). It started out life as a snapshot of the last version of wine which was completely licensed under the MIT/X11 license. The aim is to keep rewind MIT/X11 based so that companies like Transgaming can offer wine based products.

10.5.3. winex

Winex is released by a company called Transgaming <http://www.transgaming.com>. The developers take wine (see Section 10.5.1) and add DirectX / DirectDraw support. Although winex is commercial, they have an interesting business model.

The end user (you) can download the source code for free. However, for 5 US dollars per month, you can become a subscriber of Transgaming. Being a subscriber of Transgaming gives three major benefits:

  • Subscribers can download convenient packaged versions of winex in deb, rpm or tar.gz format whenever they want, including updates. They have also more functionality than the publicly available tarball: the latter is an older version which lacks some of the newest features, like support for copy protected programs.

  • There are monthly polls where subscribed users can take votes on what they want winex developers to work on. For instance, they can vote for things like "Improve support for copy protected programs", "Better Installshield support" or "Improve DirectX 8.0 support". As far as I can see, the developers really do listen to the subscriber polls.

  • The Transgaming website has a few user support forums. On one hand, they use the most godawful, horrible, confusing, wasteful, moronic format I've ever seen and I hope to god I never see a forum with a format as bad as Transgaming's. On the other hand, you can ask for help and the developers are VERY good about getting around to your answer; their vigilance is quite impressive. Non-subscribers can browse the forums, but only subscribers can post (and therefore, ask for support).

The developers of winex were going to release their Installshield, DirectX and DirectDraw enhancements to wine "every so often". In return, as wine maturation improved, the winex developers were going to take the new versions of wine and use them for winex. However, since the birth of Transgaming, parts of wine have been re-licensed under the more restrictive GNU LGPL license (Section 10.5.1). This basically means that versions of wine that are released past the date of the re-licensing can no longer be used by winex. Therefore, winex will now be based on rewind (Section 10.5.2).

10.5.4. Win4Lin

Win4Lin <http://www.netraverse.com> is a commercial product by Netraverse. Like vmware (Section 10.5.5) it uses the virtual machine approach to running Windows applications, so you'll get a big window from which you can boot Windows and run all kinds of Windows applications. Unlike vmware, Win4Lin only does Windows 95/98/ME, but this turns out to be better for gamers. Because Win4Lin concentrates on these operating systems, reports say that it's faster and does a better job at running games under these operating system than vmware. It's also much cheaper than vmware. The most recent version of Win4Lin as of June 2003 is 5.0. It suffers nevertheless from some limitations:

  • It does not support DirectX or DirectDraw, while vmware has "limited" support for DirectX.

  • It only supports serial and parallel devices. This is important for people who use USB joysticks. Note that vmware supports up to 2 USB devices.

  • As of June 2003, expect to pay $89.99 without printed docs and $99.99 with printed docs. In addition, there isn't an evaluation copy available, although you get a 30 day money back guarantee. However, since it's commercial you do get tech support. vmware is considerably more expensive.

  • Like vmware, you're required to have a licensed copy of Win95 or Win98. Win4Lin cannot use an existing Windows installation the way wine can.

  • It only runs on x86 architectures.

10.5.5. VMWare

VMWare is a virtual machine that runs multiple operating systems simultaneously on a standard PC: supported OSes include Microsoft ones, Linux, Novell Netware and FreeBSD. You can among others use it to run a MS Windows OS and launch your favourite game there. You can even run another Linux under Linux; useful is you want to test another distro for instance. Amazing! Now for the bad sides. You should definitely have a good configuration in order to run it; they claim the minimum is a 500MHz x86 CPU with 128MB RAM, but a faster processor and at least 256MB RAM seem to be the bare minimum if you want reasonable performance. Not all Linux distributions are supported: newest RedHat's, Mandrake's and Suse's are, but you're out of luck if you have an other version and/or distribution (like Debian). Moreover, vmware has only limited support for DirectX, and you might not be able to play recent games.

See http://www.vmware.com for more information. It's not very cheap (about 300$ for the Workstation version), but you can get a 30 day evaluation copy.

10.5.6. What should I choose?

First of all, you should try an emulator. Although some games may work with wine, you'll probably get the most success with winex: its DirectX support is constantly improving. As of version 3.1, the DirectX 8 support is nearly complete, but this may not be the case with older DirectX versions (are consequently older games).

You might also try a virtual machine like Win4Lin or VMWare instead of an emulator. If your goal is to run Win95/98/ME applications on Linux, without USB and on the x86 architecture, Win4Lin's cost and focus on Win95 type OS's make it a better choice than vmware. However, if you must have USB support or run Linux on a platform other than x86, vmware is your only option.

Now if your goal is to run Win95 type OS games under Linux, Win4Lin almost seems better than vmware. The show-stopper is the fact that vmware has limited DirectX support while Win4Lin has none. This fact alone makes both Win4Lin and vmware unsuitable for most hardcore gaming purposes. But if you're going to give it a try, you're more likely to have success with vmware.