home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 10 Tools
/
10-Tools.zip
/
warptlk3.zip
/
TOOLKIT
/
BETA
/
BOOK
/
GMTLKBAS.INF
(
.txt
)
< prev
next >
Wrap
OS/2 Help File
|
1995-09-06
|
140KB
|
3,225 lines
ΓòÉΓòÉΓòÉ 1. Notices ΓòÉΓòÉΓòÉ
First Edition
The following paragraph does not apply to the United Kingdom or any country
where such provisions are inconsistent with local law: INTERNATIONAL BUSINESS
MACHINES CORPORATION PROVIDES THIS PUBLICATION "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Some states
do not allow disclaimer of express or implied warranties in certain
transactions, therefore, this statement may not apply to you.
This publication could include technical inaccuracies or typographical errors.
Changes are periodically made to the information herein; these changes will be
incorporated in new editions of the publication. IBM may make improvements
and/or changes in the product(s) and/or the program(s) described in this
publication at any time.
It is possible that this publication may contain reference to, or information
about, IBM products (machines and programs), programming, or services that are
not announced in your country. Such references or information must not be
construed to mean that IBM intends to announce such IBM products, programming,
or services in your country.
Requests for technical information about IBM products should be made to your
IBM authorized reseller or IBM marketing representative.
ΓòÉΓòÉΓòÉ 1.1. Copyright Notices ΓòÉΓòÉΓòÉ
COPYRIGHT LICENSE:
(C) Copyright International Business Machines Corporation 1995. All rights
reserved.
Note to U.S. Government Users - Documentation related to restricted rights -
Use, duplication or disclosure is subject to restrictions set forth in GSA ADP
Schedule Contract with IBM Corp.
ΓòÉΓòÉΓòÉ 1.2. Disclaimers ΓòÉΓòÉΓòÉ
References in this publication to IBM products, programs, or services do not
imply that IBM intends to make these available in all countries in which IBM
operates. Any reference to an IBM product, program or service is not intended
to state or imply that only IBM's product, program, or service may be used.
Any functionally equivalent product, program, or service that does not infringe
any of IBM's intellectual property rights or other legally protectable rights
may be used instead of the IBM product, program, or service. Evaluation and
verification of operation in conjunction with other products, programs, or
services, except those expressly designated by IBM, are the user's
responsibility.
IBM may have patents or pending patent applications covering subject matter in
these programs and documentation. The furnishing of these programs and
documentation does not give you any license to these patents. You can send
license inquiries, in writing, to the IBM Director of Licensing, IBM
Corporation, 500 Columbus Avenue, Thornwood NY 10594, U.S.A.
Licensees of this program who wish to have information about it for the purpose
of enabling: (i) the exchange of information between independently created
programs and other programs (including this one) and (ii) the mutual use of the
information which has been exchanged, should contact IBM Corporation,
Department RM1A, GS00 N.W. 51st Street, Boca Raton, FL 33431, U.S.A. Such
information may be available, subject to appropriate terms and conditions,
including in some cases, payment of a fee.
ΓòÉΓòÉΓòÉ 1.3. Trademarks ΓòÉΓòÉΓòÉ
The following terms are trademarks of the IBM Corporation in the United States
or other countries:
IBM
OS/2
The following terms are trademarks of other companies:
3D Studio Autodesk, Inc.
BRender Argonaut Technologies Limited
Gravis GamePad Advanced Gravis Technologies
MacIntosh Apple Computer, Inc.
Pentium Intel Corp.
SuperFX Argonaut Technologies Ltd.
Windows Microsoft Corporation
Other company, product, and service names may be trademarks or service marks
of others.
ΓòÉΓòÉΓòÉ 1.4. OS/2 Warp and the BonusPak ΓòÉΓòÉΓòÉ
OS/2 Warp consists of the highly acclaimed, award-winning and totally cool
operating system, OS/2 Warp Version 3 and the BonusPak, a suite of productivity
applications.
In this document, we may be discussing the functions and features of OS/2 Warp.
Whenever we refer to OS/2 Warp, keep in mind that OS/2 Warp currently ships in
two flavors:
1. There is OS/2 Warp (red spine on retail box) that uses your existing DOS
and Windows. This product runs a wide variety of DOS and OS/2
applications and, if you have Windows installed on your system, you will
be able to continue to run Windows applications.
2. There is OS/2 Warp (blue spine on retail box) that includes DOS and
Windows applications support. This product also runs a wide variety of
DOS and OS/2 applications but also has WIN-OS/2-the support required to
run most Windows applications.
Which product you choose depends on whether or not you currently have Windows
installed and also depends on what types of applications you plan to run.
ΓòÉΓòÉΓòÉ 2. Introduction ΓòÉΓòÉΓòÉ
Welcome to the world of entertainment development-brought to you by the IBM
Corporation. We want you to know that IBM is committed to PC gaming. So,
here's what we at IBM intend to do for you-the entertainment developer.
We are providing you technical information about the new features specifically
for entertainment:
3D graphics
Multiplayer networking
Full-screen DIVE enhancements for video support
Real-time MIDI and direct audio enhancements for audio support
A joystick for OS/2 and for DOS sessions of OS/2
Just to name a few of the many new entertainment features you're probably
already wanting to include in your own new game. All these features are
coming in a special new toolkit specifically for you: the Entertainment
Tools.
We'll help you find our IBM home page-just for gaming stuff-on the World Wide
Web. You'll be able to have gaming information at your fingertips.
ΓòÉΓòÉΓòÉ 2.1. World Wide Web ΓòÉΓòÉΓòÉ
IBM provides easy access to an Internet home page (server) on the World Wide
Web (WWW) that contains a growing library of support information, information
about available OS/2 applications, and sample code.
Web Explorer
The Web Explorer is being included in newer versions of OS/2 Warp and is also
available electronically. To download to your PC, simply click on an icon that
is presented on the Gopher Server or IBM Home Page. It downloads and installs
itself. Web Explorer allows users to access the World Wide Web (WWW) through a
graphical user interface. The WWW links resources together in an
easy-to-use-fashion.
For example, a user can get a map of a country, click on a city to retrieve
information, see photographs, and read about current demographics. With Web
Explorer, users traverse the Internet by moving from one document to another
using links or hyperlinks, and can save and annotate documents.
OS/2 Games Home Page
The OS/2 games home page became available on April 22, 1995, at:
http://www.austin.ibm.com/os2games
As an entertainment developer, be sure to ask about having your application
listed there. Also ask about how you can supply demo code for users to
download and try.
ΓòÉΓòÉΓòÉ 2.2. Related Publications ΓòÉΓòÉΓòÉ
The following diagram provides an overview of the OS/2 Warp Technical Library.
Books can be ordered by calling toll free 1-800-342-6672 weekdays between 8:00
a.m. and 8:00 p.m. (EST). In Canada, call 1-800-465-4234.
ΓòÉΓòÉΓòÉ 2.3. Additional Games-Related Publications ΓòÉΓòÉΓòÉ
In additional to the current book you are reading, the following games-related
documentation is being provided for this Beta. You can find them in the
subdirectory \TOOLKIT\BETA\BOOK.
Argonaut's BRender Technical Reference
This book describes the Brender real-time, 3D graphics library, which has a
comprehensive Application Programming Interface (API), for quick and easy
3D development.
Argonaut's BRender Concise Guide
This book describes the Brender Power Rendering System Application
Programming Interface (API), shows how the components of the BRender system
work as a whole, and gives some idea of the capabilities of this system.
Real-Time MIDI
This book provides a discussion of the new real-time MIDI architecture and
introduces the real-time MIDI application programming interface (API),
including detailed descriptions of the real-time MIDI functions and
associated data types.
Direct Audio Interface
This book provides an overview of the direct-audio interface including
descriptions of messages and associated data types.
READMEs
For this Beta, installation information might be provided for samples as
individual README files within the same subdirectory as the samples.
ΓòÉΓòÉΓòÉ 2.4. Using This Online Book ΓòÉΓòÉΓòÉ
Before you begin to use this online book, it would be helpful to understand how
you can:
Expand the Contents to see all available topics.
Obtain additional information for a highlighted word or phrase.
Use action bar choices.
How To Use the Contents
When the Contents window first appears, some topics have a plus (+) sign
beside them. The plus sign indicates that additional topics are available.
To expand the Contents if you are using a mouse, select the plus sign (+). If
you are using a keyboard, use the Up or Down Arrow key to highlight the topic,
and press the plus key (+).
To view a topic, double-click on the topic (or press the Up or Down Arrow key
to highlight the topic, and then press Enter).
How To Obtain Additional Information
After you select a topic, the information for that topic appears in a window.
Highlighted words or phrases indicate that additional information is
available. Notice that certain words in the following paragraph are
highlighted in green letters, or in white letters on a black background.
These are called hypertext terms. If you are using a mouse, double-click on
the highlighted word. If you are using a keyboard, press the Tab key to move
to the highlighted word, and then press the Enter key. Additional information
appears in a window.
How To Use Action Bar Choices
Several choices are available for managing information presented in the
M-Control Program/2 Programming Reference. There are three pull-down menus on
the action bar: the Services menu, the Options menu, and the Help menu.
The actions that are selectable from the Services menu operate on the active
window currently displayed on the screen. These actions include the
following:
Bookmark
Sets a place holder so you can retrieve information of interest to you.
When you place a bookmark on a topic, it is added to a list of bookmarks
you have previously set. You can view the list, and you can remove one or
all bookmarks from the list. If you have not set any bookmarks, the list
is empty.
To set a bookmark, do the following:
1. Select a topic from the Contents.
2. When that topic appears, choose the Bookmark option from the Services
menu.
3. If you want to change the name used for the bookmark, type the new
name in the field.
4. Select the Place radio button (or press the Up or Down Arrow key to
select it).
5. Select OK. The bookmark is then added to the bookmark list.
Search
Finds occurrences of a word or phrase in the current topic, selected
topics, or all topics.
You can specify a word or phrase to be searched. You can also limit the
search to a set of topics by first marking the topics in the Contents list.
To search for a word or phrase in all topics, do the following:
1. Choose the Search option from the Services pull-down.
2. Type the word or words to be searched.
3. Select All sections.
4. Select Search to begin the search.
5. The list of topics where the word or phrase appears is displayed.
Print
Prints one or more topics. You can also print a set of topics by first
marking the topics in the Contents list.
You can print one or more topics. You can also print a set of topics by
first marking the topics on the Contents list.
To print the document Contents list, do the following:
1. Select Print from the Services menu.
2. Select Contents.
3. Select Print.
4. The Contents list is printed on your printer.
Copy
Copies a topic you are viewing to a file you can edit.
You can copy a topic you are viewing into a temporary file named TEXT.TMP.
You can later edit that file by using an editor such as the System Editor.
To copy a topic, do the following:
1. Expand the Contents list and select a topic.
2. When the topic appears, select Copy to file from the Services menu.
The system copies the text pertaining to that topic into the temporary
TEXT.TMP file.
For information on any of the other choices in the Services menu, highlight
the choice and press the F1 key.
Options
Changes the way the Contents is displayed.
You can control the appearance of the Contents list.
To expand the Contents and show all levels for all topics, select Expand
all from the Options menu.
For information on any of the other choices in the Options menu, highlight
the choice and press the F1 key.
ΓòÉΓòÉΓòÉ 3. OS/2 Warp Networking ΓòÉΓòÉΓòÉ
Warp network functions represent a standard application layer interface to OS/2
games for networked, multiplayer support.
The Warp network functions will eventually be supporting multiple transports
such as TCP/IP, SPX/IPX, and OEM stacks. The first implementation of Warp
network functions, however, is only using TCP/IP.
Warp network functions define a well-known user data protocol (UDP) port just
for games. The Warp networking game server (also sometimes referred to as the
daemon) monitors the well-known game port and routes packets received at this
port to the application.
The TCP/IP Services file (\TCPIP\ETC\SERVICES) must be modified to include the
well-known game port entry. The modification would look similar to the
following:
GAMED 5022/UDP #Well Known UDP based Game Port.
ΓòÉΓòÉΓòÉ 3.1. OS/2 Warp Network Functions ΓòÉΓòÉΓòÉ
The following Warp network functions are provided. The APIs are exported from
WARPNET.DLL and are resolved by WARPNET.LIB. The public header file WARPNET.H
defines all elements of the external interface, including data structures and
the following functions:
WarpNetInitialize
WarpNetOpen
WarpNetBroadcast
WarpNetPackSend
WarpNetPackRecv
WarpNetClose
ΓòÉΓòÉΓòÉ <hidden> int - Syntax ΓòÉΓòÉΓòÉ
An integer value.
ΓòÉΓòÉΓòÉ <hidden> HEV - Syntax ΓòÉΓòÉΓòÉ
32-bit value used as an event semaphore handle.
ΓòÉΓòÉΓòÉ <hidden> USHORT - Syntax ΓòÉΓòÉΓòÉ
Unsigned integer in the range 0 through 65 535.
typedef unsigned long USHORT;
ΓòÉΓòÉΓòÉ <hidden> ULONG - Syntax ΓòÉΓòÉΓòÉ
Unsigned integer in the range 0 through 4294967295.
typedef unsigned long ULONG;
ΓòÉΓòÉΓòÉ <hidden> BOOL - Syntax ΓòÉΓòÉΓòÉ
Boolean.
Valid values are FALSE, which is 0, and TRUE, which is 1.
typedef unsigned long BOOL;
ΓòÉΓòÉΓòÉ <hidden> CHAR - Syntax ΓòÉΓòÉΓòÉ
Single-byte character.
#define CHAR char
ΓòÉΓòÉΓòÉ <hidden> VOID - Syntax ΓòÉΓòÉΓòÉ
No parameter.
#define VOID void
ΓòÉΓòÉΓòÉ <hidden> PSZ - Syntax ΓòÉΓòÉΓòÉ
Pointer to a null-terminated string.
typedef unsigned char * PSZ;
ΓòÉΓòÉΓòÉ <hidden> PULONG - Syntax ΓòÉΓòÉΓòÉ
Pointer to a ULONG.
ΓòÉΓòÉΓòÉ <hidden> PEAOP2 - Syntax ΓòÉΓòÉΓòÉ
Pointer to a ULONG.
ΓòÉΓòÉΓòÉ 3.1.1. WarpNetInitialize ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> WarpNetInitialize - Syntax ΓòÉΓòÉΓòÉ
This function initializes the application with the underlying transports used.
All applications using Warp networking should call this function first. This
function initializes the application to use sockets by calling sock_init(). A
socket is a unique host identifier created by the concatenation of a port
identifier with a transmission control protocol/internet protocol (TCP/IP)
address.
The sockets are stored in the per-process-instance space of WARPNET.DLL in a
data structure called pplayer.
#include <warpnet.h>
APIRET APIENTRY WarpNetInitialize (VOID)
If the initialization succeeds, two sockets are created:
A user data protocol (UDP) datagram socket.
A transmission control protocol (TCP) stream socket.
ΓòÉΓòÉΓòÉ <hidden> WarpNetInitialize - Parameters ΓòÉΓòÉΓòÉ
VOID
No parameter.
ΓòÉΓòÉΓòÉ <hidden> WarpNetInitialize Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
You should also refer to the TCP/IP programmer's guide for an explanation of
TCP/IP error codes.
ΓòÉΓòÉΓòÉ <hidden> WarpNetInitialize - Programming Tutorial Code ΓòÉΓòÉΓòÉ
TICTAC, the programming tutorial (sample), demonstrates how to use networking
functions to develop a multiplayer, networked game. This sample uses the Warp
network functions to illustrate a 2-player TicTacToe game, where two players
play against each other.
These networking support functions are referred to as OS/2 Warp network
functions. The Warp networking functions will eventually support multiple
transports, such as TCP/IP, SPX/IPX, and OEM stacks. Currently, only TCP/IP
transport is supported.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\NETWORK\WARPNET\TICTAC.
You can start the programming tutorial by typing the programming tutorial name
(TICTAC.EXE) at the OS/2 command line:
tictac
Or by double-clicking on the TicTacToe icon.
Hardware Requirements:
Machine capable of running OS/2 Warp with TCP/IP and communications
hardware.
Software Requirements:
WARPNET.DLL
WARPNET.H
OS/2 TCP/IP Version 2.x or higher
OS/2 Warp 3.0 or higher.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> WarpNetInitialize - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
ΓòÉΓòÉΓòÉ 3.1.2. WarpNetOpen ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> WarpNetOpen - Syntax ΓòÉΓòÉΓòÉ
This function initiates communication with the game server. This function
sends a WARPNET_REGISTER_PLAYER message to the server in the body of the
function, which causes the server to update its player list. The player list
maps client addresses or sockets to unique player identifiers.
#include <warpnet.h>
APIRET APIENTRY WarpNetOpen (ToAddress Server
WarpNetPacket
* ppacket)
ΓòÉΓòÉΓòÉ <hidden> WarpNetOpen - Parameters ΓòÉΓòÉΓòÉ
Server
The Destination address can be specified as a domain name address or dotted
decimal address. The fDotted flag in the ToAddress data structure is set;
then the address is interpreted as the dotted decimal notation (for
example, 9.83.6.60). If the fDotted flag is clear, then the address is
interpreted as a domain name system (for example:
meteor.m6nova.r3galaxy.orb).
WarpNetPacket
Refer to the WarpNetPacket data type.
* ppacket
A pointer to a WarpNetPacket structure.
ΓòÉΓòÉΓòÉ <hidden> WarpNetOpen Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
You should also refer to the TCP/IP programmer's guide for an explanation of
TCP/IP error codes.
ΓòÉΓòÉΓòÉ <hidden> WarpNetOpen - Remarks ΓòÉΓòÉΓòÉ
The application after initializing itself with WarpNet, by invoking
WarpNetInitialize(), calls this function next to register itself with the game
server. The application needs to specify the server's address in the ToAddress
structure. The application should also pass a pointer to a WarpNetPacket for
return information.
ΓòÉΓòÉΓòÉ <hidden> WarpNetOpen - Programming Tutorial Code ΓòÉΓòÉΓòÉ
TICTAC, the programming tutorial (sample), demonstrates how to use networking
functions to develop a multiplayer, networked game. This sample uses the Warp
network functions to illustrate a 2-player TicTacToe game, where two players
play against each other.
These networking support functions are referred to as OS/2 Warp network
functions. The Warp networking functions will eventually support multiple
transports, such as TCP/IP, SPX/IPX, and OEM stacks. Currently, only TCP/IP
transport is supported.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\NETWORK\WARPNET\TICTAC.
You can start the programming tutorial by typing the programming tutorial name
(TICTAC.EXE) at the OS/2 command line:
tictac
Or by double-clicking on the TicTacToe icon.
Hardware Requirements:
Machine capable of running OS/2 Warp with TCP/IP and communications
hardware.
Software Requirements:
WARPNET.DLL
WARPNET.H
OS/2 TCP/IP Version 2.x or higher
OS/2 Warp 3.0 or higher.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> WarpNetOpen - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Remarks
Programming Tutorial Code
ΓòÉΓòÉΓòÉ 3.1.3. WarpNetBroadcast ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> WarpNetBroadcast - Syntax ΓòÉΓòÉΓòÉ
This function broadcasts the data to all connected clients. The player list
defines all clients or players known to the WARPNET game server.
#include <warpnet.h>
APIRET APIENTRY WarpNetBroadcast ( WarpNetPacket
* ppacket)
ΓòÉΓòÉΓòÉ <hidden> WarpNetBroadcast - Parameters ΓòÉΓòÉΓòÉ
WarpNetPacket
Refer to the WarpNetPacket data type.
* ppacket
A pointer to a WarpNetPacket structure.
ΓòÉΓòÉΓòÉ <hidden> WarpNetBroadcast Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure.
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
You should also refer to the TCP/IP programmer's guide for an explanation of
TCP/IP error codes.
ΓòÉΓòÉΓòÉ <hidden> WarpNetBroadcast - Programming Tutorial Code ΓòÉΓòÉΓòÉ
TICTAC, the programming tutorial (sample), demonstrates how to use networking
functions to develop a multiplayer, networked game. This sample uses the Warp
network functions to illustrate a 2-player TicTacToe game, where two players
play against each other.
These networking support functions are referred to as OS/2 Warp network
functions. The Warp networking functions will eventually support multiple
transports, such as TCP/IP, SPX/IPX, and OEM stacks. Currently, only TCP/IP
transport is supported.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\NETWORK\WARPNET\TICTAC.
You can start the programming tutorial by typing the programming tutorial name
(TICTAC.EXE) at the OS/2 command line:
tictac
Or by double-clicking on the TicTacToe icon.
Hardware Requirements:
Machine capable of running OS/2 Warp with TCP/IP and communications
hardware.
Software Requirements:
WARPNET.DLL
WARPNET.H
OS/2 TCP/IP Version 2.x or higher
OS/2 Warp 3.0 or higher.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> WarpNetBroadcast - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
ΓòÉΓòÉΓòÉ 3.1.4. WarpNetPackSend ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackSend - Syntax ΓòÉΓòÉΓòÉ
This function sends user data in 512-byte packets. The function determines the
number of packets necessary to transmit all of the user data, and then it
sequences, timestamps, checksums, and prepends the WARPNET header before
transmitting the packets to the destination.
#include <warpnet.h>
APIRET APIENTRY WarpNetPackSend ( ToAddress Destination,
WarpNetPacket
* ppacket)
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackSend - Parameters ΓòÉΓòÉΓòÉ
Destination
The Destination address can be specified as a domain name address or dotted
decimal address. The fDotted flag in the ToAddress data structure is set;
then the address is interpreted as the dotted decimal notation (for
example, 9.83.6.60). If the fDotted flag is clear, then the address is
interpreted as a domain name system (for example:
meteor.m6nova.r3galaxy.orb).
WarpNetPacket
Refer to the WarpNetPacket data type.
* ppacket
A pointer to a WarpNetPacket structure.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackSend Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
You should also refer to the TCP/IP programmer's guide for an explanation of
TCP/IP error codes.
The Destination address can be specified as a domain name address or dotted
decimal address. The fDotted flag in the ToAddress data structure is set;
then the address is interpreted as the dotted decimal notation (for example,
9.83.6.60). If the fDotted flag is clear, then the address is interpreted as
a domain name system (for example: meteor.m6nova.r3galaxy.orb).
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackSend - Programming Tutorial Code ΓòÉΓòÉΓòÉ
TICTAC, the programming tutorial (sample), demonstrates how to use networking
functions to develop a multiplayer, networked game. This sample uses the Warp
network functions to illustrate a 2-player TicTacToe game, where two players
play against each other.
These networking support functions are referred to as OS/2 Warp network
functions. The Warp networking functions will eventually support multiple
transports, such as TCP/IP, SPX/IPX, and OEM stacks. Currently, only TCP/IP
transport is supported.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\NETWORK\WARPNET\TICTAC.
You can start the programming tutorial by typing the programming tutorial name
(TICTAC.EXE) at the OS/2 command line:
tictac
Or by double-clicking on the TicTacToe icon.
Hardware Requirements:
Machine capable of running OS/2 Warp with TCP/IP and communications
hardware.
Software Requirements:
WARPNET.DLL
WARPNET.H
OS/2 TCP/IP Version 2.x or higher
OS/2 Warp 3.0 or higher.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackSend - Example Code ΓòÉΓòÉΓòÉ
The following example illustrates the invocation of this function.
ToAddress dest; // Destination Address
WarpNetPacket *packet; // User Data Packet
CHAR *pch;
// Allocate Memory
DosAllocMem ( (PPVOID)&packet, HEADER_SIZE,
(ULONG) PAG_COMMIT | PAG_READ | PAG_WRITE) )
DosAllocMem ( (PPVOID)&(Header->pData), 2048,
(ULONG) PAG_COMMIT | PAG_READ | PAG_WRITE) )
memset (&dest,0,sizeof(dest));
memset (packet,0,HEADER_SIZE);
dest.fDotted = TRUE;
dest.fUsePlayerID = FALSE;
strcpy (dest.Destination,"9.83.6.60");
/* Fill the user header portion of the data gram */
packet->fHeaderOnly = FALSE;
packet->Message = START_GAME; // Application specific message
// (not interpreted by warpnet)
packet ->DataSize = 2032;
memset (packet->pData,'2',2048);
// Send the Registraton Data to the server.
WarpNetPackSend (dest,packet);
The following example illustrates another different invocation of this
function.
dest.fUsePlayerID = TRUE; // Use the PlayerID to specify packet destination
dest.PlayerID = 3;
packet->fHeaderOnly = TRUE; // No data, we will just transmit the header
packet->DataSize = 0;
packet->pData = NULL;
packet->DataWord1 = Joystick.x;
packet->DataWord2 = Joystick.y;
packet->DataWord3 = Joystick.z;
packet->Message = JOYSTICK_INPUT;
WarpNetPackSend (dest,packet);
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackSend - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
Example Code
ΓòÉΓòÉΓòÉ 3.1.5. WarpNetPackRecv ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackRecv - Syntax ΓòÉΓòÉΓòÉ
This function receives data. This function does the converse of
WarpNetPackSend and has to assemble n packets to fill up a user-receiving
buffer. The application that calls WarpNetPackRecv is blocked on an event
semaphore until data is available. All packets are actually received at the
network interface by the game server's receive thread. The server looks at the
User header on the packet received, locates the local application (or the
player) entry in the player list, and posts the event semaphore.
Recall that at the application side where receive is called, the caller is
blocked on the event semaphore.
#include <warpnet.h>
APIRET APIENTRY WarpNetPackRecv ( char * pchbuf)
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackRecv - Parameters ΓòÉΓòÉΓòÉ
char
Single-byte character.
* pchbuf
Pointer to a user buffer.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackRecv Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
You should also refer to the TCP/IP programmer's guide for an explanation of
TCP/IP error codes.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackRecv - Programming Tutorial Code ΓòÉΓòÉΓòÉ
TICTAC, the programming tutorial (sample), demonstrates how to use networking
functions to develop a multiplayer, networked game. This sample uses the Warp
network functions to illustrate a 2-player TicTacToe game, where two players
play against each other.
These networking support functions are referred to as OS/2 Warp network
functions. The Warp networking functions will eventually support multiple
transports, such as TCP/IP, SPX/IPX, and OEM stacks. Currently, only TCP/IP
transport is supported.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\NETWORK\WARPNET\TICTAC.
You can start the programming tutorial by typing the programming tutorial name
(TICTAC.EXE) at the OS/2 command line:
tictac
Or by double-clicking on the TicTacToe icon.
Hardware Requirements:
Machine capable of running OS/2 Warp with TCP/IP and communications
hardware.
Software Requirements:
WARPNET.DLL
WARPNET.H
OS/2 TCP/IP Version 2.x or higher
OS/2 Warp 3.0 or higher.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPackRecv - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
ΓòÉΓòÉΓòÉ 3.1.6. WarpNetClose ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> WarpNetClose - Syntax ΓòÉΓòÉΓòÉ
This function terminates communication with the game server.
#include <warpnet.h>
APIRET APIENTRY WarpNetClose(VOID)
ΓòÉΓòÉΓòÉ <hidden> WarpNetClose - Parameters ΓòÉΓòÉΓòÉ
VOID
No parameter.
ΓòÉΓòÉΓòÉ <hidden> WarpNetClose Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
You should also refer to the TCP/IP programmer's guide for an explanation of
TCP/IP error codes.
ΓòÉΓòÉΓòÉ <hidden> WarpNetClose - Remarks ΓòÉΓòÉΓòÉ
This function de-registers itself with the Warp network subsystem. The player
ID stored internally in a per-process-instance data structure is used to
identify the player. The reason for doing this is we do not allow proxies on
close (for example, to guard against player 1 trying to close player 2). The
application is merely required to call WarpNetClose as part of its exit
procedure. In the body of WarpNetClose, we send a WARPNET_DEREGISTER_PLAYER
message to the server. The server on receipt of this message updates its
internal PLAYERLIST structure and broadcasts the list to other peers. The
player lists are kept in synchronization.
ΓòÉΓòÉΓòÉ <hidden> WarpNetClose - Programming Tutorial Code ΓòÉΓòÉΓòÉ
TICTAC, the programming tutorial (sample), demonstrates how to use networking
functions to develop a multiplayer, networked game. This sample uses the Warp
network functions to illustrate a 2-player TicTacToe game, where two players
play against each other.
These networking support functions are referred to as OS/2 Warp network
functions. The Warp networking functions will eventually support multiple
transports, such as TCP/IP, SPX/IPX, and OEM stacks. Currently, only TCP/IP
transport is supported.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\NETWORK\WARPNET\TICTAC.
You can start the programming tutorial by typing the programming tutorial name
(TICTAC.EXE) at the OS/2 command line:
tictac
Or by double-clicking on the TicTacToe icon.
Hardware Requirements:
Machine capable of running OS/2 Warp with TCP/IP and communications
hardware.
Software Requirements:
WARPNET.DLL
WARPNET.H
OS/2 TCP/IP Version 2.x or higher
OS/2 Warp 3.0 or higher.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> WarpNetClose - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
ΓòÉΓòÉΓòÉ 3.2. Warp Network Data Types ΓòÉΓòÉΓòÉ
This section describes data types in C language. A data type name beginning
with "P" (for example (PMCI_CONNECTOR_PARMS) is likely to be a pointer to
another data type (in this instance, MCI_CONNECTOR_PARMS). If no data type
definition can be found in this section for a data type name "Pxxxxxx,", it
becomes a pointer to the data type "xxxxxxx," for which a definition should be
found. The implicit type definition needed for such a pointer "Pxxxxxx" is:
typedef xxxxxx *Pxxxxxx
ΓòÉΓòÉΓòÉ 3.2.1. WarpNetPacket ΓòÉΓòÉΓòÉ
For WarpNet, external data structures are shown. In the WarpNetPacket
structure, data members are shared between the application and the Warp network
system. The data members PackSeq, chksum, Timestamp, PackMarker, and Reserved
are intended for system internal usage. Applications should not care about
these members.
Registration is done at WarpNetOpen() time by sending a WARPNET_REGISTER_PLAYER
message to the system.
typedef struct user_pack_header {
ULONG Message;
ULONG Node;
ULONG Channel;
ULONG srcPlayerId;
ULONG tgtPlayerId;
ULONG fHeaderOnly;
ULONG DataWord1;
ULONG DataWord2;
ULONG DataWord3;
ULONG DataWord4;
ULONG DataSize;
CHAR *pData;
ULONG PackSeq;
ULONG chksum;
ULONG TimeStamp;
ULONG PackMarker;
ULONG Reserved;
} WarpNetPacket;
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - Message ΓòÉΓòÉΓòÉ
Message
A Warp network message
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - Node ΓòÉΓòÉΓòÉ
Node
Packet Destination Node (currently unused).
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - Channel ΓòÉΓòÉΓòÉ
Channel
Packet Destination channel (currently unused).
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - srcPlayerId ΓòÉΓòÉΓòÉ
srcPlayerId
Packet Source Player ID
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - tgtPlayerId ΓòÉΓòÉΓòÉ
tgtPlayerId
Packet Destination Player
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - fHeaderOnly ΓòÉΓòÉΓòÉ
fHeaderOnly
Ignore Data and Transmit the header only
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - DataWord1 ΓòÉΓòÉΓòÉ
DataWord1
Optional Data Word for application use
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - DataWord2 ΓòÉΓòÉΓòÉ
DataWord2
Optional Data Word for application use
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - DataWord3 ΓòÉΓòÉΓòÉ
DataWord3
Optional Data Word for application use
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - DataWord4 ΓòÉΓòÉΓòÉ
DataWord4
Optional Data Word for application use
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - DataSize ΓòÉΓòÉΓòÉ
DataSize
Packet Data Size. Should be set by the application to indicate the size of
the data packet to be transmitted.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - *pData ΓòÉΓòÉΓòÉ
*pData
Packet Data. The data pointer that points to the actual data.
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - PackSeq ΓòÉΓòÉΓòÉ
PackSeq
Fragmented Packet Sequence
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - chksum ΓòÉΓòÉΓòÉ
chksum
Fragmented Packet Checksum
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - TimeStamp ΓòÉΓòÉΓòÉ
TimeStamp
Fragmented Packet TimeStamp
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - PackMarker ΓòÉΓòÉΓòÉ
PackMarker
Fragmentation/ Assembly Aide
ΓòÉΓòÉΓòÉ <hidden> WarpNetPacket - Reserved ΓòÉΓòÉΓòÉ
Reserved
For System use
ΓòÉΓòÉΓòÉ 3.2.2. WarpNetDest ΓòÉΓòÉΓòÉ
typedef struct _WarpNetDest {
BOOL fDotted;
CHAR Destination [255];
BOOL fUsePlayerID;
ULONG PlayerId;
} ToAddress;
ΓòÉΓòÉΓòÉ <hidden> WarpNetDest - fDotted ΓòÉΓòÉΓòÉ
fDotted (BOOL)
Dotted decimal address
ΓòÉΓòÉΓòÉ <hidden> WarpNetDest - Destination [255] ΓòÉΓòÉΓòÉ
Destination [255] (CHAR)
PlayerIds usually map to application Destinations. Existing PlayerIds can
be queried from the system.
ΓòÉΓòÉΓòÉ <hidden> WarpNetDest - fUsePlayerID ΓòÉΓòÉΓòÉ
fUsePlayerID (BOOL)
Use PlayerID instead of internet address
ΓòÉΓòÉΓòÉ <hidden> WarpNetDest - PlayerId ΓòÉΓòÉΓòÉ
PlayerId (ULONG)
The playerId value that identifies a player. PlayerId is returned to the
application as receipt of successfull registration.
ΓòÉΓòÉΓòÉ 3.2.3. PlayerInst ΓòÉΓòÉΓòÉ
Player Instances are identified by this structure:
typedef struct _group {
int cs;
int strms;
ULONG PlayerId;
HEV PackRecvSem;
HEV ConRecvSem;
BOOL Local;
ULONG ProcessId;
struct sockaddr_inclient;
} PlayerInst;
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - cs ΓòÉΓòÉΓòÉ
cs
Client UDP DataGram Socket
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - strms ΓòÉΓòÉΓòÉ
strms
Client TCP Stream Socket
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - PlayerId ΓòÉΓòÉΓòÉ
PlayerId
Player Identification number
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - PackRecvSem ΓòÉΓòÉΓòÉ
PackRecvSem
WarpNetPackRecv Semaphore
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - ConRecvSem ΓòÉΓòÉΓòÉ
ConRecvSem
WarpNetConRecv Semaphore
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - Local ΓòÉΓòÉΓòÉ
Local
Local Process Flag
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - ProcessId ΓòÉΓòÉΓòÉ
ProcessId
Process ID
ΓòÉΓòÉΓòÉ <hidden> PlayerInst - sockaddr_in client ΓòÉΓòÉΓòÉ
sockaddr_in client
Client Address Information
ΓòÉΓòÉΓòÉ <hidden> OS/2 Warp Network Messages ΓòÉΓòÉΓòÉ
The WarpNetPacket data member message identifies the application/system
messages. Certain system messages alter the system state. Application messages
are merely delivered to the application without system interpretation.
Messages for Warp network include:
#define WARPNETERR_BASE 5000
#define WARPNETMSG_BASE 4000
#define WARPNET_REGISTER_PLAYER (WARPNETMSG_BASE + 1)
#define WARPNET_DEREGISTER_PLAYER (WARPNETMSG_BASE + 2)
#define WARPNET_QUERY_NUMPLAYERS (WARPNETMSG_BASE + 3)
#define WARPNET_QUERY_PROTOCOL (WARPNETMSG_BASE + 4)
#define WARPNET_QUERY_PLAYERLIST (WARPNETMSG_BASE + 5)
#define WARPNET_CURRENT_PLAYERLIST (WARPNETMSG_BASE + 6)
#define WARPNET_REGISTERATION_COMPLETE (WARPNETMSG_BASE + 7)
#define WARPNET_ERR_INVALID_BUFFER_SIZE (WARPNETERR_BASE + 1)
#define WARPNET_ERR_INVALID_DESTINATION (WARPNETERR_BASE + 2)
#define WARPNET_ERR_INVALID_BUFFER (WARPNETERR_BASE + 3)
#define WARPNET_ERR_MEMORY_EXHAUSTED (WARPNETERR_BASE + 4)
#define WARPNET_ERR_SOCKET_INITIALIZATION (WARPNETERR_BASE + 5)
ΓòÉΓòÉΓòÉ 4. OS/2 Joystick Device Driver ΓòÉΓòÉΓòÉ
The OS/2 Joystick Device Driver (GAMEDD.SYS) is a generic drive that is not
designed to work with any particular type of joystick. It can support any two
standard joysticks, or one joystick with extended features, such as a hatch or
throttle control.
The driver simply reads the joystick port for position information and feeds
that back to the game program at the appropriate time. It is then up to your
program to interpret the data correctly.
The OS/2 Joystick Device Driver GAMEDD.SYS for OS/2 (or GAMEVDD.SYS for DOS)
allows applications to communicate with the driver, which allows games running
under OS/2 or DOS very efficient and reliable readings of the joystick port.
The OS/2 Joystick Device Driver allows an OS/2 Warp application to access the
machine's game port and provides a common interface for game port facilities in
all OS/2 games and other applications.
The driver provides an interface for reading the joysticks and for providing
reliable joystick readings. The Joystick functions are implemented within the
OS/2 Joystick Device Driver.
The IBM PC game port adapter provides a simple interface to joysticks and other
similar analog devices. The status of up to 4 analog and 4 digital signals is
read through I/O port address 201h. Two analog and two digital signals are
commonly grouped together in the form of a dual axis joystick with two "fire"
buttons. Some modern joysticks use two axes for movement and an additional
axis for throttle.
Each analog and digital signal is assigned one bit in the game adapter port. A
low (binary zero) value for a bit connected to a joystick button is returned
when that button is depressed. Bits representing analog signals are
implemented as one-shot outputs. All one-shots are fired when the I/O port is
written to and remain high until an RC timing circuit decays. The variable
position of each joystick axis provides the necessary resistance for this delay
circuit. If a joystick axis is not connected, the infinite resistance across
that signal holds the one-shot high indefinitely.
Determining the position of each joystick axis is done by measuring the
duration of the high state for each one-shot. Two methods are commonly used to
measure this duration: counting loop iterations and reading the hardware
timer. Although the iterative method is dependant on the speed of the
processor, with proper calibration of each axis this limitation becomes
irrelevant. This is the method chosen to sample the game port adapter in this
driver.
The execution of a DOS application inside an OS/2 VDM is controlled by the
operating system. As just one of many tasks being handled by the scheduler,
the DOS application can be switched away from at any moment to be returned to
that point at some later time. If this occurs when the joysticks are being
read by either of the above two methods, the result is catastrophic. In the
case of the iterative method, the suspending of execution causes the sampling
procedure to terminate early and return low values for all axes. In the case
of the timed sampling methods, the delay introduced by the suspension of
execution has the opposite effect in that the value read from the timer chip is
incorrectly high. In either case, the effect the user sees is that of the
joystick "flickering" from the correct position making the device unusable.
One of the primary functions of this driver is to provide a remedy to this
problem for DOS applications using the iterative sampling method. Not only is
this method of reading the port substantially more common, but providing a fix
is also much more feasible (selectively returning fabricated values from an
emulated timer chip could have other more dramatic side effects making this
procedure inadvisable). The solution is as simple as returning high-values to
the DOS application for each of the one-shot outputs until the correct count
has been reached. The counts are determined as part of the normal sampling
procedure inside the real-time clock timer handler.
The OS/2 Joystick Device Driver has two main purposes:
To provide a standard interface for OS/2 game programmers to use the PC
joystick port in their products
To eliminate the joystick response "flicker" effect seen in many games
running under OS/2
The obvious other function of this driver is to define and implement an
interface. The generic IOCtl interface was chosen as the method of
communication with the driver for its ability to transfer specific packets of
information to and from the application. Because this component of the driver
is simpler than the "flicker" reduction component while also supplying a large
part of its functionality, it is discussed in detail first.
ΓòÉΓòÉΓòÉ 4.1. Joystick Device Driver Functions ΓòÉΓòÉΓòÉ
Defining and implementing API functions for OS/2 applications is one of the
primary functions of this driver. After opening the device, applications
communicate with the driver using the function DosDevIOCtl after opening the
new GAME$ device. Functions are provided for getting and setting device
parameters, reading the state of the devices connected, and calibrating those
devices.
The driver samples the game port adapter inside the real-time clock timer
handler. This handler is registered with the operating system at device
initialization and is called every 32 milliseconds thereafter. It determines
if the game adapter port requires sampling based on client demand and the
current sampling rate. Client demand for the sampling procedure exists only if
an OS/2 application has the device open or if a VDM is emulating the port.
The joysticks connected are determined and calibrated as part of the device
initialization. These parameters can be modified by an OS/2 application or
refreshed through a calibration IOCtl request.
In addition to the standard device Read function, functions are also defined
for returning the state of the device connected at the next button press or at
the next timed read. These functions block the calling process until the given
event occurs when the process is run from inside the timer handler.
ΓòÉΓòÉΓòÉ 4.2. Flicker Reduction ΓòÉΓòÉΓòÉ
The pre-emptive, multi-tasking nature of OS/2 can cause DOS applications
reading the game adapter port to deduce incorrect positions for the joysticks
connected and cause flickering. The solution implemented in this driver to
this problem is to regularly sample the game adapter port inside the physical
device driver (PDD) and then return fabricated values to the DOS application
that reflect that state. With the logic for regularly sampling the port
already in the PDD, all that must be done in that regard is to activate that
procedure.
Before any of this can be initiated, the first thing that must be done is to
trap any access to the game port by the DOS application. Any time I/O ports
are to be trapped or emulated, an OS/2 virtual device driver (VDD) is required.
The VDD works in conjunction with the PDD to provide the device emulation by
capturing port reads and returning values that reflect the current state as
determined by the PDD. The VDD is also responsible for determining if a given
VDM is to have direct access to the port and if so, to obtain ownership of it.
At device initialization, the VDD first opens the PDD and then retrieves a
pointer to the data area that is to be used to store the current state of the
device. Then, the next item for the VDD is when a DOS session is started at
which time it hooks the I/O port for the game adapter. Knowing that the device
must be written to by the CPU to fire the one-shots before the read sequence
can begin, the hook handler for the Write operation is the function where
device ownership or emulation is resolved.
If the GAME_DIRECT_ACCESS for DOS property is ON for that session, this
specifies that the device is to be directly accessed by the VDM. In this case,
the VDD must first obtain ownership of the device before allowing this
operation to proceed. Device ownership is one of the more complex issues
handled by this driver. It first involves getting permission from the PDD that
can only be granted if the device is presently unused either by an OS/2
application or by another VDM through the emulation system. If not available,
the user is given the choice to kill the session, wait for the device to become
free, or ignore that error and use the device in emulation mode. If the user
chooses to wait for the device to become free, the DOS session process will be
blocked on an event semaphore to be posted when the device is available.
Once the VDD is granted ownership of the device by the PDD, it then must
arbitrate final ownership among all the VDMs competing for it. A mutual
exclusion (MUTEX) semaphore is used as the final decision maker in this process
and the VDM that is granted ownership of it is given the same status as the
game adapter port. When the DOS application, which owns the device terminates,
the MUTEX semaphore is released allowing any other VDMs waiting to compete for
its ownership once again. If no VDMs are waiting, the ownership of the device
is returned to none through a call to the PDD.
If the GAME_DIRECT_ACCESS property for a VDM is in its default state of OFF and
the game adapter port is written to, the emulation system is activated. First
the VDD informs the PDD that it wants to become a client of the sampling
procedure. If no other clients are already active, this request forces an
initial sampling so that valid data is immediately available to the VDD. Next
the VDD copies the game port data from the PDD space to its own VDM instance
data area using the pointer retrieved at initialization. This copy of the data
is used when the DOS application reads the game port.
Next, the emulation system uses the other DOS property registered at
initialization: "GAME_DIGITAL_RESPONSE." If set to "ON," the joysticks
connected are emulated as fixed resistance style joysticks such as the Gravis
GamePad. In this case, the values for each axis are selected from a field in
the PDD data area that corresponds to the range the actual value is presently
within. That is, if the current value for an axis is less than the upper limit
for the lower range, a given fixed value for the lower range is chosen.
With the given value for each axis in hand, the VDD is ready to emulate the
game port adapter when read by the DOS application. First the count on the
number of reads is zeroed as the last operation in the port Write handler.
When the port read handler is called, the value for each axis is compared
against the number of reads by this VDM and if greater, a 1 for that bit is
generated. The state of each position bit mirrors the value returned by the
actual hardware when the PDD last sampled it on that iteration. The bits for
each of the buttons is retrieved from the PDD data area and used in generating
the byte returned. This information is transferred on each read to maintain a
"freshness" in the button data.
The driver needs to poll the game port for new joystick information. However,
it only does this when an application (game) is using it and is idle otherwise.
ΓòÉΓòÉΓòÉ 4.3. Manual Installation of the Joystick Device Drivers ΓòÉΓòÉΓòÉ
NOTE: If you have an older version of these drivers installed, you will have
to delete the GAMEDD.SYS, GAMEVDD.SYS, and GAMEDD.DOC (if applicable) files
from your \OS2 directory manually. Also, modify references to these drivers
from your CONFIG.SYS as explained in the following procedure.
The Joystick Device Driver for OS/2 can be installed using the following steps:
1. Install the Entertainment Tools.
The Joystick Device Driver file (GAMEDD.SYS for OS/2) is copied to the
default directory \TOOLKIT\BETA\SYS\ unless you modify the Entertainment
Toolkit installation path.
2. Add the following line to your CONFIG.SYS file, which assumes you
installed to the default path:
device=d:\toolkit\beta\sys\gamedd.sys
Be sure to replace d: with the letter of your boot drive.
3. Reboot your system to enable the driver.
ΓòÉΓòÉΓòÉ 4.4. Known Compatibility List ΓòÉΓòÉΓòÉ
The following is a list of games that have been tested with this driver.
Name of Game Version
Alien Carnage 1.0
Boppin 1.1
Commander Keen 4.0
Doom II 1.7
Falcon 3.0
Jazz Jackrabbit 1.0
Line Wars II 1.04
Lion King NA
Magic Carpet NA
MS Flight Simulator 5.0a
Mortal Kombat 1.0
NASCAR Racing NA
One Must Fall 1.0
Rampart NA
Raptor 1.0
Star Control II NA
SVGA Air Warrior 1.16b
Tie Fighter NA
X-Wing 1 (3.5") NA
ΓòÉΓòÉΓòÉ 4.5. Known Limitations ΓòÉΓòÉΓòÉ
There are some games that do not work well work with joystick support under
OS/2. Unfortunately, the driver cannot do anything about fixing these
problems. Because the majority of games do work with a joystick under OS/2, we
suggest you either contact the authors of the game in question, or use the OS/2
Games Homepage (http://www.austin.ibm.com/os2game) to report problems you are
having with a particular type of joystick.
Because the driver is a general-purpose driver, it should work with almost any
standard game adapter.
ΓòÉΓòÉΓòÉ 4.6. OS/2 Joystick Device Driver Functions ΓòÉΓòÉΓòÉ
The OS/2 Joystick Device Driver (GAMEDD.SYS) allows an OS/2 Warp application to
access the machine's game port. The driver provides an interface or a set of
function calls for reading the joysticks.
The Joystick functions are implemented within the OS/2 Joystick Device Driver.
Currently, there are no high level versions or access of these functions except
through the function DosDevIOCtl. The sample issues the function DosDevIOCtl
to request status or send commands to the OS/2 Joystick Device Driver. The API
function numbers, input parameters to DosDevIOCtl, are defined by the OS/2
Joystick Device Driver.
ΓòÉΓòÉΓòÉ 4.6.1. DosOpen ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> DosOpen - Syntax ΓòÉΓòÉΓòÉ
This function must be called first to open the device driver name (GAME$ )
prior to any function call to the OS/2 Joystick Device Driver. When the
program terminates, DosClose must be called to end the program properly.
#include <os2.h>
#include <stdlib.h>
#include <iostream.h>
#include "joyos2.h"
APIRET DosOpen ( PSZ pszFileName, PHFILE pHf,
PULONG pulAction, ULONG cbFile,
ULONG ulAttribute, ULONG fsOpenFlags,
ULONG fsOpenMode, PEAOP2 peaop2)
ΓòÉΓòÉΓòÉ <hidden> DosOpen - Parameters ΓòÉΓòÉΓòÉ
pszFileName (PSZ) - input
Address of the ASCII path name of the device to be opened.
pHf (PHFILE) - output
Address of the handle for the file.
pulAction (PULONG) - output
Address of the variable that receives the value that specifies the action
taken by the DosOpen function.
cbFile (ULONG) - input
New logical size of the file (end of data, EOD), in bytes.
ulAttribute (ULONG) - input
File attribute information.
fsOpenFlags (ULONG) - input
The action to be taken depending on whether the file exists or does not
exist.
fsOpenMode (ULONG) - input
The mode of the open function.
peaop2 (PEAOP2) - input/output
Extended attribute.
A complete description of the DosOpen function can be found in the Control
Program Programming Reference.
ΓòÉΓòÉΓòÉ <hidden> DosOpen Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero.
Returns nonzero if not successful.
A complete description of the DosOpen function can be found in the Control
Program Programming Reference.
ΓòÉΓòÉΓòÉ <hidden> DosOpen - Programming Tutorial Code ΓòÉΓòÉΓòÉ
JOYTEST, the OS/2 Joystick programming tutorial (sample), allows an OS/2 Warp
application to access the machine's game port. The design of this sample is
based on the set of functions provided by the OS/2 Joystick device driver
(GAMEDD.SYS). The OS/2 Joystick device driver provides an interface or a set
of function calls for reading the joysticks.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\INPUT\JOYTEST
Hardware Requirements:
Joystick device.
Software Requirements:
GAMEDD.SYS driver
OS/2 Warp 3.0 or higher
OS/2 Warp Developer's Toolkit 3.0 or higher
IBM C Set ++ compiler 2.x or 3.x
You can start the programming tutorial by typing the programming tutorial name
(JOYTEST.EXE) at the OS/2 command line:
joytest
Or by double-clicking on the Joystick icon.
Note: Make sure the CONFIG.SYS has the following statement after installation
of the Entertainment Tools:
DEVICE=[drive:\] GAMEDD.SYS
where drive: is the path pointing to GAMEDD.SYS.
There is user interaction to the sample by moving the joystick handle to
different position and the user will see the status information changing as
new values are being read in by the sample. The user can press button 2 on
the joystick to see the count displayed. Depending on the number of installed
joysticks, the status and information of all joysticks will be shown similar
to the following:
Getting the current joystick values:
A (x's, y's): #x, #y
A (x's, y's, z's) : #x, #y #z (when there is an extended joystick
installed)
(where:
#x = x-position value,
#y = y-position value,
#z = value for the hatch button, pedal or thrust control)
If the driver is not installed, an error message is displayed and the program
terminates.
You might encounter the following messages while using the JOYTEST sample:
Error n:Program cannot open the device name
Check to see if the driver is installed on the system. n is the error code
returned from the function call DosOpen.
Error n:Program cannot access the API function using the IOCtl interface
This error might be caused by a General Failure, buffer overflow or an
incorrect driver level. n is the error code returned from the function call
DosDevIOCtl.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> DosOpen - Example Code ΓòÉΓòÉΓòÉ
The following example illustrates how to open the device.
HFILE hGame;
ULONG action;
APIRET rc;
rc = DosOpen ( GAMEPDDNAME, &hGame, &Action,
0, FILE_READONLY, FILE_OPEN,
OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE
rc = DosOpen ( GAMEPDDNAME, /* "GAME$" */
&hGame, &action,
0,
FILE_READONLY,
FILE_OPEN,
OPEN_ACCESS_READONLY | OPEN_SHARE_DENYNONE,
NULL);
if (rc != 0)
{
/* ERROR opening device : result code in rc */
}
ΓòÉΓòÉΓòÉ <hidden> DosOpen - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
Example Code
ΓòÉΓòÉΓòÉ 4.6.2. DosDevIOCtl ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl - Syntax ΓòÉΓòÉΓòÉ
This function is used to access the OS/2 Joystick device driver's functions
passing the unique device handle, hDevice, which is the returned value from
DosOpen. The category parameter has the value of hex 80.
#include <os2.h>
#include <stdlib.h>
#include <iostream.h>
#include "joyos2.h"
APIRET DosDevIOCtl ( HFILE hDevice, ULONG category,
ULONG function, PVOID pParams,
ULONG cbParmLenMax,
PULONG pcbParmLen, PVOID pData,
ULONG cbDataLenMax, PULONG pcbDataLen)
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl - Parameters ΓòÉΓòÉΓòÉ
hDevice (HFILE) - input
Device handle returned by DosOpen.
category (ULONG) - input
Device category.
function (ULONG) - input
Device-specific function.
pParams (PVOID) - input
Address of the command-specific argument list.
cbParmLenMax (ULONG) - input
Length, in bytes, of pParams.
pcbParmLen (PULONG) - input
Pointer to the length of parameters.
pData (PVOID) - input
Address of the data area.
cbDataLenMax (ULONG) - input
Length, in bytes, of pData.
pcbDataLen (PULONG) - in/out
Pointer to the length of data.
A complete description of the DosDevIOCtl function can be found in the Control
Program Programming Reference.
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero
Returns nonzero if not successful
A complete description of the DosDevIOCtl function can be found in the Control
Program Programming Reference.
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl - Example Code ΓòÉΓòÉΓòÉ
The following example illustrates how to call all the functions of the OS/2
device driver:
HFILE hGame;
ULONG action;
APIRET rc;
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_GET_VERSION,
NULL, 0,
NULL, &version,
dataLen, &dataLen);
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_GET_PARMS,
NULL, 0,
NULL, &gameParms,
dataLen, &dataLen);
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_GET_CALIB,
NULL, 0,
NULL, &gameCalib,
dataLen, &dataLen);
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_GET_STATUS,
NULL, 0,
NULL, &gameStatus,
dataLen, &dataLen);
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_GET_STATUS_BUTWAIT,
NULL, 0,
NULL, &gameStatus,
dataLen, &dataLen)
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_SET_PARMS,
&gameParms, parmLen,
&parmLen, NULL,
0, NULL);
rc = DosDevIOCtl ( hGame, IOCTL_CAT_USER,
GAME_GET_STATUS_SAMPWAIT,
NULL, 0,
NULL, &gameStatus,
dataLen, &dataLen);
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl - Function Numbers ΓòÉΓòÉΓòÉ
The function numbers for the functions are defined by the OS/2 Joystick device
driver as follows:
#define IOCTL_CAT_USER
0x80 The category number.
#define GAME_GET_VERSION
0x01 Get version of the device driver.
#define GAME_GET_PARMS
0x02 Get device parameters.
#define GAME_SET_PARMS
0x03 Set device parameters.
#define GAME_GET_CALIB
0x04 Get the calibration values.
#define GAME_GET_STATUS
0x10 Get the current joystick status.
#define GAME_GET_STATUS_BUTWAIT
0x11 Get status at next button press.
#define GAME_GET_STATUS_SAMPWAIT
0x12 Get status until next sample.
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl - Programming Tutorial Code ΓòÉΓòÉΓòÉ
JOYTEST, the OS/2 Joystick programming tutorial (sample), allows an OS/2 Warp
application to access the machine's game port. The design of this sample is
based on the set of functions provided by the OS/2 Joystick device driver
(GAMEDD.SYS). The OS/2 Joystick device driver provides an interface or a set
of function calls for reading the joysticks.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\INPUT\JOYTEST
Hardware Requirements:
Joystick device.
Software Requirements:
GAMEDD.SYS driver
OS/2 Warp 3.0 or higher
OS/2 Warp Developer's Toolkit 3.0 or higher
IBM C Set ++ compiler 2.x or 3.x
You can start the programming tutorial by typing the programming tutorial name
(JOYTEST.EXE) at the OS/2 command line:
joytest
Or by double-clicking on the Joystick icon.
Note: Make sure the CONFIG.SYS has the following statement after installation
of the Entertainment Tools:
DEVICE=[drive:\] GAMEDD.SYS
where drive: is the path pointing to GAMEDD.SYS.
There is user interaction to the sample by moving the joystick handle to
different position and the user will see the status information changing as
new values are being read in by the sample. The user can press button 2 on
the joystick to see the count displayed. Depending on the number of installed
joysticks, the status and information of all joysticks will be shown.
If the driver is not installed, an error message is displayed and the program
terminates.
You might encounter the following messages while using the JOYTEST sample:
Error n:Program cannot open the device name
Check to see if the driver is installed on the system. n is the error code
returned from the function call DosOpen.
Error n:Program cannot access the API function using the IOCtl interface
This error might be caused by a General Failure, buffer overflow or an
incorrect driver level. n is the error code returned from the function call
DosDevIOCtl.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> DosDevIOCtl - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Function Numbers
Programming Tutorial Code
Example Code
ΓòÉΓòÉΓòÉ 4.6.3. DosClose ΓòÉΓòÉΓòÉ
ΓòÉΓòÉΓòÉ <hidden> DosClose - Syntax ΓòÉΓòÉΓòÉ
This function is issued to end the program properly when the program
terminates.
#include <os2.h>
#include <stdlib.h>
#include <iostream.h>
#include "joyos2.h"
APIRET DosClose ( HFILE hFile )
ΓòÉΓòÉΓòÉ <hidden> DosClose - Parameters ΓòÉΓòÉΓòÉ
hFile (HFILe) - input
The handle returned by a previous call to DosOpen.
A complete description of the DosClose function can be found in the Control
Program Programming Reference.
ΓòÉΓòÉΓòÉ <hidden> DosClose Return Value - rc ΓòÉΓòÉΓòÉ
rc (ULONG) - returns
Return codes indicating success or type of failure:
rc = 0
Returns 0 if successful.
rc = nonzero
Returns nonzero if not successful.
A complete description of the DosClose function can be found in the Control
Program Programming Reference.
ΓòÉΓòÉΓòÉ <hidden> DosClose - Programming Tutorial Code ΓòÉΓòÉΓòÉ
JOYTEST, the OS/2 Joystick programming tutorial (sample), allows an OS/2 Warp
application to access the machine's game port. The design of this sample is
based on the set of functions provided by the OS/2 Joystick device driver
(GAMEDD.SYS). The OS/2 Joystick device driver provides an interface or a set
of function calls for reading the joysticks.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\INPUT\JOYTEST
Hardware Requirements:
Joystick device.
Software Requirements:
GAMEDD.SYS driver
OS/2 Warp 3.0 or higher
OS/2 Warp Developer's Toolkit 3.0 or higher
IBM C Set ++ compiler 2.x or 3.x
You can start the programming tutorial by typing the programming tutorial name
(JOYTEST.EXE) at the OS/2 command line:
joytest
Or by double-clicking on the Joystick icon.
Note: Make sure the CONFIG.SYS has the following statement after installation
of the Entertainment Tools:
DEVICE=[drive:\] GAMEDD.SYS
where drive: is the path pointing to GAMEDD.SYS.
There is user interaction to the sample by moving the joystick handle to
different position and the user will see the status information changing as
new values are being read in by the sample. The user can press button 2 on
the joystick to see the count displayed. Depending on the number of installed
joysticks, the status and information of all joysticks will be shown.
If the driver is not installed, an error message is displayed and the program
terminates.
You might encounter the following messages while using the JOYTEST sample:
Error n:Program cannot open the device name
Check to see if the driver is installed on the system. n is the error code
returned from the function call DosOpen.
Error n:Program cannot access the API function using the IOCtl interface
This error might be caused by a General Failure, buffer overflow or an
incorrect driver level. n is the error code returned from the function call
DosDevIOCtl.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ <hidden> DosClose - Example Code ΓòÉΓòÉΓòÉ
The following example illustrates how to terminate access to the the game:
HFILE hGame;
ULONG action;
APIRET rc;
rc = DosClose ( hGAME )
ΓòÉΓòÉΓòÉ <hidden> DosClose - Topics ΓòÉΓòÉΓòÉ
Select an item:
Syntax
Parameters
Returns
Programming Tutorial Code
Example Code
ΓòÉΓòÉΓòÉ 4.7. OS/2 Joystick Device Driver Data Types ΓòÉΓòÉΓòÉ
This section describes data types in C language. A data type name beginning
with "P" (for example (PMCI_CONNECTOR_PARMS) is likely to be a pointer to
another data type (in this instance, MCI_CONNECTOR_PARMS). If no data type
definition can be found in this section for a data type name "Pxxxxxx,", it
becomes a pointer to the data type "xxxxxxx," for which a definition should be
found. The implicit type definition needed for such a pointer "Pxxxxxx" is:
typedef xxxxxx *Pxxxxxx
ΓòÉΓòÉΓòÉ 4.7.1. GAME_STATUS_STRUCT ΓòÉΓòÉΓòÉ
The status structure for the current data of all joysticks as well as the
number of times each button being pressed since the last read.
typedef struct {
GAME_DATA_STRUCT curdata;
USHORT b1cnt;
USHORT b2cnt;
USHORT b3cnt;
USHORT b4cnt;
} GAME_STATUS_STRUCT;
ΓòÉΓòÉΓòÉ <hidden> GAME_STATUS_STRUCT Field - curdata ΓòÉΓòÉΓòÉ
curdata
Current status
ΓòÉΓòÉΓòÉ <hidden> GAME_STATUS_STRUCT Field - b1cnt ΓòÉΓòÉΓòÉ
b1cnt (USHORT)
Count of button 1 press.
ΓòÉΓòÉΓòÉ <hidden> GAME_STATUS_STRUCT Field - b2cnt ΓòÉΓòÉΓòÉ
b2cnt (USHORT)
Count of button 2 press.
ΓòÉΓòÉΓòÉ <hidden> GAME_STATUS_STRUCT Field - b3cnt ΓòÉΓòÉΓòÉ
b3cnt (USHORT)
Count of button 3 press.
ΓòÉΓòÉΓòÉ <hidden> GAME_STATUS_STRUCT Field - b4cnt ΓòÉΓòÉΓòÉ
b4cnt (USHORT)
Count of button 4 press.
ΓòÉΓòÉΓòÉ 4.7.2. GAME_PARM_STRUCT ΓòÉΓòÉΓòÉ
The parameter structure for parameters defining the operation of the driver and
the information on the installed joysticks.
{
typedef struct {
USHORT useA;
USHORT useB;
USHORT mode;
USHORT format;
USHORT sampDiv;
USHORT scale;
USHORT res1;
USHORT res2;
} GAME_PARM_STRUCT;
ΓòÉΓòÉΓòÉ <hidden> useA - Parameters ΓòÉΓòÉΓòÉ
useA (USHORT)
Joystick A is installed.
ΓòÉΓòÉΓòÉ <hidden> useB - Parameters ΓòÉΓòÉΓòÉ
useB (USHORT)
Joystick B is installed.
ΓòÉΓòÉΓòÉ <hidden> mode - Parameters ΓòÉΓòÉΓòÉ
mode (USHORT)
Only timed sampling was implemented.
ΓòÉΓòÉΓòÉ <hidden> format - Parameters ΓòÉΓòÉΓòÉ
format (USHORT)
Only raw format was implemented.
ΓòÉΓòÉΓòÉ <hidden> sampDiv - Parameters ΓòÉΓòÉΓòÉ
sampDiv (USHORT)
Samp freq = 32 / n.
ΓòÉΓòÉΓòÉ <hidden> scale - Parameters ΓòÉΓòÉΓòÉ
scale (USHORT)
Scaling factor.
ΓòÉΓòÉΓòÉ <hidden> res1 - Parameters ΓòÉΓòÉΓòÉ
res1 (USHORT)
Must be 0.
ΓòÉΓòÉΓòÉ <hidden> res2 - Parameters ΓòÉΓòÉΓòÉ
res2 (USHORT)
Must be 0.
ΓòÉΓòÉΓòÉ 4.7.3. GAME_CALIB_STRUCT ΓòÉΓòÉΓòÉ
The structure defines the calibration values of each axis:
Upper limit on value to be considered in lower range
Center value
Lower limit on value to be considered in upper range
typedef struct {
GAME_3POS_STRUCT Ax;
GAME_3POS_STRUCT Ay;
GAME_3POS_STRUCT Bx;
GAME_3POS_STRUCT By;
} GAME_CALIB_STRUCT;
ΓòÉΓòÉΓòÉ <hidden> GAME_3POS_STRUCT Ax - Parameters ΓòÉΓòÉΓòÉ
GAME_3POS_STRUCT Ax;
GAME_3POS_STRUCT Ax;
ΓòÉΓòÉΓòÉ <hidden> GAME_3POS_STRUCT Ay - Parameters ΓòÉΓòÉΓòÉ
GAME_3POS_STRUCT Ay;
ΓòÉΓòÉΓòÉ <hidden> GAME_3POS_STRUCT Bx - Parameters ΓòÉΓòÉΓòÉ
GAME_3POS_STRUCT Bx;
ΓòÉΓòÉΓòÉ <hidden> GAME_3POS_STRUCT By - Parameters ΓòÉΓòÉΓòÉ
GAME_3POS_STRUCT By;
ΓòÉΓòÉΓòÉ 4.7.4. GAME_DATA_STRUCT ΓòÉΓòÉΓòÉ
The structure defines the instantaneous state of the joysticks and all buttons.
typedef struct {
GAME_2DPOS_STRUCT A;
GAME_2DPOS_STRUCT B;
USHORT butMask;
} GAME_DATA_STRUCT;
ΓòÉΓòÉΓòÉ <hidden> GAME_2DPOS_STRUCT A - Parameters ΓòÉΓòÉΓòÉ
GAME_2DPOS_STRUCT A
ΓòÉΓòÉΓòÉ <hidden> GAME_2DPOS_STRUCT B - Parameters ΓòÉΓòÉΓòÉ
GAME_2DPOS_STRUCT B
ΓòÉΓòÉΓòÉ <hidden> butMask - Parameters ΓòÉΓòÉΓòÉ
butMask (USHORT)
ΓòÉΓòÉΓòÉ 4.7.5. GAME_2DPOS_STRUCT ΓòÉΓòÉΓòÉ
The structure defines the 2-D position for each joystick.
typedef USHORT GAME_POS {
GAME_POS x;
GAME_POS y;
} GAME_2DPOS_STRUCT;
typedef SHORT GAME_POS
ΓòÉΓòÉΓòÉ <hidden> GAME_POS x - Parameters ΓòÉΓòÉΓòÉ
GAME_POS x (USHORT)
Some data formats require signed values.
ΓòÉΓòÉΓòÉ <hidden> GAME_POS y - Parameters ΓòÉΓòÉΓòÉ
GAME_POS y (USHORT)
Some data formats require signed values.
ΓòÉΓòÉΓòÉ 4.7.6. GAME_3DPOS_STRUCT ΓòÉΓòÉΓòÉ
The structure to be used for calibration and digital response on each axis.
typedef struct {
GAME_POS lower;
GAME_POS centre;
GAME_POS upper;
} GAME_3POS_STRUCT;
ΓòÉΓòÉΓòÉ <hidden> GAME_POS lower ΓòÉΓòÉΓòÉ
GAME_POS lower
The lower calibration value for an extended joystick.
ΓòÉΓòÉΓòÉ <hidden> GAME_POS center ΓòÉΓòÉΓòÉ
GAME_POS center
The center calibration value for an extended joystick.
ΓòÉΓòÉΓòÉ <hidden> GAME_POS upper ΓòÉΓòÉΓòÉ
GAME_POS upper
The upper calibration value for an extended joystick.
ΓòÉΓòÉΓòÉ 5. DIVE and Full-Screen DIVE ΓòÉΓòÉΓòÉ
Software motion video implementation under OS/2 has attained sizable
performance advantages by enabling video decompressors to directly write to
video memory. While this technique provides good performance, it has the
disadvantage that each decompressor must deal with the pel format of the
display in various modes, clipping the output to visible regions, and any
scaling that is to be performed. Additionally, on bank-switched video displays,
the decompressor must return on partial frames to enable the video stream
handler to switch banks.
The Direct Interface Video Extensions (DIVE) give OS/2 Warp applications direct
access to the PC video hardware and also provide a high level of performance.
DIVE allows you to generate the high-speed graphics needed for today's advanced
multimedia software.
The new DIVE interface for displaying images permits high-speed animation from
still image data. High speed can mean 50fps or more-depending on the image
size, whether acceleration hardware is available, and what type of display is
used.
OS/2 Warp supports several ways of addressing the video display, and the
following are especially interesting to you as a game developer. Using DIVE
functions, applications can either:
Use the DIVE functions if you want your application to take advantage of
any hardware accelerator support by using a pointer returned by DiveOpen
(refer to Direct Interface Video Extensions).
Or:
Write directly to video memory, even when running in a Presentation
Manager window, by using the enhanced DIVE (EnDIVE) architecture. EnDIVE
supports the use of motion video accelerator hardware (refer to Direct
Access to Video Buffers).
ΓòÉΓòÉΓòÉ 5.1. Direct Interface Video Extensions (DIVE) ΓòÉΓòÉΓòÉ
DIVE provides optimized blitting performance for motion video subsystems and
applications that perform rapid screen updates in the OS/2 PM and full-screen
environments. The DIVE blitter uses acceleration hardware when present and
applicable to the function being performed.
Information about DIVE functions includes:
DIVE Display Engine Function Characteristics
The DIVE display engine abstracts the low-level device driver DIVE
function (EnDIVE) to a higher level resulting in easy-to-use functions
for display updates and hides the complexities of color space conversion,
window clipping, scaling, and bank switching. The DIVE display engine
detects and takes advantage of motion video acceleration hardware, when
present using EnDive, providing improved performance.
Dive Image Buffer
DIVE consolidates the complexities of dealing with direct video frame
buffer access (sometimes referred to as "direct access" or "black hole")
into a single DLL that enables efficient transfer to video memory with
clipping, scaling, and color space conversion. The optimized screen
access functionality provided by DIVE can be used for motion video
display, fast image updates for interactive games, and fast screen
display by 3D graphics libraries.
Dive Palette
Of special interest to gamers, DIVE also simulates palette animation in
direct color display modes.
Direct Frame-Buffer Access
DIVE also uses graphics display hardware acceleration capabilities when
present so your game might actually run faster through the display engine
than it would with direct video buffer access.
For complete information about Direct Interface Video Extensions (DIVE), refer
to the Multimedia Programming Reference. This reference is intended to be
used in conjunction with the Multimedia Application Programming Guide and
Multimedia Subsystem Programming Guide.
ΓòÉΓòÉΓòÉ 5.1.1. DIVE Display Engine Function Characteristics ΓòÉΓòÉΓòÉ
The DIVE system-level interface abstracts the low-level device driver DIVE
interface to a higher level and adds software emulation for operations that all
DIVE users have had to do. This system-level interface is referred to as the
DIVE engine.
The DIVE engine consists of a single, stand-alone DLL that exports the
following functions:
Query for display capabilities
Open instance
Visible region specification
Allocation of image data buffers
Buffer-to-screen/buffer-to-buffer transfer (blitter) setup
8-bit CLUT color palette simulation/specification
Transfer buffer to image display/transfer buffer to buffer
Utility functions useful for direct access, including window
starting-address calculation
Frame buffer acquire/de-acquire
VRAM bank selection (for bank-switched displays)
Close instance
The display engine enables subsystem components (for example, video CODECs)
and applications to either directly access the video buffer or to use the
display engine screen transfer functions. If direct access is used, the using
component or application is responsible for writing to the frame buffer format
for the current display mode and correctly clipping the output. In addition,
the component is responsible for acquiring and bank switching the display
apertures. If display engine screen transfer functions are used, the display
engine handles clipping, pel format and color space conversions, and any
necessary hardware serialization. The input formats and their corresponding
color encoding specification values are:
CLUT 8 (256 color) - "LUT8"
8-bit greyscale - "GREY"
RGB 16 (5-6-5, 5-5-5) - "R565", "R555", "R664"
RGB 24 (R-G-B, B-G-R) - "RGB3", "BGR3"
RGB 32 (R-G-B, B-G-R) - "RGB4", "BGR4"
YUV 9 - DVI/Indeo three-plane color subsampled - "YUV9"
YUV 422 - "Y422"
YUV CCIR601 - three-plane 2x2 color subsampled (MJPEG, MPEG) - "Y2X2"
YUV CCIR601 - three-plane 4x4 color subsampled - "Y4X4"
The output formats are:
CLUT 8 (256 color)
RGB 16 (5-6-5, 5-5-5, 6-6-4)
RGB 24 (R-G-B, B-G-R)
RGB 32 (R-G-B-x, B-G-R-x)
Blitter Operation
There are two main ways to use DIVE: using the DIVE blitter and using
direct-frame buffer access. DIVE applications gain access to DIVE functions
by obtaining a DIVE handle:
ULONG ulErrorCode;
HDIVE *phDiveInst;
BOOL fNonScreenInstance;
PPVOID ppFrameBuffer;
ulErrorCode = DiveOpen( *phDiveInst, fNonScreenInstance, ppFrameBuffer );
A corresponding DiveClose function must be called at application termination.
If DIVE is to be used for blitting to the screen, set fNonScreenInstance to
FALSE. Otherwise, if DIVE is to be used only for off-screen sizing or color
format conversion, set fNonScreenInstance to TRUE. If fNonScreenInstance is
FALSE, a pointer to the frame buffer is returned in ppFrameBuffer.
ΓòÉΓòÉΓòÉ 5.1.2. Dive Image Buffer ΓòÉΓòÉΓòÉ
Because DIVE will use off-screen VRAM where available for acceleration of
blitting operations, the application should allocate all source blitting
buffers from DIVE whenever possible. To allocate a buffer, the application
would make the following call:
ULONG ulBufNum;
FOURCC fccColorSpace;
ULONG ulWidth, ulHeight, ulLineSizeBytes;
PBYTE pbImageBuffer;
ulErrorCode = DiveAllocImageBuffer(
hDive, /* DIVE handle */
&ulBufNum, /* Buffer number (output) */
fccColorSpace, /* Color format */
ulWidth, ulHeight, /* Size of maximum image */
ulLineSizeBytes,
&pbImageBuffer);
A corresponding DiveFreeImageBuffer function call is used to deallocate the
buffer when it is no longer needed. The color format of the image buffer is
described by fccColorSpace. The DIVE interface defines constants for a variety
of 8-, 16-, and 24-bit color encoding schemes. After a buffer is allocated and
before it can be used for blitting, it must be accessed as shown in the
following example:
PBYTE pbImageBuffer;
ULONG ulBufferScanLineBytes, ulBufferScanLines;
ulErrorCode = DiveBeginImageBufferAccess(
hDiveInst, /* DIVE handle */
ulBufferNumber, /* Buffer number */
&pbImageBuffer, /* Ptr to image buffer (output) */
&ulBufferScanLineBytes); /* Scan line length (output) */
&ulBufferScanLines); /* Scan lines (output) */
DIVE calculates the number of bytes per scan line for the image buffer (based
on the color format) and returns the value in ulBufferScanLineBytes. The
application can now write color data into pbImageBuffer. For example, the
application could open a bit-map file and read the bit-map data directly into
the image buffer. After the data has been written, the application calls
DiveEndImageBufferAccess to deaccess the buffer. Be sure to use scan line
bytes (you might have to read a line at a time).
ΓòÉΓòÉΓòÉ 5.1.3. Dive Palette ΓòÉΓòÉΓòÉ
Applications must inform DIVE of the state of the physical palette upon
initialization and whenever the physical palette changes. At application
initialization, and in response to a WM_REALIZEPALETTE message, the application
calls the following sequence:
BYTE pbPal[1024];
/* Query the physical palette from PM */
GpiQueryRealColors( hps, 0, 0, 256, (PLONG)pbPal);
/* Pass it to DIVE */
DiveSetDestinationPalette( hDive, (PBYTE)pbPal);
If the application itself is using palettes, these palettes must also be
communicated to DIVE through the DiveSetSourcePalette function. For example, if
the application is using DIVE to blit 256-color palettized images to the
screen, the application must send the image palette with a call to
DiveSetSourcePalette. If a sequence of images is being used for animation and
the palette remains constant through the series, it is necessary to call
DiveSetSourcePalette only once before blitting the first image in the series.
DIVE provides high-speed screen updates by bypassing PM. In order to maintain
the integrity of the PM desktop, DIVE applications must notify DIVE whenever
the visible region of the application window changes so that output may be
clipped accordingly.
Every DIVE application will request visible region notification at window
initialization time with the following call:
WinSetVisibleRegionNotify( hwnd, TRUE);
The first parameter is the handle of the window where the graphics operations
will appear, and the second parameter turns on notification for that window.
(A corresponding WinSetVisibleRegionNotify(hwnd, FALSE) call should be made to
turn notification off at window termination time.)
Whenever the window's visible region begins to change, either because the
window is being moved or sized or another window or icon overlaying the window
is being moved or sized, the window will receive a WM_VRNDISABLED message. In
response to this message, the DIVE application will call DiveSetupBlitter
(hDiveInst, 0). After the movement is complete, the window will receive a
WM_VRNENABLED message. In response to this message, the DIVE application will
query the new visible region, using WinQueryVisibleRegion as follows:
hps = WinGetPS( hwnd );
hrgn = GpiCreateRegion( hps, 0, NULL);
WinQueryVisibleRegion( hwnd, hrgn);
Whenever the visible region, source color format, or image source or
destination size changes, the DIVE application must pass the changes to DIVE
with a call to DiveSetupBlitter. Note that it is necessary to pass the
rectangles for the region in window coordinates and the position of the window
in desktop coordinates.
First, get the rectangles and window coordinates:
RECTL rctls[50]; /* Rectangles for visible rgn */
RGNRECT rgnCtl; /* Region control struct */
SETUP_BLITTER SetupBlitter; /* DiveSetupBlitter struct */
POINTL pointl;
SWP swp;
HPS hps;
HRGN hrgn;
rgnCtl.ircStart = 0; /* Enumerate rectangles */
rgnCtl.crc = 50; /* Starting with first */
rgnCtl.ulDirection = RECTDIR_LFRT_TOPBOT;
/* Get rectangles for the visible region */
GpiQueryRegionRects( hps, hrgn, NULL, &rgnCtl, rctls);
/* Find the window position relative to its parent. */
WinQueryWindowPos( hwnd, &swp );
/* Map window position to the desktop. */
pointl.x = swp.x;
pointl.y = swp.y;
WinMapWindowPoints( WinQueryWindow( hwnd, QW_PARENT ),
HWND_DESKTOP, &pointl, 1);
Then, pass the information to DIVE:
/* Tell DIVE about the new settings. */
SIZEL sizlSrcImg; /* Size of source image */
FOURCC fccSrcColors; /* Source image format */
SetupBlitter.ulStructLen = sizeof ( SETUP_BLITTER );
SetupBlitter.fInvert = 0;
SetupBlitter.fccSrcColorFormat = fccSrcColors;
SetupBlitter.ulSrcLineSizeBytes = ulScanLineBytes;
SetupBlitter.ulSrcWidth = sizlSrcImg.cx;
SetupBlitter.ulSrcHeight = sizlSrcImg.cy;
SetupBlitter.ulSrcPosX = 0;
SetupBlitter.ulSrcPosY = 0;
SetupBlitter.fccDstColorFormat = FOURCC_SCRN;
SetupBlitter.ulDstLineSizeBytes = 0;
SetupBlitter.ulDstWidth = swp.cx;
SetupBlitter.ulDstHeight = swp.cy;
SetupBlitter.ulDstPosX = 0;
SetupBlitter.ulDstPosY = 0;
SetupBlitter.lScreenPosX = pointl.x;
SetupBlitter.lScreenPosY = pointl.y;
SetupBlitter.ulNumDstRects = rgnCtl.crcReturned;
SetupBlitter.pVisDstRects = rctls;
DiveSetupBlitter ( hDive, &SetupBlitter );
The color format of the source image is described by fccSrcColors.
Note that, in this example, the DIVE blitter is set up to blit to the screen,
but that need not be the case. DIVE could also be used to perform color
conversion and/or stretch blitting to a destination image. The destination
color-encoding format would be indicated in fccDstColorFormat; ulDstWidth and
ulDstHeight would be set to the size of the destination image; ulNumDstRects
would be set to 1; and pVisDstRects would point to a single rectangle with
xLeft=yBottom=0 xRight=ulDstWidth and yTop=ulDstHeight.
ΓòÉΓòÉΓòÉ 5.1.4. Direct Frame-Buffer Access ΓòÉΓòÉΓòÉ
As mentioned earlier, *ppFrameBuffer returned by DiveOpen gives direct
addressability to the frame buffer. In order to write directly to the frame
buffer, the DIVE application must perform its own clipping, color conversion,
and bank switching. The following functions are provided for direct-frame
buffer access:
DiveAcquireFrameBuffer
DiveDeacquireFrameBuffer
DiveSwitchBank
DiveCalcFrameBufferAddress
The DiveQueryCaps function returns whether the display subsystem is
bank-switched. DIVE provides another function called
DiveCalcFrameBufferAddress to get to a location in the frame buffer that
corresponds to a rectangle in desktop coordinates:
PRECTL prectlDest; /* Image rectangle in desktop coors */
PVOID pDestinationAddress; /* Frame buffer address - output */
PULONG pulBankNumber; /* Display h/w bank number - output */
PULONG pulRemlinesInBank; /* Lines left in bank - output */
ulErrorCode = DiveCalcFrameBufferAddress(
hDiveInst, &prectlDest, &pDestinationAddress,
&pulBankNumber, &pulRemlinesInBank);
To accomplish correct clipping, prectlDest must be in the application window's
visible region. If the display hardware is bank-switched, then the
application must not write more than pulRemlinesInBank lines of output before
switching banks. The data written to pDestinationAddress must be in the
color-encoding scheme of the screen (also provided by DiveQueryCaps). (Of
course, DIVE can be used to convert to the correct screen color-encoding prior
to writing to the frame buffer by doing a DiveBlitImage to a destination
buffer with the same color-encoding.) Additionally, if the screen supports
only 256 colors, the data must match the current physical palette.
All write access to the frame buffer must be bracketed by calls to
DiveAcquireFrameBuffer and DiveDeacquireFrameBuffer. Also, the application
must not attempt to access the frame buffer between receipt of a
WM_VRNDISABLED message and a WM_VRNENABLED message.
This method works only on even bank breaks; indirect access through Dive
BlitImage is recommended on displays with bank breaks that are not aligned on
scan-line boundaries.
In the next example, the application spins off a separate thread to perform
blitting. The procedure for this thread contains a nested loop that switches
display banks for each image blitted as long as blitting is needed. The flag
fFBAccessOK is turned off when ever the application window received
WM_VRNDISABLED and is turned on whenever WM_VRNENABLED is received.
A typical application would do the following:
BOOL fKeepBlitting = TRUE;
BOOL fFBAccessOK;
RECTL rectlOutput; /* Image rectangle in desktop coors */
RECTL rectlDest; /* Portion to blit in this bank */
ULONG ulMoreLines; /* Lines in image left to blit */
LONG lBlitTop; /* Top of next blit */
PVOID pDestinationAddress; /* Frame buffer address - output */
ULONG ulBankNumber; /* Display h/w bank number - output */
ULONG ulRemlinesInAperature; /* Lines left in bank - output */
BOOL fAcquired = FALSE; /* Acquired frame buffer yet */
while (fKeepBlitting)
{
/* ... Call DiveSetupBlitter as before ... */
/********************************************************/
/* Calculate total number of lines to blit. Then blit */
/* only those lines that will fit in the current bank. */
/* Switch to successive banks until the entire image is */
/* blitted. */
/********************************************************/
ulMoreLines = rectlDest.yTop - rectlDest.yBottom;
memcpy( &rectlDest, &rectlOutput, sizeof(RECTL));
while (ulMoreLines && fFBAccessOK)
{
ulErrorCode = DiveCalcFrameBufferAddress(
hDive, rectlDest, &pDestinationAddress,
&ulBankNumber, &ulRemlinesInAperture);
if (!fAcquired)
if (!DiveAcquireFrameBuffer( hDive, ulBankNumber))
fAcquired = TRUE;
else break;
DiveSwitchBank( hDive, ulBankNumber);
{
/* ... write data for (ulRemlinesInAperture) top lines of */
/* rectlDest to pDestinationAddress ... */
if (ulRemlinesInAperture < ulMoreLines)
{ /* if need next bank */
rectlDest.yTop -= ulRemlinesInAperture;
ulMoreLines -= ulRemlinesInAperture;
}
else ulMoreLines = 0;
}
if (fAcquired)
DiveDeacquireFrameBuffer( hDive);
} /* end: while more lines to blit */
} /* end: blitter loop */
ΓòÉΓòÉΓòÉ 5.1.5. DIVE Enhancements ΓòÉΓòÉΓòÉ
Enhancements made to the DIVE.DLL enable its communication with the
GAMESRVR.DLL, providing applications with DIVE functionality. In addition, the
following enhancements have been made to the new DIVE.DLL:
Support for YUV 4-2-2 image format as a source and destination format in
blitting operations.
YUV - LUT8 color conversion improvements.
Capability for 180-degree rotation of output screen image.
Transparent blitting by way of the following new function:
ULONG APIENTRY DiveSetTransparentBlitMode ( HDIVE hDiveInst,
ULONG ulTransBlitMode,
ULONG ulValue1,
ULONG ulValue2 );
This function enables transparent blitting using a chroma-key color or
chroma-keying on a color space range. DiveSetTransparentBlitMode must be
called before calling DiveSetBlitter.
hDiveInst (HDIVE) - input
Display engine DIVE instance.
ulTransBlitMode (ULONG) - input
Specifies the mode for transparent blitting. Set
ulTransBlitMode to one of the following values:
DIVE_TBM_NONE
No transparency; that is, all pixels are transferred.
This is the default.
DIVE_TBM_EXCLUDE_SOURCE_VALUE
Source pixels with values that exactly match the value
specified in ulValue1 are not transferred by
DiveBlitImage.
DIVE_TBM_EXCLUDE_SOURCE_RGB_RANGE
Source pixels with values that are within the range
specified in the RGB color space defined by ulValue1
(minimum) and ulValue2 (maximum) are not transferred by
DiveBlitImage.
DIVE_TBM_INCLUDE_SOURCE_RGB_RANGE
Source pixels with values that are outside the range
specified in the RGB color space defined by ulValue1
(minimum) and ulValue2 (maximum) are not transferred by
DiveBlitImage.
DIVE_TBM_EXCLUDE_SOURCE_YUV_RANGE
Source pixels with values that are outside the range
specified in the YUV color space defined by ulValue1
(minimum) and ulValue2 (maximum) are not transferred by
DiveBlitImage.
DIVE_TBM_INCLUDE_SOURCE_YUV_RANGE
Source pixels with values that are outside the range
specified in the YUV color space defined by ulValue1
(minimum) and ulValue2 (maximum) are not transferred by
DiveBlitImage.
ulValue1 (ULONG) - input
Minimum value in range.
ulValue2 (ULONG) - input
Maximum value in range.
rc (ULONG) - return
Return codes indicating success or type of failure:
DIVE_SUCCESS
If the function succeeds, 0 is returned.
DIVE_ERR_INVALID_INSTANCE
The DIVE instance handle specified in the hDiveInst
parameter is invalid.
Remarks
The transparent blitting function is based on source pixel values. A
pixel in the destination image buffer is not modified if the
corresponding pixel in the source buffer is "transparent". The
interpretation of the color values specified in ulValue1 and ulValue2 is
dependent on the source image color format (fccSrcColorFormat field in
the SETUP_BLITTER structure) and the transparent blitting mode.
The following table describes the color and range specification:
ΓöîΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö¼ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÉ
ΓöéFOURCC_LUT8 ΓöéThe color value is specified in theΓöé
Γöé Γöélow 8 bits of the parameter. Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
ΓöéFOURCC_Y888, FOURCC_Y2X2, FOURCC_Y4X4, Γöé23:8 - Y, 15:8 - U, 7:8 - V (bits Γöé
ΓöéFOURCC_YUV9, FOURCC_Y644, FOURCC_Y422 Γöé31:8 ignored) Γöé
Γö£ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö╝ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöñ
ΓöéFOURCC_R565, FOURCC_R555, FOURCC_R664, Γöé23:8 - R, 15:8 - G, 7:8 - B (bits Γöé
ΓöéFOURCC_RGB3, FOURCC_BGR3, FOURCC_RGB4, Γöé31:8 ignored). R, G, and B Γöé
ΓöéFOURCC_BGR4 Γöécomponents are specified with 8-bitΓöé
Γöé Γöésignificance regardless of Γöé
Γöé Γöésignificance in source data. Γöé
ΓööΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓö┤ΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÇΓöÿ
Transparent blitting of other source image formats is not supported.
For range comparisons in RGB or YUV, the three components are compared
independently against the minimum and maximum values specified by the
ulValue1 and ulValue2 parameters, respectively. A value is considered to
be within the specified range if it is greater to or equal to ulValue1
and less than or equal to ulValue2.
In DIVE_TBM_EXCLUDE_SOURCE_VALUE transparent blitting mode, the specified
value in ulValue1 is assumed to be in the source color space as described
in the preceding table. For range comparisons, the values specified in
ulValue1 and ulValue2 are assumed to be in the color space in which the
range comparison is to be performed, either YUV or RGB.
With LUT8 source format, in DIVE_TBM_EXCLUDE_SOURCE_VALUE transparent
blitting mode, the value is assumed to be the original LUT8 value. For
other transparent blitting modes (RGB or YUV range), an LUT8 value is
converted to a direct color value based on the current source palette to
determine whether or not it is within the specified range.
ΓòÉΓòÉΓòÉ 5.2. Direct Access to Video Buffers ΓòÉΓòÉΓòÉ
Although DIVE functions are preferred if you are writing applications, for
display drivers, you can write directly to video memory, even when running in a
Presentation Manager window, by using the enhanced DIVE (EnDIVE) architecture.
EnDIVE supports the use of motion video accelerator hardware, providing
additional functions for querying information about the color formats supported
by the hardware, video memory management and image processing. See the OS/2
Presentation Device Driver Reference for more detailed information about
EnDIVE.
While this capability provides excellent performance, there are complexities
that must be dealt with when using it. Applications that write directly to the
video buffer must provide their own clipping support, color space conversion to
the frame buffer, and scaling (if applicable). Also, on displays that are
bank-switched, these applications must invoke functions whenever access moves
from one bank to another.
ΓòÉΓòÉΓòÉ 5.3. PM Programs in Full Screen ΓòÉΓòÉΓòÉ
With our new Entertainment Tools, we're including full-screen support built on
our DIVE technology. The latest version of the DIVE interface has been
enhanced to allow an application to take over the display and change the
display resolution.
The GAMESRVR (.DLL) gives full-screen DIVE support to games in video modes
other than that used by the OS/2 desktop. By using the functions provided by
the GAMESRVR, PM programs can be written to use the entire screen without
paying the penalty of a large frame buffer.
Most games on the market today use the 320x200x256 VGA mode. There are a
number of reasons for using this mode that outweigh the mediocre resolution of
320x200 pels in 256 colors. This mode exists on all VGA and SuperVGA cards.
It is easy to use because it uses a flat frame buffer and exactly one byte per
pel. This greatly reduces the complexity of the graphics algorithms and
increases their speed.
Finally, the size of the buffer is only 64000 bytes. Compare this to a typical
desktop resolution of 1024x768x256 with a frame buffer of 786432 bytes.
Because the buffer is 12 times smaller, full-screen operations are 12 times
faster.
ΓòÉΓòÉΓòÉ 5.3.1. GAMESRVR Installation ΓòÉΓòÉΓòÉ
The purpose of the GAMESRVR is to support games in video modes other than that
used by the OS/2 desktop. The reason for this is quite simple: speed.
To install the GAMESRVR, run GSRVINST.EXE to perform the following steps:
1. Copy GAMESRVR.DLL and DIVE.DLL to d\OS2\DLL, where d is the boot drive.
2. Add the GAMESRVR key to the PM_ED_HOOKS application in OS2.INI with the
key value of d:\OS2\DLL\GAMESRVR.DLL, where d is the boot drive.
3. If SVGADATA.PMI exists in the d:\OS2 directory, copy SVGA.EXE to d:\OS2,
then execute SVGA ON INIT to rebuild the SVGADATA.PMI file, adding the
320x200x256 mode.
4. Depending on the video card that you have installed, the installation
might end in the full-screen DOS session where SVGA.EXE was executed. If
so, to return to your OS/2 session, you should type:
exit
The system will have to be rebooted to allow these changes to take
effect. Applications written to use the GAMESRVR will automatically take
advantage of its presence.
ΓòÉΓòÉΓòÉ 5.4. Programming ΓòÉΓòÉΓòÉ
The GAMESRVR is loaded at execution time by performing a DosLoadModule on
GAMESRVR. If this is successful, the address of the InitGameFrameProc routine
my be queried using DosQueryProcAddr. When you call this routine with the
handle of the frame window of the application, it subclasses the frame window
procedure. This allows the GAMESRVR to process all messages sent to the
application, especially focus change messages which may require restoration of
the original desktop mode.
Communication with the GAMESRVR is through the following three messages:
WM_SetVideoMode (0x04A0)
This message uses mp1 to select either one of the preset game window styles
or a specific video mode, as extracted from the table of supported video
modes.
mp1 == 0
Restores the original mode of the desktop, as well as the original
size and location of the application's window.
mp1 == 1
Restores the original mode of the desktop but expands the size of
the client window so that only the client window and the command
bar are visible.
mp1 == 2
Expands the client window to fill the screen. Then, sets the video
mode to the standard 320x200x256 game mode.
mp1 > 2
Expands the client window to fill the screen. Then, sets the video
mode defined by the VIDEOMODEINFO structure addressed by mp1.
The return value from this message is 1, if successful, otherwise 0.
WM_NotifyVideoModeChange (0x04A1)
This message is generated by the GAMESRVR to notify the application
immediately before and again immediately after a video mode change.
mp1 == 0
Indicates that the video mode is about to change.
mp1 == 1
Indicates the video mode change is complete.
In both cases, mp2 contains the address of the VIDEOMODEINFO structure,
which describes the video mode of 0 or 1, as described for the
WM_SetVideoMode message. The value of 2 will never be returned. Instead,
it is transformed into a pointer to a VIDEOMODEINFO structure.
The return value of this message is ignored.
WM_GetVideoModeTable (0x04A2)
This message is used only if you wish to select a video mode other than the
standard 320x200x256 mode.
mp1 Indicates the address of a PVOID to receive the address of an
array of VIDEOMODEINFO structures describing all of the modes
supported by the current display card. This array is allocated
for you. You can delete it yourself or allow it to be
automatically deleted at process termination.
mp2 Indicates the address of a ULONG to receive the number of
structures in the array that was allocated.
The return value from this message is 1 if successful, otherwise 0.
ΓòÉΓòÉΓòÉ 5.5. Full-Screen DIVE - Programming Tutorial Code ΓòÉΓòÉΓòÉ
FSDIVE, the full-screen DIVE programming tutorial (sample), demonstrates the
use of multimedia's Direct Interface Video Extensions (DIVE) by repeatedly
displaying a short animation sequence of up to 16 bitmaps in a PM window.
If other bitmaps than those provided with the sample, the names of the bitmap
files must be specified by passing the file names as command line parameters.
Also, the bitmaps must be of the same size and color depth. Only OS/2 .BMP
files are recognized and can include 8-, 16-, and 24-bit color bitmaps.
Full-Screen mode is activated by using the ALT+Home hot key. The Home key must
be the one on the keypad. Use ALT+Home to return to the desktop.
This programming tutorial is located in
TOOLKIT\BETA\SAMPLES\ENTOOLKT\VIDEO\FSDIVE.
You can start the programming tutorial by typing the programming tutorial name
(FSDIVE.EXE) at the OS/2 command line:
fsdive
Or by double-clicking on the Full-Screen DIVE icon.
Hardware Requirements:
Computer capable of running OS/2 Warp
SVGA (a screen mode of 640x480x256 constitutes a minimum SVGA system)
Software Requirements:
DIVE.DLL
OS/2 Warp 3.0 or higher
OS/2 Warp Developer's Toolkit 3.0 or higher
Multimedia support
Software motion video
The maximum window size of this sample has been limited to 640x480 because
larger window size may cause excessive swapping on machines with less than
16MB.
The DIVE sample that comes with this release of The Developer Connection for
OS/2, Volume 8, will not work with the original DIVE.DLL file, For this
release of the Warp Toolkit, an updated .DLL file is shipped with the sample.
A .DLL with equivalent function will be included in a future version of OS/2
Warp.
The sample is also discussed in Using Your Toolkit under the "What's New"
section.
ΓòÉΓòÉΓòÉ 6. 3D Graphics ΓòÉΓòÉΓòÉ
Imagine a space ship rotating through space, a fighter plane plummeting through
the sky after taking a direct hit from its enemy, or any other number of
similar scenarios-all of which could be made possible by a new OS/2 3D graphics
modeling and rendering API. 3D is the place to be!
IBM is bringing you the BRender(TM) Power Rendering System, a real-time, 3D
graphics software by Argonaut Technologies Ltd. IBM is distributing Argonaut's
3D graphics API, known as BRender(TM), in our Entertainment Tools. The BRender
technology is distributed under Argonaut's end-user license. This version,
included with the toolkit, is a limited license permitting the user to evaluate
the product. Should you wish to include BRender technology in your game, you
need to contact Argonaut for a commercial license.
The BRender Technical Reference manual, is included in addition to other
games-related documentation in this Beta. It can be found in the
\TOOLKIT\BETA\BOOK subdirectory.
For those of you not already familiar with Argonaut, they are the creators of
Nintendo's StarFox and are also the designers of the SuperFX chip, one of the
best selling RISC graphics chip in the world. The BRender technology provides
the solution for the speed, size, scalability, flexibility, and power
requirements of the most demanding 3D designers.
Speed
Additional hardware is becoming available from VGA chip companies (such as the
Cirrus 3D/VGA chip) for further acceleration. The BRender Power Rendering
System makes true hardware acceleration possible because it was designed with
this significant hardware acceleration in mind. Titles created using the
BRender software alone run astoundingly fast and, when hardware acceleration is
added, the result is lightning-fast speed. The benchmarks when running
real-world games verify the speed is unmatched by other 3D rendering software.
Size
Size for running this software is just over 100K, making it the smallest 3D
rendering around. Memory requirements are slashed because of the scanline
rendering technique it employs.
Scalability
The BRender scalable design automatically detects the presence of hardware
accelerators to seamlessly exploit available features. The BRender Power
Rendering System runs on 386, 486, Pentium, MacIntosh, and game machines. It
uses fixed and floating point math. It offers 16- and 32-bit Z-buffering and
other true 3D features such as perspective texture mapping, and object
interpenetration. It also supports almost all resolutions and popular color
depths.
Created for personal computer and games platforms, the advanced BRender
technology provides real-time workstation-class performance on low-end PC and
game hardware. It runs on numerous desktop and games platforms and ports
effortlessly to new environments.
Flexibility
Contained within the BRender Power Rendering System is it's own software
rendering 3D graphics library, a definite asset if you are considering porting
games across multiple platforms.
Power Requirements
To be able to achieve DOS-like, high-speed graphics, the BRender technology
uses a hierarchical object model for accelerated 3D development. In addition,
it provides comprehensive 3D functionality, automatic object collision
detection, and flexible call-back capability.
ΓòÉΓòÉΓòÉ 6.1. ROBOT - Programming Tutorial Code ΓòÉΓòÉΓòÉ
IMPORTANT: You must read the Argonaut licensing agreement (ARGONAUT.LIC) file
and the BRender trademark information file (BRENDER.TMK) before using the
BRender Power Rendering System technology provided with this BETA.
IBM is providing support for 3D graphics modeling and rendering. This support
is independent of the way the data is drawn to the screen. Like the OS/2
multimedia implementation of software motion video, this new 3D graphics
support can use the DIVE interface for maximum performance. However, GPI or
some other custom method can also be used to display to the screen.
ROBOT, the programming tutorial (sample), demonstrates how to use the new OS/2
version of the Argonaut BRender(TM) technology for real-time, three-dimensional
(3D) manipulation of actors. An actor can be the actual object model, a
camera, or a light.
There are two parts to this programming tutorial:
The use of BRender technology to perform the 3D manipulations
The use of full-screen DIVE to allocate and display the image buffer and
to do any palette manipulations.
This sample demonstrates a robot walking. The mouse can be used to zoom in and
out and also to rotate the robot in 3D space.
This programming tutorial is located in TOOLKIT\BETA\BRENDER\SAMPLES\ROBOT.
The sample is also discussed in see Using Your Toolkit under the "What's New"
section.
You can start the programming tutorial by typing the programming tutorial name
(ROBOT.EXE) at the OS/2 command line:
robot
Or by double-clicking on the Robot icon.
Hardware Requirements:
Computer capable of running OS/2 Warp
SVGA (a screen mode of 640x480x256 constitutes a minimum SVGA system)
Software Requirements:
DIVE.DLL
OS/2 Warp 3.0 or higher
OS/2 Warp Developer's Toolkit 3.0 or higher
Multimedia support