DIVERACE a Game-Programming example for Virtual Pascal. This is Freeware Author : Michael Mrosowski Fidonet: 2:240/5022.1 EMail: lagaffe@offline.sh.sub.de Last Chg: 27.08.95 ***************************************************************************** Preface: -------- This game and the sourcecode, as far as it is not copyrighted by other parties is free for use. It is released for the purpose to promote game programming under os/2. This software and accompanying materials are distributed "AS IS" without warranty, express, implied or statutory, including but not limited to any implied warranties of merchantability and fitness for a particular purpose. In no event shall anyone involved with the creation and production of this product be liable for indirect, special, or consequential damages, arising out of any use thereof or breach of any warranty. Warning!: --------- This software is only roughly tested and its use can lead caused either by incompatibilities or programming errors to a system halt. So be sure to save all work before first starting the game. ***************************************************************************** Notes about the Game: --------------------- Diverace is a little car driving game. It's not really finished yet but it's already some fun to play. You drive a little vehicle together with some computer controlled cars around a course. Bumping into them is the usual method to get them out of your way, and they do the same with you :). The only goal is currently to get past all others and drive some good times. I recommend a joystick for best control. Notes about the Game Options: ----------------------------- Sound-Mixing: ------------- I hope it works on your computer. I've tested it currently only with the original Gravis Drivers (0.31a) where it works satisfyingly. It uses up some computing time, so disabling it may speed up the game. For safety reasons the sound mixing is currently disabled while the game-frame has no focus (even while you are in the menu). It is re- enabled when the frame gets the focus back. Controls: --------- The mouse control is relative to the mouse movement on the whole screen. You will see a crosshair on the game screen indicating the control position. Moving the mouse up accelearates, down brakes and left and right steers the car (guess what direction). The joystick control assumes you centered the joystick on the start of the game. The joystick position is signaled with a crosshair on the game screen. The acceleration & brakes are digital so it doesn't matter if the crosshair doesn't reach the top or the bottom of the screen. If steering to one side doesn't work correctly trim your joystick in that direction and restart the game. Watch-Only: ----------- In this mode you don't have to drive. You can move around and watch the automatic cars fighting. Display Sound-Buffer: --------------------- If Sound-Mixing is enabled, you can see the result of the sound mixing on the game screen. (May slow down the game a bit). Translate Colors: ----------------- Turning off this option can speed the game up when used in 256 color mode and SNAP 1:1 Mode. But it usually results in some color distortion. Pause if lost Focus: -------------------- It is a little bit dangerous to disable this function. If the game continues and you start a full-screen session then ther will be a problem getting back. Try pressing CTRL-ESC and wait up to a minute. The WPS should be coming up again. Frame Rate: ----------- The maximum/optimal frame rate in this game is 18Fps. Keys in Game: ------------- F1: Snaps the Game Window to the resolution of the internal screen-buffer F2: Snaps the Window to the double size of the internal resolution F4: Snaps the Window to the Full Screen Width. F3: Ends the Game F5: Pauses the Game Compatibility: -------------- You need: OS/2 Warp 3.0 (or newer) MMPM/2 installed. A DIVE capable Video-Card. (The 8514 Drivers do not support DIVE). Optional: Soundcard & Joystick. My Testing Environment: OS/2 Warp 3.0 AMD 486 DX/2, 16MB ATI Mach 64 VLB Gravis Ultrasound (with Gravis Drivers 0.31a) Results: 1:1 -> 18fps with 60-70% System load 1:2 -> 14fps with 100% System load Problems: --------- No Screen updates during game. End the game with F3 and start PULSE. Check out if some other program (i.e. a bad configured dos-window) uses 100% of the CPU-Time. In this case there will be no game screen-updates, because they run at idle priority (delta +20). The sound mixing currently does not work with the gravis manley drivers because they are too "intelligent" and ignore any later changes in the buffers of the playlist. Other drivers may experience the same problem. If the System hangs with 1:2 Screen (or bigger) this may be a DIVE Problem. I experienced it some time with a Cirrus Logic card. I experienced the same effect with SHOW.EXE from IBM, so it doesn't seem to be my fault :). Joystick flickering. Implementing the usage of the Joystick driver could help resolving this problem. ***************************************************************************** Notes about the Source Code: ---------------------------- unzip the sourcecode with the option -d (for directories). Do not expect a full documented full-blown 100% perfect code. This is just an old dos game which i ported to os/2. But i hope this game can at least be an example how to use multithreading and MMPM to write a game. If you want futher development, don't ask me. You have the code so you can do it ;-). Used techniques: PALETTE: -------- The Physical Palette is set as good as possible. But usually OS/2 does not let all colors being set. This does not apply to TRUE-Color where no palette is used. SOUND: ------ Currently a playlist is used with two alternating buffers. Sound quality is at 11khz 8-Bit Mono. Mixing is currently set to 6 channels. If you want Stereo or 16-Bit you will have to extend the mixing routines. The playlist concept may not work correctly on every sound-driver because the soundbuffers are alternatively updated (always the not-played buffer). DIVE: ----- The the Dive-Blitter runs in an extra thread at nearly idle priority. It usually runs fastest in 256 colors at 1:1 resolution. Without the Color translation option the thruput is nearly doubled, but the colors are distorted. Color translation off usually does not improve performance if the display is other than 1:1. 3D: --- Stone-Aged. The 3D-Routines are quite proprietary for this game. The 3D routines write to a 256-colors frame buffer. The screen resolution can be adjusted in the file DREID.PAS. You will notice still some german comments in the file, i didn't have the time yet to translate all of them. The 3D Part turns only around the y-axis. All Objects are made up of triangles or squares. The cars are the only objects that are sorted in a little list by distance to the viewpoint and displayed furthest first. What is still to do: DIVE: The new Fullscreen DIVE interface is not yet implemented. Look for the file DIVEFS2.ZIP for docs. As an alternative could be used VIO Fullscreen-Access (see the fire.pas example) from a spawned os/2 fs-session & passing the frame-buffer via shared-memory. JOYSTICK:The game uses direct port io which ist not the best method. Look for the files JOYSTICK.ZIP and JOYDOCS.ZIP for a OS/2 MMPM joystick driver. SOUND: A playlist with alternatively updated datablocks and cuepoint-operations is used. This takes much proc-time for message processing etc. There is a new example for direct- driver access. Look for DIRAUD.ZIP for documentation. The Sound-Part is only roughly tested and may not run with some drivers. For the GUS it works with the Gravis drivers but not with the manley-drivers. The Problem here is that the driver is reading the playlist-buffer once and then is ignoring any changes in the buffer. ERRORS: Error processing is minimal or not-existing in this example. *************************************************************************** Where to put files. Files in LIB to your LIB directory. Files in OUT to your OUT directory. Files in WORK to your working directory or the VP directory. Copy the Game files (except the .exe) to your work-directory for debugging. Turn Stack-Checking off in the Compiler settings. Link as PM-Application. The Compiler is: Virtual Pascal Version 1.0 Beta (#003) (i applied no fixes yet) from : Vitaly Miryanov Used sources of information -> Credits: SHOW.C of IBM for dive-programming. The MM4EMX package of Marc E.E. van Woerkom for the MCI-Interface. The plug-n-play sound source from Semir Patel.