OS/2 e-Zine! - Now on CD (Click here)
Platform Independent Game Programming, Part 2 - by Robert Basler
OS/2 e-Zine!

Go to a Printer Friendly version of this page

Robert Basler is President and CEO of Aurora Systems, Inc., a leading edge developer of software products for people with speech, language, learning, and physical disabilities. He develops games in hopes of striking it rich one day.

Related Articles
Part I

Blast Back! Send a private message directly to Robert Basler with your thoughts:

Contact OS/2 e-Zine!

Sponsored links:
The OS/2 Supersite

Summary: This second part in our series on platform independent game programming using OS/2 will start with some cross-platform programming considerations, then we will get into the details of a few of the third party graphics and sound libraries available for OS/2.

Research Before you Code

Before you start programming your big gaming extravaganza, the first thing you should do is do a little research to find out what is going on in the industry. Take a look at the current crop of games, their feature sets, what they support, and what they don't support. Spend some time playing them, see how they work and what makes them fun, then take a few minutes to see if you can write off those games as research expenses on your taxes. Once you've done that, you're ready to start working on your game design.

I'm not going to help you choose a genre (or help you invent your own) or cover design documents and selling your game idea to publishers, but I highly recommend you have a look at "The Ultimate Game Developer's Sourcebook" by Ben Sawyer (ISBN 1-883577-59-4, Coriolis Group Books). This book has thorough coverage of everything that is not programming in games development. It tells you how to find funding and a publisher for your game, covers design documents and gaming theory, has extensive industry analysis, has legal and contract information, and provides information on many platforms including console development. There is also an invaluable section on resources for game developers, detailing a lot of groups you have heard of, but probably wouldn't know how to contact, such as the ASCAP (the Association of Composers, Authors and Publishers) who are who you would go if you wanted to license music for use in your game. This book has constantly amazed me with the wealth of information it contains. Even at 832 pages, I've read it cover to cover. I understand that there is a revised edition available now.

I don't like to state the obvious, but this is really important: Make sure you take the time to familiarize yourself with all your target operating systems before you start your design. Despite a lot of similarities between modern operating systems, you will save yourself a lot of time and effort if you take the time to find out what quirks your target OS' have, where the differences lie, and allow for them in your design. Clean modularization will help make sure that you don't have to rewrite large sections of code. But a bad design will usually have to be fixed through major rewrites as you move from platform to platform. And if you want to cover multiple platforms, the less platform-specific code you have to write and debug the better.

Selecting a Compiler & Language

Some time ago I switched from Borland to Watcom compilers. I love the Borland IDE, but Watcom has better compilers, and when you're designing games, good optimizing compilers are a must. Add to that a nice profiler, (you do use a profiler don't you?) solid debugging, a full-featured assembler, support from the manufacturer, and being able to target both Windows and OS/2 from OS/2, make Watcom a hard package to beat.

I have used both Watcom 10.6 and 11.0. If you are going to be using Vio and Mou calls, a bug in the thunk routines in 11.0 make 10.6 the better choice, but there are some nice features that include a better inline assembler and additional processor support in 11.0 that are worth looking at. One bug to watch out for is that the 11.0 OS/2 linker that targets NT will not link executables with resources without a bugfix from Powersoft.

IBM's VisualAge C++ compilers also target both OS/2 and Windows. Although I have no personal experience with them, they have a good reputation for compiled code quality and some nice object libraries. They are also well-known for being both disk and memory hungry.

When it comes to the actual coding you can use any language you like, but for cross-platform, C is really the only choice. You're welcome to add a little C++ syntactic sugar, since the basics of C++ have been around for quite a while, but be careful about using the more modern features of C++. C++ is very much an evolving standard and newer features may be only partially implemented on some compilers, or implemented differently if at all. On platforms such as BeOS, there is really only one compiler choice, so it is a good idea to make sure ahead of time that the language features you are going to use are supported.

Overview of OS/2 Gaming Libraries

There are a number of audio and graphics libraries available for OS/2 that support other platforms as well. I'm going to briefly cover a few of them, but I recommend you check out the websites for each library for a lot more detailed information than I can provide here.


The Digital Sound and Music Toolkit for OS/2 offers a complete audio mixing and music playback library for OS/2 game developers. DSMI/2 supports playback of a wide variety of music formats including MOD, S3M, STM and more. It can mix up to 32 simultaneous channels of digital sound effects and can even do Dolby Pro-Logic surround sound mixing. It supports low-latency sound output using DART, but if your sound card doesn't support DART then it can also use the MMPM drivers. From a cross-platform point of view, there are DOS and Windows ports of DSMI. License fees are very reasonable, so there's no way you're saving money writing your own sound mixer with this library out there. Licenses range from $60 for a shareware app to $600 for a commercial application. You can find detailed information at Theta Band's web site. By the way, this is the sound library used in Hopkins: FBI for OS/2.

SEAL Synthetic Audio Library

The SEAL Synthetic Audio Library for OS/2 was ported by Martin Amodeo to provide sound output for the MAME arcade emulator. SEAL can play MOD and S3M among other music formats. It can mix 32 digital audio channels and even offers digital filtering for better playback quality. If your operating system supports it (OS/2 doesn't), SEAL offers hardware assisted mixing for better performance. SEAL has been ported to DOS, Windows 95, Windows 98, Windows NT, BeOS and Linux. A commercial license for SEAL is a little steep at $1500, but shareware licenses are only $60. You can find information on the OS/2 port at The OS/2 Netlabs homepage where there is also a pointer to the original SEAL page.

SVGA Kit & VESA Kit for emx

The VESA-EMX 1.9 library offers low-level access to the graphics card, keyboard and mouse. If you want to use fullscreen graphics in OS/2, this is a good library to look at. Even if you are going to write your own fullscreen graphics library, the source code for VESA-EMX is well documented and easy to follow and will be a big help in getting your own library going. The new version, 2.0 beta 5, also adds support for windowed DIVE graphics. A unique feature of this kit is that it includes a number of card-specific drivers that support higher resolutions and color depths.

SVGA-Kit provides high-level 2-D drawing routines built on top of VESA-EMX. The routines include circles, ellipses and other geometric shapes, as well as font support.

Licenses for the VESA library are free as long as you distribute the entire VESA kit with your application and don't change the copyrights. Licenses for SVGA-Kit are subject to the copying restrictions of EMX and you will want to look at that before using SVGA-Kit. These libraries are only available for DOS and OS/2, but since source is available, porting them to other platforms shouldn't be too difficult. You can find out more about SVGA-Kit and VESA-EMX at its homepage.

Wordup Graphics Toolkit

The Wordup Graphics Toolkit from Polyex software provides a ton of features for 2D and even 3D in both windowed and fullscreen sessions. It includes routines for drawing circles, fonts, 2D texture mapping, importing various graphics file formats and performing special effects like wipes and fades. It can even play FLI/FLC animation. Input support covers keyboards, mice and joysticks. You really have to take the time to go through the extensive manuals to appreciate all it does. One of the neat features it includes is the ability to lock your data files with a password so nobody else can steal your artwork. The only drawback I could find is that it seems to be limited to 256 colors internally although it should display correctly in a DIVE window even on 15, 16 and 24-bit displays.

WGT/2 offers a sprite library that supports ultra-fast sprite blitting and animation support, plus it comes with a DOS sprite editor that supports transparent and translucent sprites. WGT/2 also has a parallax scrolling library and DOS map editor that can support up to 4 levels and everything else you need to make a fast scrolling game in OS/2. The 3D library can import 3D Studio files and DXF files and can render them in wire-frame, flat shading, gouraud shading and phong. Source for the 3D library is included so you can add your own features. A license for WGT/2 is very affordable at $149, but at this time there are no other supported platforms.

Scitech Software's MGL

MGL is the new kid on the block in the OS/2 graphics library arena and is still currently in beta testing. The most interesting thing it promises to bring to OS/2 is the ability to set the resolution and color depth when running as a PM application much like the ill-fated Fullscreen DIVE library was supposed to do. Later this year it should also bring hardware accelerated OpenGL to OS/2. MGL has an extensive list of features that include full source code, an extensive list of games developed using it, 2D & 3D graphics, both bitmap and vector font rendering, keyboard and mouse event queueing, JPEG and PCX bitmap loading, fullscreen and windowed output, and much, much more.

MGL is available for DOS, Windows 95, 98 and NT, BeOS, and has beta versions for OS/2 and Linux. I have inquired to Scitech to find out about pricing and license terms, but as of this writing I have not heard back. You can check out MGL yourself at Scitech's homepage.

Glide for Windows NT with Win32-OS/2

According to the people that made the Win32-OS/2 converter, it is supposed to be possible to run the Windows NT version of 3Dfx's (http://www.3dfx.com) Glide hardware accelerated 3D library under OS/2. Glide is designed as a subset of OpenGL and is exclusively for 3Dfx chipset cards. If the NT version of Glide worked on OS/2, OS/2 game developers could put together games that exploited the millions of Monster 3D cards out there to get cool hardware accelerated 3D effects under OS/2. Unfortunately, I tested this with Quake II on a Diamond Monster 3D and just couldn't get it to work.

Good Sources for Documentation

Just before I wrap this up, I want to mention three good sources for programming information on OS/2. The IBM Device Driver Kit contains all sorts of interesting low-level information on OS/2's internals. Ever wonder how the display system in OS/2 really works? The answers are here.

The IBM Redbooks site has an extensive collection of books on the internals of OS/2, although they are now mostly in PDF format rather than the easier to search INF format. Quite often if you find a book you like and a search of the web will turn up the same book in INF format at another site.

Despite the expense, it is well worth considering getting a subscription to the IBM Developer Connection to get access to the latest toolkits and all sorts of other useful software. Most compilers still ship with the old 2.1 toolkit, so if you want to write applications using the newer features of Warp, you need to get the newer toolkit. Fortunately, nearly all of the toolkit documentation is available at the free Guest level.

Next time we'll take a look at DART programming and some handy WWW sites. As always, please feel free to drop me an email if I miss anything important.

Gaming News

The port of Hexen to OS/2 continues to improve, you can get a copy at the porting group's homepage.

If you feel like a blast from the past, check out M.A.M.E. for some great old arcade action. I've played Battlezone, Frogger, Tempest, Centipede, PacMan and many more. The program works great, and a good source of ROMS is at EMUX.com. A tip is to unzip the games into their own directory under your M.A.M.E. directory if you have trouble getting them to work.

Copyright © 1999 - Falcon Networking ISSN 1203-5696
June 1, 1999