Initial commit: ROW Client source code
Game client codebase including: - CharacterActionControl: Character and creature management - GlobalScript: Network, items, skills, quests, utilities - RYLClient: Main client application with GUI and event handlers - Engine: 3D rendering engine (RYLGL) - MemoryManager: Custom memory allocation - Library: Third-party dependencies (DirectX, boost, etc.) - Tools: Development utilities 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
684
Library/dxx8/samples/Multimedia/Demos/DMBoids/boids.cpp
Normal file
@@ -0,0 +1,684 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Boids.cpp
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#include <stdio.h>
|
||||
#include <math.h>
|
||||
#include <d3dx8.h>
|
||||
#include "D3DApp.h"
|
||||
#include "D3DFile.h"
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "DXUtil.h"
|
||||
#include "boids.h"
|
||||
#include "music.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants, and global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
BoidMusic g_Music;
|
||||
|
||||
struct BOIDVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
};
|
||||
|
||||
struct GRIDVERTEX
|
||||
{
|
||||
D3DXVECTOR3 pos;
|
||||
D3DCOLOR color;
|
||||
};
|
||||
|
||||
#define D3DFVF_BOIDVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
|
||||
#define D3DFVF_GRIDVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE)
|
||||
|
||||
#define NUM_BOIDS 40
|
||||
|
||||
inline FLOAT rnd() { return (((FLOAT)rand())/RAND_MAX); }
|
||||
|
||||
inline FLOAT Min( D3DXVECTOR3 v )
|
||||
{
|
||||
if( v.x < v.y ) return (v.x < v.z ) ? v.x : v.z;
|
||||
else return (v.y < v.z ) ? v.y : v.z;
|
||||
}
|
||||
|
||||
inline FLOAT Max( D3DXVECTOR3 v )
|
||||
{
|
||||
if( v.x > v.y ) return (v.x > v.z ) ? v.x : v.z;
|
||||
else return (v.y > v.z ) ? v.y : v.z;
|
||||
}
|
||||
|
||||
BOOL g_bSeparation = FALSE;
|
||||
BOOL g_bAlignment = FALSE;
|
||||
BOOL g_bCohesion = FALSE;
|
||||
BOOL g_bMigratory = FALSE;
|
||||
BOOL g_bObstacle = FALSE;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMyD3DApplication
|
||||
// Desc: Application class. The base class (CD3DApplication) provides the
|
||||
// generic functionality needed in all Direct3D samples. CMyD3DApplication
|
||||
// adds functionality specific to this sample program.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMyD3DApplication : public CD3DApplication
|
||||
{
|
||||
CD3DFont* m_pFont; // Font for drawing text
|
||||
|
||||
D3DXMATRIX m_matWorld; // Transform matrices
|
||||
D3DXMATRIX m_matView;
|
||||
D3DXMATRIX m_matProj;
|
||||
|
||||
D3DLIGHT8 m_Light1; // Lights and materials
|
||||
D3DLIGHT8 m_Light2;
|
||||
D3DMATERIAL8 m_mtrlBackground;
|
||||
D3DMATERIAL8 m_mtrlGrid;
|
||||
D3DMATERIAL8 m_mtrlBoid;
|
||||
|
||||
CD3DMesh* m_pSphere; // Spheres
|
||||
FLOAT m_fSphereSpin;
|
||||
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pBoidVB; // Boid mesh
|
||||
LPDIRECT3DINDEXBUFFER8 m_pBoidIB;
|
||||
BOIDVERTEX m_vBoidVertices[16];
|
||||
WORD m_wBoidIndices[30];
|
||||
DWORD m_dwNumBoidVertices;
|
||||
DWORD m_dwNumBoidIndices;
|
||||
|
||||
CFlock m_Flock; // The flock structure
|
||||
|
||||
CD3DMesh* m_pSeaGull; // Seagull mesh
|
||||
|
||||
GRIDVERTEX m_vGridPattern1[25]; // Grid mesh
|
||||
GRIDVERTEX m_vGridPattern2[9];
|
||||
|
||||
// Internal functions
|
||||
HRESULT RenderFlock();
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit();
|
||||
HRESULT InitDeviceObjects();
|
||||
HRESULT RestoreDeviceObjects();
|
||||
HRESULT InvalidateDeviceObjects();
|
||||
HRESULT DeleteDeviceObjects();
|
||||
HRESULT FinalCleanup();
|
||||
HRESULT Render();
|
||||
HRESULT FrameMove();
|
||||
|
||||
public:
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
CMyD3DApplication();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc: Entry point to the program. Initializes everything, and goes into a
|
||||
// message-processing loop. Idle time is used to render the scene.
|
||||
//-----------------------------------------------------------------------------
|
||||
INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
|
||||
{
|
||||
CMyD3DApplication d3dApp;
|
||||
|
||||
if( FAILED( d3dApp.Create( hInst ) ) )
|
||||
return 0;
|
||||
return d3dApp.Run();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CMyD3DApplication()
|
||||
// Desc: Application constructor. Sets attributes for the app.
|
||||
//-----------------------------------------------------------------------------
|
||||
CMyD3DApplication::CMyD3DApplication()
|
||||
:CD3DApplication()
|
||||
{
|
||||
m_strWindowTitle = _T("DMBoids: DMusic Flocking Boids Sample");
|
||||
m_bUseDepthBuffer = TRUE;
|
||||
|
||||
m_fSphereSpin = 0.0f;
|
||||
m_pBoidVB = NULL;
|
||||
m_pBoidIB = NULL;
|
||||
m_pSphere = new CD3DMesh();
|
||||
m_pSeaGull = new CD3DMesh();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::OneTimeSceneInit()
|
||||
{
|
||||
D3DXVECTOR3 vNorm;
|
||||
|
||||
// generate the boid data
|
||||
m_dwNumBoidVertices = 16;
|
||||
m_dwNumBoidIndices = 30;
|
||||
|
||||
// top
|
||||
m_vBoidVertices[ 0].p = D3DXVECTOR3( 0.0f, 0.0f, 10.0f); D3DXVec3Normalize( &m_vBoidVertices[ 0].n, &D3DXVECTOR3( 0.2f, 1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 1].p = D3DXVECTOR3( 10.0f, 0.0f,-10.0f); D3DXVec3Normalize( &m_vBoidVertices[ 1].n, &D3DXVECTOR3( 0.1f, 1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 2].p = D3DXVECTOR3( 3.0f, 3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[ 2].n, &D3DXVECTOR3( 0.0f, 1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 3].p = D3DXVECTOR3( -3.0f, 3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[ 3].n, &D3DXVECTOR3(-0.1f, 1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 4].p = D3DXVECTOR3(-10.0f, 0.0f,-10.0f); D3DXVec3Normalize( &m_vBoidVertices[ 4].n, &D3DXVECTOR3(-0.2f, 1.0f, 0.0f) );
|
||||
|
||||
// bottom
|
||||
m_vBoidVertices[ 5].p = D3DXVECTOR3( 0.0f, 0.0f, 10.0f); D3DXVec3Normalize( &m_vBoidVertices[ 5].n, &D3DXVECTOR3( 0.2f, -1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 6].p = D3DXVECTOR3( 10.0f, 0.0f,-10.0f); D3DXVec3Normalize( &m_vBoidVertices[ 6].n, &D3DXVECTOR3( 0.1f, -1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 7].p = D3DXVECTOR3( 3.0f,-3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[ 7].n, &D3DXVECTOR3( 0.0f, -1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 8].p = D3DXVECTOR3( -3.0f,-3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[ 8].n, &D3DXVECTOR3(-0.1f, -1.0f, 0.0f) );
|
||||
m_vBoidVertices[ 9].p = D3DXVECTOR3(-10.0f, 0.0f,-10.0f); D3DXVec3Normalize( &m_vBoidVertices[ 9].n, &D3DXVECTOR3(-0.2f, -1.0f, 0.0f) );
|
||||
|
||||
// rear
|
||||
m_vBoidVertices[10].p = D3DXVECTOR3( 10.0f, 0.0f,-10.0f); D3DXVec3Normalize( &m_vBoidVertices[10].n, &D3DXVECTOR3(-0.4f, 0.0f, -1.0f) );
|
||||
m_vBoidVertices[11].p = D3DXVECTOR3( 3.0f, 3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[11].n, &D3DXVECTOR3(-0.2f, 0.0f, -1.0f) );
|
||||
m_vBoidVertices[12].p = D3DXVECTOR3( -3.0f, 3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[12].n, &D3DXVECTOR3( 0.2f, 0.0f, -1.0f) );
|
||||
m_vBoidVertices[13].p = D3DXVECTOR3(-10.0f, 0.0f,-10.0f); D3DXVec3Normalize( &m_vBoidVertices[13].n, &D3DXVECTOR3( 0.4f, 0.0f, -1.0f) );
|
||||
m_vBoidVertices[14].p = D3DXVECTOR3( -3.0f,-3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[14].n, &D3DXVECTOR3( 0.2f, 0.0f, -1.0f) );
|
||||
m_vBoidVertices[15].p = D3DXVECTOR3( 3.0f,-3.0f, -7.0f); D3DXVec3Normalize( &m_vBoidVertices[15].n, &D3DXVECTOR3(-0.2f, 0.0f, -1.0f) );
|
||||
|
||||
// top
|
||||
m_wBoidIndices[ 0] = 0; m_wBoidIndices[ 1] = 1; m_wBoidIndices[ 2] = 2;
|
||||
m_wBoidIndices[ 3] = 0; m_wBoidIndices[ 4] = 2; m_wBoidIndices[ 5] = 3;
|
||||
m_wBoidIndices[ 6] = 0; m_wBoidIndices[ 7] = 3; m_wBoidIndices[ 8] = 4;
|
||||
|
||||
// bottom
|
||||
m_wBoidIndices[ 9] = 5; m_wBoidIndices[10] = 7; m_wBoidIndices[11] = 6;
|
||||
m_wBoidIndices[12] = 5; m_wBoidIndices[13] = 8; m_wBoidIndices[14] = 7;
|
||||
m_wBoidIndices[15] = 5; m_wBoidIndices[16] = 9; m_wBoidIndices[17] = 8;
|
||||
|
||||
// rear
|
||||
m_wBoidIndices[18] = 10; m_wBoidIndices[19] = 15; m_wBoidIndices[20] = 11;
|
||||
m_wBoidIndices[21] = 11; m_wBoidIndices[22] = 15; m_wBoidIndices[23] = 12;
|
||||
m_wBoidIndices[24] = 12; m_wBoidIndices[25] = 15; m_wBoidIndices[26] = 14;
|
||||
m_wBoidIndices[27] = 12; m_wBoidIndices[28] = 14; m_wBoidIndices[29] = 13;
|
||||
|
||||
// scale the boid to be unit length
|
||||
for( DWORD i=0; i<16; i++ )
|
||||
{
|
||||
m_vBoidVertices[i].p.x /= 20.0f;
|
||||
m_vBoidVertices[i].p.y /= 20.0f;
|
||||
m_vBoidVertices[i].p.z /= 20.0f;
|
||||
}
|
||||
|
||||
// seed the random number generator
|
||||
srand( timeGetTime() );
|
||||
|
||||
// allocate the flock
|
||||
m_Flock.m_Boids = new Boid[NUM_BOIDS];
|
||||
m_Flock.m_dwNumBoids = NUM_BOIDS;
|
||||
m_Flock.m_afDist = (FLOAT**)new LPVOID[NUM_BOIDS];
|
||||
m_Flock.m_vGoal = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
|
||||
for( i=0; i<m_Flock.m_dwNumBoids; i++ )
|
||||
{
|
||||
D3DXMatrixIdentity( &m_Flock.m_Boids[i].matWorld );
|
||||
m_Flock.m_Boids[i].vPos = D3DXVECTOR3( 200.0f*(rnd()-rnd()), 100.0f*rnd(), 200.0f*(rnd()-rnd()) );
|
||||
D3DXVec3Normalize( &m_Flock.m_Boids[i].vDir, &D3DXVECTOR3(rnd()-rnd(), rnd()-rnd(), rnd()-rnd()));
|
||||
m_Flock.m_Boids[i].yaw = 0.0f;
|
||||
m_Flock.m_Boids[i].pitch = 0.0f;
|
||||
m_Flock.m_Boids[i].roll = 0.0f;
|
||||
m_Flock.m_Boids[i].dyaw = 0.0f;
|
||||
m_Flock.m_Boids[i].speed = 0.1f;
|
||||
m_Flock.m_Boids[i].color = D3DXVECTOR3( rnd(), rnd(), rnd() );
|
||||
m_Flock.m_Boids[i].color -= D3DXVECTOR3( Min(m_Flock.m_Boids[i].color), Min(m_Flock.m_Boids[i].color), Min(m_Flock.m_Boids[i].color) );
|
||||
m_Flock.m_Boids[i].color /= Max( m_Flock.m_Boids[i].color );
|
||||
m_Flock.m_afDist[i] = new FLOAT[NUM_BOIDS];
|
||||
}
|
||||
|
||||
m_Flock.m_dwNumObstacles = 4;
|
||||
m_Flock.m_Obstacles = new Obstacle[m_Flock.m_dwNumObstacles];
|
||||
m_Flock.m_Obstacles[0].vPos = D3DXVECTOR3( 100.0f, 10.0f, 0.0f );
|
||||
m_Flock.m_Obstacles[1].vPos = D3DXVECTOR3( 0.0f, 10.0f, 100.0f );
|
||||
m_Flock.m_Obstacles[2].vPos = D3DXVECTOR3(-100.0f, 10.0f, 0.0f );
|
||||
m_Flock.m_Obstacles[3].vPos = D3DXVECTOR3( 0.0f, 10.0f,-100.0f );
|
||||
m_Flock.m_Obstacles[0].fRadius = 0.2f;
|
||||
m_Flock.m_Obstacles[1].fRadius = 0.2f;
|
||||
m_Flock.m_Obstacles[2].fRadius = 0.2f;
|
||||
m_Flock.m_Obstacles[3].fRadius = 0.2f;
|
||||
|
||||
D3DCOLOR diffuse = D3DCOLOR_RGBA( 0, 0, 30, 128 );
|
||||
D3DCOLOR specular = D3DCOLOR_RGBA( 0, 0, 0, 0 );
|
||||
|
||||
for( i=0; i<=24; i++ )
|
||||
m_vGridPattern1[i].color = diffuse;
|
||||
|
||||
m_vGridPattern1[ 0].pos = D3DXVECTOR3(-25.0f, 0.0f, 35.0f );
|
||||
m_vGridPattern1[ 1].pos = D3DXVECTOR3(-15.0f, 0.0f, 35.0f );
|
||||
m_vGridPattern1[ 2].pos = D3DXVECTOR3( -5.0f, 0.0f, 25.0f );
|
||||
m_vGridPattern1[ 3].pos = D3DXVECTOR3( 5.0f, 0.0f, 25.0f );
|
||||
m_vGridPattern1[ 4].pos = D3DXVECTOR3( 15.0f, 0.0f, 35.0f );
|
||||
m_vGridPattern1[ 5].pos = D3DXVECTOR3( 25.0f, 0.0f, 35.0f );
|
||||
m_vGridPattern1[ 6].pos = D3DXVECTOR3( 35.0f, 0.0f, 25.0f );
|
||||
m_vGridPattern1[ 7].pos = D3DXVECTOR3( 35.0f, 0.0f, 15.0f );
|
||||
m_vGridPattern1[ 8].pos = D3DXVECTOR3( 25.0f, 0.0f, 5.0f );
|
||||
m_vGridPattern1[ 9].pos = D3DXVECTOR3( 25.0f, 0.0f, -5.0f );
|
||||
m_vGridPattern1[10].pos = D3DXVECTOR3( 35.0f, 0.0f,-15.0f );
|
||||
m_vGridPattern1[11].pos = D3DXVECTOR3( 35.0f, 0.0f,-25.0f );
|
||||
m_vGridPattern1[12].pos = D3DXVECTOR3( 25.0f, 0.0f,-35.0f );
|
||||
m_vGridPattern1[13].pos = D3DXVECTOR3( 15.0f, 0.0f,-35.0f );
|
||||
m_vGridPattern1[14].pos = D3DXVECTOR3( 5.0f, 0.0f,-25.0f );
|
||||
m_vGridPattern1[15].pos = D3DXVECTOR3( -5.0f, 0.0f,-25.0f );
|
||||
m_vGridPattern1[16].pos = D3DXVECTOR3(-15.0f, 0.0f,-35.0f );
|
||||
m_vGridPattern1[17].pos = D3DXVECTOR3(-25.0f, 0.0f,-35.0f );
|
||||
m_vGridPattern1[18].pos = D3DXVECTOR3(-35.0f, 0.0f,-25.0f );
|
||||
m_vGridPattern1[19].pos = D3DXVECTOR3(-35.0f, 0.0f,-15.0f );
|
||||
m_vGridPattern1[20].pos = D3DXVECTOR3(-25.0f, 0.0f, -5.0f );
|
||||
m_vGridPattern1[21].pos = D3DXVECTOR3(-25.0f, 0.0f, 5.0f );
|
||||
m_vGridPattern1[22].pos = D3DXVECTOR3(-35.0f, 0.0f, 15.0f );
|
||||
m_vGridPattern1[23].pos = D3DXVECTOR3(-35.0f, 0.0f, 25.0f );
|
||||
m_vGridPattern1[24].pos = D3DXVECTOR3(-25.0f, 0.0f, 35.0f );
|
||||
|
||||
for( i=0; i<=8; i++ )
|
||||
m_vGridPattern2[i].color = diffuse;
|
||||
|
||||
m_vGridPattern2[0].pos = D3DXVECTOR3( -5.0f, 0.0f, 15.0f );
|
||||
m_vGridPattern2[1].pos = D3DXVECTOR3( 5.0f, 0.0f, 15.0f );
|
||||
m_vGridPattern2[2].pos = D3DXVECTOR3( 15.0f, 0.0f, 5.0f );
|
||||
m_vGridPattern2[3].pos = D3DXVECTOR3( 15.0f, 0.0f, -5.0f );
|
||||
m_vGridPattern2[4].pos = D3DXVECTOR3( 5.0f, 0.0f,-15.0f );
|
||||
m_vGridPattern2[5].pos = D3DXVECTOR3( -5.0f, 0.0f,-15.0f );
|
||||
m_vGridPattern2[6].pos = D3DXVECTOR3(-15.0f, 0.0f, -5.0f );
|
||||
m_vGridPattern2[7].pos = D3DXVECTOR3(-15.0f, 0.0f, 5.0f );
|
||||
m_vGridPattern2[8].pos = D3DXVECTOR3( -5.0f, 0.0f, 15.0f );
|
||||
|
||||
if( FAILED( g_Music.LoadMusic( m_hWnd ) ) )
|
||||
{
|
||||
OutputDebugString("Failed to initialize DirectMusic.\n");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
g_Music.StartMusic();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FrameMove()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FrameMove()
|
||||
{
|
||||
D3DXVECTOR3 vEyePt;
|
||||
D3DXVECTOR3 vLookAtPt( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vUp( 0.0f, 1.0f, 0.0f );
|
||||
|
||||
FLOAT fTime;
|
||||
FLOAT fElapsedTime;
|
||||
|
||||
// The REF device is slow enough to throw off the animation
|
||||
// in this sample, so if using the REF device, simulate
|
||||
// running at 20fps regardless of actual rendering speed.
|
||||
if( m_d3dCaps.DeviceType == D3DDEVTYPE_REF )
|
||||
{
|
||||
static FLOAT fTimePrev = 0.0f;
|
||||
fElapsedTime = 0.05f;
|
||||
fTime = fTimePrev + fElapsedTime;
|
||||
fTimePrev = fTime;
|
||||
}
|
||||
else
|
||||
{
|
||||
fElapsedTime = m_fElapsedTime;
|
||||
fTime = m_fTime;
|
||||
}
|
||||
|
||||
// Move each boids to its new location
|
||||
m_Flock.Update( fElapsedTime );
|
||||
|
||||
// LookAt point is the center of the flock
|
||||
for( DWORD i=0; i<m_Flock.m_dwNumBoids; i++ )
|
||||
vLookAtPt += m_Flock.m_Boids[i].vPos;
|
||||
vLookAtPt /= (FLOAT)m_Flock.m_dwNumBoids;
|
||||
|
||||
vEyePt = vLookAtPt + 40 * D3DXVECTOR3( sinf(fTime*0.111f),
|
||||
0.70f+0.75f*sinf(fTime*0.163f),
|
||||
cosf(fTime*0.155f) );
|
||||
|
||||
D3DXMatrixLookAtLH( &m_matView, &vEyePt, &vLookAtPt, &vUp );
|
||||
|
||||
g_Music.SetDistance( D3DXVec3Length( &( vEyePt - vLookAtPt ) ) );
|
||||
|
||||
// Update the flock's goal
|
||||
m_Flock.m_vGoal = 100.0f * D3DXVECTOR3( sinf(fTime*0.1f), 0.1f, cosf(fTime*0.1f) );
|
||||
|
||||
m_fSphereSpin = fTime;
|
||||
|
||||
g_Music.HandleNotifies();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RenderFlock()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RenderFlock()
|
||||
{
|
||||
// Set the view and projection matrices
|
||||
m_pd3dDevice->SetTransform( D3DTS_VIEW, &m_matView );
|
||||
m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &m_matProj );
|
||||
|
||||
// Draw ground grid
|
||||
m_pd3dDevice->SetMaterial( &m_mtrlGrid );
|
||||
|
||||
for (int dx= -2; dx<3; dx++)
|
||||
{
|
||||
for (int dz= -2; dz<3; dz++)
|
||||
{
|
||||
D3DXMatrixTranslation( &m_matWorld, dx*80.0f, 0.0f, dz*80.0f );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matWorld );
|
||||
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_GRIDVERTEX );
|
||||
m_pd3dDevice->DrawPrimitiveUP( D3DPT_LINESTRIP, 24, m_vGridPattern1,
|
||||
sizeof(GRIDVERTEX) );
|
||||
m_pd3dDevice->DrawPrimitiveUP( D3DPT_LINESTRIP, 8, m_vGridPattern2,
|
||||
sizeof(GRIDVERTEX) );
|
||||
}
|
||||
}
|
||||
|
||||
// Draw the boids
|
||||
for( DWORD i=0; i<m_Flock.m_dwNumBoids; i++ )
|
||||
{
|
||||
// Most of the time display the boid
|
||||
if( i%13 || m_d3dCaps.DeviceType == D3DDEVTYPE_REF )
|
||||
{
|
||||
// Set the boid's world matrix
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_Flock.m_Boids[i].matWorld );
|
||||
|
||||
// Set the boid's color
|
||||
m_mtrlBoid.Diffuse.r = m_Flock.m_Boids[i].color.x;
|
||||
m_mtrlBoid.Diffuse.g = m_Flock.m_Boids[i].color.y;
|
||||
m_mtrlBoid.Diffuse.b = m_Flock.m_Boids[i].color.z;
|
||||
m_pd3dDevice->SetMaterial( &m_mtrlBoid );
|
||||
|
||||
// Render the boid
|
||||
m_pd3dDevice->SetVertexShader( D3DFVF_BOIDVERTEX );
|
||||
m_pd3dDevice->SetStreamSource( 0, m_pBoidVB, sizeof(BOIDVERTEX) );
|
||||
m_pd3dDevice->SetIndices( m_pBoidIB, 0L );
|
||||
m_pd3dDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST,
|
||||
0, m_dwNumBoidVertices,
|
||||
0, m_dwNumBoidIndices/3 );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set the matrix
|
||||
D3DXMATRIX matWorld, matRotateY;
|
||||
D3DXMatrixRotationY( &matRotateY, D3DX_PI );
|
||||
D3DXMatrixMultiply( &matWorld, &matRotateY, &m_Flock.m_Boids[i].matWorld );
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
// Display a seagull
|
||||
m_pSeaGull->Render( m_pd3dDevice );
|
||||
}
|
||||
}
|
||||
|
||||
for( i=0; i<m_Flock.m_dwNumObstacles; i++ )
|
||||
{
|
||||
D3DXMATRIX matRotate, matScale;
|
||||
FLOAT fScale = m_Flock.m_Obstacles[i].fRadius;
|
||||
D3DXMatrixRotationY( &matRotate, m_fSphereSpin );
|
||||
D3DXMatrixScaling( &matScale, fScale, fScale, fScale );
|
||||
D3DXMatrixMultiply( &m_matWorld, &matScale, &matRotate );
|
||||
m_matWorld._41 = m_Flock.m_Obstacles[i].vPos.x;
|
||||
m_matWorld._42 = m_Flock.m_Obstacles[i].vPos.y;
|
||||
m_matWorld._43 = m_Flock.m_Obstacles[i].vPos.z;
|
||||
|
||||
m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matWorld );
|
||||
|
||||
m_pSphere->Render( m_pd3dDevice );
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::Render()
|
||||
{
|
||||
// Clear the scene to black
|
||||
m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,
|
||||
0x00000000, 1.0f, 0L );
|
||||
|
||||
// Begin Scene
|
||||
if( FAILED( m_pd3dDevice->BeginScene() ) )
|
||||
return S_OK;
|
||||
|
||||
RenderFlock();
|
||||
|
||||
m_pd3dDevice->EndScene();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InitDeviceObjects()
|
||||
{
|
||||
if( FAILED( m_pSphere->Create( m_pd3dDevice, _T("orbiter.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
if( FAILED( m_pSeaGull->Create( m_pd3dDevice, _T("Shusui.x") ) ) )
|
||||
return D3DAPPERR_MEDIANOTFOUND;
|
||||
|
||||
// Create a VB for the boids
|
||||
if( FAILED( m_pd3dDevice->CreateVertexBuffer( m_dwNumBoidVertices*sizeof(BOIDVERTEX),
|
||||
D3DUSAGE_WRITEONLY, D3DFVF_BOIDVERTEX,
|
||||
D3DPOOL_MANAGED, &m_pBoidVB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
BOIDVERTEX* v;
|
||||
m_pBoidVB->Lock( 0, 0, (BYTE**)&v, 0 );
|
||||
memcpy( v, m_vBoidVertices, m_dwNumBoidVertices*sizeof(BOIDVERTEX) );
|
||||
m_pBoidVB->Unlock();
|
||||
|
||||
// Create an IB for the boids
|
||||
if( FAILED( m_pd3dDevice->CreateIndexBuffer( m_dwNumBoidIndices*sizeof(WORD),
|
||||
D3DUSAGE_WRITEONLY, D3DFMT_INDEX16,
|
||||
D3DPOOL_MANAGED, &m_pBoidIB ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
WORD* i;
|
||||
m_pBoidIB->Lock( 0, 0, (BYTE**)&i, 0 );
|
||||
memcpy( i, m_wBoidIndices, m_dwNumBoidIndices*sizeof(WORD) );
|
||||
m_pBoidIB->Unlock();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::RestoreDeviceObjects()
|
||||
{
|
||||
m_pSphere->RestoreDeviceObjects( m_pd3dDevice );
|
||||
m_pSeaGull->RestoreDeviceObjects( m_pd3dDevice );
|
||||
|
||||
// Set up transform matrices
|
||||
D3DXVECTOR3 vEyePt = D3DXVECTOR3( 0.0f, 0.0f, -100.0f );
|
||||
D3DXVECTOR3 vLookAtPt = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
D3DXVECTOR3 vUp = D3DXVECTOR3( 0.0f, 1.0f, 0.0f );
|
||||
D3DXMatrixIdentity( &m_matWorld );
|
||||
D3DXMatrixLookAtLH( &m_matView, &vEyePt, &vLookAtPt, &vUp );
|
||||
D3DXMatrixPerspectiveFovLH( &m_matProj, D3DX_PI/4, 1.0f, 5.0f, 400.0f );
|
||||
|
||||
// Setup materials
|
||||
D3DUtil_InitMaterial( m_mtrlBackground, 0.0f, 0.0f, 0.0f );
|
||||
D3DUtil_InitMaterial( m_mtrlGrid, 0.0f, 0.0f, 0.0f );
|
||||
m_mtrlGrid.Emissive.r = 0.0f;
|
||||
m_mtrlGrid.Emissive.g = 0.3f;
|
||||
m_mtrlGrid.Emissive.b = 0.5f;
|
||||
D3DUtil_InitMaterial( m_mtrlBoid, 1.0f, 1.0f, 1.0f );
|
||||
|
||||
// Create 2 lights
|
||||
D3DUtil_InitLight( m_Light1, D3DLIGHT_DIRECTIONAL, -0.5f, -1.0f, -0.3f );
|
||||
D3DUtil_InitLight( m_Light2, D3DLIGHT_DIRECTIONAL, 0.5f, 1.0f, 0.3f );
|
||||
m_Light2.Diffuse.r = 0.5f;
|
||||
m_Light2.Diffuse.g = 0.5f;
|
||||
m_Light2.Diffuse.b = 0.5f;
|
||||
m_pd3dDevice->SetLight( 0, &m_Light1 );
|
||||
m_pd3dDevice->SetLight( 1, &m_Light2 );
|
||||
m_pd3dDevice->LightEnable( 0, TRUE );
|
||||
m_pd3dDevice->LightEnable( 1, TRUE );
|
||||
|
||||
// Set render state
|
||||
m_pd3dDevice->SetRenderState( D3DRS_SPECULARENABLE, FALSE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_ZENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_DITHERENABLE, TRUE );
|
||||
m_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x11111111 );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::InvalidateDeviceObjects()
|
||||
{
|
||||
m_pSphere->InvalidateDeviceObjects();
|
||||
m_pSeaGull->InvalidateDeviceObjects();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::DeleteDeviceObjects()
|
||||
{
|
||||
m_pSphere->Destroy();
|
||||
m_pSeaGull->Destroy();
|
||||
|
||||
SAFE_RELEASE( m_pBoidVB );
|
||||
SAFE_RELEASE( m_pBoidIB );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMyD3DApplication::FinalCleanup()
|
||||
{
|
||||
for( int i=0; i<NUM_BOIDS; i++ )
|
||||
{
|
||||
SAFE_DELETE_ARRAY( m_Flock.m_afDist[i] );
|
||||
}
|
||||
|
||||
SAFE_DELETE_ARRAY( m_Flock.m_Boids );
|
||||
SAFE_DELETE_ARRAY( m_Flock.m_afDist );
|
||||
SAFE_DELETE_ARRAY( m_Flock.m_Obstacles );
|
||||
|
||||
SAFE_DELETE( m_pSphere );
|
||||
SAFE_DELETE( m_pSeaGull );
|
||||
|
||||
g_Music.EndMusic();
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MsgProc()
|
||||
// Desc: Message proc function to handle key and menu input
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CMyD3DApplication::MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam,
|
||||
LPARAM lParam )
|
||||
{
|
||||
// Handle menu commands
|
||||
if( WM_KEYDOWN==uMsg || WM_KEYUP==uMsg )
|
||||
{
|
||||
switch( wParam )
|
||||
{
|
||||
case 'A':
|
||||
g_bAlignment = (WM_KEYDOWN==uMsg);
|
||||
break;
|
||||
|
||||
case 'C':
|
||||
g_bCohesion = (WM_KEYDOWN==uMsg);
|
||||
break;
|
||||
|
||||
case 'O':
|
||||
g_bObstacle = (WM_KEYDOWN==uMsg);
|
||||
break;
|
||||
|
||||
case 'M':
|
||||
g_bMigratory = (WM_KEYDOWN==uMsg);
|
||||
|
||||
if( g_bMigratory )
|
||||
g_Music.Migrate();
|
||||
break;
|
||||
|
||||
case 'S':
|
||||
g_bSeparation = (WM_KEYDOWN==uMsg);
|
||||
|
||||
if( g_bSeparation )
|
||||
g_Music.Collapse();
|
||||
else
|
||||
g_Music.Expand();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( WM_ACTIVATE==uMsg )
|
||||
{
|
||||
g_Music.Activate( LOWORD( wParam ) != WA_INACTIVE );
|
||||
}
|
||||
|
||||
// Pass remaining messages to default handler
|
||||
return CD3DApplication::MsgProc( hWnd, uMsg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
79
Library/dxx8/samples/Multimedia/Demos/DMBoids/boids.h
Normal file
@@ -0,0 +1,79 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Boids.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef BOIDS_H
|
||||
#define BOIDS_H
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class Boid
|
||||
{
|
||||
public:
|
||||
D3DXMATRIX matWorld; // matrix representing the boids location/orientation
|
||||
D3DXVECTOR3 vPos; // location
|
||||
D3DXVECTOR3 vDir; // cur direction
|
||||
D3DXVECTOR3 vSeparationForce;
|
||||
D3DXVECTOR3 vAlignmentForce;
|
||||
D3DXVECTOR3 vCohesionForce;
|
||||
D3DXVECTOR3 vMigratoryForce;
|
||||
D3DXVECTOR3 vObstacleForce;
|
||||
DWORD dwNumNeighbors;
|
||||
|
||||
D3DXVECTOR3 vDeltaPos; // change in position from flock centering
|
||||
D3DXVECTOR3 vDeltaDir; // change in direction
|
||||
int iDeltaCnt; // number of boids that influence this delta_dir
|
||||
FLOAT speed;
|
||||
FLOAT yaw, pitch, roll, dyaw;
|
||||
D3DXVECTOR3 color;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
struct Obstacle
|
||||
{
|
||||
D3DXVECTOR3 vPos;
|
||||
FLOAT fRadius;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CFlock
|
||||
{
|
||||
public:
|
||||
DWORD m_dwNumBoids;
|
||||
Boid* m_Boids;
|
||||
DWORD m_dwNumObstacles;
|
||||
Obstacle* m_Obstacles;
|
||||
FLOAT** m_afDist; // 2-d array of boid distances, yuk what a waste
|
||||
D3DXVECTOR3 m_vGoal;
|
||||
|
||||
// Functions
|
||||
VOID Update( FLOAT fElapsedTime );
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/DMBoids/directx.ico
Normal file
|
After Width: | Height: | Size: 1.1 KiB |
136
Library/dxx8/samples/Multimedia/Demos/DMBoids/dmboids.dsp
Normal file
@@ -0,0 +1,136 @@
|
||||
# Microsoft Developer Studio Project File - Name="DMBoids" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=DMBoids - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "dmboids.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "dmboids.mak" CFG="DMBoids - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DMBoids - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "DMBoids - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "DMBoids - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 d3dx8.lib d3d8.lib d3dxof.lib dinput.lib dxguid.lib winspool.lib oleaut32.lib uuid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x1f4000,0x1f4000
|
||||
|
||||
!ELSEIF "$(CFG)" == "DMBoids - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 d3dx8dt.lib d3d8.lib d3dxof.lib dinput.lib dxguid.lib winspool.lib oleaut32.lib uuid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x1f4000,0x1f4000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "DMBoids - Win32 Release"
|
||||
# Name "DMBoids - Win32 Debug"
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dapp.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dmutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\boids.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dmboids.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\flock.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\music.cpp
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
Library/dxx8/samples/Multimedia/Demos/DMBoids/dmboids.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "DMBoids"=.\dmboids.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
279
Library/dxx8/samples/Multimedia/Demos/DMBoids/dmboids.mak
Normal file
@@ -0,0 +1,279 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on dmboids.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=DMBoids - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to DMBoids - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "DMBoids - Win32 Release" && "$(CFG)" != "DMBoids - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "dmboids.mak" CFG="DMBoids - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "DMBoids - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "DMBoids - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "DMBoids - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\dmboids.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\boids.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dmboids.res"
|
||||
-@erase "$(INTDIR)\dmutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\flock.obj"
|
||||
-@erase "$(INTDIR)\music.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\dmboids.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\dmboids.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\dmboids.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\dmboids.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib d3dxof.lib dinput.lib dxguid.lib winspool.lib oleaut32.lib uuid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\dmboids.pdb" /machine:I386 /out:"$(OUTDIR)\dmboids.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dmutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\boids.obj" \
|
||||
"$(INTDIR)\flock.obj" \
|
||||
"$(INTDIR)\music.obj" \
|
||||
"$(INTDIR)\dmboids.res"
|
||||
|
||||
"$(OUTDIR)\dmboids.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "DMBoids - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\dmboids.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\boids.obj"
|
||||
-@erase "$(INTDIR)\d3dapp.obj"
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\dmboids.res"
|
||||
-@erase "$(INTDIR)\dmutil.obj"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\flock.obj"
|
||||
-@erase "$(INTDIR)\music.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\dmboids.exe"
|
||||
-@erase "$(OUTDIR)\dmboids.ilk"
|
||||
-@erase "$(OUTDIR)\dmboids.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\dmboids.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\dmboids.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib d3dxof.lib dinput.lib dxguid.lib winspool.lib oleaut32.lib uuid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\dmboids.pdb" /debug /machine:I386 /out:"$(OUTDIR)\dmboids.exe" /pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dapp.obj" \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\dmutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\boids.obj" \
|
||||
"$(INTDIR)\flock.obj" \
|
||||
"$(INTDIR)\music.obj" \
|
||||
"$(INTDIR)\dmboids.res"
|
||||
|
||||
"$(OUTDIR)\dmboids.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("dmboids.dep")
|
||||
!INCLUDE "dmboids.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "dmboids.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "DMBoids - Win32 Release" || "$(CFG)" == "DMBoids - Win32 Debug"
|
||||
SOURCE=..\..\common\src\d3dapp.cpp
|
||||
|
||||
"$(INTDIR)\d3dapp.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfile.cpp
|
||||
|
||||
"$(INTDIR)\d3dfile.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
|
||||
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
|
||||
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dmutil.cpp
|
||||
|
||||
"$(INTDIR)\dmutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
|
||||
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\boids.cpp
|
||||
|
||||
"$(INTDIR)\boids.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\dmboids.rc
|
||||
|
||||
"$(INTDIR)\dmboids.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\flock.cpp
|
||||
|
||||
"$(INTDIR)\flock.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\music.cpp
|
||||
|
||||
"$(INTDIR)\music.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
211
Library/dxx8/samples/Multimedia/Demos/DMBoids/dmboids.rc
Normal file
@@ -0,0 +1,211 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define IDC_STATIC -1
|
||||
#include <windows.h>
|
||||
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN_ICON ICON DISCARDABLE "DirectX.ico"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define IDC_STATIC -1\r\n"
|
||||
"#include <windows.h>\r\n"
|
||||
"\r\n"
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
VK_ESCAPE, IDM_EXIT, VIRTKEY, NOINVERT
|
||||
VK_F1, IDM_ABOUT, VIRTKEY, NOINVERT
|
||||
VK_F2, IDM_CHANGEDEVICE, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLESTART, VIRTKEY, NOINVERT
|
||||
VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT
|
||||
VK_SPACE, IDM_SINGLESTEP, VIRTKEY, NOINVERT
|
||||
"X", IDM_EXIT, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_ABOUT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 165
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 104
|
||||
END
|
||||
|
||||
IDD_SELECTDEVICE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 259
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 109
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_ABOUT DIALOG DISCARDABLE 0, 0, 172, 111
|
||||
STYLE DS_SYSMODAL | DS_MODALFRAME | DS_NOIDLEMSG | DS_SETFOREGROUND |
|
||||
DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||
CAPTION "About"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "OK",IDOK,115,90,40,14
|
||||
ICON IDI_MAIN_ICON,IDC_STATIC,5,5,20,20
|
||||
LTEXT "Direct3D Sample",IDC_STATIC,35,5,54,8
|
||||
LTEXT "Copyright (c) 1998-1999 Microsoft Corp.",IDC_STATIC,35,
|
||||
15,126,8
|
||||
LTEXT "About",IDC_STATIC,60,40,20,8
|
||||
LTEXT "Select Driver / Device / Mode",IDC_STATIC,60,50,97,8
|
||||
CTEXT "<Alt+Enter>",IDC_STATIC,10,60,45,8
|
||||
LTEXT "Toggle Fullscreen / Windowed",IDC_STATIC,60,60,98,8
|
||||
LTEXT "Exit",IDC_STATIC,60,70,12,8
|
||||
CTEXT "<F1>",IDC_STATIC,10,40,45,8
|
||||
CTEXT "<F2>",IDC_STATIC,10,50,45,8
|
||||
CTEXT "<ESC>",IDC_STATIC,10,70,45,8
|
||||
GROUPBOX "Usage",IDC_STATIC,5,30,160,55
|
||||
END
|
||||
|
||||
IDD_SELECTDEVICE DIALOG DISCARDABLE 0, 0, 267, 116
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Select Device"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
COMBOBOX IDC_ADAPTER_COMBO,90,15,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
COMBOBOX IDC_DEVICE_COMBO,90,30,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
CONTROL "Use desktop &window",IDC_WINDOW,"Button",
|
||||
BS_AUTORADIOBUTTON | WS_GROUP | WS_TABSTOP,10,60,85,15
|
||||
CONTROL "&Fullscreen mode",IDC_FULLSCREEN,"Button",
|
||||
BS_AUTORADIOBUTTON,10,75,75,15
|
||||
CONTROL "Fullscreen &stereo",IDC_STEREO,"Button",
|
||||
BS_AUTORADIOBUTTON,10,90,75,15
|
||||
COMBOBOX IDC_FULLSCREENMODES_COMBO,90,75,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_GROUP | WS_TABSTOP
|
||||
COMBOBOX IDC_STEREOMODES_COMBO,90,90,105,100,CBS_DROPDOWNLIST |
|
||||
WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,210,10,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,210,30,50,14
|
||||
GROUPBOX "Rendering device",IDC_STATIC,5,5,200,45
|
||||
LTEXT "&Adapter:",IDC_STATIC,20,15,65,10,SS_CENTERIMAGE
|
||||
LTEXT "D3D &device:",IDC_STATIC,20,30,65,11,SS_CENTERIMAGE
|
||||
GROUPBOX "Rendering mode",IDC_STATIC,5,50,200,60
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Menu
|
||||
//
|
||||
|
||||
IDR_MENU MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "&File"
|
||||
BEGIN
|
||||
MENUITEM "&Go/stop\tEnter", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step\tSpace", IDM_SINGLESTEP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About...\tF1", IDM_ABOUT
|
||||
MENUITEM "&Change device...\tF2", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit\tESC", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
IDR_POPUP MENU DISCARDABLE
|
||||
BEGIN
|
||||
POPUP "Popup"
|
||||
BEGIN
|
||||
MENUITEM "&Go/stop", IDM_TOGGLESTART
|
||||
MENUITEM "&Single step", IDM_SINGLESTEP
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "&About...", IDM_ABOUT
|
||||
MENUITEM "&Change device...", IDM_CHANGEDEVICE
|
||||
MENUITEM SEPARATOR
|
||||
MENUITEM "E&xit", IDM_EXIT
|
||||
END
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
270
Library/dxx8/samples/Multimedia/Demos/DMBoids/flock.cpp
Normal file
@@ -0,0 +1,270 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Flock.cpp
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <D3DX8.h>
|
||||
#include <stdio.h>
|
||||
#include "DXUtil.h"
|
||||
#include "boids.h"
|
||||
#include "music.h"
|
||||
|
||||
const float g_fInfluenceRadius = 10.0f; // outside of this range forces are considered to be 0
|
||||
|
||||
const float CollisionFraction = 0.8f;
|
||||
const float InvCollisionFraction = 1.0f/(1.0f-CollisionFraction);
|
||||
|
||||
const float g_fNormalSpeed = 0.1f;
|
||||
const float AngleTweak = 0.02f;
|
||||
const float g_fPitchToSpeedRatio = 0.002f;
|
||||
|
||||
// More arbitray constants that look cool
|
||||
const float fSeparationScale = 0.05f;
|
||||
const float fAlignmentScale = 0.1f;
|
||||
const float fCohesionScale = 1.0f;
|
||||
const float fMigratoryScale = 0.4f;
|
||||
const float fObstacleScale = 1.0f;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Effects
|
||||
//-----------------------------------------------------------------------------
|
||||
extern BoidMusic g_Music;
|
||||
extern BOOL g_bSeparation;
|
||||
extern BOOL g_bAlignment;
|
||||
extern BOOL g_bCohesion;
|
||||
extern BOOL g_bMigratory;
|
||||
extern BOOL g_bObstacle;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CFlock::Update( FLOAT fElapsedTime )
|
||||
{
|
||||
DWORD i, j;
|
||||
static DWORD lastobj = 0xffffffff;
|
||||
|
||||
// First, update the dist array 0.0..1.0 with 0.0 being furthest away
|
||||
for( i=0; i<m_dwNumBoids; i++ )
|
||||
{
|
||||
for( j=i+1; j<m_dwNumBoids; j++ )
|
||||
{
|
||||
D3DXVECTOR3 vDiff = m_Boids[i].vPos - m_Boids[j].vPos;
|
||||
FLOAT fDist = D3DXVec3Length( &vDiff );
|
||||
m_afDist[i][j] = m_afDist[j][i] = fDist;
|
||||
}
|
||||
m_afDist[i][i] = 0.0f;
|
||||
|
||||
// Reset boid forces
|
||||
m_Boids[i].vSeparationForce = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
m_Boids[i].vAlignmentForce = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
m_Boids[i].vCohesionForce = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
m_Boids[i].vMigratoryForce = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
m_Boids[i].vObstacleForce = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
m_Boids[i].dwNumNeighbors = 0;
|
||||
}
|
||||
|
||||
// For each boid calculate the individual forces affecting it
|
||||
for( i=0; i<m_dwNumBoids; i++ )
|
||||
{
|
||||
// Add in effects from other boids
|
||||
for( j=i+1; j<m_dwNumBoids; j++ )
|
||||
{
|
||||
D3DXVECTOR3 vDiff = m_Boids[i].vPos - m_Boids[j].vPos;
|
||||
FLOAT fDist = D3DXVec3Length( &vDiff );
|
||||
|
||||
// if i is near j have them influence each other
|
||||
if( fDist < g_fInfluenceRadius )
|
||||
{
|
||||
// Sum seperation force
|
||||
m_Boids[i].vSeparationForce += vDiff/(fDist*fDist);
|
||||
m_Boids[j].vSeparationForce -= vDiff/(fDist*fDist);
|
||||
|
||||
// sum alignment force (actually summing the directions of the neighbors)
|
||||
m_Boids[i].vAlignmentForce += m_Boids[j].vDir / fDist;
|
||||
m_Boids[j].vAlignmentForce += m_Boids[i].vDir / fDist;
|
||||
|
||||
// sum cohesion force (actually we're summing neighbor locations)
|
||||
m_Boids[i].vCohesionForce += m_Boids[j].vPos;
|
||||
m_Boids[j].vCohesionForce += m_Boids[i].vPos;
|
||||
|
||||
m_Boids[i].dwNumNeighbors++;
|
||||
m_Boids[j].dwNumNeighbors++;
|
||||
}
|
||||
}
|
||||
|
||||
// Add in any obstacle forces
|
||||
for( j=0; j<m_dwNumObstacles; j++ )
|
||||
{
|
||||
D3DXVECTOR3 vDiff = m_Boids[i].vPos - m_Obstacles[j].vPos;
|
||||
FLOAT fObRadius = m_Obstacles[j].fRadius * 1.5f;
|
||||
|
||||
// Ignore object if already past
|
||||
if( D3DXVec3Dot( &vDiff, &m_Boids[i].vDir ) > 0.0f )
|
||||
continue;
|
||||
|
||||
FLOAT fDist = D3DXVec3Length( &vDiff ) - fObRadius;
|
||||
|
||||
if( fDist < g_fInfluenceRadius )
|
||||
{
|
||||
if( ( lastobj != j ) && ( fDist < 5.0f ) )
|
||||
{
|
||||
lastobj = j;
|
||||
g_Music.Transition();
|
||||
}
|
||||
vDiff /= fDist; // normalize
|
||||
|
||||
fDist -= fObRadius;
|
||||
if( fDist < 0.01f )
|
||||
fDist = 0.01f;
|
||||
|
||||
m_Boids[i].vObstacleForce += vDiff;
|
||||
}
|
||||
}
|
||||
|
||||
// Find cohesion force
|
||||
if( m_Boids[i].dwNumNeighbors )
|
||||
{
|
||||
m_Boids[i].vCohesionForce /= (FLOAT)m_Boids[i].dwNumNeighbors; // Find average location of neighbors
|
||||
D3DXVECTOR3 vDiff = m_Boids[i].vCohesionForce - m_Boids[i].vPos; // Find delta to center of flock
|
||||
FLOAT fMag = D3DXVec3Length( &vDiff );
|
||||
|
||||
if( fMag > 0.0f)
|
||||
m_Boids[i].vCohesionForce = vDiff/fMag; // normalized
|
||||
else
|
||||
m_Boids[i].vCohesionForce = D3DXVECTOR3( 0.0f, 0.0f, 0.0f );
|
||||
}
|
||||
|
||||
// Find the alignment force
|
||||
if( m_Boids[i].dwNumNeighbors != 0 )
|
||||
{
|
||||
m_Boids[i].vAlignmentForce /= (FLOAT)m_Boids[i].dwNumNeighbors;
|
||||
FLOAT fMag = D3DXVec3Length( &m_Boids[i].vAlignmentForce );
|
||||
|
||||
if( fMag > 0.0f )
|
||||
{
|
||||
m_Boids[i].vAlignmentForce /= fMag; // normalize
|
||||
|
||||
D3DXVECTOR3 vDiff = m_Boids[i].vAlignmentForce - m_Boids[i].vDir;
|
||||
|
||||
m_Boids[i].vAlignmentForce = vDiff / fMag;
|
||||
}
|
||||
}
|
||||
|
||||
// Finally, the migratory force
|
||||
m_Boids[i].vMigratoryForce = m_vGoal - m_Boids[i].vPos;
|
||||
D3DXVec3Normalize( &m_Boids[i].vMigratoryForce, &m_Boids[i].vMigratoryForce );
|
||||
}
|
||||
|
||||
// Update the boids
|
||||
for( i=0; i<m_dwNumBoids; i++ )
|
||||
{
|
||||
// Sum all the forces
|
||||
D3DXVECTOR3 vForce( 0.0f, 0.0f, 0.0f );
|
||||
if( !g_bObstacle ) vForce += m_Boids[i].vObstacleForce;
|
||||
if( !g_bSeparation ) vForce += m_Boids[i].vSeparationForce;
|
||||
if( !g_bAlignment ) vForce += m_Boids[i].vAlignmentForce * fAlignmentScale;
|
||||
if( !g_bCohesion ) vForce += m_Boids[i].vCohesionForce;
|
||||
if( !g_bMigratory ) vForce += m_Boids[i].vMigratoryForce;
|
||||
|
||||
// Ok, now we have a final force to apply to the boid.
|
||||
// Normalize it if too big.
|
||||
FLOAT mag = D3DXVec3Length( &vForce );
|
||||
if( mag > 1.0f )
|
||||
vForce /= mag;
|
||||
|
||||
// first deal with pitch changes
|
||||
if( vForce.y > 0.01f )
|
||||
{ // we're too low
|
||||
m_Boids[i].pitch += AngleTweak;
|
||||
if (m_Boids[i].pitch > 0.8f)
|
||||
m_Boids[i].pitch = 0.8f;
|
||||
}
|
||||
else if( vForce.y < -0.01f )
|
||||
{ // we're too high
|
||||
m_Boids[i].pitch -= AngleTweak;
|
||||
if (m_Boids[i].pitch < -0.8f)
|
||||
m_Boids[i].pitch = -0.8f;
|
||||
}
|
||||
else
|
||||
{
|
||||
// add damping
|
||||
m_Boids[i].pitch *= 0.98f;
|
||||
}
|
||||
|
||||
// speed up or slow down depending on angle of attack
|
||||
m_Boids[i].speed -= m_Boids[i].pitch * g_fPitchToSpeedRatio;
|
||||
// damp back to normal
|
||||
m_Boids[i].speed = (m_Boids[i].speed-g_fNormalSpeed)*0.99f + g_fNormalSpeed;
|
||||
|
||||
// limit speed changes to +- 50% from normal
|
||||
if( m_Boids[i].speed < g_fNormalSpeed/2 )
|
||||
m_Boids[i].speed = g_fNormalSpeed/2;
|
||||
if( m_Boids[i].speed > g_fNormalSpeed*5 )
|
||||
m_Boids[i].speed = g_fNormalSpeed*5;
|
||||
|
||||
// now figure out yaw changes
|
||||
D3DXVECTOR3 vOffset = vForce;
|
||||
vOffset.y = 0.0f;
|
||||
D3DXVECTOR3 vDelta = m_Boids[i].vDir;
|
||||
|
||||
if( D3DXVec3Length( &vOffset ) > 0.0f )
|
||||
D3DXVec3Normalize( &vOffset, &vOffset );
|
||||
|
||||
float dot = D3DXVec3Dot( &vOffset, &vDelta );
|
||||
// speed up slightly if not turning much
|
||||
if (dot > 0.7f)
|
||||
{
|
||||
dot -= 0.7f;
|
||||
m_Boids[i].speed += dot * 0.005f;
|
||||
}
|
||||
D3DXVec3Cross( &vOffset, &vOffset, &vDelta );
|
||||
// D3DXVec3Cross( &vOffset, &vDelta, &vOffset );
|
||||
dot = (1.0f-dot)/2.0f * 0.07f;
|
||||
if( vOffset.y > 0.05f )
|
||||
{
|
||||
m_Boids[i].dyaw = (m_Boids[i].dyaw*19.0f + dot) * 0.05f;
|
||||
}
|
||||
else if( vOffset.y < -0.05f )
|
||||
{
|
||||
m_Boids[i].dyaw = (m_Boids[i].dyaw*19.0f - dot) * 0.05f;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_Boids[i].dyaw *= 0.98f; // damp it
|
||||
}
|
||||
m_Boids[i].yaw += m_Boids[i].dyaw;
|
||||
m_Boids[i].roll = -m_Boids[i].dyaw * 20.0f;
|
||||
|
||||
// Take new info and create a new world matrix
|
||||
// First translate into place, then set orientation, then scale (if needed)
|
||||
D3DXMATRIX matTrans, matRotateX, matRotateY, matRotateZ, matTemp1, matTemp2;
|
||||
D3DXMatrixTranslation( &matTrans, m_Boids[i].vPos.x, m_Boids[i].vPos.y, m_Boids[i].vPos.z );
|
||||
D3DXMatrixRotationX( &matRotateX, -m_Boids[i].pitch );
|
||||
D3DXMatrixRotationY( &matRotateY, -m_Boids[i].yaw );
|
||||
D3DXMatrixRotationZ( &matRotateZ, -m_Boids[i].roll );
|
||||
D3DXMatrixMultiply( &matTemp1, &matRotateX, &matRotateY );
|
||||
D3DXMatrixMultiply( &matTemp2, &matRotateZ, &matTemp1 );
|
||||
D3DXMatrixMultiply( &m_Boids[i].matWorld, &matTemp2, &matTrans );
|
||||
|
||||
// Now extract the boid's direction out of the matrix
|
||||
m_Boids[i].vDir.x = m_Boids[i].matWorld._31;
|
||||
m_Boids[i].vDir.y = m_Boids[i].matWorld._32;
|
||||
m_Boids[i].vDir.z = m_Boids[i].matWorld._33;
|
||||
|
||||
// And update the boid's location
|
||||
m_Boids[i].vPos += m_Boids[i].vDir * m_Boids[i].speed * 100 * fElapsedTime;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1115
Library/dxx8/samples/Multimedia/Demos/DMBoids/music.cpp
Normal file
116
Library/dxx8/samples/Multimedia/Demos/DMBoids/music.h
Normal file
@@ -0,0 +1,116 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Music.h
|
||||
//
|
||||
// Desc:
|
||||
//
|
||||
// Copyright (c) 1995-2001 Microsoft Corporation. All rights reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef MUSIC_H
|
||||
#define MUSIC_H
|
||||
|
||||
#include <windows.h>
|
||||
#include <dmusicc.h>
|
||||
#include <dmusici.h>
|
||||
|
||||
interface IDirectMusicStyle;
|
||||
interface IDirectMusicChordMap;
|
||||
interface IDirectMusicPerformance;
|
||||
interface IDirectMusicSegment;
|
||||
interface IDirectMusicComposer;
|
||||
interface IDirectMusicLoader;
|
||||
interface IDirectMusicGraph;
|
||||
interface IDirectMusicBand;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTool : public IDirectMusicTool
|
||||
{
|
||||
public:
|
||||
CTool();
|
||||
~CTool();
|
||||
|
||||
public:
|
||||
// IUnknown
|
||||
virtual STDMETHODIMP QueryInterface(const IID &iid, void **ppv);
|
||||
virtual STDMETHODIMP_(ULONG) AddRef();
|
||||
virtual STDMETHODIMP_(ULONG) Release();
|
||||
|
||||
// IDirectMusicTool
|
||||
HRESULT STDMETHODCALLTYPE Init(IDirectMusicGraph* pGraph) ;
|
||||
HRESULT STDMETHODCALLTYPE GetMsgDeliveryType(DWORD* pdwDeliveryType ) ;
|
||||
HRESULT STDMETHODCALLTYPE GetMediaTypeArraySize(DWORD* pdwNumElements ) ;
|
||||
HRESULT STDMETHODCALLTYPE GetMediaTypes(DWORD** padwMediaTypes, DWORD dwNumElements) ;
|
||||
HRESULT STDMETHODCALLTYPE ProcessPMsg(IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG) ;
|
||||
HRESULT STDMETHODCALLTYPE Flush(IDirectMusicPerformance* pPerf, DMUS_PMSG* pPMSG, REFERENCE_TIME rt) ;
|
||||
|
||||
long m_cRef;
|
||||
DWORD m_dwRatio;
|
||||
DWORD m_dwEcho;
|
||||
DWORD m_dwDelay;
|
||||
DWORD m_dwStartRatio;
|
||||
IDirectMusicPerformance * m_pPerformance;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class BoidMusic
|
||||
{
|
||||
public:
|
||||
BoidMusic();
|
||||
~BoidMusic();
|
||||
HRESULT LoadMusic( HWND hWnd );
|
||||
BOOL LoadChordMap();
|
||||
BOOL LoadStyle();
|
||||
BOOL LoadSegment();
|
||||
HRESULT LoadDLS();
|
||||
BOOL LoadTemplate(DWORD dwIndex, WCHAR * pszName);
|
||||
BOOL GetMotif(DWORD dwIndex, WCHAR * pszName);
|
||||
void ComposeSegment(DWORD dwIndex);
|
||||
void EndMusic();
|
||||
void StartMusic();
|
||||
void Transition();
|
||||
void Collapse();
|
||||
void Expand();
|
||||
void Migrate();
|
||||
void HandleNotifies();
|
||||
void SetDistance(double fDistance);
|
||||
BOOL GetSearchPath(WCHAR path[MAX_PATH]);
|
||||
void Activate(BOOL bActive);
|
||||
IDirectMusicStyle* m_pStyle;
|
||||
IDirectMusicChordMap* m_pChordMap;
|
||||
IDirectMusicSegment* m_pTemplateSegments[6];
|
||||
IDirectMusicSegment* m_pPrimarySegments[6];
|
||||
IDirectMusicSegment* m_pTransitionSegment;
|
||||
IDirectMusicSegment* m_pMotifSegments[6];
|
||||
IDirectMusicSegment* m_pSegment;
|
||||
IDirectMusicComposer* m_pComposer;
|
||||
IDirectMusicLoader* m_pLoader;
|
||||
IDirectMusicPerformance* m_pPerformance;
|
||||
IDirectMusicGraph* m_pGraph;
|
||||
IDirectMusicPort* m_pPort;
|
||||
IDirectMusicBand* m_pBand;
|
||||
IDirectMusic* m_pDMusic;
|
||||
DWORD m_dwIndex;
|
||||
HANDLE m_hNotify;
|
||||
DWORD m_dwLevel;
|
||||
CTool m_Tool;
|
||||
BOOL m_dwBeatsSinceLastMotif;
|
||||
BOOL m_fCollapsed;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
58
Library/dxx8/samples/Multimedia/Demos/DMBoids/readme.txt
Normal file
@@ -0,0 +1,58 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
// Sample Name: DMBoids Sample
|
||||
//
|
||||
// Copyright <20> 1999-2001 Microsoft Corp. All Rights Reserved.
|
||||
//
|
||||
// GM/GS<47> Sound Set Copyright <20>1996, Roland Corporation U.S.
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
|
||||
|
||||
Description
|
||||
===========
|
||||
DMBoids is a version of Boids that adds DirectMusic support. As objects fly
|
||||
over a simple landscape, the music responds to user input and events on the
|
||||
screen.
|
||||
|
||||
Path
|
||||
====
|
||||
Source: DXSDK\Samples\Multimedia\Dmusic\DMBoids
|
||||
|
||||
Executable: DXSDK\Samples\Multimedia\DMusic\Bin
|
||||
|
||||
User's Guide
|
||||
============
|
||||
Press F10 to access the main menu. The Drivers menu allows you to change the
|
||||
driver, device, and video mode. The application runs only in full-screen
|
||||
modes.
|
||||
|
||||
The A (alignment), C (cohesion) and O (obstacle) keys alter behavior of the
|
||||
boids in various ways as long as they are held down.
|
||||
|
||||
Hold down the S key or the spacebar and the birds flock in closer. Release
|
||||
the key and they spread apart. Note the use of motifs to track this
|
||||
behavior.
|
||||
|
||||
Hold down the M key and the birds wander off their path. Notice that the
|
||||
music completely changes. Release and the birds will eventually get back on
|
||||
the path.
|
||||
|
||||
Press the ESC key to quit.
|
||||
|
||||
Programming Notes
|
||||
=================
|
||||
DirectMusic features illustrated include the following:
|
||||
Software synthesis with DLS. In addition to the musical instruments
|
||||
from the GS sound set, the application uses custom downloadable sounds
|
||||
such as the voices that appear to come from the planets.
|
||||
|
||||
Composing and performing style-based segments.
|
||||
|
||||
Musical transitions using style-based motifs and segment cues.
|
||||
|
||||
Echo/articulation tool coded that uses the proximity of the birds to
|
||||
adjust the echoes and note durations of the music as it plays.
|
||||
|
||||
|
||||
40
Library/dxx8/samples/Multimedia/Demos/DMBoids/resource.h
Normal file
@@ -0,0 +1,40 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by WinMain.rc
|
||||
//
|
||||
#define IDI_MAIN_ICON 101
|
||||
#define IDR_MAIN_ACCEL 113
|
||||
#define IDR_MENU 141
|
||||
#define IDR_POPUP 142
|
||||
#define IDD_ABOUT 143
|
||||
#define IDD_CHANGEDEVICE 144
|
||||
#define IDD_SELECTDEVICE 144
|
||||
#define IDC_DEVICE_COMBO 1000
|
||||
#define IDC_MODE_COMBO 1001
|
||||
#define IDC_ADAPTER_COMBO 1002
|
||||
#define IDC_FULLSCREENMODES_COMBO 1003
|
||||
#define IDC_STEREOMODES_COMBO 1004
|
||||
#define IDC_WINDOWED_CHECKBOX 1012
|
||||
#define IDC_STEREO_CHECKBOX 1013
|
||||
#define IDC_FULLSCREEN_TEXT 1014
|
||||
#define IDC_WINDOW 1016
|
||||
#define IDC_STEREO 1017
|
||||
#define IDC_FULLSCREEN 1018
|
||||
#define IDM_ABOUT 40001
|
||||
#define IDM_CHANGEDEVICE 40002
|
||||
#define IDM_TOGGLEFULLSCREEN 40003
|
||||
#define IDM_TOGGLESTART 40004
|
||||
#define IDM_SINGLESTEP 40005
|
||||
#define IDM_EXIT 40006
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_3D_CONTROLS 1
|
||||
#define _APS_NEXT_RESOURCE_VALUE 146
|
||||
#define _APS_NEXT_COMMAND_VALUE 40011
|
||||
#define _APS_NEXT_CONTROL_VALUE 1027
|
||||
#define _APS_NEXT_SYMED_VALUE 102
|
||||
#endif
|
||||
#endif
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/bangbang.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/bounce.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/c_bang.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/d_bang.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts.bmp
Normal file
|
After Width: | Height: | Size: 768 KiB |
2927
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts.cpp
Normal file
544
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts.h
Normal file
@@ -0,0 +1,544 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Donuts.h
|
||||
//
|
||||
// Desc: Header for Donuts3D game
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DONUTS_H
|
||||
#define DONUTS_H
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, and constants
|
||||
//-----------------------------------------------------------------------------
|
||||
// This GUID must be unique for every game, and the same for
|
||||
// every instance of this app. // {2014BAAC-F1FD-458e-9091-0F85C8CF6AFE}
|
||||
// The GUID allows DirectInput to remember input settings
|
||||
GUID g_guidApp = { 0x2014baac, 0xf1fd, 0x458e, { 0x90, 0x91, 0xf, 0x85, 0xc8, 0xcf, 0x6a, 0xfe } };
|
||||
|
||||
// Error codes
|
||||
#define DONUTS3DERR_NODIRECT3D 0x00000001
|
||||
#define DONUTS3DERR_NOD3DDEVICE 0x00000002
|
||||
#define DONUTS3DERR_NOTEXTURES 0x00000003
|
||||
#define DONUTS3DERR_NOGEOMETRY 0x00000004
|
||||
#define DONUTS3DERR_NO3DRESOURCES 0x00000005
|
||||
#define DONUTS3DERR_NOINPUT 0x00000006
|
||||
|
||||
// States the app can be in
|
||||
enum{ APPSTATE_LOADSPLASH, APPSTATE_DISPLAYSPLASH, APPSTATE_ACTIVE,
|
||||
APPSTATE_BEGINLEVELSCREEN, APPSTATE_DISPLAYLEVELSCREEN };
|
||||
|
||||
// Game object types
|
||||
enum{ OBJ_DONUT=0, OBJ_PYRAMID, OBJ_CUBE, OBJ_SPHERE, OBJ_CLOUD, OBJ_SHIP,
|
||||
OBJ_BULLET };
|
||||
|
||||
// Object dimensions and fixed properties
|
||||
#define DONUT_WIDTH 32
|
||||
#define DONUT_HEIGHT 32
|
||||
#define PYRAMID_WIDTH 32
|
||||
#define PYRAMID_HEIGHT 32
|
||||
#define SPHERE_WIDTH 16
|
||||
#define SPHERE_HEIGHT 16
|
||||
#define CUBE_WIDTH 16
|
||||
#define CUBE_HEIGHT 16
|
||||
#define CLOUD_WIDTH 32
|
||||
#define CLOUD_HEIGHT 32
|
||||
#define BULLET_WIDTH 3
|
||||
#define BULLET_HEIGHT 3
|
||||
|
||||
#define NUM_DONUT_FRAMES 30
|
||||
#define NUM_PYRAMID_FRAMES 40
|
||||
#define NUM_SPHERE_FRAMES 40
|
||||
#define NUM_CUBE_FRAMES 40
|
||||
#define NUM_BULLET_FRAMES 400
|
||||
|
||||
#define BULLET_XOFFSET 304
|
||||
#define BULLET_YOFFSET 0
|
||||
|
||||
// Defines for the in-game menu
|
||||
#define MENU_MAIN 1
|
||||
#define MENU_SOUND 2
|
||||
#define MENU_VIDEO 3
|
||||
#define MENU_INPUT 4
|
||||
#define MENU_VIEWDEVICES 5
|
||||
#define MENU_CONFIGDEVICES 6
|
||||
#define MENU_WINDOWED 7
|
||||
#define MENU_640x480 8
|
||||
#define MENU_800x600 9
|
||||
#define MENU_1024x768 10
|
||||
#define MENU_BACK 11
|
||||
#define MENU_SOUNDON 12
|
||||
#define MENU_SOUNDOFF 13
|
||||
#define MENU_QUIT 14
|
||||
|
||||
|
||||
TCHAR* g_strShipFiles[] = { _T("Concept Plane 3.x"), _T("Spaceship 2.x"), _T("Shusui.x"),
|
||||
_T("Space Station 7.x"), _T("Spaceship 8.x"), _T("Orbiter.x"),
|
||||
_T("Spaceship 13.x"), _T("Spaceship 5.x"), _T("Star Sail.x"),
|
||||
_T("Heli.x"), };
|
||||
TCHAR* g_strShipNames[] = { _T("Concept Plane"), _T("Green Machine"), _T("Purple Prowler"),
|
||||
_T("Drone Clone"), _T("Canyon Fighter"), _T("Roundabout"),
|
||||
_T("Tie-X7"), _T("Gunner"), _T("Star Sail"),
|
||||
_T("Helicopter"), };
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct DisplayObject
|
||||
// Desc: A game object that goes in the display list
|
||||
//-----------------------------------------------------------------------------
|
||||
struct DisplayObject
|
||||
{
|
||||
DisplayObject* pNext; // Link to next object
|
||||
DisplayObject* pPrev; // Link to previous object
|
||||
|
||||
DWORD dwType; // Type of object
|
||||
BOOL bVisible; // Whether the object is visible
|
||||
D3DXVECTOR3 vPos; // Position
|
||||
D3DXVECTOR3 vVel; // Velocity
|
||||
FLOAT fSize;
|
||||
|
||||
// Constructor
|
||||
DisplayObject( DWORD type, D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Derived classes for displayable game objects
|
||||
//-----------------------------------------------------------------------------
|
||||
struct C3DSprite : public DisplayObject
|
||||
{
|
||||
DWORD dwFramesPerLine; // How anim frames are packed in bitmap
|
||||
FLOAT frame; // Current animation frame
|
||||
FLOAT fMaxFrame; // Max animation frame value
|
||||
FLOAT delay; // Frame/second
|
||||
|
||||
DWORD dwColor;
|
||||
|
||||
DWORD dwTextureOffsetX; // Pixel offsets into the game texture
|
||||
DWORD dwTextureOffsetY;
|
||||
DWORD dwTextureWidth; // Width and height in pixels
|
||||
DWORD dwTextureHeight;
|
||||
|
||||
C3DSprite( DWORD type, D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
class CDonut : public C3DSprite
|
||||
{
|
||||
public:
|
||||
CDonut( D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
class CPyramid : public C3DSprite
|
||||
{
|
||||
public:
|
||||
CPyramid( D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
class CSphere : public C3DSprite
|
||||
{
|
||||
public:
|
||||
CSphere( D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
class CCube : public C3DSprite
|
||||
{
|
||||
public:
|
||||
CCube( D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
class CCloud : public C3DSprite
|
||||
{
|
||||
public:
|
||||
CCloud( D3DVECTOR p, D3DVECTOR v );
|
||||
};
|
||||
|
||||
|
||||
class CBullet : public C3DSprite
|
||||
{
|
||||
public:
|
||||
CBullet( D3DVECTOR p, D3DVECTOR v, DWORD dwType );
|
||||
};
|
||||
|
||||
|
||||
class CShip : public DisplayObject
|
||||
{
|
||||
public:
|
||||
FLOAT fRoll;
|
||||
|
||||
FLOAT fAngle;
|
||||
|
||||
BOOL bExploded;
|
||||
FLOAT fShowDelay;
|
||||
|
||||
public:
|
||||
CShip( D3DVECTOR p );
|
||||
};
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Custom Direct3D vertex types
|
||||
//-----------------------------------------------------------------------------
|
||||
struct SCREENVERTEX
|
||||
{
|
||||
D3DXVECTOR4 p;
|
||||
DWORD color;
|
||||
};
|
||||
|
||||
struct SPRITEVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
DWORD color;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
struct MODELVERTEX
|
||||
{
|
||||
D3DXVECTOR3 p;
|
||||
D3DXVECTOR3 n;
|
||||
FLOAT tu, tv;
|
||||
};
|
||||
|
||||
#define D3DFVF_SCREENVERTEX (D3DFVF_XYZRHW|D3DFVF_DIFFUSE)
|
||||
#define D3DFVF_SPRITEVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1)
|
||||
#define D3DFVF_MODELVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1)
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// App defined structures
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// DirectInput action mapper reports events only when buttons/axis change
|
||||
// so we need to remember the present state of relevant axis/buttons for
|
||||
// each DirectInput device. The CInputDeviceManager will store a
|
||||
// pointer for each device that points to this struct
|
||||
struct InputDeviceState
|
||||
{
|
||||
FLOAT fAxisMoveUD;
|
||||
BOOL bButtonForwardThrust;
|
||||
BOOL bButtonReverseThrust;
|
||||
|
||||
FLOAT fAxisRotateLR;
|
||||
BOOL bButtonRotateLeft;
|
||||
BOOL bButtonRotateRight;
|
||||
|
||||
BOOL bButtonFireWeapons;
|
||||
|
||||
// Menu input variables
|
||||
FLOAT fAxisMenuUD;
|
||||
};
|
||||
|
||||
// Struct to store the current input state
|
||||
struct UserInput
|
||||
{
|
||||
FLOAT fAxisMoveUD;
|
||||
FLOAT fAxisRotateLR;
|
||||
BOOL bButtonFireWeapons;
|
||||
BOOL bButtonEnableShield;
|
||||
|
||||
// One-shot variables
|
||||
BOOL bDoChangeView;
|
||||
|
||||
// Menu input variables
|
||||
BOOL bDoMenuUp;
|
||||
BOOL bDoMenuDown;
|
||||
BOOL bDoMenuSelect;
|
||||
BOOL bDoMenuQuit;
|
||||
|
||||
};
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Game actions (using DInput semantic mapper). The definitions here are kind
|
||||
// of the whole point of this sample. The game uses these actions to map
|
||||
// physical input like, "the user pressed the 'W' key", to a more useable
|
||||
// constant for the game, like "if( dwInput == INPUT_CHANGEWEAPONS )...".
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Input semantics used by this game
|
||||
enum INPUT_SEMANTICS
|
||||
{
|
||||
// Gameplay semantics
|
||||
INPUT_AXIS_LR=1, INPUT_AXIS_UD,
|
||||
INPUT_MOUSE_LR, INPUT_MOUSE_UD, INPUT_MOUSE_SHIPTYPE,
|
||||
INPUT_TURNLEFT, INPUT_TURNRIGHT, INPUT_FORWARDTHRUST,
|
||||
INPUT_REVERSETHRUST, INPUT_FIREWEAPONS, INPUT_CHANGESHIPTYPE,
|
||||
INPUT_CHANGEVIEW, INPUT_CHANGEWEAPONS, INPUT_DISPLAYGAMEMENU,
|
||||
INPUT_QUITGAME, INPUT_START,
|
||||
|
||||
// Menu semantics
|
||||
INPUT_MENU_UD, INPUT_MENU_WHEEL,
|
||||
INPUT_MENU_UP, INPUT_MENU_DOWN,
|
||||
INPUT_MENU_SELECT, INPUT_MENU_QUIT,
|
||||
};
|
||||
|
||||
// Game actions used by this game.
|
||||
DIACTION g_rgGameAction[] =
|
||||
{
|
||||
// (C:\Program Files\DirectX\DirectInput\User Maps\*.ini)
|
||||
// after changing this, otherwise settings won't reset and will be read
|
||||
// from the out of date ini files
|
||||
|
||||
// Device input (joystick, etc.) that is pre-defined by DInput, according
|
||||
// to genre type. The genre for this app is space simulators.
|
||||
{ INPUT_AXIS_LR, DIAXIS_SPACESIM_LATERAL, 0, TEXT("Turn"), },
|
||||
{ INPUT_AXIS_UD, DIAXIS_SPACESIM_MOVE, 0, TEXT("Move"), },
|
||||
{ INPUT_FIREWEAPONS, DIBUTTON_SPACESIM_FIRE, 0, TEXT("Fire weapons"), },
|
||||
{ INPUT_CHANGEVIEW, DIBUTTON_SPACESIM_VIEW, 0, TEXT("Change view"), },
|
||||
{ INPUT_CHANGEWEAPONS, DIBUTTON_SPACESIM_WEAPONS, 0, TEXT("Change weapons"), },
|
||||
{ INPUT_CHANGESHIPTYPE, DIBUTTON_SPACESIM_LOWER, 0, TEXT("Change ship type"), },
|
||||
{ INPUT_DISPLAYGAMEMENU, DIBUTTON_SPACESIM_DEVICE, 0, TEXT("Display game menu"), },
|
||||
{ INPUT_START, DIBUTTON_SPACESIM_MENU, 0, TEXT("Start/pause"), },
|
||||
|
||||
// Keyboard input mappings
|
||||
{ INPUT_TURNLEFT, DIKEYBOARD_LEFT, 0, TEXT("Turn left"), },
|
||||
{ INPUT_TURNRIGHT, DIKEYBOARD_RIGHT, 0, TEXT("Turn right"), },
|
||||
{ INPUT_FORWARDTHRUST, DIKEYBOARD_UP, 0, TEXT("Forward thrust"), },
|
||||
{ INPUT_REVERSETHRUST, DIKEYBOARD_DOWN, 0, TEXT("Reverse thrust"), },
|
||||
{ INPUT_FIREWEAPONS, DIKEYBOARD_SPACE, 0, TEXT("Fire weapons"), },
|
||||
{ INPUT_CHANGESHIPTYPE, DIKEYBOARD_A, 0, TEXT("Change ship type"), },
|
||||
{ INPUT_CHANGEVIEW, DIKEYBOARD_V, 0, TEXT("Change view"), },
|
||||
{ INPUT_CHANGEWEAPONS, DIKEYBOARD_W, 0, TEXT("Change weapons"), },
|
||||
{ INPUT_DISPLAYGAMEMENU, DIKEYBOARD_F1, DIA_APPFIXED, TEXT("Display game menu"), },
|
||||
{ INPUT_START, DIKEYBOARD_PAUSE, 0, TEXT("Start/pause"), },
|
||||
{ INPUT_QUITGAME, DIKEYBOARD_ESCAPE, DIA_APPFIXED, TEXT("Quit game"), },
|
||||
|
||||
// Mouse input mappings
|
||||
{ INPUT_MOUSE_LR, DIMOUSE_XAXIS, 0, TEXT("Turn"), },
|
||||
{ INPUT_MOUSE_UD, DIMOUSE_YAXIS, 0, TEXT("Move"), },
|
||||
{ INPUT_MOUSE_SHIPTYPE, DIMOUSE_WHEEL, 0, TEXT("Change ship type"), },
|
||||
{ INPUT_FIREWEAPONS, DIMOUSE_BUTTON0, 0, TEXT("Fire weapons"), },
|
||||
{ INPUT_CHANGEWEAPONS, DIMOUSE_BUTTON1, 0, TEXT("Change weapons"), },
|
||||
};
|
||||
|
||||
// Game actions used by this game.
|
||||
DIACTION g_rgBrowserAction[] =
|
||||
{
|
||||
// (C:\Program Files\DirectX\DirectInput\User Maps\*.ini)
|
||||
// after changing this, otherwise settings won't reset and will be read
|
||||
// from the out of date ini files
|
||||
|
||||
// Device input (joystick, etc.) that is pre-defined by DInput, according
|
||||
// to genre type. The genre for this app is space simulators.
|
||||
{ INPUT_MENU_UD, DIAXIS_BROWSER_MOVE, 0, TEXT("Up/down"), },
|
||||
{ INPUT_MENU_UP, DIBUTTON_BROWSER_PREVIOUS, 0, TEXT("Up"), },
|
||||
{ INPUT_MENU_DOWN, DIBUTTON_BROWSER_NEXT, 0, TEXT("Down"), },
|
||||
{ INPUT_MENU_SELECT, DIBUTTON_BROWSER_SELECT, 0, TEXT("Select"), },
|
||||
{ INPUT_MENU_QUIT, DIBUTTON_BROWSER_DEVICE, 0, TEXT("Quit menu"), },
|
||||
|
||||
// Keyboard input mappings
|
||||
{ INPUT_MENU_UP, DIKEYBOARD_UP, 0, TEXT("Up"), },
|
||||
{ INPUT_MENU_DOWN, DIKEYBOARD_DOWN, 0, TEXT("Down"), },
|
||||
{ INPUT_MENU_SELECT, DIKEYBOARD_SPACE, 0, TEXT("Select"), },
|
||||
{ INPUT_MENU_SELECT, DIKEYBOARD_RETURN, 0, TEXT("Select"), },
|
||||
{ INPUT_MENU_SELECT, DIKEYBOARD_NUMPADENTER, 0, TEXT("Select"), },
|
||||
{ INPUT_MENU_QUIT, DIKEYBOARD_ESCAPE, 0, TEXT("Quit menu"), },
|
||||
|
||||
// Mouse input mappings
|
||||
{ INPUT_MENU_WHEEL, DIMOUSE_WHEEL, 0, TEXT("Up/down"), },
|
||||
{ INPUT_MENU_SELECT, DIMOUSE_BUTTON0, 0, TEXT("Select"), },
|
||||
};
|
||||
|
||||
// Number of actions
|
||||
#define NUMBER_OF_GAMEACTIONS (sizeof(g_rgGameAction)/sizeof(DIACTION))
|
||||
#define NUMBER_OF_BROWSERACTIONS (sizeof(g_rgBrowserAction)/sizeof(DIACTION))
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inline helper functions
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Simple function to define "hilliness" for terrain
|
||||
inline FLOAT HeightField( FLOAT x, FLOAT z )
|
||||
{
|
||||
return (cosf(x/2.0f+0.2f)*cosf(z/1.5f-0.2f)+1.0f) - 2.0f;
|
||||
}
|
||||
|
||||
// Simple function for generating random numbers
|
||||
inline FLOAT rnd( FLOAT low, FLOAT high )
|
||||
{
|
||||
return low + ( high - low ) * ( (FLOAT)rand() ) / RAND_MAX;
|
||||
}
|
||||
|
||||
FLOAT rnd( FLOAT low=-1.0f, FLOAT high=1.0f );
|
||||
|
||||
// Convenient macros for playing sounds
|
||||
inline VOID PlaySound( CMusicSegment* pSound )
|
||||
{
|
||||
if( pSound ) pSound->Play( DMUS_SEGF_SECONDARY );
|
||||
}
|
||||
|
||||
inline VOID StopSound( CMusicSegment* pSound )
|
||||
{
|
||||
if( pSound ) pSound->Stop();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK StaticMsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMyApplication
|
||||
// Desc: Application class.
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMyApplication
|
||||
{
|
||||
public:
|
||||
HRESULT Create( HINSTANCE hInstance );
|
||||
INT Run();
|
||||
LRESULT MsgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam );
|
||||
|
||||
CMyApplication();
|
||||
|
||||
HRESULT InputAddDeviceCB( CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi );
|
||||
static HRESULT CALLBACK StaticInputAddDeviceCB( CInputDeviceManager::DeviceInfo* pDeviceInfo, const DIDEVICEINSTANCE* pdidi, LPVOID pParam );
|
||||
BOOL ConfigureInputDevicesCB( IUnknown* pUnknown );
|
||||
static BOOL CALLBACK StaticConfigureInputDevicesCB( IUnknown* pUnknown, VOID* pUserData );
|
||||
|
||||
protected:
|
||||
HRESULT OneTimeSceneInit( HWND hWnd );
|
||||
HRESULT FrameMove();
|
||||
HRESULT RenderFrame();
|
||||
VOID FinalCleanup();
|
||||
|
||||
// Sound functions
|
||||
HRESULT CreateSoundObjects( HWND hWnd );
|
||||
VOID DestroySoundObjects();
|
||||
|
||||
// Input functions
|
||||
HRESULT CreateInputObjects( HWND hWnd );
|
||||
VOID DestroyInputObjects();
|
||||
void UpdateInput( UserInput* pUserInput );
|
||||
|
||||
// Display functions
|
||||
HRESULT CreateDisplayObjects( HWND hWnd );
|
||||
HRESULT RestoreDisplayObjects();
|
||||
HRESULT InvalidateDisplayObjects();
|
||||
HRESULT DestroyDisplayObjects();
|
||||
HRESULT SwitchDisplayModes( BOOL bFullScreen, DWORD dwWidth, DWORD dwHeight );
|
||||
|
||||
// Menu functions
|
||||
VOID ConstructMenus();
|
||||
VOID DestroyMenus();
|
||||
VOID UpdateMenus();
|
||||
|
||||
// Rendering functions
|
||||
VOID UpdateDisplayList();
|
||||
VOID DrawDisplayList();
|
||||
VOID ShowFrame();
|
||||
VOID DarkenScene( FLOAT fAmount );
|
||||
VOID RenderFieryText( CD3DFont* pFont, TCHAR* strText );
|
||||
|
||||
// Misc game functions
|
||||
VOID DisplayLevelIntroScreen( DWORD dwLevel );
|
||||
VOID AdvanceLevel();
|
||||
BOOL IsDisplayListEmpty();
|
||||
VOID AddToList( DisplayObject* pObject );
|
||||
VOID DeleteFromList( DisplayObject* pObject );
|
||||
VOID CheckForHits();
|
||||
|
||||
HRESULT LoadTerrainModel();
|
||||
HRESULT LoadShipModel();
|
||||
HRESULT SwitchModel();
|
||||
|
||||
// Error handling
|
||||
VOID CleanupAndDisplayError( DWORD dwError );
|
||||
|
||||
protected:
|
||||
TCHAR* m_strAppName;
|
||||
HWND m_hWndMain; // Main window
|
||||
DWORD m_dwScreenWidth; // Dimensions for fullscreen modes
|
||||
DWORD m_dwScreenHeight;
|
||||
D3DDISPLAYMODE m_DesktopMode;
|
||||
D3DFORMAT m_d3dfmtFullscreen; // Pixel format for fullscreen modes
|
||||
D3DFORMAT m_d3dfmtTexture; // Pixel format for textures
|
||||
BOOL m_bFullScreen; // Whether app is fullscreen (or windowed)
|
||||
BOOL m_bIsActive; // Whether app is active
|
||||
BOOL m_bDisplayReady; // Whether display class is initialized
|
||||
BOOL m_bMouseVisible; // Whether mouse is visible
|
||||
HBITMAP m_hSplashBitmap; // Bitmap for splash screen
|
||||
|
||||
DWORD m_dwAppState; // Current state the app is in
|
||||
DWORD m_dwLevel; // Current game level
|
||||
DWORD m_dwScore; // Current game score
|
||||
|
||||
// Player view mode
|
||||
#define NUMVIEWMODES 3
|
||||
CD3DCamera m_Camera; // Camera used for 3D scene
|
||||
DWORD m_dwViewMode; // Which view mode is being used
|
||||
FLOAT m_fViewTransition; // Amount used to transittion views
|
||||
BOOL m_bAnimatingViewChange; // Whether view is transitioning
|
||||
BOOL m_bFirstPersonView; // Whether view is first-person
|
||||
|
||||
// Bullet mode
|
||||
FLOAT m_fBulletRechargeTime; // Recharge time for firing bullets
|
||||
DWORD m_dwBulletType; // Current bullet type
|
||||
|
||||
// Display list and player ship
|
||||
DisplayObject* m_pDisplayList; // Global display list
|
||||
CShip* m_pShip; // Player's display object
|
||||
|
||||
// DirectDraw/Direct3D objects
|
||||
LPDIRECT3DDEVICE8 m_pd3dDevice; // Class to handle D3D device
|
||||
D3DPRESENT_PARAMETERS m_d3dpp;
|
||||
LPDIRECT3DSURFACE8 m_pConfigSurface; // Surface for config'ing DInput devices
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pViewportVB;
|
||||
LPDIRECT3DVERTEXBUFFER8 m_pSpriteVB;
|
||||
|
||||
// Support for the ship model
|
||||
CD3DMesh* m_pShipFileObject; // Geometry model of player's ship
|
||||
DWORD m_dwNumShipTypes;
|
||||
DWORD m_dwCurrentShipType;
|
||||
|
||||
// DirectMusic objects
|
||||
CMusicManager* m_pMusicManager; // Class to manage DMusic objects
|
||||
CMusicSegment* m_pBeginLevelSound; // Sounds for the app
|
||||
CMusicSegment* m_pEngineIdleSound;
|
||||
CMusicSegment* m_pEngineRevSound;
|
||||
CMusicSegment* m_pShieldBuzzSound;
|
||||
CMusicSegment* m_pShipExplodeSound;
|
||||
CMusicSegment* m_pFireBulletSound;
|
||||
CMusicSegment* m_pShipBounceSound;
|
||||
CMusicSegment* m_pDonutExplodeSound;
|
||||
CMusicSegment* m_pPyramidExplodeSound;
|
||||
CMusicSegment* m_pCubeExplodeSound;
|
||||
CMusicSegment* m_pSphereExplodeSound;
|
||||
|
||||
// Game objects
|
||||
LPDIRECT3DTEXTURE8 m_pGameTexture1; // Texture with game object animations
|
||||
LPDIRECT3DTEXTURE8 m_pGameTexture2; // Texture with game object animations
|
||||
CD3DMesh* m_pTerrain; // Geometry model of terrain
|
||||
CD3DFont* m_pGameFont; // Font for displaying score, etc.
|
||||
CD3DFont* m_pMenuFont; // Font for displaying in-game menus
|
||||
|
||||
|
||||
// Menu objects
|
||||
CMenuItem* m_pMainMenu; // Menu class for in-game menus
|
||||
CMenuItem* m_pQuitMenu;
|
||||
CMenuItem* m_pCurrentMenu;
|
||||
|
||||
// DirectInput objects
|
||||
CInputDeviceManager* m_pInputDeviceManager; // Class for managing DInput devices
|
||||
UserInput m_UserInput; // Struct for storing user input
|
||||
DIACTIONFORMAT m_diafGame; // Action format for game play
|
||||
DIACTIONFORMAT m_diafBrowser; // Action format for menu navigation
|
||||
|
||||
BOOL m_bPaused;
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts.ico
Normal file
|
After Width: | Height: | Size: 766 B |
113
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts.rc
Normal file
@@ -0,0 +1,113 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#define APSTUDIO_HIDDEN_SYMBOLS
|
||||
#include "windows.h"
|
||||
#undef APSTUDIO_HIDDEN_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
DONUTS_ICON ICON DISCARDABLE "donuts.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
SPLASH BITMAP MOVEABLE PURE "SPLASH.BMP"
|
||||
DONUTS8 BITMAP MOVEABLE PURE "donuts.bmp"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WAV
|
||||
//
|
||||
|
||||
BEGINLEVEL WAV MOVEABLE PURE "level.wav"
|
||||
ENGINEIDLE WAV MOVEABLE PURE "hum.wav"
|
||||
ENGINEREV WAV MOVEABLE PURE "rev.wav"
|
||||
SKIDTOSTOP WAV MOVEABLE PURE "skid.wav"
|
||||
SHIELDBUZZ WAV MOVEABLE PURE "shield.wav"
|
||||
GUNFIRE WAV MOVEABLE PURE "gunfire.wav"
|
||||
SHIPBOUNCE WAV MOVEABLE PURE "bounce.wav"
|
||||
SHIPEXPLODE WAV MOVEABLE PURE "bangbang.wav"
|
||||
DONUTEXPLODE WAV MOVEABLE PURE "d_bang.wav"
|
||||
PYRAMIDEXPLODE WAV MOVEABLE PURE "p_bang.wav"
|
||||
CUBEEXPLODE WAV MOVEABLE PURE "c_bang.wav"
|
||||
SPHEREEXPLODE WAV MOVEABLE PURE "s_bang.wav"
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#define APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"#include ""windows.h""\r\n"
|
||||
"#undef APSTUDIO_HIDDEN_SYMBOLS\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Accelerator
|
||||
//
|
||||
|
||||
IDR_MAIN_ACCEL ACCELERATORS DISCARDABLE
|
||||
BEGIN
|
||||
VK_RETURN, IDM_TOGGLEFULLSCREEN, VIRTKEY, ALT, NOINVERT
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
228
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts3d.dsp
Normal file
@@ -0,0 +1,228 @@
|
||||
# Microsoft Developer Studio Project File - Name="Donuts3D" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=Donuts3D - Win32 Debug
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "donuts3d.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "donuts3d.mak" CFG="Donuts3D - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Donuts3D - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Donuts3D - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "Donuts3D - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib dinput8.lib dsound.lib winspool.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x1f4000,0x1f4000
|
||||
|
||||
!ELSEIF "$(CFG)" == "Donuts3D - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /YX /FD /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /FD /c
|
||||
# SUBTRACT CPP /YX
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept
|
||||
# ADD LINK32 d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib dinput8.lib dsound.lib winspool.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /pdbtype:sept /stack:0x1f4000,0x1f4000
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "Donuts3D - Win32 Release"
|
||||
# Name "Donuts3D - Win32 Debug"
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bangbang.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\bounce.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\c_bang.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\d_bang.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\donuts.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\donuts.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\donuts.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gunfire.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\hum.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\level.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\p_bang.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\rev.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\s_bang.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\shield.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\skid.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\splash.bmp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Common"
|
||||
|
||||
# PROP Default_Filter ""
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfile.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dfile.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\d3dfont.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\diutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\diutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dmutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\dmutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=..\..\common\include\dxutil.h
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\donuts.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\donuts.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gamemenu.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gamemenu.h
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts3d.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "Donuts3D"=.\donuts3d.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
270
Library/dxx8/samples/Multimedia/Demos/Donuts3D/donuts3d.mak
Normal file
@@ -0,0 +1,270 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on donuts3d.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=Donuts3D - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to Donuts3D - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "Donuts3D - Win32 Release" && "$(CFG)" != "Donuts3D - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "donuts3d.mak" CFG="Donuts3D - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "Donuts3D - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "Donuts3D - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "Donuts3D - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\donuts3d.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\dmutil.obj"
|
||||
-@erase "$(INTDIR)\donuts.obj"
|
||||
-@erase "$(INTDIR)\donuts.res"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\gamemenu.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\donuts3d.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"$(INTDIR)\donuts3d.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\donuts.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\donuts3d.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8.lib d3d8.lib d3dxof.lib dxguid.lib dinput8.lib dsound.lib winspool.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\donuts3d.pdb" /machine:I386 /out:"$(OUTDIR)\donuts3d.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dmutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\donuts.obj" \
|
||||
"$(INTDIR)\gamemenu.obj" \
|
||||
"$(INTDIR)\donuts.res"
|
||||
|
||||
"$(OUTDIR)\donuts3d.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "Donuts3D - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\donuts3d.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\d3dfile.obj"
|
||||
-@erase "$(INTDIR)\d3dfont.obj"
|
||||
-@erase "$(INTDIR)\d3dutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\dmutil.obj"
|
||||
-@erase "$(INTDIR)\donuts.obj"
|
||||
-@erase "$(INTDIR)\donuts.res"
|
||||
-@erase "$(INTDIR)\dxutil.obj"
|
||||
-@erase "$(INTDIR)\gamemenu.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\donuts3d.exe"
|
||||
-@erase "$(OUTDIR)\donuts3d.ilk"
|
||||
-@erase "$(OUTDIR)\donuts3d.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\donuts.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\donuts3d.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=d3dx8dt.lib d3d8.lib d3dxof.lib dxguid.lib dinput8.lib dsound.lib winspool.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\donuts3d.pdb" /debug /machine:I386 /out:"$(OUTDIR)\donuts3d.exe" /pdbtype:sept
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\d3dfile.obj" \
|
||||
"$(INTDIR)\d3dfont.obj" \
|
||||
"$(INTDIR)\d3dutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dmutil.obj" \
|
||||
"$(INTDIR)\dxutil.obj" \
|
||||
"$(INTDIR)\donuts.obj" \
|
||||
"$(INTDIR)\gamemenu.obj" \
|
||||
"$(INTDIR)\donuts.res"
|
||||
|
||||
"$(OUTDIR)\donuts3d.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("donuts3d.dep")
|
||||
!INCLUDE "donuts3d.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "donuts3d.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "Donuts3D - Win32 Release" || "$(CFG)" == "Donuts3D - Win32 Debug"
|
||||
SOURCE=.\donuts.rc
|
||||
|
||||
"$(INTDIR)\donuts.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfile.cpp
|
||||
|
||||
"$(INTDIR)\d3dfile.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dfont.cpp
|
||||
|
||||
"$(INTDIR)\d3dfont.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\d3dutil.cpp
|
||||
|
||||
"$(INTDIR)\d3dutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\diutil.cpp
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dmutil.cpp
|
||||
|
||||
"$(INTDIR)\dmutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=..\..\common\src\dxutil.cpp
|
||||
|
||||
"$(INTDIR)\dxutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
$(CPP) $(CPP_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\donuts.cpp
|
||||
|
||||
"$(INTDIR)\donuts.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
SOURCE=.\gamemenu.cpp
|
||||
|
||||
"$(INTDIR)\gamemenu.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
141
Library/dxx8/samples/Multimedia/Demos/Donuts3D/gamemenu.cpp
Normal file
@@ -0,0 +1,141 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: GameMenu.cpp
|
||||
//
|
||||
// Desc: Code for in-game menus
|
||||
//
|
||||
// Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define STRICT
|
||||
#define D3D_OVERLOADS
|
||||
#include <D3D8.h>
|
||||
#include <D3DX8Math.h>
|
||||
#include <mmsystem.h>
|
||||
#include "D3DFont.h"
|
||||
#include "D3DUtil.h"
|
||||
#include "GameMenu.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
CMenuItem::CMenuItem( TCHAR* strNewLabel, DWORD dwNewID )
|
||||
{
|
||||
_tcscpy( strLabel, strNewLabel );
|
||||
dwID = dwNewID;
|
||||
pParent = NULL;
|
||||
dwNumChildren = 0L;
|
||||
dwSelectedMenu = 0L;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
CMenuItem::~CMenuItem()
|
||||
{
|
||||
while( dwNumChildren )
|
||||
delete pChild[--dwNumChildren];
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
CMenuItem* CMenuItem::Add( CMenuItem* pNewChild )
|
||||
{
|
||||
pChild[dwNumChildren++] = pNewChild;
|
||||
pNewChild->pParent = this;
|
||||
|
||||
return pNewChild;
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: Render()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT CMenuItem::Render( LPDIRECT3DDEVICE8 pd3dDevice, CD3DFont* pFont )
|
||||
{
|
||||
// Check parameters
|
||||
if( NULL==pd3dDevice || NULL==pFont )
|
||||
return E_INVALIDARG;
|
||||
|
||||
// Save current matrices
|
||||
D3DXMATRIX matViewSaved, matProjSaved;
|
||||
pd3dDevice->GetTransform( D3DTS_VIEW, &matViewSaved );
|
||||
pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProjSaved );
|
||||
|
||||
// Setup new view and proj matrices for head-on viewing
|
||||
D3DXMATRIX matView, matProj;
|
||||
D3DXMatrixLookAtLH( &matView, &D3DXVECTOR3(0.0f,0.0f,-30.0f),
|
||||
&D3DXVECTOR3(0.0f,0.0f,0.0f),
|
||||
&D3DXVECTOR3(0.0f,1.0f,0.0f) );
|
||||
D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, 1.0f, 1.0f, 100.0f );
|
||||
pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
|
||||
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
|
||||
|
||||
// Establish colors for selected vs. normal menu items
|
||||
D3DMATERIAL8 mtrlNormal, mtrlSelected, mtrlTitle;
|
||||
D3DUtil_InitMaterial( mtrlTitle, 1.0f, 0.0f, 0.0f, 1.0f );
|
||||
D3DUtil_InitMaterial( mtrlNormal, 1.0f, 1.0f, 1.0f, 0.5f );
|
||||
D3DUtil_InitMaterial( mtrlSelected, 1.0f, 1.0f, 0.0f, 1.0f );
|
||||
|
||||
pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
|
||||
pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xffffffff );
|
||||
|
||||
// Translate the menuitem into place
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixScaling( &matWorld, 0.4f, 0.4f, 0.4f );
|
||||
matWorld._42 = (dwNumChildren*1.0f) + 2.0f;
|
||||
pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
pd3dDevice->SetMaterial( &mtrlTitle );
|
||||
|
||||
// Render the menuitem's label
|
||||
pFont->Render3DText( strLabel, D3DFONT_CENTERED|D3DFONT_TWOSIDED );
|
||||
|
||||
// Loop through and render all menuitem lables
|
||||
for( DWORD i=0; i<dwNumChildren; i++ )
|
||||
{
|
||||
D3DXMATRIX matWorld;
|
||||
D3DXMatrixScaling( &matWorld, 0.3f, 0.3f, 0.3f );
|
||||
pd3dDevice->SetMaterial( &mtrlNormal );
|
||||
|
||||
// Give a different effect for selected items
|
||||
if( dwSelectedMenu == i )
|
||||
{
|
||||
D3DXMATRIX matRotate;
|
||||
D3DXMatrixRotationY( &matRotate, (D3DX_PI/3)*sinf(timeGetTime()/200.0f) );
|
||||
D3DXMatrixMultiply( &matWorld, &matWorld, &matRotate );
|
||||
pd3dDevice->SetMaterial( &mtrlSelected );
|
||||
}
|
||||
|
||||
// Translate the menuitem into place
|
||||
matWorld._42 = (dwNumChildren*1.0f) - (i*2.0f);
|
||||
pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
|
||||
|
||||
// Render the menuitem's label
|
||||
pFont->Render3DText( pChild[i]->strLabel,
|
||||
D3DFONT_CENTERED|D3DFONT_TWOSIDED );
|
||||
}
|
||||
|
||||
// Restore matrices
|
||||
pd3dDevice->SetTransform( D3DTS_VIEW, &matViewSaved );
|
||||
pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProjSaved );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
47
Library/dxx8/samples/Multimedia/Demos/Donuts3D/gamemenu.h
Normal file
@@ -0,0 +1,47 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: GameMenu.h
|
||||
//
|
||||
// Desc: Code for in-game menus
|
||||
//
|
||||
// Copyright (C) 1999-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef GAMEMENU_H
|
||||
#define GAMEMENU_H
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: class CMenuItem
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
class CMenuItem
|
||||
{
|
||||
public:
|
||||
TCHAR strLabel[80];
|
||||
DWORD dwID;
|
||||
CMenuItem* pParent;
|
||||
|
||||
CMenuItem* pChild[10];
|
||||
DWORD dwNumChildren;
|
||||
|
||||
DWORD dwSelectedMenu;
|
||||
|
||||
public:
|
||||
HRESULT Render( LPDIRECT3DDEVICE8 pd3dDevice, CD3DFont* pFont );
|
||||
|
||||
CMenuItem* Add( CMenuItem* );
|
||||
|
||||
CMenuItem( TCHAR* strLabel, DWORD dwID );
|
||||
~CMenuItem();
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/gunfire.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/hum.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/level.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/p_bang.wav
Normal file
18
Library/dxx8/samples/Multimedia/Demos/Donuts3D/resource.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by donuts.rc
|
||||
//
|
||||
#define DONUTS_ICON 101
|
||||
#define IDR_MAIN_ACCEL 103
|
||||
#define IDM_TOGGLEFULLSCREEN 40002
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 105
|
||||
#define _APS_NEXT_COMMAND_VALUE 40015
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
17
Library/dxx8/samples/Multimedia/Demos/Donuts3D/resrc1.h
Normal file
@@ -0,0 +1,17 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by donuts.rc
|
||||
//
|
||||
#define IDR_MAIN_ACCEL 103
|
||||
#define IDM_TOGGLEFULLSCREEN 40002
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 104
|
||||
#define _APS_NEXT_COMMAND_VALUE 40003
|
||||
#define _APS_NEXT_CONTROL_VALUE 1000
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/rev.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/s_bang.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/shield.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/skid.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Donuts3D/splash.bmp
Normal file
|
After Width: | Height: | Size: 750 KiB |
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/bfire.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/csession.bmp
Normal file
|
After Width: | Height: | Size: 518 B |
221
Library/dxx8/samples/Multimedia/Demos/Duel/ddutil.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DDutil.cpp
|
||||
//
|
||||
// Desc: Routines for loading bitmap and palettes from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <ddraw.h>
|
||||
#include "ddutil.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_CopyBitmap()
|
||||
// Desc: Draw a bitmap into a DirectDrawSurface
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DDUtil_CopyBitmap( LPDIRECTDRAWSURFACE pdds, HBITMAP hbm, int x, int y,
|
||||
int dx, int dy )
|
||||
{
|
||||
HDC hdcImage;
|
||||
HDC hdc;
|
||||
BITMAP bm;
|
||||
DDSURFACEDESC ddsd;
|
||||
HRESULT hr;
|
||||
|
||||
if( hbm == NULL || pdds == NULL )
|
||||
return E_FAIL;
|
||||
|
||||
// Make sure this surface is restored.
|
||||
pdds->Restore();
|
||||
|
||||
// Select bitmap into a memoryDC so we can use it.
|
||||
hdcImage = CreateCompatibleDC(NULL);
|
||||
if( !hdcImage )
|
||||
{
|
||||
OutputDebugString( TEXT("CreateCompatibleDC() failed\n") );
|
||||
return E_FAIL;
|
||||
}
|
||||
SelectObject( hdcImage, hbm );
|
||||
|
||||
// Get size of the bitmap
|
||||
GetObject( hbm, sizeof(bm), &bm ); // get size of bitmap
|
||||
dx = dx == 0 ? bm.bmWidth : dx; // use the passed size, unless zero
|
||||
dy = dy == 0 ? bm.bmHeight : dy;
|
||||
|
||||
// Gt size of surface.
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
|
||||
pdds->GetSurfaceDesc(&ddsd);
|
||||
|
||||
if( SUCCEEDED( hr = pdds->GetDC(&hdc) ) )
|
||||
{
|
||||
StretchBlt( hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage,
|
||||
x, y, dx, dy, SRCCOPY);
|
||||
pdds->ReleaseDC( hdc );
|
||||
}
|
||||
|
||||
DeleteDC( hdcImage );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_LoadPalette()
|
||||
// Desc: Create a DirectDraw palette object from a bitmap resoure
|
||||
// If the resource does not exist or NULL is passed create a
|
||||
// default 332 palette.
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTDRAWPALETTE DDUtil_LoadPalette( LPDIRECTDRAW pDD, TCHAR* strBitmap )
|
||||
{
|
||||
LPDIRECTDRAWPALETTE pddPalette;
|
||||
int i;
|
||||
int n;
|
||||
HANDLE fh;
|
||||
HRSRC h;
|
||||
LPBITMAPINFOHEADER lpbi;
|
||||
PALETTEENTRY ape[256];
|
||||
RGBQUAD* prgb;
|
||||
DWORD dwRead;
|
||||
|
||||
// Build a 332 palette as the default.
|
||||
for( i=0; i<256; i++ )
|
||||
{
|
||||
ape[i].peRed = (BYTE)(((i >> 5) & 0x07) * 255 / 7);
|
||||
ape[i].peGreen = (BYTE)(((i >> 2) & 0x07) * 255 / 7);
|
||||
ape[i].peBlue = (BYTE)(((i >> 0) & 0x03) * 255 / 3);
|
||||
ape[i].peFlags = (BYTE)0;
|
||||
}
|
||||
|
||||
// Gt a pointer to the bitmap resource.
|
||||
if( strBitmap && ( h = FindResource( NULL, strBitmap, RT_BITMAP ) ) )
|
||||
{
|
||||
lpbi = (LPBITMAPINFOHEADER)LockResource( LoadResource( NULL, h ) );
|
||||
if( NULL == lpbi )
|
||||
OutputDebugString(TEXT("lock resource failed\n"));
|
||||
prgb = (RGBQUAD*)((BYTE*)lpbi + lpbi->biSize);
|
||||
|
||||
if (lpbi == NULL || lpbi->biSize < sizeof(BITMAPINFOHEADER))
|
||||
n = 0;
|
||||
else if (lpbi->biBitCount > 8)
|
||||
n = 0;
|
||||
else if (lpbi->biClrUsed == 0)
|
||||
n = 1 << lpbi->biBitCount;
|
||||
else
|
||||
n = lpbi->biClrUsed;
|
||||
|
||||
// A DIB color table has its colors stored BGR not RGB, so flip them
|
||||
for(i=0; i<n; i++ )
|
||||
{
|
||||
ape[i].peRed = prgb[i].rgbRed;
|
||||
ape[i].peGreen = prgb[i].rgbGreen;
|
||||
ape[i].peBlue = prgb[i].rgbBlue;
|
||||
ape[i].peFlags = 0;
|
||||
}
|
||||
}
|
||||
else if( strBitmap && ( fh = CreateFile( strBitmap, GENERIC_READ,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE )
|
||||
{
|
||||
BITMAPFILEHEADER bf;
|
||||
BITMAPINFOHEADER bi;
|
||||
|
||||
ReadFile( fh, &bf, sizeof(bf), &dwRead, NULL );
|
||||
ReadFile( fh, &bi, sizeof(bi), &dwRead, NULL );
|
||||
ReadFile( fh, ape, sizeof(ape), &dwRead, NULL );
|
||||
CloseHandle( fh );
|
||||
|
||||
if( bi.biSize != sizeof(BITMAPINFOHEADER) )
|
||||
n = 0;
|
||||
else if( bi.biBitCount > 8 )
|
||||
n = 0;
|
||||
else if( bi.biClrUsed == 0 )
|
||||
n = 1 << bi.biBitCount;
|
||||
else
|
||||
n = bi.biClrUsed;
|
||||
|
||||
// A DIB color table has its colors stored BGR not RGB so flip them
|
||||
for(i=0; i<n; i++ )
|
||||
{
|
||||
BYTE r = ape[i].peRed;
|
||||
ape[i].peRed = ape[i].peBlue;
|
||||
ape[i].peBlue = r;
|
||||
}
|
||||
}
|
||||
|
||||
pDD->CreatePalette( DDPCAPS_8BIT, ape, &pddPalette, NULL );
|
||||
|
||||
return pddPalette;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_ColorMatch()
|
||||
// Desc: Convert a RGB color to a pysical color. We do this by leting GDI
|
||||
// SetPixel() do the color matching.
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD DDUtil_ColorMatch( LPDIRECTDRAWSURFACE pdds, COLORREF rgb )
|
||||
{
|
||||
DDSURFACEDESC ddsd;
|
||||
COLORREF rgbT;
|
||||
HDC hdc;
|
||||
DWORD dw = CLR_INVALID;
|
||||
HRESULT hr;
|
||||
|
||||
// Wse GDI SetPixel to color match for us
|
||||
if( rgb != CLR_INVALID && SUCCEEDED( pdds->GetDC(&hdc) ) )
|
||||
{
|
||||
rgbT = GetPixel( hdc, 0, 0 ); // Save current pixel value
|
||||
SetPixel( hdc, 0, 0, rgb ); // Set our value
|
||||
pdds->ReleaseDC( hdc );
|
||||
}
|
||||
|
||||
// Now lock the surface so we can read back the converted color
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
while( ( hr = pdds->Lock( NULL, &ddsd, 0, NULL ) ) == DDERR_WASSTILLDRAWING )
|
||||
{}
|
||||
|
||||
if( SUCCEEDED(hr) )
|
||||
{
|
||||
dw = *(DWORD *)ddsd.lpSurface; // get DWORD
|
||||
dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount)-1; // mask it to bpp
|
||||
pdds->Unlock(NULL);
|
||||
}
|
||||
|
||||
// Now put the color that was there back.
|
||||
if( rgb != CLR_INVALID && SUCCEEDED( pdds->GetDC(&hdc) ) )
|
||||
{
|
||||
SetPixel( hdc, 0, 0, rgbT );
|
||||
pdds->ReleaseDC( hdc );
|
||||
}
|
||||
|
||||
return dw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_SetColorKey()
|
||||
// Desc: Set a color key for a surface, given a RGB. If you pass CLR_INVALID as
|
||||
// the color key, the pixel in the upper-left corner will be used.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DDUtil_SetColorKey( LPDIRECTDRAWSURFACE pdds, COLORREF rgb )
|
||||
{
|
||||
DDCOLORKEY ddck;
|
||||
ddck.dwColorSpaceLowValue = DDUtil_ColorMatch( pdds, rgb );
|
||||
ddck.dwColorSpaceHighValue = ddck.dwColorSpaceLowValue;
|
||||
|
||||
return pdds->SetColorKey( DDCKEY_SRCBLT, &ddck );
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
Library/dxx8/samples/Multimedia/Demos/Duel/ddutil.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DDutil.h
|
||||
//
|
||||
// Desc: Routines for loading bitmap and palettes from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <tchar.h>
|
||||
|
||||
LPDIRECTDRAWPALETTE DDUtil_LoadPalette( LPDIRECTDRAW pDD, TCHAR* strBitmap );
|
||||
HRESULT DDUtil_CopyBitmap( LPDIRECTDRAWSURFACE pdds, HBITMAP hbm,
|
||||
int x, int y, int dx, int dy );
|
||||
DWORD DDUtil_ColorMatch( LPDIRECTDRAWSURFACE pdds, COLORREF rgb );
|
||||
HRESULT DDUtil_SetColorKey( LPDIRECTDRAWSURFACE pdds, COLORREF rgb );
|
||||
|
||||
|
||||
|
||||
|
||||
169
Library/dxx8/samples/Multimedia/Demos/Duel/diutil.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DIUtil.cpp
|
||||
//
|
||||
// Desc: Input routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "diutil.h"
|
||||
#include "gameproc.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
static LPDIRECTINPUT g_pDI; // DirectInput interface
|
||||
static LPDIRECTINPUTDEVICE g_pdidKeyboard; // Keyboard device interface
|
||||
static BOOL g_bKeyboardAcquired; // Whether eyboard is acquired
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_InitInput()
|
||||
// Desc: Initialize DirectInput objects & devices
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DIUtil_InitInput( HWND hWnd )
|
||||
{
|
||||
// Create DI object
|
||||
HINSTANCE hInst;
|
||||
#ifdef _WIN64
|
||||
hInst = (HINSTANCE)GetWindowLongPtr( hWnd, GWLP_HINSTANCE );
|
||||
#else
|
||||
hInst = (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE );
|
||||
#endif
|
||||
|
||||
if( FAILED( DirectInputCreate( hInst, DIRECTINPUT_VERSION, &g_pDI, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_DIC);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Create keyboard device
|
||||
if( FAILED( g_pDI->CreateDevice( GUID_SysKeyboard, &g_pdidKeyboard, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_CD);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Tell DirectInput that we want to receive data in keyboard format
|
||||
if( FAILED( g_pdidKeyboard->SetDataFormat( &c_dfDIKeyboard) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_DF);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Set cooperative level
|
||||
if( FAILED( g_pdidKeyboard->SetCooperativeLevel( hWnd,
|
||||
DISCL_NONEXCLUSIVE | DISCL_FOREGROUND ) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_SP);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// try to acquire the keyboard
|
||||
if( SUCCEEDED( g_pdidKeyboard->Acquire() ) )
|
||||
g_bKeyboardAcquired = TRUE;
|
||||
else
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_ReadKeys()
|
||||
// Desc: Use DirectInput to read game-play keys
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DIUtil_ReadKeys( DWORD* pdwKeys )
|
||||
{
|
||||
BYTE rgbKeybd[256];
|
||||
DWORD dwKeys = 0L;
|
||||
HRESULT hr;
|
||||
|
||||
hr = g_pdidKeyboard->GetDeviceState( sizeof(rgbKeybd), rgbKeybd );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if( hr == DIERR_INPUTLOST )
|
||||
{
|
||||
// We lost control of the keyboard, reacquire
|
||||
if( SUCCEEDED( g_pdidKeyboard->Acquire() ) )
|
||||
g_bKeyboardAcquired = TRUE;
|
||||
else
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
}
|
||||
|
||||
// Failed to read the keyboard, just return
|
||||
return;
|
||||
}
|
||||
|
||||
// check & update key states
|
||||
if( rgbKeybd[DIK_NUMPAD5] & 0x80 )
|
||||
dwKeys |= KEY_STOP;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD2] & 0x80) || (rgbKeybd[DIK_DOWN] & 0x80) )
|
||||
dwKeys |= KEY_DOWN;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD4] & 0x80) || (rgbKeybd[DIK_LEFT] & 0x80) )
|
||||
dwKeys |= KEY_LEFT;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD6] & 0x80) || (rgbKeybd[DIK_RIGHT] & 0x80) )
|
||||
dwKeys |= KEY_RIGHT;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD8] & 0x80) || (rgbKeybd[DIK_UP] & 0x80) )
|
||||
dwKeys |= KEY_UP;
|
||||
|
||||
if( rgbKeybd[DIK_SPACE] & 0x80 )
|
||||
dwKeys |= KEY_FIRE;
|
||||
|
||||
// Return the keys
|
||||
(*pdwKeys) = dwKeys;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_CleanupInput()
|
||||
// Desc: Cleans up DirectInput objects
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DIUtil_CleanupInput()
|
||||
{
|
||||
if(g_bKeyboardAcquired)
|
||||
{
|
||||
g_pdidKeyboard->Unacquire();
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
}
|
||||
|
||||
if( g_pdidKeyboard )
|
||||
g_pdidKeyboard->Release();
|
||||
|
||||
if( g_pDI )
|
||||
g_pDI->Release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_ReacquireInputDevices()
|
||||
// Desc: Reacquires DirectInput devices as needed
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DIUtil_ReacquireInputDevices()
|
||||
{
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
|
||||
if( NULL == g_pdidKeyboard )
|
||||
return E_FAIL;
|
||||
|
||||
g_pdidKeyboard->Acquire();
|
||||
g_bKeyboardAcquired = TRUE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
24
Library/dxx8/samples/Multimedia/Demos/Duel/diutil.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DIUtil.h
|
||||
//
|
||||
// Desc: Input routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DIUTIL_H
|
||||
#define DIUTIL_H
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x700
|
||||
#include <dinput.h>
|
||||
|
||||
|
||||
HRESULT DIUtil_InitInput( HWND hWnd );
|
||||
VOID DIUtil_ReadKeys( DWORD* pdwKey );
|
||||
VOID DIUtil_CleanupInput();
|
||||
HRESULT DIUtil_ReacquireInputDevices();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
1284
Library/dxx8/samples/Multimedia/Demos/Duel/dpconnect.cpp
Normal file
425
Library/dxx8/samples/Multimedia/Demos/Duel/dputil.cpp
Normal file
@@ -0,0 +1,425 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DPUtil.cpp
|
||||
//
|
||||
// Desc: Communication routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "DPUtil.h"
|
||||
#include "lobby.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
extern GUID g_AppGUID; // Duel's guid
|
||||
extern DPLCONNECTION* g_pDPLConnection; // Connection settings
|
||||
extern BOOL g_bUseProtocol; // DirectPlay Protocol messaging
|
||||
extern BOOL g_bAsyncSupported; // Asynchronous sends supported
|
||||
|
||||
DPSESSIONDESC2* g_pdpsd; // Durrent session description
|
||||
LPDIRECTPLAY4 g_pDP = NULL; // DPlay object pointer
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CheckCaps()
|
||||
// Desc: Helper function to check for certain Capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CheckCaps()
|
||||
{
|
||||
HRESULT hr;
|
||||
DPCAPS dpcaps;
|
||||
ZeroMemory( &dpcaps, sizeof(DPCAPS) );
|
||||
dpcaps.dwSize = sizeof(DPCAPS);
|
||||
|
||||
if( NULL == g_pDP )
|
||||
return;
|
||||
|
||||
// The caps we are checking do not differ for guaranteed msg
|
||||
hr = g_pDP->GetCaps( &dpcaps, 0 );
|
||||
if( FAILED(hr) )
|
||||
return;
|
||||
|
||||
// Determine if Aync messages are supported.
|
||||
g_bAsyncSupported = (dpcaps.dwFlags & DPCAPS_ASYNCSUPPORTED) != 0;
|
||||
|
||||
// Diagnostic traces of caps supported
|
||||
if( g_bAsyncSupported )
|
||||
{
|
||||
TRACE(_T("Capabilities supported: Async %s %s %s\n"),
|
||||
(dpcaps.dwFlags & DPCAPS_SENDPRIORITYSUPPORTED ? _T("SendPriority") : _T("")),
|
||||
(dpcaps.dwFlags & DPCAPS_SENDTIMEOUTSUPPORTED ? _T("SendTimeout") : _T("")),
|
||||
(dpcaps.dwFlags & DPCAPS_ASYNCCANCELSUPPORTED
|
||||
? _T("AsyncCancel")
|
||||
: (dpcaps.dwFlags & DPCAPS_ASYNCCANCELALLSUPPORTED
|
||||
? _T("AsyncCancelAll") : _T("")))
|
||||
);
|
||||
}
|
||||
else
|
||||
TRACE(_T("CheckCaps - Async not supported\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_FreeDirectPlay()
|
||||
// Desc: Wrapper for DirectPlay Close API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_FreeDirectPlay()
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_InitDirectPlay()
|
||||
// Desc: Wrapper for DirectPlay Create API. Retrieves a DirectPlay4/4A
|
||||
// interface based on the UNICODE flag
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_InitDirectPlay( VOID* pCon )
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Create a DirectPlay4(A) interface
|
||||
#ifdef UNICODE
|
||||
hr = CoCreateInstance( CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay4, (VOID**)&g_pDP );
|
||||
#else
|
||||
hr = CoCreateInstance( CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay4A, (VOID**)&g_pDP );
|
||||
#endif
|
||||
if( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
// Initialize w/address
|
||||
if( pCon )
|
||||
{
|
||||
hr = g_pDP->InitializeConnection( pCon, 0 );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
g_pDP->Release();
|
||||
g_pDP = NULL;
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_CreatePlayer()
|
||||
// Desc: Wrapper for DirectPlay CreatePlayer API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_CreatePlayer( DPID* ppidID, TCHAR* strPlayerName, HANDLE hEvent,
|
||||
VOID* pData, DWORD dwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
DPNAME dpname;
|
||||
ZeroMemory( &dpname, sizeof(DPNAME) );
|
||||
dpname.dwSize = sizeof(DPNAME);
|
||||
|
||||
#ifdef UNICODE
|
||||
dpname.lpszShortName = strPlayerName;
|
||||
#else
|
||||
dpname.lpszShortNameA = strPlayerName;
|
||||
#endif
|
||||
|
||||
return g_pDP->CreatePlayer( ppidID, &dpname, hEvent, pData, dwDataSize, 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_CreateSession()
|
||||
// Desc: Wrapper for DirectPlay CreateSession API.Uses the global application
|
||||
// guid.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_CreateSession( TCHAR* strSessionName )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
DPSESSIONDESC2 dpDesc;
|
||||
ZeroMemory( &dpDesc, sizeof(dpDesc) );
|
||||
dpDesc.dwSize = sizeof(dpDesc);
|
||||
dpDesc.dwFlags = DPSESSION_MIGRATEHOST | DPSESSION_KEEPALIVE;
|
||||
if( g_bUseProtocol )
|
||||
dpDesc.dwFlags |= DPSESSION_DIRECTPLAYPROTOCOL;
|
||||
|
||||
#ifdef UNICODE
|
||||
dpDesc.lpszSessionName = strSessionName;
|
||||
#else
|
||||
dpDesc.lpszSessionNameA = strSessionName;
|
||||
#endif
|
||||
|
||||
// Set the application guid
|
||||
dpDesc.guidApplication = g_AppGUID;
|
||||
|
||||
HRESULT hr = g_pDP->Open( &dpDesc, DPOPEN_CREATE );
|
||||
|
||||
// Check for Async message support
|
||||
if( SUCCEEDED(hr) )
|
||||
CheckCaps();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_DestroyPlayer()
|
||||
// Desc: Wrapper for DirectPlay DestroyPlayer API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_DestroyPlayer( DPID pid )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->DestroyPlayer( pid );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_EnumPlayers()
|
||||
// Desc: Wrapper for DirectPlay API EnumPlayers
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_EnumPlayers( GUID* pSessionGuid,
|
||||
LPDPENUMPLAYERSCALLBACK2 pEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->EnumPlayers( pSessionGuid, pEnumCallback, pContext, dwFlags );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_EnumSessions()
|
||||
// Desc: Wrapper for DirectPlay EnumSessions API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_EnumSessions( DWORD dwTimeout,
|
||||
LPDPENUMSESSIONSCALLBACK2 pEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
DPSESSIONDESC2 dpDesc;
|
||||
ZeroMemory( &dpDesc, sizeof(dpDesc) );
|
||||
dpDesc.dwSize = sizeof(dpDesc);
|
||||
dpDesc.guidApplication = g_AppGUID;
|
||||
|
||||
return g_pDP->EnumSessions( &dpDesc, dwTimeout, pEnumCallback,
|
||||
pContext, dwFlags );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_GetPlayerLocalData()
|
||||
// Desc: Wrapper for DirectPlay GetPlayerData API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_GetPlayerLocalData( DPID pid, VOID* pData, DWORD* pdwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
HRESULT hr = g_pDP->GetPlayerData( pid, pData, pdwDataSize, DPGET_LOCAL );
|
||||
if( FAILED(hr) )
|
||||
TRACE( TEXT("Get Player local data failed for id %d\n"), pid );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_GetSessionDesc()
|
||||
// Desc: Wrapper for DirectPlay GetSessionDesc API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_GetSessionDesc()
|
||||
{
|
||||
DWORD dwSize;
|
||||
HRESULT hr;
|
||||
|
||||
// Free old session desc, if any
|
||||
if( g_pdpsd )
|
||||
free( g_pdpsd );
|
||||
g_pdpsd = NULL;
|
||||
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
// First get the size for the session desc
|
||||
hr = g_pDP->GetSessionDesc( NULL, &dwSize );
|
||||
if( DPERR_BUFFERTOOSMALL == hr )
|
||||
{
|
||||
// Allocate memory for it
|
||||
g_pdpsd = (DPSESSIONDESC2*)malloc( dwSize );
|
||||
if( NULL == g_pdpsd )
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
// Now get the session desc
|
||||
hr = g_pDP->GetSessionDesc( g_pdpsd, &dwSize );
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_IsDPlayInitialized()
|
||||
// Desc: Returns TRUE if a DirectPlay interface exists, otherwise FALSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL DPUtil_IsDPlayInitialized()
|
||||
{
|
||||
return( g_pDP ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_OpenSession()
|
||||
// Desc: Wrapper for DirectPlay OpenSession API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_OpenSession( GUID* pSessionGUID )
|
||||
{
|
||||
if( NULL == g_pDP)
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
DPSESSIONDESC2 dpDesc;
|
||||
ZeroMemory( &dpDesc, sizeof(dpDesc) );
|
||||
dpDesc.dwSize = sizeof(dpDesc);
|
||||
if( g_bUseProtocol )
|
||||
dpDesc.dwFlags = DPSESSION_DIRECTPLAYPROTOCOL;
|
||||
|
||||
// Set the session guid
|
||||
if( pSessionGUID )
|
||||
dpDesc.guidInstance = (*pSessionGUID);
|
||||
// Set the application guid
|
||||
dpDesc.guidApplication = g_AppGUID;
|
||||
|
||||
// Open it
|
||||
HRESULT hr = g_pDP->Open( &dpDesc, DPOPEN_JOIN );
|
||||
|
||||
// Check for Async message support
|
||||
if( SUCCEEDED(hr) )
|
||||
CheckCaps();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_Receive()
|
||||
// Desc: Wrapper for DirectPlay Receive API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_Receive( DPID* pidFrom, DPID* pidTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD* pdwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->Receive( pidFrom, pidTo, dwFlags, pData, pdwDataSize );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_Release()
|
||||
// Desc: Wrapper for DirectPlay Release API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_Release()
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
// Free session desc, if any
|
||||
if( g_pdpsd )
|
||||
free( g_pdpsd );
|
||||
g_pdpsd = NULL;
|
||||
|
||||
// Free connection settings structure, if any (lobby stuff)
|
||||
if( g_pDPLConnection )
|
||||
delete[] g_pDPLConnection;
|
||||
g_pDPLConnection = NULL;
|
||||
|
||||
// Release dplay
|
||||
HRESULT hr = g_pDP->Release();
|
||||
g_pDP = NULL;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_Send()
|
||||
// Desc: Wrapper for DirectPlay Send[Ex] API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_Send( DPID idFrom, DPID idTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD dwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
if (dwFlags & DPSEND_ASYNC)
|
||||
// We don't specify a priority or timeout. Would have to check
|
||||
// GetCaps() first to see if they were supported
|
||||
return g_pDP->SendEx( idFrom, idTo, dwFlags, pData, dwDataSize,
|
||||
0, 0, NULL, NULL );
|
||||
else
|
||||
return g_pDP->Send( idFrom, idTo, dwFlags, pData, dwDataSize );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_SetPlayerLocalData()
|
||||
// Desc: Wrapper for DirectPlay SetPlayerData API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_SetPlayerLocalData( DPID pid, VOID* pData, DWORD dwSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
HRESULT hr = g_pDP->SetPlayerData( pid, pData, dwSize, DPSET_LOCAL );
|
||||
if( FAILED(hr) )
|
||||
TRACE( TEXT("Set Player local data failed for id %d\n"), pid );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
41
Library/dxx8/samples/Multimedia/Demos/Duel/dputil.h
Normal file
@@ -0,0 +1,41 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DPUtil.h
|
||||
//
|
||||
// Desc: Communication routines include file
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IDIRECTPLAY2_OR_GREATER
|
||||
#include <dplay.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_FreeDirectPlay();
|
||||
HRESULT DPUtil_InitDirectPlay( VOID* pCon );
|
||||
HRESULT DPUtil_CreatePlayer( DPID* ppidID, LPTSTR pPlayerName, HANDLE hEvent,
|
||||
VOID* pData, DWORD dwDataSize );
|
||||
HRESULT DPUtil_CreateSession( TCHAR* strSessionName );
|
||||
HRESULT DPUtil_DestroyPlayer( DPID pid );
|
||||
HRESULT DPUtil_EnumPlayers( GUID* pSessionGuid,
|
||||
LPDPENUMPLAYERSCALLBACK2 lpEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags );
|
||||
HRESULT DPUtil_EnumSessions( DWORD dwTimeout,
|
||||
LPDPENUMSESSIONSCALLBACK2 lpEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags );
|
||||
HRESULT DPUtil_GetSessionDesc();
|
||||
BOOL DPUtil_IsDPlayInitialized();
|
||||
HRESULT DPUtil_OpenSession( GUID* pSessionGuid );
|
||||
HRESULT DPUtil_Receive( DPID* pidFrom, DPID* pidTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD* pdwDataSize );
|
||||
HRESULT DPUtil_Release();
|
||||
HRESULT DPUtil_Send( DPID idFrom, DPID idTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD dwDataSize );
|
||||
HRESULT DPUtil_SetPlayerLocalData( DPID pid, VOID* pData, DWORD dwSize );
|
||||
HRESULT DPUtil_GetPlayerLocalData( DPID pid, VOID* pData, DWORD* pdwDataSize );
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
465
Library/dxx8/samples/Multimedia/Demos/Duel/dsutil.cpp
Normal file
@@ -0,0 +1,465 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: dsutil.cpp
|
||||
//
|
||||
// Desc: Routines for dealing with sounds from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
#include "dsutil.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUND g_pDS = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_LoadSoundBuffer()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_LoadSoundBuffer( LPDIRECTSOUND pDS, LPCTSTR strName )
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSB = NULL;
|
||||
DSBUFFERDESC dsbd;
|
||||
BYTE* pbWaveData;
|
||||
|
||||
ZeroMemory( &dsbd, sizeof(dsbd) );
|
||||
dsbd.dwSize = sizeof(dsbd);
|
||||
dsbd.dwFlags = DSBCAPS_STATIC|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME|
|
||||
DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPOSITIONNOTIFY;
|
||||
|
||||
if( SUCCEEDED( DSUtil_GetWaveResource( NULL, strName, &dsbd.lpwfxFormat,
|
||||
&pbWaveData, &dsbd.dwBufferBytes ) ) )
|
||||
{
|
||||
|
||||
if( SUCCEEDED( pDS->CreateSoundBuffer( &dsbd, &pDSB, NULL ) ) )
|
||||
{
|
||||
if( FAILED( DSUtil_FillSoundBuffer( pDSB, pbWaveData,
|
||||
dsbd.dwBufferBytes ) ) )
|
||||
{
|
||||
pDSB->Release();
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pDSB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_ReloadSoundBuffer()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_ReloadSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, LPCTSTR strName )
|
||||
{
|
||||
BYTE* pbWaveData;
|
||||
DWORD cbWaveSize;
|
||||
|
||||
if( FAILED( DSUtil_GetWaveResource( NULL, strName, NULL, &pbWaveData,
|
||||
&cbWaveSize ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( pDSB->Restore() ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( DSUtil_FillSoundBuffer( pDSB, pbWaveData, cbWaveSize ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_GetWaveResource( HMODULE hModule, LPCTSTR strName,
|
||||
WAVEFORMATEX** ppWaveHeader, BYTE** ppbWaveData,
|
||||
DWORD* pcbWaveSize )
|
||||
{
|
||||
HRSRC hResInfo;
|
||||
HGLOBAL hResData;
|
||||
VOID* pvRes;
|
||||
|
||||
if( NULL == ( hResInfo = FindResource( hModule, strName, TEXT("WAVE") ) ) )
|
||||
{
|
||||
if( NULL == ( hResInfo = FindResource( hModule, strName, TEXT("WAV") ) ) )
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( NULL == ( hResData = LoadResource( hModule, hResInfo ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( NULL == ( pvRes = LockResource( hResData ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( DSUtil_ParseWaveResource( pvRes, ppWaveHeader, ppbWaveData,
|
||||
pcbWaveSize ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
SoundObject* DSUtil_CreateSound( LPCTSTR strName, DWORD dwNumConcurrentBuffers )
|
||||
{
|
||||
SoundObject* pSound = NULL;
|
||||
LPWAVEFORMATEX pWaveHeader;
|
||||
BYTE* pbData;
|
||||
DWORD cbData;
|
||||
|
||||
if( NULL == g_pDS )
|
||||
return NULL;
|
||||
|
||||
if( dwNumConcurrentBuffers < 1 )
|
||||
dwNumConcurrentBuffers = 1;
|
||||
|
||||
if( SUCCEEDED( DSUtil_GetWaveResource( NULL, strName, &pWaveHeader,
|
||||
&pbData, &cbData ) ) )
|
||||
{
|
||||
pSound = new SoundObject;
|
||||
pSound->dwNumBuffers = dwNumConcurrentBuffers;
|
||||
pSound->pbWaveData = pbData;
|
||||
pSound->cbWaveSize = cbData;
|
||||
pSound->dwCurrent = 0;
|
||||
pSound->pdsbBuffers = new LPDIRECTSOUNDBUFFER[dwNumConcurrentBuffers+1];
|
||||
|
||||
pSound->pdsbBuffers[0] = DSUtil_LoadSoundBuffer( g_pDS, strName );
|
||||
|
||||
for( DWORD i=1; i<pSound->dwNumBuffers; i++ )
|
||||
{
|
||||
if( FAILED( g_pDS->DuplicateSoundBuffer( pSound->pdsbBuffers[0],
|
||||
&pSound->pdsbBuffers[i] ) ) )
|
||||
{
|
||||
pSound->pdsbBuffers[i] = DSUtil_LoadSoundBuffer( g_pDS, strName );
|
||||
if( NULL == pSound->pdsbBuffers[i] )
|
||||
{
|
||||
DSUtil_DestroySound( pSound );
|
||||
pSound = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pSound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_DestroySound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_DestroySound( SoundObject* pSound )
|
||||
{
|
||||
if( pSound )
|
||||
{
|
||||
for( DWORD i=0; i<pSound->dwNumBuffers; i++ )
|
||||
{
|
||||
if( pSound->pdsbBuffers[i] )
|
||||
pSound->pdsbBuffers[i]->Release();
|
||||
}
|
||||
|
||||
delete pSound->pdsbBuffers;
|
||||
delete pSound;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_GetFreeSoundBuffer( SoundObject* pSound )
|
||||
{
|
||||
HRESULT hr;
|
||||
DWORD dwStatus;
|
||||
|
||||
if( NULL == pSound )
|
||||
return NULL;
|
||||
|
||||
LPDIRECTSOUNDBUFFER pDSB = pSound->pdsbBuffers[pSound->dwCurrent];
|
||||
if( NULL == pDSB )
|
||||
return NULL;
|
||||
|
||||
hr = pDSB->GetStatus( &dwStatus );
|
||||
if( FAILED(hr) )
|
||||
dwStatus = 0;
|
||||
|
||||
if( dwStatus & DSBSTATUS_PLAYING )
|
||||
{
|
||||
if( pSound->dwNumBuffers <= 1 )
|
||||
return NULL;
|
||||
|
||||
if( ++pSound->dwCurrent >= pSound->dwNumBuffers )
|
||||
pSound->dwCurrent = 0;
|
||||
|
||||
pDSB = pSound->pdsbBuffers[pSound->dwCurrent];
|
||||
|
||||
hr = pDSB->GetStatus( &dwStatus);
|
||||
if( FAILED(hr) )
|
||||
dwStatus = 0;
|
||||
|
||||
if( dwStatus & DSBSTATUS_PLAYING )
|
||||
{
|
||||
pDSB->Stop();
|
||||
pDSB->SetCurrentPosition( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if( dwStatus & DSBSTATUS_BUFFERLOST )
|
||||
{
|
||||
if( FAILED( pDSB->Restore() ) )
|
||||
return NULL;
|
||||
|
||||
if( FAILED( DSUtil_FillSoundBuffer( pDSB, pSound->pbWaveData,
|
||||
pSound->cbWaveSize ) ) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pDSB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlaySound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_PlaySound( SoundObject* pSound, DWORD dwPlayFlags )
|
||||
{
|
||||
if( NULL == pSound )
|
||||
return E_FAIL;
|
||||
|
||||
if( !(dwPlayFlags & DSBPLAY_LOOPING) || (pSound->dwNumBuffers == 1) )
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSB = DSUtil_GetFreeSoundBuffer( pSound );
|
||||
if( pDSB )
|
||||
{
|
||||
if( SUCCEEDED( pDSB->Play( 0, 0, dwPlayFlags ) ) )
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_StopSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_StopSound( SoundObject* pSound )
|
||||
{
|
||||
if( NULL == pSound )
|
||||
return E_FAIL;
|
||||
|
||||
for( DWORD i=0; i<pSound->dwNumBuffers; i++ )
|
||||
{
|
||||
pSound->pdsbBuffers[i]->Stop();
|
||||
pSound->pdsbBuffers[i]->SetCurrentPosition( 0 );
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_FillSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, BYTE* pbWaveData,
|
||||
DWORD dwWaveSize )
|
||||
{
|
||||
VOID* pMem1;
|
||||
VOID* pMem2;
|
||||
DWORD dwSize1;
|
||||
DWORD dwSize2;
|
||||
|
||||
if( NULL == pDSB || NULL == pbWaveData || 0 == dwWaveSize )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( pDSB->Lock( 0, dwWaveSize, &pMem1, &dwSize1, &pMem2,
|
||||
&dwSize2, 0 ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( 0 != dwSize1 ) CopyMemory( pMem1, pbWaveData, dwSize1 );
|
||||
if( 0 != dwSize2 ) CopyMemory( pMem2, pbWaveData+dwSize1, dwSize2 );
|
||||
|
||||
pDSB->Unlock( pMem1, dwSize1, pMem2, dwSize2);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_ParseWaveResource( VOID* pvRes, WAVEFORMATEX** ppWaveHeader,
|
||||
BYTE** ppbWaveData, DWORD* pcbWaveSize )
|
||||
{
|
||||
DWORD* pdw;
|
||||
DWORD* pdwEnd;
|
||||
DWORD dwRiff;
|
||||
DWORD dwType;
|
||||
DWORD dwLength;
|
||||
|
||||
if( ppWaveHeader )
|
||||
*ppWaveHeader = NULL;
|
||||
|
||||
if( ppbWaveData )
|
||||
*ppbWaveData = NULL;
|
||||
|
||||
if( pcbWaveSize )
|
||||
*pcbWaveSize = 0;
|
||||
|
||||
pdw = (DWORD*)pvRes;
|
||||
dwRiff = *pdw++;
|
||||
dwLength = *pdw++;
|
||||
dwType = *pdw++;
|
||||
|
||||
if( dwRiff != mmioFOURCC('R', 'I', 'F', 'F') )
|
||||
return E_FAIL;
|
||||
|
||||
if( dwType != mmioFOURCC('W', 'A', 'V', 'E') )
|
||||
return E_FAIL;
|
||||
|
||||
pdwEnd = (DWORD *)((BYTE *)pdw + dwLength-4);
|
||||
|
||||
while( pdw < pdwEnd )
|
||||
{
|
||||
dwType = *pdw++;
|
||||
dwLength = *pdw++;
|
||||
|
||||
if( dwType == mmioFOURCC('f', 'm', 't', ' ') )
|
||||
{
|
||||
if (ppWaveHeader && !*ppWaveHeader)
|
||||
{
|
||||
if( dwLength < sizeof(WAVEFORMAT) )
|
||||
return E_FAIL;
|
||||
|
||||
*ppWaveHeader = (WAVEFORMATEX*)pdw;
|
||||
|
||||
if( (!ppbWaveData || *ppbWaveData) &&
|
||||
(!pcbWaveSize || *pcbWaveSize) )
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( dwType == mmioFOURCC('d', 'a', 't', 'a') )
|
||||
{
|
||||
if( (ppbWaveData && !*ppbWaveData) ||
|
||||
(pcbWaveSize && !*pcbWaveSize) )
|
||||
{
|
||||
if( ppbWaveData )
|
||||
*ppbWaveData = (BYTE*)pdw;
|
||||
|
||||
if( pcbWaveSize )
|
||||
*pcbWaveSize = dwLength;
|
||||
|
||||
if( !ppWaveHeader || *ppWaveHeader )
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
pdw = (DWORD*)( (BYTE*)pdw + ((dwLength+1)&~1) );
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlayPannedSound()
|
||||
// Desc: Play a sound, but first set the panning according to where the
|
||||
// object is on the screen. fScreenXPos is between -1.0f (left) and
|
||||
// 1.0f (right).
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_PlayPannedSound( SoundObject* pSound, FLOAT fScreenXPos )
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSB = DSUtil_GetFreeSoundBuffer( pSound );
|
||||
|
||||
if( pDSB )
|
||||
{
|
||||
pDSB->SetPan( (LONG)( 10000L * fScreenXPos ) );
|
||||
pDSB->Play( 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_InitDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_InitDirectSound( HWND hWnd )
|
||||
{
|
||||
if( FAILED( DirectSoundCreate( NULL, &g_pDS, NULL ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( g_pDS->SetCooperativeLevel( hWnd, DSSCL_NORMAL ) ) )
|
||||
{
|
||||
g_pDS->Release();
|
||||
g_pDS = NULL;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_FreeDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_FreeDirectSound()
|
||||
{
|
||||
if( g_pDS )
|
||||
g_pDS->Release();
|
||||
g_pDS = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
152
Library/dxx8/samples/Multimedia/Demos/Duel/dsutil.h
Normal file
@@ -0,0 +1,152 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: dsutil.cpp
|
||||
//
|
||||
// Desc: Routines for dealing with sounds from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DSUTIL_H
|
||||
#define DSUTIL_H
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper routines
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_FillSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, BYTE* pbWaveData,
|
||||
DWORD dwWaveSize );
|
||||
HRESULT DSUtil_ParseWaveResource( VOID* pvRes, WAVEFORMATEX** ppWaveHeader,
|
||||
BYTE** ppbWaveData, DWORD* pdwWaveSize );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_LoadSoundBuffer()
|
||||
// Desc: Loads an IDirectSoundBuffer from a Win32 resource in the current
|
||||
// application.
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_LoadSoundBuffer( LPDIRECTSOUND* pDS,
|
||||
LPCTSTR strName );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_ReloadSoundBuffer()
|
||||
// Desc: Reloads an IDirectSoundBuffer from a Win32 resource in the current
|
||||
// application. normally used to handle a DSERR_BUFFERLOST error.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_ReloadSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, LPCTSTR strName );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_GetWaveResource()
|
||||
// Desc: Finds a WAV resource in a Win32 module.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_GetWaveResource( HMODULE hModule, LPCTSTR strName,
|
||||
WAVEFORMATEX** ppWaveHeader, BYTE** ppbWaveData,
|
||||
DWORD* pdwWaveSize );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_InitDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_InitDirectSound( HWND hWnd );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_FreeDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_FreeDirectSound();
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct SoundObject
|
||||
// Desc: Used to manage individual sounds which need to be played multiple
|
||||
// times concurrently. A SoundObject represents a queue of
|
||||
// IDirectSoundBuffer objects which all refer to the same buffer memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
struct SoundObject
|
||||
{
|
||||
BYTE* pbWaveData; // Ptr into wave resource (for restore)
|
||||
DWORD cbWaveSize; // Size of wave data (for restore)
|
||||
DWORD dwNumBuffers; // Number of sound buffers.
|
||||
DWORD dwCurrent; // Current sound buffer
|
||||
LPDIRECTSOUNDBUFFER* pdsbBuffers; // List of sound buffers
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_CreateSound()
|
||||
// Desc: Loads a SoundObject from a Win32 resource in the current application.
|
||||
//-----------------------------------------------------------------------------
|
||||
SoundObject* DSUtil_CreateSound( LPCTSTR strName, DWORD dwNumBuffers );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_DestroySound()
|
||||
// Desc: Frees a SoundObject and releases all of its buffers.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_DestroySound( SoundObject* pSound );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlayPannedSound()
|
||||
// Desc: Play a sound, but first set the panning according to where the
|
||||
// object is on the screen. fScreenXPos is between -1.0f (left) and
|
||||
// 1.0f (right).
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_PlayPannedSound( SoundObject* pSound, FLOAT fScreenXPos );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlaySound()
|
||||
// Desc: Plays a buffer in a SoundObject.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_PlaySound( SoundObject* pSound, DWORD dwPlayFlags );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_StopSound()
|
||||
// Desc: Stops one or more buffers in a SoundObject.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_StopSound( SoundObject* pSound );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_GetFreeSoundBuffer()
|
||||
// Desc: Returns one of the cloned buffers that is not currently playing
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_GetFreeSoundBuffer( SoundObject* pSound );
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DSUTIL_H
|
||||
|
||||
|
||||
|
||||
690
Library/dxx8/samples/Multimedia/Demos/Duel/duel.001
Normal file
@@ -0,0 +1,690 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=duel - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to duel - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "duel - Win32 Release" && "$(CFG)" != "duel - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duel.mak" CFG="duel - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "duel - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "duel - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "duel - Win32 Debug"
|
||||
MTL=mktyplib.exe
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\duel.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.res"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\wizard.obj"
|
||||
-@erase "$(OUTDIR)\duel.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)/duel.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/duel.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/duel.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib dinput.lib dsound.lib /nologo /subsystem:windows /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib\
|
||||
dinput.lib dsound.lib /nologo /subsystem:windows /incremental:no\
|
||||
/pdb:"$(OUTDIR)/duel.pdb" /machine:I386 /out:"$(OUTDIR)/duel.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\duel.res" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\wizard.obj"
|
||||
|
||||
"$(OUTDIR)\duel.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\duel.exe" "$(OUTDIR)\duel.bsc"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\ddutil.sbr"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.sbr"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dputil.sbr"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.sbr"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.res"
|
||||
-@erase "$(INTDIR)\duel.sbr"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gameproc.sbr"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\gfx.sbr"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\lobby.sbr"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\util.sbr"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(INTDIR)\wizard.obj"
|
||||
-@erase "$(INTDIR)\wizard.sbr"
|
||||
-@erase "$(OUTDIR)\duel.bsc"
|
||||
-@erase "$(OUTDIR)\duel.exe"
|
||||
-@erase "$(OUTDIR)\duel.ilk"
|
||||
-@erase "$(OUTDIR)\duel.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
|
||||
/FR"$(INTDIR)/" /Fp"$(INTDIR)/duel.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\Debug/
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/duel.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/duel.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\ddutil.sbr" \
|
||||
"$(INTDIR)\diutil.sbr" \
|
||||
"$(INTDIR)\dputil.sbr" \
|
||||
"$(INTDIR)\dsutil.sbr" \
|
||||
"$(INTDIR)\duel.sbr" \
|
||||
"$(INTDIR)\gameproc.sbr" \
|
||||
"$(INTDIR)\gfx.sbr" \
|
||||
"$(INTDIR)\lobby.sbr" \
|
||||
"$(INTDIR)\util.sbr" \
|
||||
"$(INTDIR)\wizard.sbr"
|
||||
|
||||
"$(OUTDIR)\duel.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib dinput.lib dsound.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib\
|
||||
dinput.lib dsound.lib /nologo /subsystem:windows /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/duel.pdb" /debug /machine:I386 /out:"$(OUTDIR)/duel.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\duel.res" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\wizard.obj"
|
||||
|
||||
"$(OUTDIR)\duel.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "duel - Win32 Release"
|
||||
# Name "duel - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wizard.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.cpp
|
||||
DEP_CPP_DIUTI=\
|
||||
".\diutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\diutil.sbr" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.cpp
|
||||
DEP_CPP_DPUTI=\
|
||||
".\dputil.h"\
|
||||
".\duel.h"\
|
||||
".\lobby.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\dputil.sbr" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.cpp
|
||||
DEP_CPP_DSUTI=\
|
||||
".\dsutil.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\dsutil.sbr" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.cpp
|
||||
DEP_CPP_DUEL_=\
|
||||
".\diutil.h"\
|
||||
".\dputil.h"\
|
||||
".\dsutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\gfx.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\duel.sbr" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.rc
|
||||
DEP_RSC_DUEL_R=\
|
||||
".\Bfire.wav"\
|
||||
".\csession.bmp"\
|
||||
".\DUEL.BMP"\
|
||||
".\duel.ico"\
|
||||
".\Lboom.wav"\
|
||||
".\osession.bmp"\
|
||||
".\player.bmp"\
|
||||
".\Sboom.wav"\
|
||||
".\Sbounce.wav"\
|
||||
".\Sengine.wav"\
|
||||
".\SPLASH.BMP"\
|
||||
".\Sstart.wav"\
|
||||
".\Sstop.wav"\
|
||||
".\verinfo.h"\
|
||||
".\verinfo.ver"\
|
||||
|
||||
|
||||
"$(INTDIR)\duel.res" : $(SOURCE) $(DEP_RSC_DUEL_R) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.cpp
|
||||
DEP_CPP_GAMEP=\
|
||||
".\diutil.h"\
|
||||
".\dputil.h"\
|
||||
".\dsutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\gfx.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\gameproc.sbr" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.cpp
|
||||
DEP_CPP_GFX_C=\
|
||||
".\ddutil.h"\
|
||||
".\diutil.h"\
|
||||
".\duel.h"\
|
||||
".\gfx.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\gfx.sbr" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.cpp
|
||||
DEP_CPP_LOBBY=\
|
||||
".\duel.h"\
|
||||
".\lobby.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\lobby.sbr" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
DEP_CPP_UTIL_=\
|
||||
".\duel.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\util.sbr" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wizard.cpp
|
||||
DEP_CPP_WIZAR=\
|
||||
".\dputil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\wizard.obj" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\wizard.obj" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\wizard.sbr" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.cpp
|
||||
DEP_CPP_DDUTI=\
|
||||
".\ddutil.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\ddutil.sbr" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/duel.bmp
Normal file
|
After Width: | Height: | Size: 166 KiB |
536
Library/dxx8/samples/Multimedia/Demos/Duel/duel.cpp
Normal file
@@ -0,0 +1,536 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Duel.cpp
|
||||
//
|
||||
// Desc: Multi-player game
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "gameproc.h"
|
||||
#include "gfx.h"
|
||||
#include "DPUtil.h"
|
||||
#include "diutil.h"
|
||||
#include "dsutil.h"
|
||||
#include "lobby.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
// This GUID allows DirectPlay to find other instances of the same game on
|
||||
// the network. So it must be unique for every game, and the same for
|
||||
// every instance of that game. // {33925241-05F8-11d0-8063-00A0C90AE891}
|
||||
GUID g_AppGUID = { 0x33925241, 0x5f8, 0x11d0, { 0x80, 0x63, 0x0, 0xa0, 0xc9, 0xa, 0xe8, 0x91 } };
|
||||
|
||||
extern DWORD g_dwFrameCount;
|
||||
extern DWORD g_dwFrameTime;
|
||||
extern int g_nProgramState;
|
||||
extern SHIP g_OurShip;
|
||||
extern DPID g_LocalPlayerDPID;
|
||||
|
||||
static BOOL g_bReinitialize; // Used for switching display modes
|
||||
|
||||
TCHAR g_strAppName[256] = "Duel"; // The name of the sample
|
||||
HANDLE g_hDPMessageEvent = NULL; // Not used in this sample, needed for DPConnect.cpp
|
||||
TCHAR g_strLocalPlayerName[MAX_PLAYER_NAME]; // Local player name
|
||||
TCHAR g_strSessionName[MAX_SESSION_NAME]; // Default session name
|
||||
TCHAR g_strPreferredProvider[MAX_SESSION_NAME]; // Default preferred provider
|
||||
|
||||
LPDPLCONNECTION g_pDPLConnection = NULL;
|
||||
LPDIRECTPLAYLOBBY3 g_pDPLobby = NULL;
|
||||
|
||||
HWND g_hwndMain; // Main application window handle
|
||||
HKEY g_hDuelKey = NULL; // Duel registry key handle
|
||||
HINSTANCE g_hInst; // Application instance handle
|
||||
BOOL g_bShowFrameCount=TRUE; // Show FPS ?
|
||||
BOOL g_bIsActive; // Is the application active ?
|
||||
BOOL g_bHostPlayer; // Are we hosting or joining a game
|
||||
DWORD g_dwKeys; // User keyboard input
|
||||
DWORD g_dwOldKeys; // Last frame's keyboard input
|
||||
BOOL g_bFullscreen=FALSE; // Window or FullScreen mode ?
|
||||
RECT g_rcWindow; // client rectangle of main window
|
||||
BOOL g_bReliable; // sends are reliable
|
||||
BOOL g_bAsync; // asynchronous sends
|
||||
BOOL g_bAsyncSupported; // asynchronous sends supported
|
||||
BOOL g_bUseProtocol; // DirectPlay Protocol messaging
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
extern int DPConnect_StartDirectPlayConnect( HINSTANCE hInst, BOOL bBackTrack = FALSE );
|
||||
extern HRESULT DPConnect_CheckForLobbyLaunch( BOOL* pbLaunchedByLobby );
|
||||
|
||||
LRESULT CALLBACK MainWndproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
||||
HRESULT InitApplication( HINSTANCE hInst );
|
||||
HRESULT ReadRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
|
||||
HRESULT WriteRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue );
|
||||
VOID CleanupApplication();
|
||||
BOOL WasLaunchedByLobby();
|
||||
BOOL FinishLobbyLaunch();
|
||||
VOID DoHelp();
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int )
|
||||
{
|
||||
MSG msg;
|
||||
BOOL bLaunchedByLobby;
|
||||
HRESULT hr;
|
||||
|
||||
g_hInst = hInstance;
|
||||
|
||||
// Read information from registry
|
||||
RegCreateKeyEx( HKEY_CURRENT_USER, DUEL_KEY, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
|
||||
&g_hDuelKey, NULL );
|
||||
|
||||
ReadRegKey( g_hDuelKey, "Player Name",
|
||||
g_strLocalPlayerName, MAX_PLAYER_NAME, "" );
|
||||
ReadRegKey( g_hDuelKey, "Session Name",
|
||||
g_strSessionName, MAX_SESSION_NAME, "" );
|
||||
ReadRegKey( g_hDuelKey, "Preferred Provider",
|
||||
g_strPreferredProvider, MAX_SESSION_NAME, "" );
|
||||
|
||||
CoInitialize( NULL );
|
||||
|
||||
if( FAILED( InitApplication( hInstance ) ) )
|
||||
return 0;
|
||||
|
||||
// See if we were launched from a lobby server
|
||||
hr = DPConnect_CheckForLobbyLaunch( &bLaunchedByLobby );
|
||||
if( FAILED(hr) )
|
||||
return 1;
|
||||
|
||||
if( bLaunchedByLobby )
|
||||
{
|
||||
// Start game
|
||||
PostMessage( g_hwndMain, UM_LAUNCH, 0, 0 );
|
||||
g_bIsActive = TRUE;
|
||||
}
|
||||
|
||||
g_dwFrameTime = timeGetTime();
|
||||
|
||||
while( TRUE )
|
||||
{
|
||||
if( g_bIsActive )
|
||||
{
|
||||
// Any windows messages ? (returns immediately)
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
if( !GetMessage( &msg, NULL, 0, 0 ) )
|
||||
break;
|
||||
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Poll our receive queue. Polling is used in the sample only for simplicity.
|
||||
// Receiving messages using an event is the recommended way.
|
||||
if( g_nProgramState != PS_SPLASH )
|
||||
{
|
||||
ReceiveMessages();
|
||||
LobbyMessageReceive(LMR_PROPERTIES);
|
||||
}
|
||||
|
||||
// update screen
|
||||
if( !UpdateFrame() )
|
||||
ExitGame(); // posts QUIT msg
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Any windows messages ? (blocks until a message arrives)
|
||||
if( !GetMessage( &msg, NULL, 0, 0 ) )
|
||||
break;
|
||||
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
// Write information to the registry
|
||||
WriteRegKey( g_hDuelKey, "Player Name", g_strLocalPlayerName );
|
||||
WriteRegKey( g_hDuelKey, "Session Name", g_strSessionName );
|
||||
WriteRegKey( g_hDuelKey, "Preferred Provider", g_strPreferredProvider );
|
||||
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MainWndproc()
|
||||
// Desc: Callback for all Windows messages
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK MainWndproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch( msg )
|
||||
{
|
||||
case WM_SIZE:
|
||||
case WM_MOVE:
|
||||
// Get the client rectangle
|
||||
if( g_bFullscreen )
|
||||
{
|
||||
SetRect( &g_rcWindow, 0, 0, GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetClientRect( hWnd, &g_rcWindow );
|
||||
ClientToScreen( hWnd, (POINT*)&g_rcWindow );
|
||||
ClientToScreen( hWnd, (POINT*)&g_rcWindow+1 );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ACTIVATE:
|
||||
// Ignore this message during reinitializing graphics
|
||||
if( g_bReinitialize )
|
||||
return 0;
|
||||
|
||||
// When we are deactivated, although we don't update our screen, we
|
||||
// still need to to empty our receive queue periodically as
|
||||
// messages will pile up otherwise. Polling the receive queue
|
||||
// continuously even when we are deactivated causes our app to
|
||||
// consume all the CPU time. To avoid hogging the CPU, we block on
|
||||
// GetMessage() WIN API and setup a timer to wake ourselves up at
|
||||
// regular intervals to process our messages.
|
||||
|
||||
if( LOWORD(wParam) == WA_INACTIVE )
|
||||
{
|
||||
// Aeactivated
|
||||
g_bIsActive = FALSE;
|
||||
if( PS_ACTIVE == g_nProgramState )
|
||||
SetTimer( hWnd, RECEIVE_TIMER_ID, RECEIVE_TIMEOUT, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Activated
|
||||
g_bIsActive = TRUE;
|
||||
if( PS_ACTIVE == g_nProgramState )
|
||||
KillTimer( hWnd, RECEIVE_TIMER_ID );
|
||||
}
|
||||
|
||||
// set game palette, if activated in game mode
|
||||
if( g_bIsActive && (g_nProgramState != PS_SPLASH) )
|
||||
SetGamePalette();
|
||||
|
||||
DIUtil_ReacquireInputDevices();
|
||||
|
||||
return 0;
|
||||
|
||||
case WM_CREATE:
|
||||
break;
|
||||
|
||||
case WM_SYSKEYUP:
|
||||
switch( wParam )
|
||||
{
|
||||
// Handle ALT+ENTER (fullscreen/window mode)
|
||||
case VK_RETURN:
|
||||
// Mode switch is allowed only during the game
|
||||
if( g_nProgramState == PS_ACTIVE )
|
||||
{
|
||||
g_bReinitialize = TRUE;
|
||||
ReleaseLocalData(); //only sound buffers have to be rels'd anyway.
|
||||
CleanupGameSounds();
|
||||
DIUtil_CleanupInput();
|
||||
CleanupGraphics();
|
||||
DestroyWindow( g_hwndMain );
|
||||
g_bFullscreen = !g_bFullscreen;
|
||||
InitGraphics();
|
||||
DIUtil_InitInput( g_hwndMain );
|
||||
InitializeGameSounds();
|
||||
InitLocalSoundData();
|
||||
g_bReinitialize = FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch( wParam )
|
||||
{
|
||||
case 'a':
|
||||
case 'A':
|
||||
// Toggle Async sends on/off
|
||||
if( g_bAsyncSupported )
|
||||
{
|
||||
g_bAsync = !g_bAsync;
|
||||
UpdateTitle(); // caption bar status
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'R':
|
||||
// Toggle reliable sends
|
||||
g_bReliable = !g_bReliable;
|
||||
UpdateTitle();
|
||||
break;
|
||||
|
||||
case VK_F1:
|
||||
// Display help
|
||||
DoHelp();
|
||||
break;
|
||||
|
||||
case VK_F5:
|
||||
// Toggle frame rate display
|
||||
g_bShowFrameCount = !g_bShowFrameCount;
|
||||
if( g_bShowFrameCount )
|
||||
{
|
||||
g_dwFrameCount = 0;
|
||||
g_dwFrameTime = timeGetTime();
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_RETURN:
|
||||
// Launch game setup wizard
|
||||
if( (g_nProgramState == PS_SPLASH) && !g_bFullscreen )
|
||||
{
|
||||
int nExitCode;
|
||||
nExitCode = DPConnect_StartDirectPlayConnect( g_hInst, FALSE );
|
||||
|
||||
// Figure out what happened, and post a reflecting message
|
||||
if( nExitCode == EXITCODE_FORWARD )
|
||||
PostMessage(g_hwndMain, UM_LAUNCH, 0, 0);
|
||||
|
||||
if( nExitCode == EXITCODE_QUIT )
|
||||
PostMessage(g_hwndMain, UM_ABORT, 0, 0);
|
||||
|
||||
if( nExitCode == EXITCODE_LOBBYCONNECT )
|
||||
PostMessage( g_hwndMain, UM_LAUNCH, 0, 0 );
|
||||
|
||||
if( nExitCode == EXITCODE_ERROR )
|
||||
{
|
||||
MessageBox( g_hwndMain, TEXT("Mutliplayer connect failed. "
|
||||
"The sample will now quit."),
|
||||
TEXT("DirectPlay Sample"), MB_OK | MB_ICONERROR );
|
||||
PostMessage(g_hwndMain, UM_ABORT, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_ESCAPE:
|
||||
case VK_F12:
|
||||
// Exit the game
|
||||
ExitGame();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ERASEBKGND:
|
||||
return 1;
|
||||
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint( hWnd, &ps );
|
||||
if( g_nProgramState == PS_SPLASH )
|
||||
{
|
||||
// Display the splash screen
|
||||
BltSplashScreen( NULL );
|
||||
}
|
||||
|
||||
EndPaint( hWnd, &ps );
|
||||
return 1;
|
||||
|
||||
case UM_LAUNCH:
|
||||
case UM_ABORT:
|
||||
// if we were launched by the lobby and not (failed to finish a lobby launch)
|
||||
// where wParam is bLobbyLaunched
|
||||
if( msg == UM_LAUNCH )
|
||||
{
|
||||
// Init lobby msg support for reporting score
|
||||
// Note that we don't release the lobby object
|
||||
LobbyMessageInit();
|
||||
|
||||
// Start the game in rest mode
|
||||
g_nProgramState = PS_REST;
|
||||
LaunchGame();
|
||||
return 1;
|
||||
}
|
||||
// Else aborting
|
||||
ExitGame();
|
||||
return 1;
|
||||
|
||||
case WM_TIMER:
|
||||
ReceiveMessages();
|
||||
LobbyMessageReceive( LMR_PROPERTIES );
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
// If g_bReinitialize is TRUE don't quit, we are just switching
|
||||
// display modes
|
||||
if( !g_bReinitialize )
|
||||
{
|
||||
CleanupApplication();
|
||||
PostQuitMessage( 0 );
|
||||
}
|
||||
return 0;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc( hWnd, msg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitApplication()
|
||||
// Desc: Do that initialization stuff...
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT InitApplication( HINSTANCE hInst )
|
||||
{
|
||||
WNDCLASS wndClass = { CS_DBLCLKS, MainWndproc, 0, 0, hInst,
|
||||
LoadIcon( hInst, MAKEINTRESOURCE(IDI_MAIN)),
|
||||
LoadCursor(NULL, IDC_ARROW),
|
||||
(HBRUSH)GetStockObject(BLACK_BRUSH),
|
||||
NULL, TEXT("DuelClass") };
|
||||
RegisterClass( &wndClass );
|
||||
|
||||
// Initialize all components
|
||||
if( FAILED( InitGraphics() ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( DIUtil_InitInput( g_hwndMain ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( InitializeGameSounds() ) )
|
||||
{
|
||||
// Can play game without sound. Do not exit
|
||||
}
|
||||
|
||||
// Start in splash mode
|
||||
g_nProgramState = PS_SPLASH;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CleanupApplication()
|
||||
// Desc: Calls clean up on all components
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CleanupApplication()
|
||||
{
|
||||
CleanupComm();
|
||||
CleanupGameSounds();
|
||||
CleanupGraphics();
|
||||
DIUtil_CleanupInput();
|
||||
DPLobbyRelease(); // in case we were doing lobby messages
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ShowError()
|
||||
// Desc: Displays error to the user
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID ShowError( int iStrID )
|
||||
{
|
||||
TCHAR strMsg[MAX_ERRORMSG];
|
||||
LoadString( g_hInst, iStrID, strMsg, MAX_ERRORMSG );
|
||||
MessageBox( g_hwndMain, strMsg, TEXT("Duel Message"), MB_OK );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: UpdateTitle()
|
||||
// Desc: Updates the window title based on application status
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID UpdateTitle()
|
||||
{
|
||||
// Build the window title
|
||||
TCHAR strTitle[MAX_WINDOWTITLE] = TEXT("Duel");
|
||||
|
||||
// State options in window title
|
||||
if( g_bHostPlayer | g_bUseProtocol | g_bReliable | g_bAsync )
|
||||
{
|
||||
strcat( strTitle, " - |" );
|
||||
if( g_bHostPlayer )
|
||||
_tcscat( strTitle, TEXT(" Host |") );
|
||||
if( g_bUseProtocol )
|
||||
_tcscat( strTitle, TEXT(" Protocol |") );
|
||||
if( g_bReliable )
|
||||
_tcscat( strTitle, TEXT(" Reliable |") );
|
||||
if( g_bAsync )
|
||||
_tcscat( strTitle, TEXT(" Async |") );
|
||||
}
|
||||
|
||||
// Change window title
|
||||
SetWindowText( g_hwndMain, strTitle );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DoHelp()
|
||||
// Desc: Display a Help summary in a message box.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DoHelp()
|
||||
{
|
||||
TCHAR strHelpMsg[MAX_HELPMSG];
|
||||
LoadString( g_hInst, IDS_DUEL_HELP, strHelpMsg, MAX_HELPMSG );
|
||||
MessageBox( g_hwndMain, strHelpMsg, TEXT("DUEL"), MB_OK );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ReadRegKey()
|
||||
// Desc: Read a registry key
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT ReadRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue,
|
||||
DWORD dwLength, TCHAR* strDefault )
|
||||
{
|
||||
DWORD dwType;
|
||||
LONG bResult;
|
||||
|
||||
bResult = RegQueryValueEx( hKey, strName, 0, &dwType,
|
||||
(LPBYTE) strValue, &dwLength );
|
||||
if ( bResult != ERROR_SUCCESS )
|
||||
strcpy( strValue, strDefault );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WriteRegKey()
|
||||
// Desc: Writes a registry key
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT WriteRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue )
|
||||
{
|
||||
LONG bResult;
|
||||
|
||||
bResult = RegSetValueEx( hKey, strName, 0, REG_SZ,
|
||||
(LPBYTE) strValue, strlen(strValue) + 1 );
|
||||
if ( bResult != ERROR_SUCCESS )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
237
Library/dxx8/samples/Multimedia/Demos/Duel/duel.dsp
Normal file
@@ -0,0 +1,237 @@
|
||||
# Microsoft Developer Studio Project File - Name="duel" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=duel - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duel.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duel.mak" CFG="duel - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "duel - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "duel - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 uuid.lib comctl32.lib dplayx.lib ddraw.lib dinput.lib dsound.lib dxguid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x1f4000,0x1f4000
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 uuid.lib comctl32.lib dplayx.lib ddraw.lib dinput.lib dsound.lib dxguid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /stack:0x1f4000,0x1f4000
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "duel - Win32 Release"
|
||||
# Name "duel - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dpconnect.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\csession.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DUEL.BMP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\osession.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\player.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SPLASH.BMP
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Bfire.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Lboom.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sboom.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sbounce.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sengine.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sstart.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sstop.wav
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
29
Library/dxx8/samples/Multimedia/Demos/Duel/duel.dsw
Normal file
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "duel"=.\duel.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
97
Library/dxx8/samples/Multimedia/Demos/Duel/duel.h
Normal file
@@ -0,0 +1,97 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Duel.h
|
||||
//
|
||||
// Desc: Duel include file
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DUEL_INCLUDED
|
||||
#define DUEL_INCLUDED
|
||||
|
||||
// bcc32 does not support nameless unions in C mode
|
||||
#if defined(__BORLANDC__) && !defined(__cplusplus)
|
||||
#define NONAMELESSUNION
|
||||
#endif
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <mmsystem.h>
|
||||
#include "resource.h"
|
||||
#include <wtypes.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Application constants
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Dialog exit codes
|
||||
#define EXITCODE_FORWARD 1 // Dialog success, so go forward
|
||||
#define EXITCODE_BACKUP 2 // Dialog canceled, show previous dialog
|
||||
#define EXITCODE_QUIT 3 // Dialog quit, close app
|
||||
#define EXITCODE_ERROR 4 // Dialog error, terminate app
|
||||
#define EXITCODE_LOBBYCONNECT 5 // Dialog connected from lobby, connect success
|
||||
|
||||
// User messages
|
||||
#define UM_LAUNCH WM_USER
|
||||
#define UM_ABORT WM_USER+1
|
||||
#define UM_RESTARTTIMER WM_USER+2
|
||||
|
||||
// program states
|
||||
enum{ PS_SPLASH, PS_ACTIVE, PS_REST };
|
||||
|
||||
#define MAX_SCREEN_X 639
|
||||
#define MAX_SCREEN_Y 479
|
||||
#define MAX_PLAYER_NAME 14
|
||||
#define MAX_SESSION_NAME 256
|
||||
#define MAX_SPNAME 50
|
||||
#define MAX_CLASSNAME 50
|
||||
#define MAX_WINDOWTITLE 50
|
||||
#define MAX_ERRORMSG 256
|
||||
#define MAX_FONTNAME 50
|
||||
#define MAX_HELPMSG 512
|
||||
|
||||
#define RECEIVE_TIMER_ID 1
|
||||
#define RECEIVE_TIMEOUT 1000 // in milliseconds
|
||||
|
||||
#define ENUM_TIMER_ID 2
|
||||
#define ENUM_TIMEOUT 2000 // in milliseconds
|
||||
|
||||
// Default window size
|
||||
#define MAX_DEFWIN_X 640
|
||||
#define MAX_DEFWIN_Y 480
|
||||
|
||||
|
||||
// Tree view image info
|
||||
#define CX_BITMAP 25
|
||||
#define CY_BITMAP 25
|
||||
#define NUM_BITMAPS 2
|
||||
|
||||
// registry info
|
||||
#define DUEL_KEY (TEXT("Software\\Microsoft\\Duel"))
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID ShowError( int err );
|
||||
VOID UpdateTitle();
|
||||
|
||||
// Functions defined in util.c
|
||||
int randInt( int low, int high );
|
||||
double randDouble( double low, double high );
|
||||
#define TRACE dtrace
|
||||
void dtrace( TCHAR* strFormat, ...);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/duel.ico
Normal file
|
After Width: | Height: | Size: 766 B |
690
Library/dxx8/samples/Multimedia/Demos/Duel/duel.mak
Normal file
@@ -0,0 +1,690 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=duel - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to duel - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "duel - Win32 Release" && "$(CFG)" != "duel - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duel.mak" CFG="duel - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "duel - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "duel - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "duel - Win32 Debug"
|
||||
MTL=mktyplib.exe
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\duel.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.res"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\wizard.obj"
|
||||
-@erase "$(OUTDIR)\duel.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)/duel.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/duel.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/duel.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib dinput.lib dsound.lib /nologo /subsystem:windows /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib\
|
||||
dinput.lib dsound.lib /nologo /subsystem:windows /incremental:no\
|
||||
/pdb:"$(OUTDIR)/duel.pdb" /machine:I386 /out:"$(OUTDIR)/duel.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\duel.res" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\wizard.obj"
|
||||
|
||||
"$(OUTDIR)\duel.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\duel.exe" "$(OUTDIR)\duel.bsc"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\ddutil.sbr"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.sbr"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dputil.sbr"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.sbr"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.res"
|
||||
-@erase "$(INTDIR)\duel.sbr"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gameproc.sbr"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\gfx.sbr"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\lobby.sbr"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\util.sbr"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(INTDIR)\wizard.obj"
|
||||
-@erase "$(INTDIR)\wizard.sbr"
|
||||
-@erase "$(OUTDIR)\duel.bsc"
|
||||
-@erase "$(OUTDIR)\duel.exe"
|
||||
-@erase "$(OUTDIR)\duel.ilk"
|
||||
-@erase "$(OUTDIR)\duel.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
|
||||
/FR"$(INTDIR)/" /Fp"$(INTDIR)/duel.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\Debug/
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/duel.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/duel.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\ddutil.sbr" \
|
||||
"$(INTDIR)\diutil.sbr" \
|
||||
"$(INTDIR)\dputil.sbr" \
|
||||
"$(INTDIR)\dsutil.sbr" \
|
||||
"$(INTDIR)\duel.sbr" \
|
||||
"$(INTDIR)\gameproc.sbr" \
|
||||
"$(INTDIR)\gfx.sbr" \
|
||||
"$(INTDIR)\lobby.sbr" \
|
||||
"$(INTDIR)\util.sbr" \
|
||||
"$(INTDIR)\wizard.sbr"
|
||||
|
||||
"$(OUTDIR)\duel.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib dinput.lib dsound.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib\
|
||||
dinput.lib dsound.lib /nologo /subsystem:windows /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/duel.pdb" /debug /machine:I386 /out:"$(OUTDIR)/duel.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\duel.res" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\wizard.obj"
|
||||
|
||||
"$(OUTDIR)\duel.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "duel - Win32 Release"
|
||||
# Name "duel - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wizard.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.cpp
|
||||
DEP_CPP_DIUTI=\
|
||||
".\diutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\diutil.sbr" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.cpp
|
||||
DEP_CPP_DPUTI=\
|
||||
".\dputil.h"\
|
||||
".\duel.h"\
|
||||
".\lobby.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\dputil.sbr" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.cpp
|
||||
DEP_CPP_DSUTI=\
|
||||
".\dsutil.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\dsutil.sbr" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.cpp
|
||||
DEP_CPP_DUEL_=\
|
||||
".\diutil.h"\
|
||||
".\dputil.h"\
|
||||
".\dsutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\gfx.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\duel.sbr" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.rc
|
||||
DEP_RSC_DUEL_R=\
|
||||
".\Bfire.wav"\
|
||||
".\csession.bmp"\
|
||||
".\DUEL.BMP"\
|
||||
".\duel.ico"\
|
||||
".\Lboom.wav"\
|
||||
".\osession.bmp"\
|
||||
".\player.bmp"\
|
||||
".\Sboom.wav"\
|
||||
".\Sbounce.wav"\
|
||||
".\Sengine.wav"\
|
||||
".\SPLASH.BMP"\
|
||||
".\Sstart.wav"\
|
||||
".\Sstop.wav"\
|
||||
".\verinfo.h"\
|
||||
".\verinfo.ver"\
|
||||
|
||||
|
||||
"$(INTDIR)\duel.res" : $(SOURCE) $(DEP_RSC_DUEL_R) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.cpp
|
||||
DEP_CPP_GAMEP=\
|
||||
".\diutil.h"\
|
||||
".\dputil.h"\
|
||||
".\dsutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\gfx.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\gameproc.sbr" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.cpp
|
||||
DEP_CPP_GFX_C=\
|
||||
".\ddutil.h"\
|
||||
".\diutil.h"\
|
||||
".\duel.h"\
|
||||
".\gfx.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\gfx.sbr" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.cpp
|
||||
DEP_CPP_LOBBY=\
|
||||
".\duel.h"\
|
||||
".\lobby.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\lobby.sbr" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
DEP_CPP_UTIL_=\
|
||||
".\duel.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\util.sbr" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wizard.cpp
|
||||
DEP_CPP_WIZAR=\
|
||||
".\dputil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\wizard.obj" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\wizard.obj" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\wizard.sbr" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.cpp
|
||||
DEP_CPP_DDUTI=\
|
||||
".\ddutil.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\ddutil.sbr" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/duel.mdp
Normal file
272
Library/dxx8/samples/Multimedia/Demos/Duel/duel.rc
Normal file
@@ -0,0 +1,272 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
" \0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_CONNECT_STATUS DIALOG DISCARDABLE 120, 110, 162, 52
|
||||
STYLE DS_MODALFRAME | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||
CAPTION "Duel Connection Status"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
CTEXT "Finding game...",IDC_DUEL_STATUSTEXT,7,7,141,13
|
||||
DEFPUSHBUTTON "&Cancel",IDC_LOBBYCONNECTCANCEL,52,29,51,14
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_GAMES DIALOG DISCARDABLE 0, 0, 282, 140
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Multiplayer Games"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Select Game To Join:",-1,7,15,69,8
|
||||
LISTBOX IDC_GAMES_LIST,7,24,268,91,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Join",IDC_JOIN,7,119,50,14
|
||||
DEFPUSHBUTTON "Create",IDC_CREATE,61,119,50,14
|
||||
PUSHBUTTON "Cancel",IDC_BACK,225,119,50,14
|
||||
CONTROL "Start Search",IDC_SEARCH_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
BS_PUSHLIKE | WS_TABSTOP,220,7,55,14
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CONNECT DIALOG DISCARDABLE 0, 0, 282, 151
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Multiplayer Connect"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Player Name:",IDC_STATIC,7,10,43,8
|
||||
EDITTEXT IDC_PLAYER_NAME_EDIT,7,22,268,14,ES_AUTOHSCROLL
|
||||
LTEXT "Connection Type:",IDC_STATIC,7,41,57,8
|
||||
LISTBOX IDC_CONNECTION_LIST,7,53,268,72,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,171,130,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,225,130,50,14
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CREATE DIALOG DISCARDABLE 0, 0, 186, 77
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Create Game"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
EDITTEXT IDC_EDIT_SESSION_NAME,7,19,172,14,ES_AUTOHSCROLL
|
||||
CONTROL "Use DirectPlay Protocol",IDC_CHECK_DPLAY_PROTOCOL,
|
||||
"Button",BS_AUTOCHECKBOX | WS_TABSTOP,49,40,91,10
|
||||
DEFPUSHBUTTON "OK",IDOK,7,56,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,129,56,50,14
|
||||
LTEXT "Game Name:",IDC_STATIC,7,7,42,8
|
||||
END
|
||||
|
||||
IDD_LOBBY_WAIT_STATUS DIALOG DISCARDABLE 120, 110, 162, 52
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||
CAPTION "Lobby Connection Status"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "&Cancel",IDC_LOBBYCONNECTCANCEL,55,31,51,14
|
||||
CTEXT "Finding Game...",IDC_WAIT_TEXT,7,14,141,8
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
SPLASH BITMAP MOVEABLE PURE "SPLASH.BMP"
|
||||
DUEL8 BITMAP MOVEABLE PURE "DUEL.BMP"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN ICON DISCARDABLE "duel.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WAVE
|
||||
//
|
||||
|
||||
SBOUNCE WAVE DISCARDABLE "Sbounce.wav"
|
||||
LBOOM WAVE DISCARDABLE "Lboom.wav"
|
||||
SBOOM WAVE DISCARDABLE "Sboom.wav"
|
||||
BFIRE WAVE DISCARDABLE "Bfire.wav"
|
||||
SENGINE WAVE DISCARDABLE "Sengine.wav"
|
||||
SSTART WAVE DISCARDABLE "Sstart.wav"
|
||||
SSTOP WAVE DISCARDABLE "Sstop.wav"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_CONNECT_STATUS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 148
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 24
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CREATE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
VERTGUIDE, 94
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 70
|
||||
END
|
||||
|
||||
IDD_LOBBY_WAIT_STATUS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 148
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 45
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WIZARD_FONTNAME "Times"
|
||||
IDS_WIZARD_TITLE "Duel Setup"
|
||||
IDS_WIZARD_TITLE_SP "Communications Channel (Step 2 of 3)"
|
||||
IDS_WIZARD_TITLE_GS "Game Setup (Step 1 of 3)"
|
||||
IDS_WIZARD_TITLE_JS "Join Session (Step 3 of 3)"
|
||||
IDS_WIZARD_TITLE_HS "Host Session (Step 3 of 3)"
|
||||
IDS_DUEL_HELP "Spacebar\t\t- Fire\nRight Arrow\t- Rotate right\nLeft Arrow\t- Rotate left\nUp Arrow\t\t- Forward\nDown Arrow\t- Backward\nNumPad 5\t- Stop\nA\t\t- Asynchronous Messaging\nR\t\t- Reliable Messaging\nF1\t\t- Help\nF5\t\t- Frames/sec\nESC or F12\t- Quit\n"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DDRAW_ERROR_DDC "DirectDraw create failed"
|
||||
IDS_DDRAW_ERROR_SCL "SetCooperativeLevel failed"
|
||||
IDS_DDRAW_ERROR_SDM "SetDisplayMode failed"
|
||||
IDS_DDRAW_ERROR_CREATESURFACE "IDirectDraw::CreateSurface() failed"
|
||||
IDS_DDRAW_ERROR_GAS "Backbuffer couldn't be obtained"
|
||||
IDS_DDRAW_ERROR_CC "CreateClipper failed"
|
||||
IDS_DDRAW_ERROR_SH "Clipper SetHwnd failed"
|
||||
IDS_DDRAW_ERROR_SC "Clipper object couldn't be attached to the front buffer"
|
||||
IDS_DDRAW_ERROR_RS "Surfaces couldn't be restored"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DINPUT_ERROR_DIC "DirectInputCreate failed"
|
||||
IDS_DINPUT_ERROR_ED "Enum keyboard devices failed"
|
||||
IDS_DINPUT_ERROR_CD "Create keyboard device failed"
|
||||
IDS_DINPUT_ERROR_SP "Set non-exclusive mode failed"
|
||||
IDS_DINPUT_ERROR_A "Keyboard acquire failed"
|
||||
IDS_DINPUT_ERROR_DF "Set keyboard data format failed"
|
||||
IDS_DDUTIL_ERROR_LI "LoadImage failed. Handle is NULL."
|
||||
IDS_DDUTIL_ERROR_DDCB "DDUtil_CopyBitmap failed"
|
||||
IDS_DDUTIL_ERROR_CCDC "CreateCompatibleDC failed"
|
||||
IDS_DSOUND_LOADWAVES "Could not load WAVE resource."
|
||||
IDS_DSOUND_DUPBUF "Could not duplicate a sound buffer for new ship"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DPLAY_ERROR_CP "Player create failed"
|
||||
IDS_DPLAY_ERROR_JS "Session join failed"
|
||||
IDS_DPLAY_ERROR_CS "Session create failed"
|
||||
IDS_DPLAY_ERROR_IDC "DirectPlay object create failed"
|
||||
IDS_DPLAY_ERROR_SL "You have been disconnected from the session"
|
||||
IDS_DPLAY_ERROR_GPLD "Get player local data failed"
|
||||
IDS_DPLAY_ERROR_SPLD "Set player local data failed"
|
||||
IDS_DPLAY_ERROR_GPRD "Get player remote data failed"
|
||||
IDS_DPLAY_ERROR_SPRD "Set player remote data failed"
|
||||
IDS_DPLAY_ERROR_GSD "Get session description failed"
|
||||
IDS_DPLAY_ERROR_EP "Enumerate players failed"
|
||||
IDS_DPLAY_ERROR_ES "Enumerate sessions failed"
|
||||
IDS_DPLAY_ERROR_C "DirectPlay Close failed"
|
||||
IDS_DPLAY_ERROR_R "DirectPlay Release failed"
|
||||
IDS_DPLAY_ERROR_DP "Destroy player failed"
|
||||
IDS_DPLAY_ERROR_CLSID "This application requires DirectPlay 6 or later"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DPLOBBY_ERROR_R "DirectPlayLobby Release failed"
|
||||
IDS_DPLOBBY_ERROR_GCS "DirectPlayLobby GetConnectionSettings failed"
|
||||
IDS_DPLOBBY_ERROR_SCS "DirectPlayLobby SetConnectionSettings failed"
|
||||
IDS_DPLOBBY_ERROR_C "DirectPlayLobby Create failed"
|
||||
IDS_DPLOBBY_ERROR_CONNECT "DirectPlayLobby Connect failed"
|
||||
IDS_WIZARD_ERROR_GSG "Session guid couldn't be obtained from the parent item"
|
||||
IDS_WIN_ERROR "Windows API failure"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
1899
Library/dxx8/samples/Multimedia/Demos/Duel/gameproc.cpp
Normal file
221
Library/dxx8/samples/Multimedia/Demos/Duel/gameproc.h
Normal file
@@ -0,0 +1,221 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: GameProc.h
|
||||
//
|
||||
// Desc: Game processing routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IDIRECTPLAY2_OR_GREATER
|
||||
#include <ddraw.h>
|
||||
#include <dplay.h>
|
||||
#include <dsound.h>
|
||||
|
||||
// align on single byte boundaries
|
||||
// this is a stop-gap measure until the structures can be re-arranged.
|
||||
#pragma pack(1)
|
||||
|
||||
#define MAX_SHIP_X (MAX_SCREEN_X - 32)
|
||||
#define MAX_SHIP_Y (MAX_SCREEN_Y - 32)
|
||||
#define MAX_SHIP_FRAME 40
|
||||
#define MAX_BULLET_X (MAX_SCREEN_X - 3)
|
||||
#define MAX_BULLET_Y (MAX_SCREEN_Y - 3)
|
||||
#define MAX_BULLET_FRAME 400
|
||||
|
||||
#define NUM_SHIP_TYPES 4
|
||||
|
||||
#define DEF_SHOW_DELAY (2000)
|
||||
#define MAX_BUFFER_SIZE 256
|
||||
|
||||
#define UPDATE_INTERVAL 40 // interval between position updates in milliseconds (25 FPS)
|
||||
#define SYNC_INTERVAL 1000 // synchronize once every second
|
||||
#define HIDE_TIMEOUT 5000 // time for which a ship is disabled after a hit
|
||||
|
||||
// Keyboard commands
|
||||
#define KEY_STOP 0x00000001l
|
||||
#define KEY_DOWN 0x00000002l
|
||||
#define KEY_LEFT 0x00000004l
|
||||
#define KEY_RIGHT 0x00000008l
|
||||
#define KEY_UP 0x00000010l
|
||||
#define KEY_FIRE 0x00000020l
|
||||
#define KEY_ENGINEOFF 0x00000040l
|
||||
|
||||
// Offsets for the bullet bitmap
|
||||
#define BULLET_X 304
|
||||
#define BULLET_Y 0
|
||||
|
||||
struct FRAG
|
||||
{
|
||||
double dPosX;
|
||||
double dPosY;
|
||||
LPDIRECTDRAWSURFACE pdds;
|
||||
RECT src;
|
||||
double dVelX;
|
||||
double dVelY;
|
||||
BOOL valid;
|
||||
};
|
||||
|
||||
struct SHIP
|
||||
{
|
||||
double dPosX, dPosY; // ship x and y position
|
||||
double dBulletPosX, dBulletPosY; // bullet x and y position
|
||||
DWORD dwBulletFrame; // bullet frame
|
||||
char cFrame; // current ship frame
|
||||
BYTE byType; // ship type
|
||||
BOOL bEnable; // is this ship active?
|
||||
BOOL bBulletEnable; // Is there an active bullet?
|
||||
|
||||
double dVelX, dVelY; // ship x and y velocity (pixels/millisecond)
|
||||
double dBulletVelX, dBulletVelY; // bullet x and y velocity (pixels/millisecond)
|
||||
DWORD dwScore; // current score
|
||||
DWORD dwLastTick; // most recent time stamp
|
||||
BOOL bIgnore; // flag used to synchronize ship explosions
|
||||
int iCountDown; // enable time-out
|
||||
DWORD dwFrameCount; // number of frames since beginning of time
|
||||
|
||||
// DSound members
|
||||
DWORD dwKeys; // the keyboard state
|
||||
BOOL bEngineRunning; // These BOOLs keep track of the ship's
|
||||
BOOL bMoving; // last condition so we can play sounds
|
||||
BOOL bBounced; // when they change
|
||||
BOOL bBlockHit;
|
||||
BOOL bDeath;
|
||||
BOOL bFiring;
|
||||
};
|
||||
|
||||
struct BLOCKS
|
||||
{
|
||||
BYTE bits[30][5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// communication packet structures
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MSG_HOST 0x11 // message containing field layout, sent by host
|
||||
#define MSG_BLOCKHIT 0x22 // block hit message
|
||||
#define MSG_SHIPHIT 0x33 // ship hit message
|
||||
#define MSG_ADDBLOCK 0x44 // add block message
|
||||
#define MSG_CONTROL 0x55 // game keys message
|
||||
#define MSG_SYNC 0x66 // synchronization message containing the rendezvous location
|
||||
|
||||
struct GENERICMSG
|
||||
{
|
||||
BYTE byType;
|
||||
};
|
||||
|
||||
struct OLDHOSTMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BLOCKS Blocks;
|
||||
};
|
||||
|
||||
struct HOSTMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BLOCKS Blocks;
|
||||
int usedShipTypes[NUM_SHIP_TYPES];
|
||||
};
|
||||
|
||||
struct BLOCKHITMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byRow;
|
||||
BYTE byCol;
|
||||
BYTE byMask;
|
||||
};
|
||||
|
||||
struct SHIPHITMSG
|
||||
{
|
||||
BYTE byType;
|
||||
DPID Id;
|
||||
};
|
||||
|
||||
struct ADDBLOCKMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byX;
|
||||
BYTE byY;
|
||||
};
|
||||
|
||||
struct CONTROLMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byState;
|
||||
};
|
||||
|
||||
struct SYNCMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byShipType; // this is needed only when sends are unreliable
|
||||
char cFrame;
|
||||
double dPosX;
|
||||
double dPosY;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID LaunchGame();
|
||||
VOID ExitGame();
|
||||
HRESULT InitOurShip();
|
||||
|
||||
HRESULT InitLocalSoundData();
|
||||
BOOL WINAPI SetPlayerLocalSoundDataCB( DPID dpId, DWORD dwPlayerType,
|
||||
LPCDPNAME pName, DWORD dwFlags,
|
||||
VOID* pContext );
|
||||
|
||||
VOID ReleaseLocalData();
|
||||
VOID ReleasePlayerLocalSoundData( SHIP* pShip );
|
||||
BOOL WINAPI ReleasePlayerLocalDataCB( DPID dpId, DWORD dwPlayerType,
|
||||
LPCDPNAME pName, DWORD dwFlags,
|
||||
VOID* pContext );
|
||||
|
||||
VOID UpdateState( SHIP* pShip, DWORD dwControls );
|
||||
VOID SendSync( SHIP* pShip );
|
||||
VOID UpdateDisplayStatus( SHIP* pShip );
|
||||
VOID UpdatePosition( DPID dpId, SHIP* ship );
|
||||
BOOL IsHit( int x, int y );
|
||||
VOID InitField();
|
||||
BOOL setBlock( int x, int y );
|
||||
VOID AddFrag( SHIP* pShip, int offX, int offY );
|
||||
VOID UpdateFragment( int i );
|
||||
VOID DestroyShip( SHIP* pShip );
|
||||
VOID DestroyGame();
|
||||
BOOL UpdateFrame();
|
||||
|
||||
VOID ProcessSoundFlags( SHIP* pShip );
|
||||
BOOL WINAPI RenderPlayerCB( DPID dpId, DWORD dwPlayerType, LPCDPNAME pName,
|
||||
DWORD dwFlags, VOID* pContext );
|
||||
BOOL DrawScreen();
|
||||
BOOL DrawScore();
|
||||
VOID DrawShip( SHIP* pShip );
|
||||
VOID DrawBlock( int x, int y );
|
||||
VOID DrawBullet( SHIP* pShip );
|
||||
VOID DrawFragments();
|
||||
VOID DisplayFrameRate();
|
||||
|
||||
VOID GetConnection();
|
||||
HRESULT ReceiveMessages();
|
||||
VOID DoSystemMessage( DPMSG_GENERIC* pMsg, DWORD dwMsgSize, DPID idFrom,
|
||||
DPID idTo );
|
||||
VOID DoApplicationMessage( GENERICMSG* pMsg, DWORD dwMsgSize, DPID idFrom,
|
||||
DPID idTo );
|
||||
VOID SendGameMessage( GENERICMSG* pMsg, DPID idTo );
|
||||
VOID CleanupComm();
|
||||
|
||||
|
||||
HRESULT InitializeGameSounds();
|
||||
VOID CleanupGameSounds();
|
||||
|
||||
|
||||
|
||||
// restore default alignment
|
||||
#pragma pack()
|
||||
|
||||
|
||||
|
||||
534
Library/dxx8/samples/Multimedia/Demos/Duel/gfx.cpp
Normal file
@@ -0,0 +1,534 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: gfx.cpp
|
||||
//
|
||||
// Desc: Graphics routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "gfx.h"
|
||||
#include "diutil.h"
|
||||
#include "ddutil.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
extern BOOL g_bFullscreen; // Window or fullscreen mode ?
|
||||
extern HWND g_hwndMain; // Main window
|
||||
extern DWORD g_dwKeys;
|
||||
extern int g_nProgramState; // Current state of program
|
||||
extern RECT g_rcWindow; // Client window rectangle
|
||||
extern HINSTANCE g_hInst; // Application instance handle
|
||||
|
||||
|
||||
LPDIRECTDRAW g_pDD = NULL; // DirectDraw interface
|
||||
LPDIRECTDRAWPALETTE g_pArtPalette = NULL; // Game screen palette
|
||||
LPDIRECTDRAWPALETTE g_pSplashPalette = NULL; // Splash screen palette
|
||||
LPDIRECTDRAWSURFACE g_pddsFrontBuffer = NULL; // primary surface
|
||||
LPDIRECTDRAWSURFACE g_pddsBackBuffer = NULL; // back buffer for animation
|
||||
LPDIRECTDRAWSURFACE g_pddsShip[4]; // ship bitmaps
|
||||
LPDIRECTDRAWSURFACE g_pddsNumbers; // Numbers bitmap
|
||||
DWORD g_dwFillColor;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitGraphics()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT InitGraphics()
|
||||
{
|
||||
DDCAPS ddcaps;
|
||||
HRESULT hr;
|
||||
DDSURFACEDESC ddsd;
|
||||
DDSCAPS ddscaps;
|
||||
|
||||
// Create a window
|
||||
g_hwndMain = CreateWindowEx( WS_EX_APPWINDOW, TEXT("DuelClass"),
|
||||
TEXT("Duel"), WS_POPUP | WS_SYSMENU, 0, 0,
|
||||
GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN),
|
||||
NULL, NULL, g_hInst, NULL );
|
||||
if( NULL == g_hwndMain )
|
||||
return E_FAIL;
|
||||
|
||||
UpdateWindow( g_hwndMain );
|
||||
SetFocus( g_hwndMain );
|
||||
|
||||
// DDraw stuff begins here
|
||||
if( FAILED( hr = DirectDrawCreate( NULL, &g_pDD, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_DDC);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Set access mode based on fullscreen/window
|
||||
if( g_bFullscreen )
|
||||
{
|
||||
hr = g_pDD->SetCooperativeLevel( g_hwndMain,
|
||||
DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN );
|
||||
}
|
||||
else
|
||||
{
|
||||
hr = g_pDD->SetCooperativeLevel( g_hwndMain,
|
||||
DDSCL_NORMAL);
|
||||
}
|
||||
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_SCL);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( g_bFullscreen )
|
||||
{
|
||||
// Set the mode to 640 by 480 by 8
|
||||
if( FAILED( g_pDD->SetDisplayMode( 640, 480, 8 ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_SDM);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
RECT rcWork;
|
||||
RECT rc;
|
||||
DWORD dwStyle;
|
||||
|
||||
// If we are still a WS_POPUP window we should convert to a
|
||||
// normal app window so we look like a windows app.
|
||||
dwStyle = GetWindowStyle(g_hwndMain);
|
||||
dwStyle &= ~WS_POPUP;
|
||||
dwStyle |= WS_OVERLAPPED | WS_CAPTION | WS_THICKFRAME | WS_MINIMIZEBOX;
|
||||
SetWindowLong( g_hwndMain, GWL_STYLE, dwStyle );
|
||||
|
||||
// Aet window size
|
||||
SetRect( &rc, 0, 0, MAX_DEFWIN_X, MAX_DEFWIN_Y );
|
||||
|
||||
AdjustWindowRectEx( &rc, GetWindowStyle(g_hwndMain),
|
||||
GetMenu(g_hwndMain) != NULL,
|
||||
GetWindowExStyle(g_hwndMain) );
|
||||
|
||||
SetWindowPos( g_hwndMain, NULL, 0, 0, rc.right-rc.left,
|
||||
rc.bottom-rc.top,
|
||||
SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE);
|
||||
|
||||
SetWindowPos( g_hwndMain, HWND_NOTOPMOST, 0, 0, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE);
|
||||
|
||||
// Make sure our window does not hang outside of the work area
|
||||
SystemParametersInfo( SPI_GETWORKAREA, 0, &rcWork, 0 );
|
||||
GetWindowRect( g_hwndMain, &rc );
|
||||
if( rc.left < rcWork.left ) rc.left = rcWork.left;
|
||||
if( rc.top < rcWork.top ) rc.top = rcWork.top;
|
||||
SetWindowPos( g_hwndMain, NULL, rc.left, rc.top, 0, 0,
|
||||
SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE );
|
||||
}
|
||||
|
||||
// Check the color key hardware capabilities
|
||||
ddcaps.dwSize = sizeof( ddcaps );
|
||||
memset( &ddsd, 0, sizeof( ddsd ) );
|
||||
ddsd.dwSize = sizeof( ddsd );
|
||||
|
||||
if( g_bFullscreen )
|
||||
{
|
||||
// Create surfaces
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE |
|
||||
DDSCAPS_FLIP |
|
||||
DDSCAPS_COMPLEX;
|
||||
ddsd.dwBackBufferCount = 1;
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsFrontBuffer,
|
||||
NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Get a pointer to the back buffer
|
||||
ddscaps.dwCaps = DDSCAPS_BACKBUFFER;
|
||||
if( FAILED( hr = g_pddsFrontBuffer->GetAttachedSurface( &ddscaps,
|
||||
&g_pddsBackBuffer ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_GAS);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LPDIRECTDRAWCLIPPER pcClipper;
|
||||
|
||||
// Window case, create the primary surface
|
||||
// and create a backbuffer in offscreen memory
|
||||
ddsd.dwFlags = DDSD_CAPS;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;
|
||||
|
||||
if( FAILED( g_pDD->CreateSurface( &ddsd, &g_pddsFrontBuffer, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
ddsd.dwWidth = MAX_DEFWIN_X;
|
||||
ddsd.dwHeight = MAX_DEFWIN_Y;
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsBackBuffer, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = g_pDD->CreateClipper( 0, &pcClipper, NULL) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_CC);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = pcClipper->SetHWnd( 0, g_hwndMain) ) )
|
||||
{
|
||||
pcClipper->Release();
|
||||
ShowError(IDS_DDRAW_ERROR_SH);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = g_pddsFrontBuffer->SetClipper( pcClipper) ) )
|
||||
{
|
||||
pcClipper->Release();
|
||||
ShowError(IDS_DDRAW_ERROR_SC);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Done with clipper
|
||||
pcClipper->Release();
|
||||
}
|
||||
|
||||
ddsd.dwFlags = DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
|
||||
ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN;
|
||||
|
||||
ddsd.dwWidth = 320;
|
||||
ddsd.dwHeight = 128;
|
||||
|
||||
for( DWORD i=0; i<4; i++ )
|
||||
{
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsShip[i], NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
ddsd.dwHeight = 16;
|
||||
if( FAILED( hr = g_pDD->CreateSurface( &ddsd, &g_pddsNumbers, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_CREATESURFACE);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( RestoreSurfaces() ) )
|
||||
{
|
||||
ShowError(IDS_DDRAW_ERROR_RS);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
g_dwKeys = 0;
|
||||
ShowWindow( g_hwndMain, SW_SHOW);
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CleanupGraphics()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CleanupGraphics()
|
||||
{
|
||||
for( DWORD i=0; i<4; i++ )
|
||||
if( g_pddsShip[i] )
|
||||
g_pddsShip[i]->Release();
|
||||
if( g_pddsNumbers )
|
||||
g_pddsNumbers->Release();
|
||||
if( g_pddsFrontBuffer )
|
||||
g_pddsFrontBuffer->Release();
|
||||
if( g_pArtPalette )
|
||||
g_pArtPalette->Release();
|
||||
if( g_pSplashPalette )
|
||||
g_pSplashPalette->Release();
|
||||
if( !g_bFullscreen && g_pddsBackBuffer )
|
||||
g_pddsBackBuffer->Release();
|
||||
if( g_pDD )
|
||||
g_pDD->Release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BltSplashScreen()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT BltSplashScreen( RECT* prc )
|
||||
{
|
||||
HRESULT hr;
|
||||
HBITMAP hbm;
|
||||
|
||||
if( ( g_pddsFrontBuffer == NULL ) || ( g_pSplashPalette == NULL ) ||
|
||||
( g_pddsBackBuffer == NULL ) )
|
||||
return E_FAIL;
|
||||
|
||||
// Set the palette before loading the splash screen
|
||||
g_pddsFrontBuffer->SetPalette( g_pSplashPalette );
|
||||
|
||||
hbm = (HBITMAP)LoadImage( GetModuleHandle( NULL ), TEXT("SPLASH"),
|
||||
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
|
||||
if( NULL == hbm )
|
||||
return E_FAIL;
|
||||
|
||||
// If the surface is lost, DDUtil_CopyBitmap will fail and the surface will
|
||||
// be restored below.
|
||||
hr = DDUtil_CopyBitmap( g_pddsBackBuffer, hbm, 0, 0, 0, 0 );
|
||||
|
||||
DeleteObject( hbm );
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
hr = g_pddsFrontBuffer->Blt( &g_rcWindow, g_pddsBackBuffer,
|
||||
prc, DDBLT_WAIT, NULL);
|
||||
if( SUCCEEDED(hr) )
|
||||
return S_OK;
|
||||
if( hr == DDERR_SURFACELOST )
|
||||
if( FAILED( RestoreSurfaces() ) )
|
||||
return E_FAIL;
|
||||
if( hr != DDERR_WASSTILLDRAWING )
|
||||
return E_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BltNumber()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT BltNumber( CHAR* strScore, int x, int y )
|
||||
{
|
||||
while( *strScore )
|
||||
{
|
||||
RECT src;
|
||||
src.left = ((*strScore++)-'0')*16;
|
||||
src.top = 0;
|
||||
src.right = src.left + 16;
|
||||
src.bottom = src.top + 16;
|
||||
|
||||
BltObject( x, y, g_pddsNumbers, &src, DDBLTFAST_SRCCOLORKEY );
|
||||
x += 16;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: BltObject()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT BltObject( int x, int y, LPDIRECTDRAWSURFACE pdds, RECT* prc,
|
||||
DWORD flags )
|
||||
{
|
||||
if( NULL == pdds )
|
||||
return E_FAIL;
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
HRESULT hr = g_pddsBackBuffer->BltFast( x, y, pdds, prc, flags );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if( hr == DDERR_WASSTILLDRAWING )
|
||||
continue;
|
||||
|
||||
if( hr == DDERR_SURFACELOST )
|
||||
if( SUCCEEDED( RestoreSurfaces() ) )
|
||||
continue;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: EraseScreen()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID EraseScreen()
|
||||
{
|
||||
// Erase the background
|
||||
DDBLTFX ddbltfx;
|
||||
ZeroMemory( &ddbltfx, sizeof(ddbltfx) );
|
||||
ddbltfx.dwSize = sizeof(ddbltfx);
|
||||
#ifdef NONAMELESSUNION
|
||||
ddbltfx.u5.dwFillColor = g_dwFillColor;
|
||||
#else
|
||||
ddbltfx.dwFillColor = g_dwFillColor;
|
||||
#endif
|
||||
|
||||
while( 1 )
|
||||
{
|
||||
HRESULT hr = g_pddsBackBuffer->Blt( NULL, NULL, NULL,
|
||||
DDBLT_COLORFILL, &ddbltfx );
|
||||
if( SUCCEEDED(hr) )
|
||||
return;
|
||||
|
||||
if( hr == DDERR_SURFACELOST )
|
||||
{
|
||||
if( FAILED( RestoreSurfaces() ) )
|
||||
return;
|
||||
}
|
||||
|
||||
if( hr != DDERR_WASSTILLDRAWING )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: FlipScreen()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID FlipScreen()
|
||||
{
|
||||
// Flip the surfaces
|
||||
if( g_bFullscreen )
|
||||
{
|
||||
while( 1 )
|
||||
{
|
||||
HRESULT hr = g_pddsFrontBuffer->Flip( NULL, 0 );
|
||||
|
||||
if( hr == DDERR_SURFACELOST )
|
||||
{
|
||||
if( FAILED( RestoreSurfaces() ) )
|
||||
return;
|
||||
}
|
||||
if( hr != DDERR_WASSTILLDRAWING )
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
g_pddsFrontBuffer->Blt( &g_rcWindow, g_pddsBackBuffer, NULL,
|
||||
DDBLT_WAIT, NULL );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: RestoreSurfaces()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT RestoreSurfaces()
|
||||
{
|
||||
HRESULT hr;
|
||||
HBITMAP hbm;
|
||||
|
||||
if( FAILED( hr = g_pddsFrontBuffer->Restore() ) )
|
||||
return hr;
|
||||
if( FAILED( hr = g_pddsBackBuffer->Restore() ) )
|
||||
return hr;
|
||||
|
||||
for( DWORD i=0; i<4; i++ )
|
||||
if( FAILED( hr = g_pddsShip[i]->Restore() ) )
|
||||
return hr;
|
||||
|
||||
// Create and set the palette for the splash bitmap
|
||||
g_pSplashPalette = DDUtil_LoadPalette( g_pDD, TEXT("SPLASH") );
|
||||
if( NULL == g_pSplashPalette )
|
||||
return E_FAIL;
|
||||
|
||||
// Create and set the palette for the art bitmap
|
||||
g_pArtPalette = DDUtil_LoadPalette( g_pDD, TEXT("Duel8") );
|
||||
if( NULL == g_pArtPalette )
|
||||
return E_FAIL;
|
||||
|
||||
// set the palette before loading the art
|
||||
g_pddsFrontBuffer->SetPalette( g_pArtPalette );
|
||||
|
||||
hbm = (HBITMAP)LoadImage( GetModuleHandle(NULL), TEXT("Duel8"),
|
||||
IMAGE_BITMAP, 0, 0, LR_CREATEDIBSECTION );
|
||||
if( NULL == hbm )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[0], hbm, 0, 0, 320, 128 ) ) )
|
||||
{
|
||||
DeleteObject( hbm );
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[1], hbm, 0, 128, 320, 128 ) ) )
|
||||
{
|
||||
DeleteObject( hbm );
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[2], hbm, 0, 256, 320, 128 ) ) )
|
||||
{
|
||||
DeleteObject( hbm );
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsShip[3], hbm, 0, 384, 320, 128 ) ) )
|
||||
{
|
||||
DeleteObject( hbm );
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( FAILED( hr = DDUtil_CopyBitmap( g_pddsNumbers, hbm, 0, 512, 320, 16 ) ) )
|
||||
{
|
||||
DeleteObject( hbm );
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
DeleteObject( hbm );
|
||||
|
||||
// set colorfill colors and colorkeys according to bitmap contents
|
||||
g_dwFillColor = DDUtil_ColorMatch( g_pddsShip[0], CLR_INVALID );
|
||||
|
||||
DDUtil_SetColorKey( g_pddsShip[0], CLR_INVALID );
|
||||
DDUtil_SetColorKey( g_pddsShip[1], CLR_INVALID );
|
||||
DDUtil_SetColorKey( g_pddsShip[2], CLR_INVALID );
|
||||
DDUtil_SetColorKey( g_pddsShip[3], CLR_INVALID );
|
||||
DDUtil_SetColorKey( g_pddsNumbers, CLR_INVALID );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: SetGamePalette()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID SetGamePalette()
|
||||
{
|
||||
if( g_pddsFrontBuffer )
|
||||
g_pddsFrontBuffer->SetPalette( g_pArtPalette );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
22
Library/dxx8/samples/Multimedia/Demos/Duel/gfx.h
Normal file
@@ -0,0 +1,22 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: gfx.h
|
||||
//
|
||||
// Desc: Graphics routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "ddraw.h"
|
||||
|
||||
HRESULT InitGraphics();
|
||||
VOID CleanupGraphics();
|
||||
HRESULT BltSplashScreen( RECT* prc );
|
||||
HRESULT BltNumber( CHAR* strScore, int x, int y );
|
||||
HRESULT BltObject( int x, int y, LPDIRECTDRAWSURFACE pdds, RECT* src,
|
||||
DWORD dwFlags );
|
||||
VOID EraseScreen();
|
||||
VOID FlipScreen();
|
||||
HRESULT RestoreSurfaces();
|
||||
VOID SetGamePalette();
|
||||
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/lboom.wav
Normal file
240
Library/dxx8/samples/Multimedia/Demos/Duel/lobby.cpp
Normal file
@@ -0,0 +1,240 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Lobby.cpp
|
||||
//
|
||||
// Desc: DP lobby related routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "lobby.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Definitions
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
#define TIMERID 1 // Timer ID to use
|
||||
#define TIMERINTERVAL 250 // Timer interval
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
extern LPDIRECTPLAY4 g_pDP; // DirectPlay object pointer
|
||||
extern LPDPLCONNECTION g_pDPLConnection; // Connection settings
|
||||
extern LPDIRECTPLAYLOBBY3 g_pDPLobby; // Lobby object pointer
|
||||
extern BOOL g_bHostPlayer; // Flag indicating if we are hosting
|
||||
extern HWND g_hwndMain; // Main application window handle
|
||||
extern HINSTANCE g_hInst; // Application instance handle
|
||||
|
||||
BOOL g_bLobbyMsgSupported; // Lobby messages are supported
|
||||
GUID g_guidPlayer; // This player in this session
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPLobbyRelease()
|
||||
// Desc: Wrapper for DirectPlayLobby Release API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPLobbyRelease()
|
||||
{
|
||||
// Cleanup lobby
|
||||
SAFE_DELETE_ARRAY( g_pDPLConnection );
|
||||
SAFE_RELEASE( g_pDPLobby );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DoingLobbyMessages()
|
||||
// Desc: Return TRUE if connected to a lobby and messages are supported.
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL DoingLobbyMessages()
|
||||
{
|
||||
return( g_pDPLobby && g_bLobbyMsgSupported );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: LobbyMessageInit()
|
||||
// Desc: Initialize lobby message processing. Must be done while a lobby
|
||||
// connection is open.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT LobbyMessageInit()
|
||||
{
|
||||
if( NULL ==g_pDPLobby ) // Not connected to a lobby
|
||||
return E_FAIL;
|
||||
|
||||
g_bLobbyMsgSupported = FALSE; // Until we find out otherwise.
|
||||
|
||||
// Find out if lobby messages are supported by the lobby
|
||||
DPLMSG_GETPROPERTY msgGetProp;
|
||||
ZeroMemory( &msgGetProp, sizeof(DPLMSG_GETPROPERTY) );
|
||||
msgGetProp.dwType = DPLSYS_GETPROPERTY;
|
||||
msgGetProp.dwRequestID = 1; // guidPlayer is not used
|
||||
msgGetProp.guidPropertyTag = DPLPROPERTY_MessagesSupported;
|
||||
|
||||
return g_pDPLobby->SendLobbyMessage( DPLMSG_STANDARD, 0, &msgGetProp,
|
||||
sizeof(DPLMSG_GETPROPERTY) );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: LobbyMessageReceive()
|
||||
// Desc: Check for any lobby messages and handle them
|
||||
// There are two modes:
|
||||
// LMR_CONNECTIONSETTINGS - Waiting only for settings from a lobby
|
||||
// LMR_PROPERTIES - Handle property message responses
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT LobbyMessageReceive( DWORD dwMode )
|
||||
{
|
||||
HRESULT hr = NOERROR;
|
||||
LPVOID lpMsgBuffer = NULL;
|
||||
DWORD dwBufferSize = 0;
|
||||
DWORD dwRequiredSize;
|
||||
DWORD dwMsgFlags;
|
||||
|
||||
if( NULL == g_pDPLobby ) // No lobby interface
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
while( SUCCEEDED(hr) ) // Get all queued messages
|
||||
{
|
||||
dwRequiredSize = dwBufferSize;
|
||||
hr = g_pDPLobby->ReceiveLobbyMessage( 0, 0, &dwMsgFlags,
|
||||
lpMsgBuffer, &dwRequiredSize );
|
||||
if( hr == DPERR_BUFFERTOOSMALL ) // Alloc msg buffer and try again
|
||||
{
|
||||
if( NULL == lpMsgBuffer )
|
||||
lpMsgBuffer = GlobalAllocPtr( GHND, dwRequiredSize );
|
||||
else
|
||||
lpMsgBuffer = GlobalReAllocPtr( lpMsgBuffer, dwRequiredSize, 0 );
|
||||
|
||||
if( NULL == lpMsgBuffer)
|
||||
return DPERR_NOMEMORY;
|
||||
|
||||
dwBufferSize = dwRequiredSize;
|
||||
hr = S_OK;
|
||||
}
|
||||
else if( SUCCEEDED(hr) && dwRequiredSize >= sizeof(DPLMSG_GENERIC) )
|
||||
{
|
||||
// Decode the message
|
||||
|
||||
// Are we just looking for the CONNECTIONSETTINGS msg?
|
||||
if( dwMode == LMR_CONNECTIONSETTINGS )
|
||||
{
|
||||
if( (dwMsgFlags & DPLMSG_SYSTEM) &&
|
||||
((DPLMSG_GENERIC*)lpMsgBuffer)->dwType ==
|
||||
DPLSYS_NEWCONNECTIONSETTINGS )
|
||||
break;
|
||||
else
|
||||
TRACE(_T("Non CONNECTIONSETTINGS lobby message ignored\n"));
|
||||
}
|
||||
|
||||
// Otherwise we handle only GetProperty responses
|
||||
else if( (dwMsgFlags & DPLMSG_STANDARD) &&
|
||||
((DPLMSG_GENERIC*)lpMsgBuffer)->dwType ==
|
||||
DPLSYS_GETPROPERTYRESPONSE )
|
||||
{
|
||||
DPLMSG_GETPROPERTYRESPONSE* lpMsgGPR =
|
||||
(DPLMSG_GETPROPERTYRESPONSE*)lpMsgBuffer;
|
||||
if( IsEqualGUID( lpMsgGPR->guidPropertyTag,
|
||||
DPLPROPERTY_MessagesSupported ) )
|
||||
{
|
||||
if( (BOOL)lpMsgGPR->dwPropertyData[0] ) // Supported
|
||||
{
|
||||
// So request our player instance guid
|
||||
DPLMSG_GETPROPERTY msgGetProp;
|
||||
ZeroMemory(&msgGetProp, sizeof(DPLMSG_GETPROPERTY));
|
||||
msgGetProp.dwType = DPLSYS_GETPROPERTY;
|
||||
msgGetProp.dwRequestID = 2;
|
||||
// guidPlayer is left NULL
|
||||
msgGetProp.guidPropertyTag = DPLPROPERTY_PlayerGuid;
|
||||
hr = g_pDPLobby->SendLobbyMessage( DPLMSG_STANDARD, 0,
|
||||
&msgGetProp,
|
||||
sizeof(DPLMSG_GETPROPERTY) );
|
||||
hr = S_OK; // keep fetching messages
|
||||
}
|
||||
else // not supported so close up shop
|
||||
{
|
||||
TRACE(_T("Lobby Messages not supported\n"));
|
||||
DPLobbyRelease();
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if( IsEqualGUID( lpMsgGPR->guidPropertyTag,
|
||||
DPLPROPERTY_PlayerGuid ) )
|
||||
{
|
||||
// Have our player guid, ready to send property msgs
|
||||
g_guidPlayer = ( (DPLDATA_PLAYERGUID*)
|
||||
&lpMsgGPR->dwPropertyData)->guidPlayer;
|
||||
g_bLobbyMsgSupported = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
TRACE(_T("Unrecognized lobby message ignored\n"));
|
||||
}
|
||||
}
|
||||
|
||||
if( lpMsgBuffer )
|
||||
GlobalFreePtr( lpMsgBuffer );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: LobbyMessageSetProperty()
|
||||
// Desc: Send a SetProperty message
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT LobbyMessageSetProperty( const GUID* pPropTagGUID, VOID* pData,
|
||||
DWORD dwDataSize )
|
||||
{
|
||||
HRESULT hr;
|
||||
LPBYTE lpBuffer;
|
||||
LPDPLMSG_SETPROPERTY lpMsgSP;
|
||||
DWORD dwMsgSize;
|
||||
|
||||
if( NULL == g_pDPLobby )
|
||||
return DPERR_NOCONNECTION;
|
||||
if( NULL == g_bLobbyMsgSupported )
|
||||
return DPERR_UNAVAILABLE;
|
||||
|
||||
// Allocate and pack up the message
|
||||
// Property data starts at dwPropertyData[0] for the size calculation
|
||||
dwMsgSize = sizeof(DPLMSG_SETPROPERTY) - sizeof(DWORD) + dwDataSize;
|
||||
lpBuffer = (LPBYTE)GlobalAllocPtr(GHND, dwMsgSize);
|
||||
if( NULL == lpBuffer )
|
||||
return (DPERR_NOMEMORY);
|
||||
lpMsgSP = (LPDPLMSG_SETPROPERTY)lpBuffer;
|
||||
lpMsgSP->dwType = DPLSYS_SETPROPERTY;
|
||||
lpMsgSP->dwRequestID = DPL_NOCONFIRMATION;
|
||||
lpMsgSP->guidPlayer = g_guidPlayer; // player property assumed
|
||||
lpMsgSP->guidPropertyTag = (*pPropTagGUID);
|
||||
lpMsgSP->dwDataSize = dwDataSize;
|
||||
memcpy( lpMsgSP->dwPropertyData, pData, dwDataSize );
|
||||
hr = g_pDPLobby->SendLobbyMessage( DPLMSG_STANDARD, 0, lpBuffer, dwMsgSize );
|
||||
|
||||
GlobalFreePtr( lpBuffer );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
33
Library/dxx8/samples/Multimedia/Demos/Duel/lobby.h
Normal file
@@ -0,0 +1,33 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Lobby.h
|
||||
//
|
||||
// Desc: DP lobby related routines include file
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IDIRECTPLAY2_OR_GREATER
|
||||
#include <dplobby.h>
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// LobbyMessageReceive Modes
|
||||
//-----------------------------------------------------------------------------
|
||||
#define LMR_PROPERTIES 0
|
||||
#define LMR_CONNECTIONSETTINGS 1
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPLobbyRelease();
|
||||
HRESULT DPLobbySetConnectionSettings();
|
||||
|
||||
BOOL DoingLobbyMessages();
|
||||
HRESULT LobbyMessageInit();
|
||||
HRESULT LobbyMessageReceive( DWORD dwMode );
|
||||
HRESULT LobbyMessageSetProperty( const GUID* pPropTagGUID, VOID* pData,
|
||||
DWORD dwDataSize );
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/osession.bmp
Normal file
|
After Width: | Height: | Size: 518 B |
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/player.bmp
Normal file
|
After Width: | Height: | Size: 518 B |
51
Library/dxx8/samples/Multimedia/Demos/Duel/readme.txt
Normal file
@@ -0,0 +1,51 @@
|
||||
Duel Sample Game
|
||||
------------------
|
||||
|
||||
This program requires less than 1 Meg of video ram.
|
||||
|
||||
The commands which this game recognizes are listed on the opening screen
|
||||
and in the help dialog (F1).
|
||||
|
||||
ENTER - Starts game and multiplayer session setup
|
||||
LEFT ARROW - Turn left
|
||||
RIGHT ARROW - Turn right
|
||||
UP ARROW - Accelerate forward
|
||||
DOWN ARROW - Accelerate backward
|
||||
NUMPAD 5 - Stop moving
|
||||
SPACEBAR - Fire
|
||||
ESC, F12 - Quit
|
||||
F1 - Help - list of commands
|
||||
F5 - toggle frame rate display
|
||||
|
||||
|
||||
To play multiplayer one machine hosts a game, the others join.
|
||||
|
||||
To play using TCP/IP over the Internet, the people who are joining the
|
||||
game must enter the IP address of the machine that hosted the game.
|
||||
You can find out the IP address of your machine by running "winipcfg".
|
||||
If you have a net card and a modem installed, you will need to make
|
||||
sure you read the IP address of the modem connection to the Internet.
|
||||
The modem will show up as a "PPP Adapter". DirectPlay will not work
|
||||
through proxies or firewalls.
|
||||
|
||||
This game allows the selection of which DirectPlay messaging protocol
|
||||
is used. The host machine can select the optimized DirectPlay
|
||||
guaranteed protocol for the game session in the setup wizard. Reliable
|
||||
and asynchronous messaging, when supported by the service provider or
|
||||
by using the DirectPlay Protocol, can be toggled on and off with the R
|
||||
and A keys. The protocol status will be displayed in the caption bar.
|
||||
|
||||
Also see the DPLAUNCH sample as an example of lobby launching this game.
|
||||
|
||||
Note: MSVC may include older versions of the DirectX header files and
|
||||
libraries. In order to avoid compile errors, make sure the path to the
|
||||
latest DirectX header files and libraries are listed BEFORE the MSVC header
|
||||
files and libraries through the Tools -> Options -> Directories menu.
|
||||
|
||||
In order to support multi-byte character sets like Kanji, the dialogs in the
|
||||
rc file need to be changed to use the "SYSTEM" font and the rc file needs to
|
||||
be recompiled.
|
||||
|
||||
|
||||
|
||||
|
||||
84
Library/dxx8/samples/Multimedia/Demos/Duel/resource.h
Normal file
@@ -0,0 +1,84 @@
|
||||
//{{NO_DEPENDENCIES}}
|
||||
// Microsoft Developer Studio generated include file.
|
||||
// Used by duel.rc
|
||||
//
|
||||
#define IDS_WIZARD_FONTNAME 6
|
||||
#define IDS_WIZARD_TITLE 7
|
||||
#define IDS_WIZARD_TITLE_SP 8
|
||||
#define IDS_WIZARD_TITLE_GS 9
|
||||
#define IDS_WIZARD_TITLE_JS 10
|
||||
#define IDS_WIZARD_TITLE_HS 11
|
||||
#define IDS_DUEL_HELP 12
|
||||
#define IDS_DDRAW_ERROR_DDC 16
|
||||
#define IDS_DDRAW_ERROR_SCL 17
|
||||
#define IDS_DDRAW_ERROR_SDM 18
|
||||
#define IDS_DDRAW_ERROR_CREATESURFACE 19
|
||||
#define IDS_DDRAW_ERROR_GAS 20
|
||||
#define IDS_DDRAW_ERROR_CC 21
|
||||
#define IDS_DDRAW_ERROR_SH 22
|
||||
#define IDS_DDRAW_ERROR_SC 23
|
||||
#define IDS_DDRAW_ERROR_CSN 28
|
||||
#define IDS_DDRAW_ERROR_RS 29
|
||||
#define IDS_DINPUT_ERROR_DIC 32
|
||||
#define IDS_DINPUT_ERROR_ED 33
|
||||
#define IDS_DINPUT_ERROR_CD 34
|
||||
#define IDS_DINPUT_ERROR_SP 35
|
||||
#define IDS_DINPUT_ERROR_A 36
|
||||
#define IDS_DINPUT_ERROR_DF 37
|
||||
#define IDS_DDUTIL_ERROR_LI 38
|
||||
#define IDS_DDUTIL_ERROR_DDCB 39
|
||||
#define IDS_DDUTIL_ERROR_CCDC 40
|
||||
#define IDS_DSOUND_LOADWAVES 41
|
||||
#define IDS_DSOUND_DUPBUF 42
|
||||
#define IDS_DPLAY_ERROR_CP 48
|
||||
#define IDS_DPLAY_ERROR_JS 49
|
||||
#define IDS_DPLAY_ERROR_CS 50
|
||||
#define IDS_DPLAY_ERROR_IDC 51
|
||||
#define IDS_DPLAY_ERROR_SL 52
|
||||
#define IDS_DPLAY_ERROR_GPLD 53
|
||||
#define IDS_DPLAY_ERROR_SPLD 54
|
||||
#define IDS_DPLAY_ERROR_GPRD 55
|
||||
#define IDS_DPLAY_ERROR_SPRD 56
|
||||
#define IDS_DPLAY_ERROR_GSD 57
|
||||
#define IDS_DPLAY_ERROR_EP 58
|
||||
#define IDS_DPLAY_ERROR_ES 59
|
||||
#define IDS_DPLAY_ERROR_C 60
|
||||
#define IDS_DPLAY_ERROR_R 61
|
||||
#define IDS_DPLAY_ERROR_DP 62
|
||||
#define IDS_DPLAY_ERROR_CLSID 63
|
||||
#define IDS_DPLOBBY_ERROR_R 64
|
||||
#define IDS_DPLOBBY_ERROR_GCS 66
|
||||
#define IDS_DPLOBBY_ERROR_SCS 67
|
||||
#define IDS_DPLOBBY_ERROR_C 68
|
||||
#define IDS_DPLOBBY_ERROR_CONNECT 69
|
||||
#define IDS_WIZARD_ERROR_GSG 70
|
||||
#define IDS_WIN_ERROR 71
|
||||
#define IDD_MULTIPLAYER_CREATE 104
|
||||
#define IDI_MAIN 104
|
||||
#define IDD_CONNECT_STATUS 114
|
||||
#define IDD_LOBBY_WAIT_STATUS 133
|
||||
#define IDD_MULTIPLAYER_CONNECT 136
|
||||
#define IDD_MULTIPLAYER_GAMES 137
|
||||
#define IDC_PLAYER_NAME_EDIT 1000
|
||||
#define IDC_GAMES_LIST 1001
|
||||
#define IDC_JOIN 1002
|
||||
#define IDC_CREATE 1003
|
||||
#define IDC_CONNECTION_LIST 1004
|
||||
#define IDC_BACK 1005
|
||||
#define IDC_CHECK_DPLAY_PROTOCOL 1006
|
||||
#define IDC_EDIT_SESSION_NAME 1007
|
||||
#define IDC_DUEL_STATUSTEXT 1010
|
||||
#define IDC_SEARCH_CHECK 1013
|
||||
#define IDC_LOBBYCONNECTCANCEL 1029
|
||||
#define IDC_WAIT_TEXT 1035
|
||||
|
||||
// Next default values for new objects
|
||||
//
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
#ifndef APSTUDIO_READONLY_SYMBOLS
|
||||
#define _APS_NEXT_RESOURCE_VALUE 138
|
||||
#define _APS_NEXT_COMMAND_VALUE 40001
|
||||
#define _APS_NEXT_CONTROL_VALUE 1033
|
||||
#define _APS_NEXT_SYMED_VALUE 101
|
||||
#endif
|
||||
#endif
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/sboom.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/sbounce.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/sengine.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/splash.bmp
Normal file
|
After Width: | Height: | Size: 301 KiB |
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/sstart.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/Duel/sstop.wav
Normal file
64
Library/dxx8/samples/Multimedia/Demos/Duel/util.cpp
Normal file
@@ -0,0 +1,64 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Util.cpp
|
||||
//
|
||||
// Desc: Misc routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: randInt()
|
||||
// Desc: Returns a random integer in the specified range
|
||||
//-----------------------------------------------------------------------------
|
||||
int randInt( int low, int high )
|
||||
{
|
||||
int range = high - low;
|
||||
int num = rand() % range;
|
||||
return( num + low );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: randDouble()
|
||||
// Desc: Returns a random double in the specified range
|
||||
//-----------------------------------------------------------------------------
|
||||
double randDouble( double low, double high )
|
||||
{
|
||||
double range = high - low;
|
||||
double num = range * (double)rand()/(double)RAND_MAX;
|
||||
return( num + low );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: dtrace()
|
||||
// Desc: Diagnostic trace to OutputDebugString() (UNICODE supported)
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID dtrace( TCHAR* strFormat, ... )
|
||||
{
|
||||
int offset = 0;
|
||||
TCHAR strBuf[256];
|
||||
va_list ap;
|
||||
|
||||
va_start( ap, strFormat );
|
||||
|
||||
offset = wsprintf( strBuf, TEXT("DUEL: ") );
|
||||
offset += wvsprintf( strBuf+offset, strFormat, ap );
|
||||
|
||||
OutputDebugString( strBuf );
|
||||
|
||||
va_end( ap );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
1295
Library/dxx8/samples/Multimedia/Demos/Duel/wizard.cpp
Normal file
51
Library/dxx8/samples/Multimedia/Demos/Duel/wizard.h
Normal file
@@ -0,0 +1,51 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Wizard.h
|
||||
//
|
||||
// Desc: UI routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IDIRECTPLAY2_OR_GREATER
|
||||
#include <commctrl.h>
|
||||
#include <dplay.h>
|
||||
|
||||
|
||||
// Structure for the tree control
|
||||
struct TREEDATA
|
||||
{
|
||||
GUID guid; // Session GUID
|
||||
DWORD dwRefresh; // Used to detect when sessions go away
|
||||
};
|
||||
|
||||
|
||||
BOOL SetupFonts();
|
||||
VOID CleanupFonts();
|
||||
LONG RegSet( const TCHAR* strName, const BYTE* pData, DWORD dwSize );
|
||||
LONG RegGet( const TCHAR* strName, BYTE* pData, DWORD* pdwDataSize );
|
||||
|
||||
DWORD WINAPI DoWizard( VOID* pv );
|
||||
BOOL CALLBACK DlgProcChooseProvider( HWND hDlg, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam);
|
||||
BOOL FAR PASCAL DPEnumConnectionsCallback( const GUID* pguidSP,
|
||||
VOID* pConnection, DWORD dwSize,
|
||||
const DPNAME* pName, DWORD dwFlags,
|
||||
VOID* pContext );
|
||||
BOOL WINAPI EnumSession( const DPSESSIONDESC2* pDPSessionDesc,
|
||||
DWORD* pdwTimeOut, DWORD dwFlags, VOID* pContext );
|
||||
BOOL CALLBACK DlgProcGameSetup( HWND hDlg, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam );
|
||||
BOOL WINAPI EnumPlayer( DPID pidID, DWORD dwPlayerType,
|
||||
const DPNAME* pName, DWORD dwFlags,
|
||||
VOID* pContext );
|
||||
BOOL CALLBACK DlgProcJoinSession( HWND hDlg, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam );
|
||||
BOOL CALLBACK DlgProcHostSession( HWND hDlg, UINT msg, WPARAM wParam,
|
||||
LPARAM lParam );
|
||||
|
||||
BOOL InitTreeViewImageLists( HWND hwndTV );
|
||||
HTREEITEM AddItemToTree( HWND hwndTV, TCHAR* strItem, DWORD dwData, int nLevel );
|
||||
VOID ReleaseSessionData( HWND hWndCtl );
|
||||
VOID ReleaseSPData();
|
||||
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/DuelVoice/bfire.wav
Normal file
BIN
Library/dxx8/samples/Multimedia/Demos/DuelVoice/csession.bmp
Normal file
|
After Width: | Height: | Size: 518 B |
221
Library/dxx8/samples/Multimedia/Demos/DuelVoice/ddutil.cpp
Normal file
@@ -0,0 +1,221 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DDutil.cpp
|
||||
//
|
||||
// Desc: Routines for loading bitmap and palettes from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#undef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#include <ddraw.h>
|
||||
#include "ddutil.h"
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_CopyBitmap()
|
||||
// Desc: Draw a bitmap into a DirectDrawSurface
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DDUtil_CopyBitmap( LPDIRECTDRAWSURFACE pdds, HBITMAP hbm, int x, int y,
|
||||
int dx, int dy )
|
||||
{
|
||||
HDC hdcImage;
|
||||
HDC hdc;
|
||||
BITMAP bm;
|
||||
DDSURFACEDESC ddsd;
|
||||
HRESULT hr;
|
||||
|
||||
if( hbm == NULL || pdds == NULL )
|
||||
return E_FAIL;
|
||||
|
||||
// Make sure this surface is restored.
|
||||
pdds->Restore();
|
||||
|
||||
// Select bitmap into a memoryDC so we can use it.
|
||||
hdcImage = CreateCompatibleDC(NULL);
|
||||
if( !hdcImage )
|
||||
{
|
||||
OutputDebugString( TEXT("CreateCompatibleDC() failed\n") );
|
||||
return E_FAIL;
|
||||
}
|
||||
SelectObject( hdcImage, hbm );
|
||||
|
||||
// Get size of the bitmap
|
||||
GetObject( hbm, sizeof(bm), &bm ); // get size of bitmap
|
||||
dx = dx == 0 ? bm.bmWidth : dx; // use the passed size, unless zero
|
||||
dy = dy == 0 ? bm.bmHeight : dy;
|
||||
|
||||
// Gt size of surface.
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
ddsd.dwFlags = DDSD_HEIGHT | DDSD_WIDTH;
|
||||
pdds->GetSurfaceDesc(&ddsd);
|
||||
|
||||
if( SUCCEEDED( hr = pdds->GetDC(&hdc) ) )
|
||||
{
|
||||
StretchBlt( hdc, 0, 0, ddsd.dwWidth, ddsd.dwHeight, hdcImage,
|
||||
x, y, dx, dy, SRCCOPY);
|
||||
pdds->ReleaseDC( hdc );
|
||||
}
|
||||
|
||||
DeleteDC( hdcImage );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_LoadPalette()
|
||||
// Desc: Create a DirectDraw palette object from a bitmap resoure
|
||||
// If the resource does not exist or NULL is passed create a
|
||||
// default 332 palette.
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTDRAWPALETTE DDUtil_LoadPalette( LPDIRECTDRAW pDD, TCHAR* strBitmap )
|
||||
{
|
||||
LPDIRECTDRAWPALETTE pddPalette;
|
||||
int i;
|
||||
int n;
|
||||
HANDLE fh;
|
||||
HRSRC h;
|
||||
LPBITMAPINFOHEADER lpbi;
|
||||
PALETTEENTRY ape[256];
|
||||
RGBQUAD* prgb;
|
||||
DWORD dwRead;
|
||||
|
||||
// Build a 332 palette as the default.
|
||||
for( i=0; i<256; i++ )
|
||||
{
|
||||
ape[i].peRed = (BYTE)(((i >> 5) & 0x07) * 255 / 7);
|
||||
ape[i].peGreen = (BYTE)(((i >> 2) & 0x07) * 255 / 7);
|
||||
ape[i].peBlue = (BYTE)(((i >> 0) & 0x03) * 255 / 3);
|
||||
ape[i].peFlags = (BYTE)0;
|
||||
}
|
||||
|
||||
// Gt a pointer to the bitmap resource.
|
||||
if( strBitmap && ( h = FindResource( NULL, strBitmap, RT_BITMAP ) ) )
|
||||
{
|
||||
lpbi = (LPBITMAPINFOHEADER)LockResource( LoadResource( NULL, h ) );
|
||||
if( NULL == lpbi )
|
||||
OutputDebugString(TEXT("lock resource failed\n"));
|
||||
prgb = (RGBQUAD*)((BYTE*)lpbi + lpbi->biSize);
|
||||
|
||||
if (lpbi == NULL || lpbi->biSize < sizeof(BITMAPINFOHEADER))
|
||||
n = 0;
|
||||
else if (lpbi->biBitCount > 8)
|
||||
n = 0;
|
||||
else if (lpbi->biClrUsed == 0)
|
||||
n = 1 << lpbi->biBitCount;
|
||||
else
|
||||
n = lpbi->biClrUsed;
|
||||
|
||||
// A DIB color table has its colors stored BGR not RGB, so flip them
|
||||
for(i=0; i<n; i++ )
|
||||
{
|
||||
ape[i].peRed = prgb[i].rgbRed;
|
||||
ape[i].peGreen = prgb[i].rgbGreen;
|
||||
ape[i].peBlue = prgb[i].rgbBlue;
|
||||
ape[i].peFlags = 0;
|
||||
}
|
||||
}
|
||||
else if( strBitmap && ( fh = CreateFile( strBitmap, GENERIC_READ,
|
||||
FILE_SHARE_READ, NULL, OPEN_EXISTING,
|
||||
FILE_ATTRIBUTE_NORMAL, NULL ) ) != INVALID_HANDLE_VALUE )
|
||||
{
|
||||
BITMAPFILEHEADER bf;
|
||||
BITMAPINFOHEADER bi;
|
||||
|
||||
ReadFile( fh, &bf, sizeof(bf), &dwRead, NULL );
|
||||
ReadFile( fh, &bi, sizeof(bi), &dwRead, NULL );
|
||||
ReadFile( fh, ape, sizeof(ape), &dwRead, NULL );
|
||||
CloseHandle( fh );
|
||||
|
||||
if( bi.biSize != sizeof(BITMAPINFOHEADER) )
|
||||
n = 0;
|
||||
else if( bi.biBitCount > 8 )
|
||||
n = 0;
|
||||
else if( bi.biClrUsed == 0 )
|
||||
n = 1 << bi.biBitCount;
|
||||
else
|
||||
n = bi.biClrUsed;
|
||||
|
||||
// A DIB color table has its colors stored BGR not RGB so flip them
|
||||
for(i=0; i<n; i++ )
|
||||
{
|
||||
BYTE r = ape[i].peRed;
|
||||
ape[i].peRed = ape[i].peBlue;
|
||||
ape[i].peBlue = r;
|
||||
}
|
||||
}
|
||||
|
||||
pDD->CreatePalette( DDPCAPS_8BIT, ape, &pddPalette, NULL );
|
||||
|
||||
return pddPalette;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_ColorMatch()
|
||||
// Desc: Convert a RGB color to a pysical color. We do this by leting GDI
|
||||
// SetPixel() do the color matching.
|
||||
//-----------------------------------------------------------------------------
|
||||
DWORD DDUtil_ColorMatch( LPDIRECTDRAWSURFACE pdds, COLORREF rgb )
|
||||
{
|
||||
DDSURFACEDESC ddsd;
|
||||
COLORREF rgbT;
|
||||
HDC hdc;
|
||||
DWORD dw = CLR_INVALID;
|
||||
HRESULT hr;
|
||||
|
||||
// Wse GDI SetPixel to color match for us
|
||||
if( rgb != CLR_INVALID && SUCCEEDED( pdds->GetDC(&hdc) ) )
|
||||
{
|
||||
rgbT = GetPixel( hdc, 0, 0 ); // Save current pixel value
|
||||
SetPixel( hdc, 0, 0, rgb ); // Set our value
|
||||
pdds->ReleaseDC( hdc );
|
||||
}
|
||||
|
||||
// Now lock the surface so we can read back the converted color
|
||||
ddsd.dwSize = sizeof(ddsd);
|
||||
while( ( hr = pdds->Lock( NULL, &ddsd, 0, NULL ) ) == DDERR_WASSTILLDRAWING )
|
||||
{}
|
||||
|
||||
if( SUCCEEDED(hr) )
|
||||
{
|
||||
dw = *(DWORD *)ddsd.lpSurface; // get DWORD
|
||||
dw &= (1 << ddsd.ddpfPixelFormat.dwRGBBitCount)-1; // mask it to bpp
|
||||
pdds->Unlock(NULL);
|
||||
}
|
||||
|
||||
// Now put the color that was there back.
|
||||
if( rgb != CLR_INVALID && SUCCEEDED( pdds->GetDC(&hdc) ) )
|
||||
{
|
||||
SetPixel( hdc, 0, 0, rgbT );
|
||||
pdds->ReleaseDC( hdc );
|
||||
}
|
||||
|
||||
return dw;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DDUtil_SetColorKey()
|
||||
// Desc: Set a color key for a surface, given a RGB. If you pass CLR_INVALID as
|
||||
// the color key, the pixel in the upper-left corner will be used.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DDUtil_SetColorKey( LPDIRECTDRAWSURFACE pdds, COLORREF rgb )
|
||||
{
|
||||
DDCOLORKEY ddck;
|
||||
ddck.dwColorSpaceLowValue = DDUtil_ColorMatch( pdds, rgb );
|
||||
ddck.dwColorSpaceHighValue = ddck.dwColorSpaceLowValue;
|
||||
|
||||
return pdds->SetColorKey( DDCKEY_SRCBLT, &ddck );
|
||||
}
|
||||
|
||||
|
||||
|
||||
18
Library/dxx8/samples/Multimedia/Demos/DuelVoice/ddutil.h
Normal file
@@ -0,0 +1,18 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DDutil.h
|
||||
//
|
||||
// Desc: Routines for loading bitmap and palettes from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <tchar.h>
|
||||
|
||||
LPDIRECTDRAWPALETTE DDUtil_LoadPalette( LPDIRECTDRAW pDD, TCHAR* strBitmap );
|
||||
HRESULT DDUtil_CopyBitmap( LPDIRECTDRAWSURFACE pdds, HBITMAP hbm,
|
||||
int x, int y, int dx, int dy );
|
||||
DWORD DDUtil_ColorMatch( LPDIRECTDRAWSURFACE pdds, COLORREF rgb );
|
||||
HRESULT DDUtil_SetColorKey( LPDIRECTDRAWSURFACE pdds, COLORREF rgb );
|
||||
|
||||
|
||||
|
||||
|
||||
169
Library/dxx8/samples/Multimedia/Demos/DuelVoice/diutil.cpp
Normal file
@@ -0,0 +1,169 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DIUtil.cpp
|
||||
//
|
||||
// Desc: Input routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "diutil.h"
|
||||
#include "gameproc.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
static LPDIRECTINPUT g_pDI; // DirectInput interface
|
||||
static LPDIRECTINPUTDEVICE g_pdidKeyboard; // Keyboard device interface
|
||||
static BOOL g_bKeyboardAcquired; // Whether eyboard is acquired
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_InitInput()
|
||||
// Desc: Initialize DirectInput objects & devices
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DIUtil_InitInput( HWND hWnd )
|
||||
{
|
||||
// Create DI object
|
||||
HINSTANCE hInst;
|
||||
#ifdef _WIN64
|
||||
hInst = (HINSTANCE)GetWindowLongPtr( hWnd, GWLP_HINSTANCE );
|
||||
#else
|
||||
hInst = (HINSTANCE)GetWindowLong( hWnd, GWL_HINSTANCE );
|
||||
#endif
|
||||
if( FAILED( DirectInputCreate( hInst,
|
||||
DIRECTINPUT_VERSION, &g_pDI, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_DIC);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Create keyboard device
|
||||
if( FAILED( g_pDI->CreateDevice( GUID_SysKeyboard, &g_pdidKeyboard, NULL ) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_CD);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Tell DirectInput that we want to receive data in keyboard format
|
||||
if( FAILED( g_pdidKeyboard->SetDataFormat( &c_dfDIKeyboard) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_DF);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// Set cooperative level
|
||||
if( FAILED( g_pdidKeyboard->SetCooperativeLevel( hWnd,
|
||||
DISCL_NONEXCLUSIVE | DISCL_FOREGROUND ) ) )
|
||||
{
|
||||
ShowError(IDS_DINPUT_ERROR_SP);
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
// try to acquire the keyboard
|
||||
if( SUCCEEDED( g_pdidKeyboard->Acquire() ) )
|
||||
g_bKeyboardAcquired = TRUE;
|
||||
else
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_ReadKeys()
|
||||
// Desc: Use DirectInput to read game-play keys
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DIUtil_ReadKeys( DWORD* pdwKeys )
|
||||
{
|
||||
BYTE rgbKeybd[256];
|
||||
DWORD dwKeys = 0L;
|
||||
HRESULT hr;
|
||||
|
||||
hr = g_pdidKeyboard->GetDeviceState( sizeof(rgbKeybd), rgbKeybd );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
if( hr == DIERR_INPUTLOST )
|
||||
{
|
||||
// We lost control of the keyboard, reacquire
|
||||
if( SUCCEEDED( g_pdidKeyboard->Acquire() ) )
|
||||
g_bKeyboardAcquired = TRUE;
|
||||
else
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
}
|
||||
|
||||
// Failed to read the keyboard, just return
|
||||
return;
|
||||
}
|
||||
|
||||
// check & update key states
|
||||
if( rgbKeybd[DIK_NUMPAD5] & 0x80 )
|
||||
dwKeys |= KEY_STOP;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD2] & 0x80) || (rgbKeybd[DIK_DOWN] & 0x80) )
|
||||
dwKeys |= KEY_DOWN;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD4] & 0x80) || (rgbKeybd[DIK_LEFT] & 0x80) )
|
||||
dwKeys |= KEY_LEFT;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD6] & 0x80) || (rgbKeybd[DIK_RIGHT] & 0x80) )
|
||||
dwKeys |= KEY_RIGHT;
|
||||
|
||||
if( (rgbKeybd[DIK_NUMPAD8] & 0x80) || (rgbKeybd[DIK_UP] & 0x80) )
|
||||
dwKeys |= KEY_UP;
|
||||
|
||||
if( rgbKeybd[DIK_SPACE] & 0x80 )
|
||||
dwKeys |= KEY_FIRE;
|
||||
|
||||
// Return the keys
|
||||
(*pdwKeys) = dwKeys;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_CleanupInput()
|
||||
// Desc: Cleans up DirectInput objects
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DIUtil_CleanupInput()
|
||||
{
|
||||
if(g_bKeyboardAcquired)
|
||||
{
|
||||
g_pdidKeyboard->Unacquire();
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
}
|
||||
|
||||
if( g_pdidKeyboard )
|
||||
g_pdidKeyboard->Release();
|
||||
|
||||
if( g_pDI )
|
||||
g_pDI->Release();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DIUtil_ReacquireInputDevices()
|
||||
// Desc: Reacquires DirectInput devices as needed
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DIUtil_ReacquireInputDevices()
|
||||
{
|
||||
g_bKeyboardAcquired = FALSE;
|
||||
|
||||
if( NULL == g_pdidKeyboard )
|
||||
return E_FAIL;
|
||||
|
||||
g_pdidKeyboard->Acquire();
|
||||
g_bKeyboardAcquired = TRUE;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
24
Library/dxx8/samples/Multimedia/Demos/DuelVoice/diutil.h
Normal file
@@ -0,0 +1,24 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DIUtil.h
|
||||
//
|
||||
// Desc: Input routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DIUTIL_H
|
||||
#define DIUTIL_H
|
||||
|
||||
#define DIRECTINPUT_VERSION 0x700
|
||||
#include <dinput.h>
|
||||
|
||||
|
||||
HRESULT DIUtil_InitInput( HWND hWnd );
|
||||
VOID DIUtil_ReadKeys( DWORD* pdwKey );
|
||||
VOID DIUtil_CleanupInput();
|
||||
HRESULT DIUtil_ReacquireInputDevices();
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
1282
Library/dxx8/samples/Multimedia/Demos/DuelVoice/dpconnect.cpp
Normal file
626
Library/dxx8/samples/Multimedia/Demos/DuelVoice/dputil.cpp
Normal file
@@ -0,0 +1,626 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DPUtil.cpp
|
||||
//
|
||||
// Desc: Communication routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "DPUtil.h"
|
||||
#include "lobby.h"
|
||||
#include "diutil.h"
|
||||
#include <cguid.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants and globals
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_DELETE_ARRAY(p) { if(p) { delete[] (p); (p)=NULL; } }
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
extern GUID g_AppGUID; // Duel's guid
|
||||
extern DPLCONNECTION* g_pDPLConnection; // Connection settings
|
||||
extern BOOL g_bUseProtocol; // DirectPlay Protocol messaging
|
||||
extern BOOL g_bAsyncSupported; // Asynchronous sends supported
|
||||
extern LPDIRECTSOUND g_pDS;
|
||||
extern BOOL g_bHostPlayer;
|
||||
extern HWND g_hwndMain;
|
||||
|
||||
DPSESSIONDESC2* g_pdpsd; // Durrent session description
|
||||
LPDIRECTPLAY4 g_pDP = NULL; // DPlay object pointer
|
||||
|
||||
LPDIRECTPLAYVOICECLIENT g_pVoiceClient = NULL;
|
||||
LPDIRECTPLAYVOICESERVER g_pVoiceServer = NULL;
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CheckCaps()
|
||||
// Desc: Helper function to check for certain Capabilities
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CheckCaps()
|
||||
{
|
||||
HRESULT hr;
|
||||
DPCAPS dpcaps;
|
||||
ZeroMemory( &dpcaps, sizeof(DPCAPS) );
|
||||
dpcaps.dwSize = sizeof(DPCAPS);
|
||||
|
||||
if( NULL == g_pDP )
|
||||
return;
|
||||
|
||||
// The caps we are checking do not differ for guaranteed msg
|
||||
hr = g_pDP->GetCaps( &dpcaps, 0 );
|
||||
if( FAILED(hr) )
|
||||
return;
|
||||
|
||||
// Determine if Aync messages are supported.
|
||||
g_bAsyncSupported = (dpcaps.dwFlags & DPCAPS_ASYNCSUPPORTED) != 0;
|
||||
|
||||
// Diagnostic traces of caps supported
|
||||
if( g_bAsyncSupported )
|
||||
{
|
||||
TRACE(_T("Capabilities supported: Async %s %s %s\n"),
|
||||
(dpcaps.dwFlags & DPCAPS_SENDPRIORITYSUPPORTED ? _T("SendPriority") : _T("")),
|
||||
(dpcaps.dwFlags & DPCAPS_SENDTIMEOUTSUPPORTED ? _T("SendTimeout") : _T("")),
|
||||
(dpcaps.dwFlags & DPCAPS_ASYNCCANCELSUPPORTED
|
||||
? _T("AsyncCancel")
|
||||
: (dpcaps.dwFlags & DPCAPS_ASYNCCANCELALLSUPPORTED
|
||||
? _T("AsyncCancelAll") : _T("")))
|
||||
);
|
||||
}
|
||||
else
|
||||
TRACE(_T("CheckCaps - Async not supported\n"));
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_FreeDirectPlay()
|
||||
// Desc: Wrapper for DirectPlay Close API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_FreeDirectPlay()
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->Close();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_InitDirectPlay()
|
||||
// Desc: Wrapper for DirectPlay Create API. Retrieves a DirectPlay4/4A
|
||||
// interface based on the UNICODE flag
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_InitDirectPlay( VOID* pCon )
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
// Create a DirectPlay4(A) interface
|
||||
#ifdef UNICODE
|
||||
hr = CoCreateInstance( CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay4, (VOID**)&g_pDP );
|
||||
#else
|
||||
hr = CoCreateInstance( CLSID_DirectPlay, NULL, CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlay4A, (VOID**)&g_pDP );
|
||||
#endif
|
||||
if( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
// Initialize w/address
|
||||
if( pCon )
|
||||
{
|
||||
hr = g_pDP->InitializeConnection( pCon, 0 );
|
||||
if( FAILED(hr) )
|
||||
{
|
||||
g_pDP->Release();
|
||||
g_pDP = NULL;
|
||||
return hr;
|
||||
}
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_CreatePlayer()
|
||||
// Desc: Wrapper for DirectPlay CreatePlayer API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_CreatePlayer( DPID* ppidID, TCHAR* strPlayerName, HANDLE hEvent,
|
||||
VOID* pData, DWORD dwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
DPNAME dpname;
|
||||
ZeroMemory( &dpname, sizeof(DPNAME) );
|
||||
dpname.dwSize = sizeof(DPNAME);
|
||||
|
||||
#ifdef UNICODE
|
||||
dpname.lpszShortName = strPlayerName;
|
||||
#else
|
||||
dpname.lpszShortNameA = strPlayerName;
|
||||
#endif
|
||||
|
||||
return g_pDP->CreatePlayer( ppidID, &dpname, hEvent, pData, dwDataSize, 0 );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_CreateSession()
|
||||
// Desc: Wrapper for DirectPlay CreateSession API.Uses the global application
|
||||
// guid.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_CreateSession( TCHAR* strSessionName )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
DPSESSIONDESC2 dpDesc;
|
||||
ZeroMemory( &dpDesc, sizeof(dpDesc) );
|
||||
dpDesc.dwSize = sizeof(dpDesc);
|
||||
dpDesc.dwFlags = DPSESSION_MIGRATEHOST | DPSESSION_KEEPALIVE;
|
||||
if( g_bUseProtocol )
|
||||
dpDesc.dwFlags |= DPSESSION_DIRECTPLAYPROTOCOL;
|
||||
|
||||
#ifdef UNICODE
|
||||
dpDesc.lpszSessionName = strSessionName;
|
||||
#else
|
||||
dpDesc.lpszSessionNameA = strSessionName;
|
||||
#endif
|
||||
|
||||
// Set the application guid
|
||||
dpDesc.guidApplication = g_AppGUID;
|
||||
|
||||
HRESULT hr = g_pDP->Open( &dpDesc, DPOPEN_CREATE );
|
||||
|
||||
// Check for Async message support
|
||||
if( SUCCEEDED(hr) )
|
||||
CheckCaps();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_DestroyPlayer()
|
||||
// Desc: Wrapper for DirectPlay DestroyPlayer API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_DestroyPlayer( DPID pid )
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
if( g_pVoiceClient )
|
||||
{
|
||||
if( FAILED( hr = DPUtil_VoiceDisconnect() ) )
|
||||
return hr;
|
||||
}
|
||||
|
||||
if( g_pVoiceServer )
|
||||
{
|
||||
if( FAILED( hr = DPUtil_VoiceStop() ) )
|
||||
return hr;
|
||||
}
|
||||
|
||||
return g_pDP->DestroyPlayer( pid );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_EnumPlayers()
|
||||
// Desc: Wrapper for DirectPlay API EnumPlayers
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_EnumPlayers( GUID* pSessionGuid,
|
||||
LPDPENUMPLAYERSCALLBACK2 pEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->EnumPlayers( pSessionGuid, pEnumCallback, pContext, dwFlags );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_EnumSessions()
|
||||
// Desc: Wrapper for DirectPlay EnumSessions API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_EnumSessions( DWORD dwTimeout,
|
||||
LPDPENUMSESSIONSCALLBACK2 pEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
DPSESSIONDESC2 dpDesc;
|
||||
ZeroMemory( &dpDesc, sizeof(dpDesc) );
|
||||
dpDesc.dwSize = sizeof(dpDesc);
|
||||
dpDesc.guidApplication = g_AppGUID;
|
||||
|
||||
return g_pDP->EnumSessions( &dpDesc, dwTimeout, pEnumCallback,
|
||||
pContext, dwFlags );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_GetPlayerLocalData()
|
||||
// Desc: Wrapper for DirectPlay GetPlayerData API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_GetPlayerLocalData( DPID pid, VOID* pData, DWORD* pdwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
HRESULT hr = g_pDP->GetPlayerData( pid, pData, pdwDataSize, DPGET_LOCAL );
|
||||
if( FAILED(hr) )
|
||||
TRACE( TEXT("Get Player local data failed for id %d\n"), pid );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_GetSessionDesc()
|
||||
// Desc: Wrapper for DirectPlay GetSessionDesc API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_GetSessionDesc()
|
||||
{
|
||||
DWORD dwSize;
|
||||
HRESULT hr;
|
||||
|
||||
// Free old session desc, if any
|
||||
if( g_pdpsd )
|
||||
free( g_pdpsd );
|
||||
g_pdpsd = NULL;
|
||||
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
// First get the size for the session desc
|
||||
hr = g_pDP->GetSessionDesc( NULL, &dwSize );
|
||||
if( DPERR_BUFFERTOOSMALL == hr )
|
||||
{
|
||||
// Allocate memory for it
|
||||
g_pdpsd = (DPSESSIONDESC2*)malloc( dwSize );
|
||||
if( NULL == g_pdpsd )
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
// Now get the session desc
|
||||
hr = g_pDP->GetSessionDesc( g_pdpsd, &dwSize );
|
||||
}
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_IsDPlayInitialized()
|
||||
// Desc: Returns TRUE if a DirectPlay interface exists, otherwise FALSE.
|
||||
//-----------------------------------------------------------------------------
|
||||
BOOL DPUtil_IsDPlayInitialized()
|
||||
{
|
||||
return( g_pDP ? TRUE : FALSE );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_OpenSession()
|
||||
// Desc: Wrapper for DirectPlay OpenSession API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_OpenSession( GUID* pSessionGUID )
|
||||
{
|
||||
if( NULL == g_pDP)
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
DPSESSIONDESC2 dpDesc;
|
||||
ZeroMemory( &dpDesc, sizeof(dpDesc) );
|
||||
dpDesc.dwSize = sizeof(dpDesc);
|
||||
if( g_bUseProtocol )
|
||||
dpDesc.dwFlags = DPSESSION_DIRECTPLAYPROTOCOL;
|
||||
|
||||
// Set the session guid
|
||||
if( pSessionGUID )
|
||||
dpDesc.guidInstance = (*pSessionGUID);
|
||||
// Set the application guid
|
||||
dpDesc.guidApplication = g_AppGUID;
|
||||
|
||||
// Open it
|
||||
HRESULT hr = g_pDP->Open( &dpDesc, DPOPEN_JOIN );
|
||||
|
||||
// Check for Async message support
|
||||
if( SUCCEEDED(hr) )
|
||||
CheckCaps();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_Receive()
|
||||
// Desc: Wrapper for DirectPlay Receive API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_Receive( DPID* pidFrom, DPID* pidTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD* pdwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
return g_pDP->Receive( pidFrom, pidTo, dwFlags, pData, pdwDataSize );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_Release()
|
||||
// Desc: Wrapper for DirectPlay Release API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_Release()
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
// Free session desc, if any
|
||||
if( g_pdpsd )
|
||||
free( g_pdpsd );
|
||||
g_pdpsd = NULL;
|
||||
|
||||
// Free connection settings structure, if any (lobby stuff)
|
||||
if( g_pDPLConnection )
|
||||
delete[] g_pDPLConnection;
|
||||
g_pDPLConnection = NULL;
|
||||
|
||||
// Release dplay
|
||||
HRESULT hr = g_pDP->Release();
|
||||
g_pDP = NULL;
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_Send()
|
||||
// Desc: Wrapper for DirectPlay Send[Ex] API.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_Send( DPID idFrom, DPID idTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD dwDataSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return DPERR_NOINTERFACE;
|
||||
|
||||
if (dwFlags & DPSEND_ASYNC)
|
||||
// We don't specify a priority or timeout. Would have to check
|
||||
// GetCaps() first to see if they were supported
|
||||
return g_pDP->SendEx( idFrom, idTo, dwFlags, pData, dwDataSize,
|
||||
0, 0, NULL, NULL );
|
||||
else
|
||||
return g_pDP->Send( idFrom, idTo, dwFlags, pData, dwDataSize );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_SetPlayerLocalData()
|
||||
// Desc: Wrapper for DirectPlay SetPlayerData API
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_SetPlayerLocalData( DPID pid, VOID* pData, DWORD dwSize )
|
||||
{
|
||||
if( NULL == g_pDP )
|
||||
return E_FAIL;
|
||||
|
||||
HRESULT hr = g_pDP->SetPlayerData( pid, pData, dwSize, DPSET_LOCAL );
|
||||
if( FAILED(hr) )
|
||||
TRACE( TEXT("Set Player local data failed for id %d\n"), pid );
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_VoiceStart()
|
||||
// Desc: Starts the DirectPlayVoice session
|
||||
// The host player should call this to create the voice session.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_VoiceStart()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if( FAILED( hr = CoCreateInstance( CLSID_DirectPlayVoiceServer, NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlayVoiceServer,
|
||||
(LPVOID*) &g_pVoiceServer ) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = g_pVoiceServer->Initialize( g_pDP, NULL, NULL, 0, 0 ) ) )
|
||||
return hr;
|
||||
|
||||
DVSESSIONDESC dvSessionDesc;
|
||||
ZeroMemory( &dvSessionDesc, sizeof(DVSESSIONDESC) );
|
||||
dvSessionDesc.dwSize = sizeof( DVSESSIONDESC );
|
||||
dvSessionDesc.dwBufferAggressiveness = DVBUFFERAGGRESSIVENESS_DEFAULT;
|
||||
dvSessionDesc.dwBufferQuality = DVBUFFERQUALITY_DEFAULT;
|
||||
dvSessionDesc.dwFlags = 0;
|
||||
dvSessionDesc.dwSessionType = DVSESSIONTYPE_PEER;
|
||||
dvSessionDesc.guidCT = DPVCTGUID_TRUESPEECH;
|
||||
|
||||
if( FAILED( hr = g_pVoiceServer->StartSession( &dvSessionDesc, 0 ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_TestAudioSetup()
|
||||
// Desc: Uses IDirectPlayVoiceSetup to test the voice setup.
|
||||
// All clients should call this once to test the voice audio setup.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_TestAudioSetup( HWND hDlg )
|
||||
{
|
||||
LPDIRECTPLAYVOICETEST pVoiceSetup = NULL;
|
||||
HRESULT hr;
|
||||
|
||||
// Create a DirectPlayVoice setup interface.
|
||||
if( FAILED( hr = CoCreateInstance( CLSID_DirectPlayVoiceTest, NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlayVoiceTest,
|
||||
(LPVOID*) &pVoiceSetup) ) )
|
||||
return hr;
|
||||
|
||||
// Check to see if the audio tests have been run yet
|
||||
hr = pVoiceSetup->CheckAudioSetup( &DSDEVID_DefaultVoicePlayback,
|
||||
&DSDEVID_DefaultVoiceCapture,
|
||||
hDlg, DVFLAGS_QUERYONLY );
|
||||
|
||||
if( hr == DVERR_RUNSETUP )
|
||||
{
|
||||
// Perform the audio tests, since they need to be done before
|
||||
// any of the DPVoice calls will work.
|
||||
hr = pVoiceSetup->CheckAudioSetup( NULL, NULL, hDlg, 0 );
|
||||
}
|
||||
|
||||
if( FAILED(hr) )
|
||||
return hr;
|
||||
|
||||
// Done with setup
|
||||
SAFE_RELEASE( pVoiceSetup );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_VoiceConnect()
|
||||
// Desc: Connects to the DirectPlayVoice session.
|
||||
/// All clients should call this once to join the voice session.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_VoiceConnect()
|
||||
{
|
||||
HRESULT hr;
|
||||
|
||||
if( FAILED( hr = CoCreateInstance( CLSID_DirectPlayVoiceClient, NULL,
|
||||
CLSCTX_INPROC_SERVER,
|
||||
IID_IDirectPlayVoiceClient,
|
||||
(LPVOID*) &g_pVoiceClient ) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = g_pVoiceClient->Initialize( g_pDP, NULL, NULL, 0, 0 ) ) )
|
||||
return hr;
|
||||
|
||||
DVSOUNDDEVICECONFIG dvSoundDeviceConfig;
|
||||
ZeroMemory( &dvSoundDeviceConfig, sizeof(DVSOUNDDEVICECONFIG) );
|
||||
dvSoundDeviceConfig.dwSize = sizeof( DVSOUNDDEVICECONFIG );
|
||||
dvSoundDeviceConfig.dwFlags = 0;
|
||||
dvSoundDeviceConfig.guidPlaybackDevice = DSDEVID_DefaultVoicePlayback;
|
||||
dvSoundDeviceConfig.lpdsPlaybackDevice = NULL;
|
||||
dvSoundDeviceConfig.guidCaptureDevice = DSDEVID_DefaultVoiceCapture;
|
||||
dvSoundDeviceConfig.lpdsCaptureDevice = NULL;
|
||||
dvSoundDeviceConfig.hwndAppWindow = g_hwndMain;
|
||||
dvSoundDeviceConfig.lpdsMainBuffer = NULL;
|
||||
dvSoundDeviceConfig.dwMainBufferFlags = 0;
|
||||
dvSoundDeviceConfig.dwMainBufferPriority = 0;
|
||||
|
||||
DVCLIENTCONFIG dvClientConfig;
|
||||
ZeroMemory( &dvClientConfig, sizeof(DVCLIENTCONFIG) );
|
||||
dvClientConfig.dwSize = sizeof( DVCLIENTCONFIG );
|
||||
dvClientConfig.dwFlags = DVCLIENTCONFIG_AUTOVOICEACTIVATED |
|
||||
DVCLIENTCONFIG_AUTORECORDVOLUME;
|
||||
dvClientConfig.lPlaybackVolume = DVPLAYBACKVOLUME_DEFAULT;
|
||||
dvClientConfig.dwBufferQuality = DVBUFFERQUALITY_DEFAULT;
|
||||
dvClientConfig.dwBufferAggressiveness = DVBUFFERAGGRESSIVENESS_DEFAULT;
|
||||
dvClientConfig.dwThreshold = DVTHRESHOLD_UNUSED;
|
||||
dvClientConfig.lRecordVolume = 0;
|
||||
dvClientConfig.dwNotifyPeriod = 0;
|
||||
|
||||
// Connect to the voice session
|
||||
if( FAILED( hr = g_pVoiceClient->Connect( &dvSoundDeviceConfig,
|
||||
&dvClientConfig,
|
||||
DVFLAGS_SYNC ) ) )
|
||||
return hr;
|
||||
|
||||
// Talk to everyone in the session
|
||||
DVID dvid = DVID_ALLPLAYERS;
|
||||
if( FAILED( hr = g_pVoiceClient->SetTransmitTargets( &dvid, 1, 0 ) ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_VoiceDisconnect()
|
||||
// Desc: Disconnects from the DirectPlayVoice session
|
||||
// All clients should call this once to leave the voice session.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_VoiceDisconnect()
|
||||
{
|
||||
if( g_pVoiceClient )
|
||||
{
|
||||
g_pVoiceClient->Disconnect( DVFLAGS_SYNC );
|
||||
g_pVoiceClient->Release();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DPUtil_VoiceStop()
|
||||
// Desc: Stops the DirectPlayVoice session
|
||||
// The host player should call this once to destroy the voice session.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_VoiceStop()
|
||||
{
|
||||
if( g_pVoiceServer )
|
||||
{
|
||||
g_pVoiceServer->StopSession( 0 );
|
||||
g_pVoiceServer->Release();
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
48
Library/dxx8/samples/Multimedia/Demos/DuelVoice/dputil.h
Normal file
@@ -0,0 +1,48 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: DPUtil.h
|
||||
//
|
||||
// Desc: Communication routines include file
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IDIRECTPLAY2_OR_GREATER
|
||||
#include <dplay.h>
|
||||
#include <dvoice.h>
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DPUtil_FreeDirectPlay();
|
||||
HRESULT DPUtil_InitDirectPlay( VOID* pCon );
|
||||
HRESULT DPUtil_CreatePlayer( DPID* ppidID, LPTSTR pPlayerName, HANDLE hEvent,
|
||||
VOID* pData, DWORD dwDataSize );
|
||||
HRESULT DPUtil_CreateSession( TCHAR* strSessionName );
|
||||
HRESULT DPUtil_DestroyPlayer( DPID pid );
|
||||
HRESULT DPUtil_EnumPlayers( GUID* pSessionGuid,
|
||||
LPDPENUMPLAYERSCALLBACK2 lpEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags );
|
||||
HRESULT DPUtil_EnumSessions( DWORD dwTimeout,
|
||||
LPDPENUMSESSIONSCALLBACK2 lpEnumCallback,
|
||||
VOID* pContext, DWORD dwFlags );
|
||||
HRESULT DPUtil_GetSessionDesc();
|
||||
BOOL DPUtil_IsDPlayInitialized();
|
||||
HRESULT DPUtil_OpenSession( GUID* pSessionGuid );
|
||||
HRESULT DPUtil_Receive( DPID* pidFrom, DPID* pidTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD* pdwDataSize );
|
||||
HRESULT DPUtil_Release();
|
||||
HRESULT DPUtil_Send( DPID idFrom, DPID idTo, DWORD dwFlags, VOID* pData,
|
||||
DWORD dwDataSize );
|
||||
HRESULT DPUtil_SetPlayerLocalData( DPID pid, VOID* pData, DWORD dwSize );
|
||||
HRESULT DPUtil_GetPlayerLocalData( DPID pid, VOID* pData, DWORD* pdwDataSize );
|
||||
|
||||
HRESULT DPUtil_VoiceStart();
|
||||
HRESULT DPUtil_TestAudioSetup( HWND hDlg );
|
||||
HRESULT DPUtil_VoiceConnect();
|
||||
HRESULT DPUtil_VoiceDisconnect();
|
||||
HRESULT DPUtil_VoiceStop();
|
||||
|
||||
|
||||
|
||||
|
||||
512
Library/dxx8/samples/Multimedia/Demos/DuelVoice/dsutil.cpp
Normal file
@@ -0,0 +1,512 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: dsutil.cpp
|
||||
//
|
||||
// Desc: Routines for dealing with sounds from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include <windows.h>
|
||||
#include <mmsystem.h>
|
||||
#include <dsound.h>
|
||||
#include "dsutil.h"
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Defines, constants, and global variables
|
||||
//-----------------------------------------------------------------------------
|
||||
#define SAFE_DELETE(p) { if(p) { delete (p); (p)=NULL; } }
|
||||
#define SAFE_RELEASE(p) { if(p) { (p)->Release(); (p)=NULL; } }
|
||||
|
||||
LPDIRECTSOUND g_pDS = NULL;
|
||||
LPDIRECTSOUND3DLISTENER g_pDSListener = NULL;
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_LoadSoundBuffer()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_LoadSoundBuffer( LPDIRECTSOUND pDS, LPCTSTR strName )
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSB = NULL;
|
||||
DSBUFFERDESC dsbd;
|
||||
BYTE* pbWaveData;
|
||||
|
||||
ZeroMemory( &dsbd, sizeof(dsbd) );
|
||||
dsbd.dwSize = sizeof(dsbd);
|
||||
dsbd.dwFlags = DSBCAPS_STATIC|DSBCAPS_CTRLPAN|DSBCAPS_CTRLVOLUME|
|
||||
DSBCAPS_CTRLFREQUENCY|DSBCAPS_CTRLPOSITIONNOTIFY;
|
||||
|
||||
if( SUCCEEDED( DSUtil_GetWaveResource( NULL, strName, &dsbd.lpwfxFormat,
|
||||
&pbWaveData, &dsbd.dwBufferBytes ) ) )
|
||||
{
|
||||
|
||||
if( SUCCEEDED( pDS->CreateSoundBuffer( &dsbd, &pDSB, NULL ) ) )
|
||||
{
|
||||
if( FAILED( DSUtil_FillSoundBuffer( pDSB, pbWaveData,
|
||||
dsbd.dwBufferBytes ) ) )
|
||||
{
|
||||
pDSB->Release();
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
pDSB = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
return pDSB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_ReloadSoundBuffer()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_ReloadSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, LPCTSTR strName )
|
||||
{
|
||||
BYTE* pbWaveData;
|
||||
DWORD cbWaveSize;
|
||||
|
||||
if( FAILED( DSUtil_GetWaveResource( NULL, strName, NULL, &pbWaveData,
|
||||
&cbWaveSize ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( pDSB->Restore() ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( DSUtil_FillSoundBuffer( pDSB, pbWaveData, cbWaveSize ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_GetWaveResource( HMODULE hModule, LPCTSTR strName,
|
||||
WAVEFORMATEX** ppWaveHeader, BYTE** ppbWaveData,
|
||||
DWORD* pcbWaveSize )
|
||||
{
|
||||
HRSRC hResInfo;
|
||||
HGLOBAL hResData;
|
||||
VOID* pvRes;
|
||||
|
||||
if( NULL == ( hResInfo = FindResource( hModule, strName, TEXT("WAVE") ) ) )
|
||||
{
|
||||
if( NULL == ( hResInfo = FindResource( hModule, strName, TEXT("WAV") ) ) )
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
if( NULL == ( hResData = LoadResource( hModule, hResInfo ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( NULL == ( pvRes = LockResource( hResData ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( DSUtil_ParseWaveResource( pvRes, ppWaveHeader, ppbWaveData,
|
||||
pcbWaveSize ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
SoundObject* DSUtil_CreateSound( LPCTSTR strName, DWORD dwNumConcurrentBuffers )
|
||||
{
|
||||
SoundObject* pSound = NULL;
|
||||
LPWAVEFORMATEX pWaveHeader;
|
||||
BYTE* pbData;
|
||||
DWORD cbData;
|
||||
|
||||
if( NULL == g_pDS )
|
||||
return NULL;
|
||||
|
||||
if( dwNumConcurrentBuffers < 1 )
|
||||
dwNumConcurrentBuffers = 1;
|
||||
|
||||
if( SUCCEEDED( DSUtil_GetWaveResource( NULL, strName, &pWaveHeader,
|
||||
&pbData, &cbData ) ) )
|
||||
{
|
||||
pSound = new SoundObject;
|
||||
pSound->dwNumBuffers = dwNumConcurrentBuffers;
|
||||
pSound->pbWaveData = pbData;
|
||||
pSound->cbWaveSize = cbData;
|
||||
pSound->dwCurrent = 0;
|
||||
pSound->pdsbBuffers = new LPDIRECTSOUNDBUFFER[dwNumConcurrentBuffers+1];
|
||||
|
||||
pSound->pdsbBuffers[0] = DSUtil_LoadSoundBuffer( g_pDS, strName );
|
||||
|
||||
for( DWORD i=1; i<pSound->dwNumBuffers; i++ )
|
||||
{
|
||||
if( FAILED( g_pDS->DuplicateSoundBuffer( pSound->pdsbBuffers[0],
|
||||
&pSound->pdsbBuffers[i] ) ) )
|
||||
{
|
||||
pSound->pdsbBuffers[i] = DSUtil_LoadSoundBuffer( g_pDS, strName );
|
||||
if( NULL == pSound->pdsbBuffers[i] )
|
||||
{
|
||||
DSUtil_DestroySound( pSound );
|
||||
pSound = NULL;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pSound;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_DestroySound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_DestroySound( SoundObject* pSound )
|
||||
{
|
||||
if( pSound )
|
||||
{
|
||||
for( DWORD i=0; i<pSound->dwNumBuffers; i++ )
|
||||
{
|
||||
if( pSound->pdsbBuffers[i] )
|
||||
pSound->pdsbBuffers[i]->Release();
|
||||
}
|
||||
|
||||
delete pSound->pdsbBuffers;
|
||||
delete pSound;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_GetFreeSoundBuffer( SoundObject* pSound )
|
||||
{
|
||||
HRESULT hr;
|
||||
DWORD dwStatus;
|
||||
|
||||
if( NULL == pSound )
|
||||
return NULL;
|
||||
|
||||
LPDIRECTSOUNDBUFFER pDSB = pSound->pdsbBuffers[pSound->dwCurrent];
|
||||
if( NULL == pDSB )
|
||||
return NULL;
|
||||
|
||||
hr = pDSB->GetStatus( &dwStatus );
|
||||
if( FAILED(hr) )
|
||||
dwStatus = 0;
|
||||
|
||||
if( dwStatus & DSBSTATUS_PLAYING )
|
||||
{
|
||||
if( pSound->dwNumBuffers <= 1 )
|
||||
return NULL;
|
||||
|
||||
if( ++pSound->dwCurrent >= pSound->dwNumBuffers )
|
||||
pSound->dwCurrent = 0;
|
||||
|
||||
pDSB = pSound->pdsbBuffers[pSound->dwCurrent];
|
||||
|
||||
hr = pDSB->GetStatus( &dwStatus);
|
||||
if( FAILED(hr) )
|
||||
dwStatus = 0;
|
||||
|
||||
if( dwStatus & DSBSTATUS_PLAYING )
|
||||
{
|
||||
pDSB->Stop();
|
||||
pDSB->SetCurrentPosition( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
if( dwStatus & DSBSTATUS_BUFFERLOST )
|
||||
{
|
||||
if( FAILED( pDSB->Restore() ) )
|
||||
return NULL;
|
||||
|
||||
if( FAILED( DSUtil_FillSoundBuffer( pDSB, pSound->pbWaveData,
|
||||
pSound->cbWaveSize ) ) )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return pDSB;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlaySound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_PlaySound( SoundObject* pSound, DWORD dwPlayFlags )
|
||||
{
|
||||
if( NULL == pSound )
|
||||
return E_FAIL;
|
||||
|
||||
if( !(dwPlayFlags & DSBPLAY_LOOPING) || (pSound->dwNumBuffers == 1) )
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSB = DSUtil_GetFreeSoundBuffer( pSound );
|
||||
if( pDSB )
|
||||
{
|
||||
if( SUCCEEDED( pDSB->Play( 0, 0, dwPlayFlags ) ) )
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_StopSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_StopSound( SoundObject* pSound )
|
||||
{
|
||||
if( NULL == pSound )
|
||||
return E_FAIL;
|
||||
|
||||
for( DWORD i=0; i<pSound->dwNumBuffers; i++ )
|
||||
{
|
||||
pSound->pdsbBuffers[i]->Stop();
|
||||
pSound->pdsbBuffers[i]->SetCurrentPosition( 0 );
|
||||
}
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_FillSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, BYTE* pbWaveData,
|
||||
DWORD dwWaveSize )
|
||||
{
|
||||
VOID* pMem1;
|
||||
VOID* pMem2;
|
||||
DWORD dwSize1;
|
||||
DWORD dwSize2;
|
||||
|
||||
if( NULL == pDSB || NULL == pbWaveData || 0 == dwWaveSize )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( pDSB->Lock( 0, dwWaveSize, &pMem1, &dwSize1, &pMem2,
|
||||
&dwSize2, 0 ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( 0 != dwSize1 ) CopyMemory( pMem1, pbWaveData, dwSize1 );
|
||||
if( 0 != dwSize2 ) CopyMemory( pMem2, pbWaveData+dwSize1, dwSize2 );
|
||||
|
||||
pDSB->Unlock( pMem1, dwSize1, pMem2, dwSize2);
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name:
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_ParseWaveResource( VOID* pvRes, WAVEFORMATEX** ppWaveHeader,
|
||||
BYTE** ppbWaveData, DWORD* pcbWaveSize )
|
||||
{
|
||||
DWORD* pdw;
|
||||
DWORD* pdwEnd;
|
||||
DWORD dwRiff;
|
||||
DWORD dwType;
|
||||
DWORD dwLength;
|
||||
|
||||
if( ppWaveHeader )
|
||||
*ppWaveHeader = NULL;
|
||||
|
||||
if( ppbWaveData )
|
||||
*ppbWaveData = NULL;
|
||||
|
||||
if( pcbWaveSize )
|
||||
*pcbWaveSize = 0;
|
||||
|
||||
pdw = (DWORD*)pvRes;
|
||||
dwRiff = *pdw++;
|
||||
dwLength = *pdw++;
|
||||
dwType = *pdw++;
|
||||
|
||||
if( dwRiff != mmioFOURCC('R', 'I', 'F', 'F') )
|
||||
return E_FAIL;
|
||||
|
||||
if( dwType != mmioFOURCC('W', 'A', 'V', 'E') )
|
||||
return E_FAIL;
|
||||
|
||||
pdwEnd = (DWORD *)((BYTE *)pdw + dwLength-4);
|
||||
|
||||
while( pdw < pdwEnd )
|
||||
{
|
||||
dwType = *pdw++;
|
||||
dwLength = *pdw++;
|
||||
|
||||
if( dwType == mmioFOURCC('f', 'm', 't', ' ') )
|
||||
{
|
||||
if (ppWaveHeader && !*ppWaveHeader)
|
||||
{
|
||||
if( dwLength < sizeof(WAVEFORMAT) )
|
||||
return E_FAIL;
|
||||
|
||||
*ppWaveHeader = (WAVEFORMATEX*)pdw;
|
||||
|
||||
if( (!ppbWaveData || *ppbWaveData) &&
|
||||
(!pcbWaveSize || *pcbWaveSize) )
|
||||
{
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( dwType == mmioFOURCC('d', 'a', 't', 'a') )
|
||||
{
|
||||
if( (ppbWaveData && !*ppbWaveData) ||
|
||||
(pcbWaveSize && !*pcbWaveSize) )
|
||||
{
|
||||
if( ppbWaveData )
|
||||
*ppbWaveData = (BYTE*)pdw;
|
||||
|
||||
if( pcbWaveSize )
|
||||
*pcbWaveSize = dwLength;
|
||||
|
||||
if( !ppWaveHeader || *ppWaveHeader )
|
||||
return S_OK;
|
||||
}
|
||||
}
|
||||
|
||||
pdw = (DWORD*)( (BYTE*)pdw + ((dwLength+1)&~1) );
|
||||
}
|
||||
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlayPannedSound()
|
||||
// Desc: Play a sound, but first set the panning according to where the
|
||||
// object is on the screen. fScreenXPos is between -1.0f (left) and
|
||||
// 1.0f (right).
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_PlayPannedSound( SoundObject* pSound, FLOAT fScreenXPos )
|
||||
{
|
||||
LPDIRECTSOUNDBUFFER pDSB = DSUtil_GetFreeSoundBuffer( pSound );
|
||||
|
||||
if( pDSB )
|
||||
{
|
||||
pDSB->SetPan( (LONG)( 10000L * fScreenXPos ) );
|
||||
pDSB->Play( 0, 0, 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_InitDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_InitDirectSound( HWND hWnd )
|
||||
{
|
||||
if( FAILED( DirectSoundCreate( NULL, &g_pDS, NULL ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( g_pDS->SetCooperativeLevel( hWnd, DSSCL_PRIORITY ) ) )
|
||||
{
|
||||
g_pDS->Release();
|
||||
g_pDS = NULL;
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
HRESULT hr;
|
||||
LPDIRECTSOUNDBUFFER pDSBPrimary = NULL;
|
||||
|
||||
// Get the primary buffer
|
||||
DSBUFFERDESC dsbd;
|
||||
ZeroMemory( &dsbd, sizeof(DSBUFFERDESC) );
|
||||
dsbd.dwSize = sizeof(DSBUFFERDESC);
|
||||
dsbd.dwFlags = DSBCAPS_PRIMARYBUFFER | DSBCAPS_CTRL3D;
|
||||
dsbd.dwBufferBytes = 0;
|
||||
dsbd.lpwfxFormat = NULL;
|
||||
|
||||
if( FAILED( hr = g_pDS->CreateSoundBuffer( &dsbd, &pDSBPrimary, NULL ) ) )
|
||||
return hr;
|
||||
|
||||
WAVEFORMATEX wfx;
|
||||
ZeroMemory( &wfx, sizeof(WAVEFORMATEX) );
|
||||
wfx.wFormatTag = WAVE_FORMAT_PCM;
|
||||
wfx.nChannels = 2;
|
||||
wfx.nSamplesPerSec = 22050;
|
||||
wfx.wBitsPerSample = 16;
|
||||
wfx.nBlockAlign = wfx.wBitsPerSample / 8 * wfx.nChannels;
|
||||
wfx.nAvgBytesPerSec = wfx.nSamplesPerSec * wfx.nBlockAlign;
|
||||
|
||||
if( FAILED( hr = pDSBPrimary->SetFormat(&wfx) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = pDSBPrimary->QueryInterface( IID_IDirectSound3DListener,
|
||||
(VOID**)&g_pDSListener ) ) )
|
||||
return hr;
|
||||
|
||||
SAFE_RELEASE( pDSBPrimary );
|
||||
|
||||
if( FAILED( hr = g_pDSListener->SetPosition( 0.f, 0.f, -1.f, DS3D_DEFERRED ) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = g_pDSListener->SetDopplerFactor( 9.9f ,DS3D_DEFERRED ) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = g_pDSListener->SetRolloffFactor( 0.25f ,DS3D_DEFERRED ) ) )
|
||||
return hr;
|
||||
|
||||
if( FAILED( hr = g_pDSListener->CommitDeferredSettings() ) )
|
||||
return hr;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_FreeDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_FreeDirectSound()
|
||||
{
|
||||
SAFE_RELEASE( g_pDSListener );
|
||||
SAFE_RELEASE( g_pDS );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
152
Library/dxx8/samples/Multimedia/Demos/DuelVoice/dsutil.h
Normal file
@@ -0,0 +1,152 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: dsutil.cpp
|
||||
//
|
||||
// Desc: Routines for dealing with sounds from resources
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DSUTIL_H
|
||||
#define DSUTIL_H
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Helper routines
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_FillSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, BYTE* pbWaveData,
|
||||
DWORD dwWaveSize );
|
||||
HRESULT DSUtil_ParseWaveResource( VOID* pvRes, WAVEFORMATEX** ppWaveHeader,
|
||||
BYTE** ppbWaveData, DWORD* pdwWaveSize );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_LoadSoundBuffer()
|
||||
// Desc: Loads an IDirectSoundBuffer from a Win32 resource in the current
|
||||
// application.
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_LoadSoundBuffer( LPDIRECTSOUND* pDS,
|
||||
LPCTSTR strName );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_ReloadSoundBuffer()
|
||||
// Desc: Reloads an IDirectSoundBuffer from a Win32 resource in the current
|
||||
// application. normally used to handle a DSERR_BUFFERLOST error.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_ReloadSoundBuffer( LPDIRECTSOUNDBUFFER pDSB, LPCTSTR strName );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_GetWaveResource()
|
||||
// Desc: Finds a WAV resource in a Win32 module.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_GetWaveResource( HMODULE hModule, LPCTSTR strName,
|
||||
WAVEFORMATEX** ppWaveHeader, BYTE** ppbWaveData,
|
||||
DWORD* pdwWaveSize );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_InitDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_InitDirectSound( HWND hWnd );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_FreeDirectSound()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_FreeDirectSound();
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: struct SoundObject
|
||||
// Desc: Used to manage individual sounds which need to be played multiple
|
||||
// times concurrently. A SoundObject represents a queue of
|
||||
// IDirectSoundBuffer objects which all refer to the same buffer memory.
|
||||
//-----------------------------------------------------------------------------
|
||||
struct SoundObject
|
||||
{
|
||||
BYTE* pbWaveData; // Ptr into wave resource (for restore)
|
||||
DWORD cbWaveSize; // Size of wave data (for restore)
|
||||
DWORD dwNumBuffers; // Number of sound buffers.
|
||||
DWORD dwCurrent; // Current sound buffer
|
||||
LPDIRECTSOUNDBUFFER* pdsbBuffers; // List of sound buffers
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_CreateSound()
|
||||
// Desc: Loads a SoundObject from a Win32 resource in the current application.
|
||||
//-----------------------------------------------------------------------------
|
||||
SoundObject* DSUtil_CreateSound( LPCTSTR strName, DWORD dwNumBuffers );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_DestroySound()
|
||||
// Desc: Frees a SoundObject and releases all of its buffers.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_DestroySound( SoundObject* pSound );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlayPannedSound()
|
||||
// Desc: Play a sound, but first set the panning according to where the
|
||||
// object is on the screen. fScreenXPos is between -1.0f (left) and
|
||||
// 1.0f (right).
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DSUtil_PlayPannedSound( SoundObject* pSound, FLOAT fScreenXPos );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_PlaySound()
|
||||
// Desc: Plays a buffer in a SoundObject.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_PlaySound( SoundObject* pSound, DWORD dwPlayFlags );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_StopSound()
|
||||
// Desc: Stops one or more buffers in a SoundObject.
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT DSUtil_StopSound( SoundObject* pSound );
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DSUtil_GetFreeSoundBuffer()
|
||||
// Desc: Returns one of the cloned buffers that is not currently playing
|
||||
//-----------------------------------------------------------------------------
|
||||
LPDIRECTSOUNDBUFFER DSUtil_GetFreeSoundBuffer( SoundObject* pSound );
|
||||
|
||||
|
||||
|
||||
|
||||
#endif // DSUTIL_H
|
||||
|
||||
|
||||
|
||||
690
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duel.001
Normal file
@@ -0,0 +1,690 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=duel - Win32 Debug
|
||||
!MESSAGE No configuration specified. Defaulting to duel - Win32 Debug.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "duel - Win32 Release" && "$(CFG)" != "duel - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE on this makefile
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duel.mak" CFG="duel - Win32 Debug"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "duel - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "duel - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
################################################################################
|
||||
# Begin Project
|
||||
# PROP Target_Last_Scanned "duel - Win32 Debug"
|
||||
MTL=mktyplib.exe
|
||||
CPP=cl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir "Release"
|
||||
# PROP BASE Intermediate_Dir "Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir "Release"
|
||||
# PROP Intermediate_Dir "Release"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
|
||||
ALL : "$(OUTDIR)\duel.exe"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.res"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\wizard.obj"
|
||||
-@erase "$(OUTDIR)\duel.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS"\
|
||||
/Fp"$(INTDIR)/duel.pch" /YX /Fo"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Release/
|
||||
CPP_SBRS=.\.
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/duel.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/duel.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib dinput.lib dsound.lib /nologo /subsystem:windows /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib\
|
||||
dinput.lib dsound.lib /nologo /subsystem:windows /incremental:no\
|
||||
/pdb:"$(OUTDIR)/duel.pdb" /machine:I386 /out:"$(OUTDIR)/duel.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\duel.res" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\wizard.obj"
|
||||
|
||||
"$(OUTDIR)\duel.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir "Debug"
|
||||
# PROP BASE Intermediate_Dir "Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir "Debug"
|
||||
# PROP Intermediate_Dir "Debug"
|
||||
# PROP Target_Dir ""
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
|
||||
ALL : "$(OUTDIR)\duel.exe" "$(OUTDIR)\duel.bsc"
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\ddutil.sbr"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.sbr"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dputil.sbr"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.sbr"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.res"
|
||||
-@erase "$(INTDIR)\duel.sbr"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gameproc.sbr"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\gfx.sbr"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\lobby.sbr"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\util.sbr"
|
||||
-@erase "$(INTDIR)\vc40.idb"
|
||||
-@erase "$(INTDIR)\vc40.pdb"
|
||||
-@erase "$(INTDIR)\wizard.obj"
|
||||
-@erase "$(INTDIR)\wizard.sbr"
|
||||
-@erase "$(OUTDIR)\duel.bsc"
|
||||
-@erase "$(OUTDIR)\duel.exe"
|
||||
-@erase "$(OUTDIR)\duel.ilk"
|
||||
-@erase "$(OUTDIR)\duel.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /c
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS"\
|
||||
/FR"$(INTDIR)/" /Fp"$(INTDIR)/duel.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
|
||||
CPP_OBJS=.\Debug/
|
||||
CPP_SBRS=.\Debug/
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /win32
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)/duel.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)/duel.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\ddutil.sbr" \
|
||||
"$(INTDIR)\diutil.sbr" \
|
||||
"$(INTDIR)\dputil.sbr" \
|
||||
"$(INTDIR)\dsutil.sbr" \
|
||||
"$(INTDIR)\duel.sbr" \
|
||||
"$(INTDIR)\gameproc.sbr" \
|
||||
"$(INTDIR)\gfx.sbr" \
|
||||
"$(INTDIR)\lobby.sbr" \
|
||||
"$(INTDIR)\util.sbr" \
|
||||
"$(INTDIR)\wizard.sbr"
|
||||
|
||||
"$(OUTDIR)\duel.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib dinput.lib dsound.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib ole32.lib comdlg32.lib\
|
||||
advapi32.lib shell32.lib uuid.lib comctl32.lib winmm.lib dplayx.lib ddraw.lib\
|
||||
dinput.lib dsound.lib /nologo /subsystem:windows /incremental:yes\
|
||||
/pdb:"$(OUTDIR)/duel.pdb" /debug /machine:I386 /out:"$(OUTDIR)/duel.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\duel.res" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\wizard.obj"
|
||||
|
||||
"$(OUTDIR)\duel.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
.c{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_OBJS)}.obj:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.c{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cpp{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
.cxx{$(CPP_SBRS)}.sbr:
|
||||
$(CPP) $(CPP_PROJ) $<
|
||||
|
||||
################################################################################
|
||||
# Begin Target
|
||||
|
||||
# Name "duel - Win32 Release"
|
||||
# Name "duel - Win32 Debug"
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wizard.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.cpp
|
||||
DEP_CPP_DIUTI=\
|
||||
".\diutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\diutil.sbr" : $(SOURCE) $(DEP_CPP_DIUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.cpp
|
||||
DEP_CPP_DPUTI=\
|
||||
".\dputil.h"\
|
||||
".\duel.h"\
|
||||
".\lobby.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\dputil.sbr" : $(SOURCE) $(DEP_CPP_DPUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.cpp
|
||||
DEP_CPP_DSUTI=\
|
||||
".\dsutil.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\dsutil.sbr" : $(SOURCE) $(DEP_CPP_DSUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.cpp
|
||||
DEP_CPP_DUEL_=\
|
||||
".\diutil.h"\
|
||||
".\dputil.h"\
|
||||
".\dsutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\gfx.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\duel.sbr" : $(SOURCE) $(DEP_CPP_DUEL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.rc
|
||||
DEP_RSC_DUEL_R=\
|
||||
".\Bfire.wav"\
|
||||
".\csession.bmp"\
|
||||
".\DUEL.BMP"\
|
||||
".\duel.ico"\
|
||||
".\Lboom.wav"\
|
||||
".\osession.bmp"\
|
||||
".\player.bmp"\
|
||||
".\Sboom.wav"\
|
||||
".\Sbounce.wav"\
|
||||
".\Sengine.wav"\
|
||||
".\SPLASH.BMP"\
|
||||
".\Sstart.wav"\
|
||||
".\Sstop.wav"\
|
||||
".\verinfo.h"\
|
||||
".\verinfo.ver"\
|
||||
|
||||
|
||||
"$(INTDIR)\duel.res" : $(SOURCE) $(DEP_RSC_DUEL_R) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.cpp
|
||||
DEP_CPP_GAMEP=\
|
||||
".\diutil.h"\
|
||||
".\dputil.h"\
|
||||
".\dsutil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\gfx.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\gameproc.sbr" : $(SOURCE) $(DEP_CPP_GAMEP) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.cpp
|
||||
DEP_CPP_GFX_C=\
|
||||
".\ddutil.h"\
|
||||
".\diutil.h"\
|
||||
".\duel.h"\
|
||||
".\gfx.h"\
|
||||
{$(INCLUDE)}"\Dinput.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\gfx.sbr" : $(SOURCE) $(DEP_CPP_GFX_C) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.cpp
|
||||
DEP_CPP_LOBBY=\
|
||||
".\duel.h"\
|
||||
".\lobby.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\lobby.sbr" : $(SOURCE) $(DEP_CPP_LOBBY) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
DEP_CPP_UTIL_=\
|
||||
".\duel.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\util.sbr" : $(SOURCE) $(DEP_CPP_UTIL_) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\wizard.cpp
|
||||
DEP_CPP_WIZAR=\
|
||||
".\dputil.h"\
|
||||
".\duel.h"\
|
||||
".\gameproc.h"\
|
||||
".\lobby.h"\
|
||||
".\wizard.h"\
|
||||
{$(INCLUDE)}"\dplobby.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\wizard.obj" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\wizard.obj" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\wizard.sbr" : $(SOURCE) $(DEP_CPP_WIZAR) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
################################################################################
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.cpp
|
||||
DEP_CPP_DDUTI=\
|
||||
".\ddutil.h"\
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duel - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duel - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
"$(INTDIR)\ddutil.sbr" : $(SOURCE) $(DEP_CPP_DDUTI) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
################################################################################
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duel.bmp
Normal file
|
After Width: | Height: | Size: 166 KiB |
533
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duel.cpp
Normal file
@@ -0,0 +1,533 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Duel.cpp
|
||||
//
|
||||
// Desc: Multi-player game
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#include "duel.h"
|
||||
#include "gameproc.h"
|
||||
#include "gfx.h"
|
||||
#include "DPUtil.h"
|
||||
#include "diutil.h"
|
||||
#include "dsutil.h"
|
||||
#include "lobby.h"
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Globals
|
||||
//-----------------------------------------------------------------------------
|
||||
// This GUID allows DirectPlay to find other instances of the same game on
|
||||
// the network. So it must be unique for every game, and the same for
|
||||
// every instance of that game. // {88789F50-0BDB-43b4-AF06-F951EC05D6CE}
|
||||
GUID g_AppGUID = { 0x88789f50, 0xbdb, 0x43b4, { 0xaf, 0x6, 0xf9, 0x51, 0xec, 0x5, 0xd6, 0xce } };
|
||||
|
||||
extern DWORD g_dwFrameCount;
|
||||
extern DWORD g_dwFrameTime;
|
||||
extern int g_nProgramState;
|
||||
extern SHIP g_OurShip;
|
||||
extern DPID g_LocalPlayerDPID;
|
||||
|
||||
static BOOL g_bReinitialize; // Used for switching display modes
|
||||
|
||||
TCHAR g_strAppName[256] = "Duel"; // The name of the sample
|
||||
HANDLE g_hDPMessageEvent = NULL; // Not used in this sample, needed for DPConnect.cpp
|
||||
TCHAR g_strLocalPlayerName[MAX_PLAYER_NAME]; // Local player name
|
||||
TCHAR g_strSessionName[MAX_SESSION_NAME]; // Default session name
|
||||
TCHAR g_strPreferredProvider[MAX_SESSION_NAME]; // Default preferred provider
|
||||
|
||||
LPDPLCONNECTION g_pDPLConnection = NULL;
|
||||
LPDIRECTPLAYLOBBY3 g_pDPLobby = NULL;
|
||||
|
||||
HWND g_hwndMain; // Main application window handle
|
||||
HKEY g_hDuelKey = NULL; // Duel registry key handle
|
||||
HINSTANCE g_hInst; // Application instance handle
|
||||
BOOL g_bShowFrameCount=TRUE; // Show FPS ?
|
||||
BOOL g_bIsActive; // Is the application active ?
|
||||
BOOL g_bHostPlayer; // Are we hosting or joining a game
|
||||
DWORD g_dwKeys; // User keyboard input
|
||||
DWORD g_dwOldKeys; // Last frame's keyboard input
|
||||
BOOL g_bFullscreen=FALSE; // Window or FullScreen mode ?
|
||||
RECT g_rcWindow; // client rectangle of main window
|
||||
BOOL g_bReliable; // sends are reliable
|
||||
BOOL g_bAsync; // asynchronous sends
|
||||
BOOL g_bAsyncSupported; // asynchronous sends supported
|
||||
BOOL g_bUseProtocol; // DirectPlay Protocol messaging
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Function prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
extern int DPConnect_StartDirectPlayConnect( HINSTANCE hInst, BOOL bBackTrack = FALSE );
|
||||
extern HRESULT DPConnect_CheckForLobbyLaunch( BOOL* pbLaunchedByLobby );
|
||||
|
||||
LRESULT CALLBACK MainWndproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam );
|
||||
HRESULT InitApplication( HINSTANCE hInst );
|
||||
HRESULT ReadRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue, DWORD dwLength, TCHAR* strDefault );
|
||||
HRESULT WriteRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue );
|
||||
VOID CleanupApplication();
|
||||
BOOL WasLaunchedByLobby();
|
||||
BOOL FinishLobbyLaunch();
|
||||
VOID DoHelp();
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WinMain()
|
||||
// Desc:
|
||||
//-----------------------------------------------------------------------------
|
||||
int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int )
|
||||
{
|
||||
MSG msg;
|
||||
BOOL bLaunchedByLobby;
|
||||
HRESULT hr;
|
||||
|
||||
g_hInst = hInstance;
|
||||
|
||||
// Read information from registry
|
||||
RegCreateKeyEx( HKEY_CURRENT_USER, DUEL_KEY, 0, NULL,
|
||||
REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, NULL,
|
||||
&g_hDuelKey, NULL );
|
||||
|
||||
ReadRegKey( g_hDuelKey, "Player Name",
|
||||
g_strLocalPlayerName, MAX_PLAYER_NAME, "" );
|
||||
ReadRegKey( g_hDuelKey, "Session Name",
|
||||
g_strSessionName, MAX_SESSION_NAME, "" );
|
||||
ReadRegKey( g_hDuelKey, "Preferred Provider",
|
||||
g_strPreferredProvider, MAX_SESSION_NAME, "" );
|
||||
|
||||
CoInitialize( NULL );
|
||||
|
||||
if( FAILED( InitApplication( hInstance ) ) )
|
||||
return 0;
|
||||
|
||||
// See if we were launched from a lobby server
|
||||
hr = DPConnect_CheckForLobbyLaunch( &bLaunchedByLobby );
|
||||
if( FAILED(hr) )
|
||||
return 1;
|
||||
|
||||
if( bLaunchedByLobby )
|
||||
{
|
||||
// Start game
|
||||
PostMessage( g_hwndMain, UM_LAUNCH, 0, 0 );
|
||||
g_bIsActive = TRUE;
|
||||
}
|
||||
|
||||
g_dwFrameTime = timeGetTime();
|
||||
|
||||
while( TRUE )
|
||||
{
|
||||
if( g_bIsActive )
|
||||
{
|
||||
// Any windows messages ? (returns immediately)
|
||||
if( PeekMessage( &msg, NULL, 0, 0, PM_NOREMOVE ) )
|
||||
{
|
||||
if( !GetMessage( &msg, NULL, 0, 0 ) )
|
||||
break;
|
||||
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Poll our receive queue. Polling is used in the sample only for simplicity.
|
||||
// Receiving messages using an event is the recommended way.
|
||||
if( g_nProgramState != PS_SPLASH )
|
||||
{
|
||||
ReceiveMessages();
|
||||
LobbyMessageReceive(LMR_PROPERTIES);
|
||||
}
|
||||
|
||||
// update screen
|
||||
if( !UpdateFrame() )
|
||||
ExitGame(); // posts QUIT msg
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Any windows messages ? (blocks until a message arrives)
|
||||
if( !GetMessage( &msg, NULL, 0, 0 ) )
|
||||
break;
|
||||
|
||||
TranslateMessage( &msg );
|
||||
DispatchMessage( &msg );
|
||||
}
|
||||
}
|
||||
|
||||
CoUninitialize();
|
||||
|
||||
// Write information to the registry
|
||||
WriteRegKey( g_hDuelKey, "Player Name", g_strLocalPlayerName );
|
||||
WriteRegKey( g_hDuelKey, "Session Name", g_strSessionName );
|
||||
WriteRegKey( g_hDuelKey, "Preferred Provider", g_strPreferredProvider );
|
||||
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: MainWndproc()
|
||||
// Desc: Callback for all Windows messages
|
||||
//-----------------------------------------------------------------------------
|
||||
LRESULT CALLBACK MainWndproc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
|
||||
{
|
||||
PAINTSTRUCT ps;
|
||||
HDC hdc;
|
||||
|
||||
switch( msg )
|
||||
{
|
||||
case WM_SIZE:
|
||||
case WM_MOVE:
|
||||
// Get the client rectangle
|
||||
if( g_bFullscreen )
|
||||
{
|
||||
SetRect( &g_rcWindow, 0, 0, GetSystemMetrics(SM_CXSCREEN),
|
||||
GetSystemMetrics(SM_CYSCREEN) );
|
||||
}
|
||||
else
|
||||
{
|
||||
GetClientRect( hWnd, &g_rcWindow );
|
||||
ClientToScreen( hWnd, (POINT*)&g_rcWindow );
|
||||
ClientToScreen( hWnd, (POINT*)&g_rcWindow+1 );
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_ACTIVATE:
|
||||
// Ignore this message during reinitializing graphics
|
||||
if( g_bReinitialize )
|
||||
return 0;
|
||||
|
||||
// When we are deactivated, although we don't update our screen, we
|
||||
// still need to to empty our receive queue periodically as
|
||||
// messages will pile up otherwise. Polling the receive queue
|
||||
// continuously even when we are deactivated causes our app to
|
||||
// consume all the CPU time. To avoid hogging the CPU, we block on
|
||||
// GetMessage() WIN API and setup a timer to wake ourselves up at
|
||||
// regular intervals to process our messages.
|
||||
|
||||
if( LOWORD(wParam) == WA_INACTIVE )
|
||||
{
|
||||
// Aeactivated
|
||||
g_bIsActive = FALSE;
|
||||
if( PS_ACTIVE == g_nProgramState )
|
||||
SetTimer( hWnd, RECEIVE_TIMER_ID, RECEIVE_TIMEOUT, NULL );
|
||||
}
|
||||
else
|
||||
{
|
||||
// Activated
|
||||
g_bIsActive = TRUE;
|
||||
if( PS_ACTIVE == g_nProgramState )
|
||||
KillTimer( hWnd, RECEIVE_TIMER_ID );
|
||||
}
|
||||
|
||||
// set game palette, if activated in game mode
|
||||
if( g_bIsActive && (g_nProgramState != PS_SPLASH) )
|
||||
SetGamePalette();
|
||||
|
||||
DIUtil_ReacquireInputDevices();
|
||||
|
||||
return 0;
|
||||
|
||||
case WM_CREATE:
|
||||
break;
|
||||
|
||||
case WM_SYSKEYUP:
|
||||
switch( wParam )
|
||||
{
|
||||
// Handle ALT+ENTER (fullscreen/window mode)
|
||||
case VK_RETURN:
|
||||
// Mode switch is allowed only during the game
|
||||
if( g_nProgramState == PS_ACTIVE )
|
||||
{
|
||||
g_bReinitialize = TRUE;
|
||||
ReleaseLocalData(); //only sound buffers have to be rels'd anyway.
|
||||
CleanupGameSounds();
|
||||
DIUtil_CleanupInput();
|
||||
CleanupGraphics();
|
||||
DestroyWindow( g_hwndMain );
|
||||
g_bFullscreen = !g_bFullscreen;
|
||||
InitGraphics();
|
||||
DIUtil_InitInput( g_hwndMain );
|
||||
InitializeGameSounds();
|
||||
InitLocalSoundData();
|
||||
g_bReinitialize = FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_KEYDOWN:
|
||||
switch( wParam )
|
||||
{
|
||||
case 'a':
|
||||
case 'A':
|
||||
// Toggle Async sends on/off
|
||||
if( g_bAsyncSupported )
|
||||
{
|
||||
g_bAsync = !g_bAsync;
|
||||
UpdateTitle(); // caption bar status
|
||||
}
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
case 'R':
|
||||
// Toggle reliable sends
|
||||
g_bReliable = !g_bReliable;
|
||||
UpdateTitle();
|
||||
break;
|
||||
|
||||
case VK_F1:
|
||||
// Display help
|
||||
DoHelp();
|
||||
break;
|
||||
|
||||
case VK_F5:
|
||||
// Toggle frame rate display
|
||||
g_bShowFrameCount = !g_bShowFrameCount;
|
||||
if( g_bShowFrameCount )
|
||||
{
|
||||
g_dwFrameCount = 0;
|
||||
g_dwFrameTime = timeGetTime();
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_RETURN:
|
||||
// Launch game setup wizard
|
||||
if( (g_nProgramState == PS_SPLASH) && !g_bFullscreen )
|
||||
{
|
||||
int nExitCode;
|
||||
nExitCode = DPConnect_StartDirectPlayConnect( g_hInst, FALSE );
|
||||
|
||||
// Figure out what happened, and post a reflecting message
|
||||
if( nExitCode == EXITCODE_FORWARD )
|
||||
PostMessage(g_hwndMain, UM_LAUNCH, 0, 0);
|
||||
|
||||
if( nExitCode == EXITCODE_QUIT )
|
||||
PostMessage(g_hwndMain, UM_ABORT, 0, 0);
|
||||
|
||||
if( nExitCode == EXITCODE_LOBBYCONNECT )
|
||||
PostMessage( g_hwndMain, UM_LAUNCH, 0, 0 );
|
||||
|
||||
if( nExitCode == EXITCODE_ERROR )
|
||||
{
|
||||
MessageBox( g_hwndMain, TEXT("Mutliplayer connect failed. "
|
||||
"The sample will now quit."),
|
||||
TEXT("DirectPlay Sample"), MB_OK | MB_ICONERROR );
|
||||
PostMessage(g_hwndMain, UM_ABORT, 0, 0);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case VK_ESCAPE:
|
||||
case VK_F12:
|
||||
// Exit the game
|
||||
ExitGame();
|
||||
return 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case WM_PAINT:
|
||||
hdc = BeginPaint( hWnd, &ps );
|
||||
if( g_nProgramState == PS_SPLASH )
|
||||
{
|
||||
// Display the splash screen
|
||||
BltSplashScreen( NULL );
|
||||
}
|
||||
|
||||
EndPaint( hWnd, &ps );
|
||||
return 1;
|
||||
|
||||
case UM_LAUNCH:
|
||||
case UM_ABORT:
|
||||
// if we were launched by the lobby and not (failed to finish a lobby launch)
|
||||
// where wParam is bLobbyLaunched
|
||||
if( msg == UM_LAUNCH )
|
||||
{
|
||||
// Init lobby msg support for reporting score
|
||||
// Note that we don't release the lobby object
|
||||
LobbyMessageInit();
|
||||
|
||||
// Start the game in rest mode
|
||||
g_nProgramState = PS_REST;
|
||||
LaunchGame();
|
||||
return 1;
|
||||
}
|
||||
// Else aborting
|
||||
ExitGame();
|
||||
return 1;
|
||||
|
||||
case WM_TIMER:
|
||||
ReceiveMessages();
|
||||
LobbyMessageReceive( LMR_PROPERTIES );
|
||||
break;
|
||||
|
||||
case WM_DESTROY:
|
||||
// If g_bReinitialize is TRUE don't quit, we are just switching
|
||||
// display modes
|
||||
if( !g_bReinitialize )
|
||||
{
|
||||
CleanupApplication();
|
||||
PostQuitMessage( 0 );
|
||||
}
|
||||
return 0;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return DefWindowProc( hWnd, msg, wParam, lParam );
|
||||
}
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: InitApplication()
|
||||
// Desc: Do that initialization stuff...
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT InitApplication( HINSTANCE hInst )
|
||||
{
|
||||
WNDCLASS wndClass = { CS_DBLCLKS, MainWndproc, 0, 0, hInst,
|
||||
LoadIcon( hInst, MAKEINTRESOURCE(IDI_MAIN)),
|
||||
LoadCursor(NULL, IDC_ARROW),
|
||||
(HBRUSH)GetStockObject(BLACK_BRUSH),
|
||||
NULL, TEXT("DuelClass") };
|
||||
RegisterClass( &wndClass );
|
||||
|
||||
// Initialize all components
|
||||
if( FAILED( InitGraphics() ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( DIUtil_InitInput( g_hwndMain ) ) )
|
||||
return E_FAIL;
|
||||
|
||||
if( FAILED( InitializeGameSounds() ) )
|
||||
{
|
||||
// Can play game without sound. Do not exit
|
||||
}
|
||||
|
||||
// Start in splash mode
|
||||
g_nProgramState = PS_SPLASH;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: CleanupApplication()
|
||||
// Desc: Calls clean up on all components
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID CleanupApplication()
|
||||
{
|
||||
CleanupComm();
|
||||
CleanupGameSounds();
|
||||
CleanupGraphics();
|
||||
DIUtil_CleanupInput();
|
||||
DPLobbyRelease(); // in case we were doing lobby messages
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ShowError()
|
||||
// Desc: Displays error to the user
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID ShowError( int iStrID )
|
||||
{
|
||||
TCHAR strMsg[MAX_ERRORMSG];
|
||||
LoadString( g_hInst, iStrID, strMsg, MAX_ERRORMSG );
|
||||
MessageBox( g_hwndMain, strMsg, TEXT("Duel Message"), MB_OK );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: UpdateTitle()
|
||||
// Desc: Updates the window title based on application status
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID UpdateTitle()
|
||||
{
|
||||
// Build the window title
|
||||
TCHAR strTitle[MAX_WINDOWTITLE] = TEXT("Duel");
|
||||
|
||||
// State options in window title
|
||||
if( g_bHostPlayer | g_bUseProtocol | g_bReliable | g_bAsync )
|
||||
{
|
||||
strcat( strTitle, " - |" );
|
||||
if( g_bHostPlayer )
|
||||
_tcscat( strTitle, TEXT(" Host |") );
|
||||
if( g_bUseProtocol )
|
||||
_tcscat( strTitle, TEXT(" Protocol |") );
|
||||
if( g_bReliable )
|
||||
_tcscat( strTitle, TEXT(" Reliable |") );
|
||||
if( g_bAsync )
|
||||
_tcscat( strTitle, TEXT(" Async |") );
|
||||
}
|
||||
|
||||
// Change window title
|
||||
SetWindowText( g_hwndMain, strTitle );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: DoHelp()
|
||||
// Desc: Display a Help summary in a message box.
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID DoHelp()
|
||||
{
|
||||
TCHAR strHelpMsg[MAX_HELPMSG];
|
||||
LoadString( g_hInst, IDS_DUEL_HELP, strHelpMsg, MAX_HELPMSG );
|
||||
MessageBox( g_hwndMain, strHelpMsg, TEXT("DUEL"), MB_OK );
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: ReadRegKey()
|
||||
// Desc: Read a registry key
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT ReadRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue,
|
||||
DWORD dwLength, TCHAR* strDefault )
|
||||
{
|
||||
DWORD dwType;
|
||||
LONG bResult;
|
||||
|
||||
bResult = RegQueryValueEx( hKey, strName, 0, &dwType,
|
||||
(LPBYTE) strValue, &dwLength );
|
||||
if ( bResult != ERROR_SUCCESS )
|
||||
strcpy( strValue, strDefault );
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Name: WriteRegKey()
|
||||
// Desc: Writes a registry key
|
||||
//-----------------------------------------------------------------------------
|
||||
HRESULT WriteRegKey( HKEY hKey, TCHAR* strName, TCHAR* strValue )
|
||||
{
|
||||
LONG bResult;
|
||||
|
||||
bResult = RegSetValueEx( hKey, strName, 0, REG_SZ,
|
||||
(LPBYTE) strValue, strlen(strValue) + 1 );
|
||||
if ( bResult != ERROR_SUCCESS )
|
||||
return E_FAIL;
|
||||
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
97
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duel.h
Normal file
@@ -0,0 +1,97 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: Duel.h
|
||||
//
|
||||
// Desc: Duel include file
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#ifndef DUEL_INCLUDED
|
||||
#define DUEL_INCLUDED
|
||||
|
||||
// bcc32 does not support nameless unions in C mode
|
||||
#if defined(__BORLANDC__) && !defined(__cplusplus)
|
||||
#define NONAMELESSUNION
|
||||
#endif
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
#endif
|
||||
#include <windows.h>
|
||||
#include <windowsx.h>
|
||||
#include <mmsystem.h>
|
||||
#include "resource.h"
|
||||
#include <wtypes.h>
|
||||
#include <tchar.h>
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Application constants
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
// Dialog exit codes
|
||||
#define EXITCODE_FORWARD 1 // Dialog success, so go forward
|
||||
#define EXITCODE_BACKUP 2 // Dialog canceled, show previous dialog
|
||||
#define EXITCODE_QUIT 3 // Dialog quit, close app
|
||||
#define EXITCODE_ERROR 4 // Dialog error, terminate app
|
||||
#define EXITCODE_LOBBYCONNECT 5 // Dialog connected from lobby, connect success
|
||||
|
||||
// User messages
|
||||
#define UM_LAUNCH WM_USER
|
||||
#define UM_ABORT WM_USER+1
|
||||
#define UM_RESTARTTIMER WM_USER+2
|
||||
|
||||
// program states
|
||||
enum{ PS_SPLASH, PS_ACTIVE, PS_REST };
|
||||
|
||||
#define MAX_SCREEN_X 639
|
||||
#define MAX_SCREEN_Y 479
|
||||
#define MAX_PLAYER_NAME 14
|
||||
#define MAX_SESSION_NAME 256
|
||||
#define MAX_SPNAME 50
|
||||
#define MAX_CLASSNAME 50
|
||||
#define MAX_WINDOWTITLE 50
|
||||
#define MAX_ERRORMSG 256
|
||||
#define MAX_FONTNAME 50
|
||||
#define MAX_HELPMSG 512
|
||||
|
||||
#define RECEIVE_TIMER_ID 1
|
||||
#define RECEIVE_TIMEOUT 1000 // in milliseconds
|
||||
|
||||
#define ENUM_TIMER_ID 2
|
||||
#define ENUM_TIMEOUT 2000 // in milliseconds
|
||||
|
||||
// Default window size
|
||||
#define MAX_DEFWIN_X 640
|
||||
#define MAX_DEFWIN_Y 480
|
||||
|
||||
|
||||
// Tree view image info
|
||||
#define CX_BITMAP 25
|
||||
#define CY_BITMAP 25
|
||||
#define NUM_BITMAPS 2
|
||||
|
||||
// registry info
|
||||
#define DUEL_KEY (TEXT("Software\\Microsoft\\Duel"))
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID ShowError( int err );
|
||||
VOID UpdateTitle();
|
||||
|
||||
// Functions defined in util.c
|
||||
int randInt( int low, int high );
|
||||
double randDouble( double low, double high );
|
||||
#define TRACE dtrace
|
||||
void dtrace( TCHAR* strFormat, ...);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
BIN
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duel.ico
Normal file
|
After Width: | Height: | Size: 766 B |
237
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duelvoice.dsp
Normal file
@@ -0,0 +1,237 @@
|
||||
# Microsoft Developer Studio Project File - Name="duelvoice" - Package Owner=<4>
|
||||
# Microsoft Developer Studio Generated Build File, Format Version 6.00
|
||||
# ** DO NOT EDIT **
|
||||
|
||||
# TARGTYPE "Win32 (x86) Application" 0x0101
|
||||
|
||||
CFG=duelvoice - Win32 Release
|
||||
!MESSAGE This is not a valid makefile. To build this project using NMAKE,
|
||||
!MESSAGE use the Export Makefile command and run
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duelvoice.mak".
|
||||
!MESSAGE
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duelvoice.mak" CFG="duelvoice - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "duelvoice - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "duelvoice - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
|
||||
# Begin Project
|
||||
# PROP AllowPerConfigDependencies 0
|
||||
# PROP Scc_ProjName ""
|
||||
# PROP Scc_LocalPath ""
|
||||
CPP=cl.exe
|
||||
MTL=midl.exe
|
||||
RSC=rc.exe
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 0
|
||||
# PROP BASE Output_Dir ".\Release"
|
||||
# PROP BASE Intermediate_Dir ".\Release"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 0
|
||||
# PROP Output_Dir ".\Release"
|
||||
# PROP Intermediate_Dir ".\Release"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "NDEBUG" /win32
|
||||
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "NDEBUG"
|
||||
# ADD RSC /l 0x409 /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /machine:I386
|
||||
# ADD LINK32 uuid.lib comctl32.lib ddraw.lib dinput.lib dsound.lib dplayx.lib dxguid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /machine:I386 /stack:0x1f4000,0x1f4000
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
# PROP BASE Use_MFC 0
|
||||
# PROP BASE Use_Debug_Libraries 1
|
||||
# PROP BASE Output_Dir ".\Debug"
|
||||
# PROP BASE Intermediate_Dir ".\Debug"
|
||||
# PROP BASE Target_Dir ""
|
||||
# PROP Use_MFC 0
|
||||
# PROP Use_Debug_Libraries 1
|
||||
# PROP Output_Dir ".\Debug"
|
||||
# PROP Intermediate_Dir ".\Debug"
|
||||
# PROP Ignore_Export_Lib 0
|
||||
# PROP Target_Dir ""
|
||||
# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /c
|
||||
# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR /YX /FD /c
|
||||
# ADD BASE MTL /nologo /D "_DEBUG" /win32
|
||||
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
# ADD BASE RSC /l 0x409 /d "_DEBUG"
|
||||
# ADD RSC /l 0x409 /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
# ADD BASE BSC32 /nologo
|
||||
# ADD BSC32 /nologo
|
||||
LINK32=link.exe
|
||||
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /subsystem:windows /debug /machine:I386
|
||||
# ADD LINK32 uuid.lib comctl32.lib ddraw.lib dinput.lib dsound.lib dplayx.lib dxguid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /debug /machine:I386 /stack:0x1f4000,0x1f4000
|
||||
# SUBTRACT LINK32 /nodefaultlib
|
||||
|
||||
!ENDIF
|
||||
|
||||
# Begin Target
|
||||
|
||||
# Name "duelvoice - Win32 Release"
|
||||
# Name "duelvoice - Win32 Debug"
|
||||
# Begin Group "Source Files"
|
||||
|
||||
# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat;for;f90"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\ddutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\diutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dpconnect.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dputil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\dsutil.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duelvoice.rc
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gameproc.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\gfx.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.cpp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\lobby.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\resource.h
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Group "Header Files"
|
||||
|
||||
# PROP Default_Filter "h;hpp;hxx;hm;inl;fi;fd"
|
||||
# End Group
|
||||
# Begin Group "Resource Files"
|
||||
|
||||
# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;cnt;rtf;gif;jpg;jpeg;jpe"
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\csession.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\DUEL.BMP
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\duel.ico
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\osession.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\player.bmp
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\SPLASH.BMP
|
||||
# End Source File
|
||||
# End Group
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Bfire.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Lboom.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sboom.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sbounce.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sengine.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sstart.wav
|
||||
# End Source File
|
||||
# Begin Source File
|
||||
|
||||
SOURCE=.\Sstop.wav
|
||||
# End Source File
|
||||
# End Target
|
||||
# End Project
|
||||
@@ -0,0 +1,29 @@
|
||||
Microsoft Developer Studio Workspace File, Format Version 6.00
|
||||
# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
|
||||
|
||||
###############################################################################
|
||||
|
||||
Project: "duelvoice"=.\duelvoice.dsp - Package Owner=<4>
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<4>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
Global:
|
||||
|
||||
Package=<5>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
Package=<3>
|
||||
{{{
|
||||
}}}
|
||||
|
||||
###############################################################################
|
||||
|
||||
418
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duelvoice.mak
Normal file
@@ -0,0 +1,418 @@
|
||||
# Microsoft Developer Studio Generated NMAKE File, Based on duelvoice.dsp
|
||||
!IF "$(CFG)" == ""
|
||||
CFG=duelvoice - Win32 Release
|
||||
!MESSAGE No configuration specified. Defaulting to duelvoice - Win32 Release.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" != "duelvoice - Win32 Release" && "$(CFG)" != "duelvoice - Win32 Debug"
|
||||
!MESSAGE Invalid configuration "$(CFG)" specified.
|
||||
!MESSAGE You can specify a configuration when running NMAKE
|
||||
!MESSAGE by defining the macro CFG on the command line. For example:
|
||||
!MESSAGE
|
||||
!MESSAGE NMAKE /f "duelvoice.mak" CFG="duelvoice - Win32 Release"
|
||||
!MESSAGE
|
||||
!MESSAGE Possible choices for configuration are:
|
||||
!MESSAGE
|
||||
!MESSAGE "duelvoice - Win32 Release" (based on "Win32 (x86) Application")
|
||||
!MESSAGE "duelvoice - Win32 Debug" (based on "Win32 (x86) Application")
|
||||
!MESSAGE
|
||||
!ERROR An invalid configuration is specified.
|
||||
!ENDIF
|
||||
|
||||
!IF "$(OS)" == "Windows_NT"
|
||||
NULL=
|
||||
!ELSE
|
||||
NULL=nul
|
||||
!ENDIF
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
OUTDIR=.\Release
|
||||
INTDIR=.\Release
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Release
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\duelvoice.exe"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\dpconnect.obj"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duelvoice.res"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(OUTDIR)\duelvoice.exe"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /ML /W3 /GX /O2 /I "..\..\common\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /Fp"$(INTDIR)\duelvoice.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "NDEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\duelvoice.res" /d "NDEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\duelvoice.bsc"
|
||||
BSC32_SBRS= \
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=uuid.lib comctl32.lib ddraw.lib dinput.lib dsound.lib dplayx.lib dxguid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:no /pdb:"$(OUTDIR)\duelvoice.pdb" /machine:I386 /out:"$(OUTDIR)\duelvoice.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dpconnect.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\duelvoice.res"
|
||||
|
||||
"$(OUTDIR)\duelvoice.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
OUTDIR=.\Debug
|
||||
INTDIR=.\Debug
|
||||
# Begin Custom Macros
|
||||
OutDir=.\Debug
|
||||
# End Custom Macros
|
||||
|
||||
ALL : "$(OUTDIR)\duelvoice.exe" "$(OUTDIR)\duelvoice.bsc"
|
||||
|
||||
|
||||
CLEAN :
|
||||
-@erase "$(INTDIR)\ddutil.obj"
|
||||
-@erase "$(INTDIR)\ddutil.sbr"
|
||||
-@erase "$(INTDIR)\diutil.obj"
|
||||
-@erase "$(INTDIR)\diutil.sbr"
|
||||
-@erase "$(INTDIR)\dpconnect.obj"
|
||||
-@erase "$(INTDIR)\dpconnect.sbr"
|
||||
-@erase "$(INTDIR)\dputil.obj"
|
||||
-@erase "$(INTDIR)\dputil.sbr"
|
||||
-@erase "$(INTDIR)\dsutil.obj"
|
||||
-@erase "$(INTDIR)\dsutil.sbr"
|
||||
-@erase "$(INTDIR)\duel.obj"
|
||||
-@erase "$(INTDIR)\duel.sbr"
|
||||
-@erase "$(INTDIR)\duelvoice.res"
|
||||
-@erase "$(INTDIR)\gameproc.obj"
|
||||
-@erase "$(INTDIR)\gameproc.sbr"
|
||||
-@erase "$(INTDIR)\gfx.obj"
|
||||
-@erase "$(INTDIR)\gfx.sbr"
|
||||
-@erase "$(INTDIR)\lobby.obj"
|
||||
-@erase "$(INTDIR)\lobby.sbr"
|
||||
-@erase "$(INTDIR)\util.obj"
|
||||
-@erase "$(INTDIR)\util.sbr"
|
||||
-@erase "$(INTDIR)\vc60.idb"
|
||||
-@erase "$(INTDIR)\vc60.pdb"
|
||||
-@erase "$(OUTDIR)\duelvoice.bsc"
|
||||
-@erase "$(OUTDIR)\duelvoice.exe"
|
||||
-@erase "$(OUTDIR)\duelvoice.ilk"
|
||||
-@erase "$(OUTDIR)\duelvoice.pdb"
|
||||
|
||||
"$(OUTDIR)" :
|
||||
if not exist "$(OUTDIR)/$(NULL)" mkdir "$(OUTDIR)"
|
||||
|
||||
CPP=cl.exe
|
||||
CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /I "..\..\common\include" /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /FR"$(INTDIR)\\" /Fp"$(INTDIR)\duelvoice.pch" /YX /Fo"$(INTDIR)\\" /Fd"$(INTDIR)\\" /FD /c
|
||||
|
||||
.c{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.obj::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.c{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cpp{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
.cxx{$(INTDIR)}.sbr::
|
||||
$(CPP) @<<
|
||||
$(CPP_PROJ) $<
|
||||
<<
|
||||
|
||||
MTL=midl.exe
|
||||
MTL_PROJ=/nologo /D "_DEBUG" /mktyplib203 /win32
|
||||
RSC=rc.exe
|
||||
RSC_PROJ=/l 0x409 /fo"$(INTDIR)\duelvoice.res" /d "_DEBUG"
|
||||
BSC32=bscmake.exe
|
||||
BSC32_FLAGS=/nologo /o"$(OUTDIR)\duelvoice.bsc"
|
||||
BSC32_SBRS= \
|
||||
"$(INTDIR)\ddutil.sbr" \
|
||||
"$(INTDIR)\diutil.sbr" \
|
||||
"$(INTDIR)\dpconnect.sbr" \
|
||||
"$(INTDIR)\dputil.sbr" \
|
||||
"$(INTDIR)\dsutil.sbr" \
|
||||
"$(INTDIR)\duel.sbr" \
|
||||
"$(INTDIR)\gameproc.sbr" \
|
||||
"$(INTDIR)\gfx.sbr" \
|
||||
"$(INTDIR)\lobby.sbr" \
|
||||
"$(INTDIR)\util.sbr"
|
||||
|
||||
"$(OUTDIR)\duelvoice.bsc" : "$(OUTDIR)" $(BSC32_SBRS)
|
||||
$(BSC32) @<<
|
||||
$(BSC32_FLAGS) $(BSC32_SBRS)
|
||||
<<
|
||||
|
||||
LINK32=link.exe
|
||||
LINK32_FLAGS=uuid.lib comctl32.lib ddraw.lib dinput.lib dsound.lib dplayx.lib dxguid.lib dxerr8.lib ole32.lib winmm.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib advapi32.lib shell32.lib /nologo /subsystem:windows /incremental:yes /pdb:"$(OUTDIR)\duelvoice.pdb" /debug /machine:I386 /out:"$(OUTDIR)\duelvoice.exe"
|
||||
LINK32_OBJS= \
|
||||
"$(INTDIR)\ddutil.obj" \
|
||||
"$(INTDIR)\diutil.obj" \
|
||||
"$(INTDIR)\dpconnect.obj" \
|
||||
"$(INTDIR)\dputil.obj" \
|
||||
"$(INTDIR)\dsutil.obj" \
|
||||
"$(INTDIR)\duel.obj" \
|
||||
"$(INTDIR)\gameproc.obj" \
|
||||
"$(INTDIR)\gfx.obj" \
|
||||
"$(INTDIR)\lobby.obj" \
|
||||
"$(INTDIR)\util.obj" \
|
||||
"$(INTDIR)\duelvoice.res"
|
||||
|
||||
"$(OUTDIR)\duelvoice.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
|
||||
$(LINK32) @<<
|
||||
$(LINK32_FLAGS) $(LINK32_OBJS)
|
||||
<<
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(NO_EXTERNAL_DEPS)" != "1"
|
||||
!IF EXISTS("duelvoice.dep")
|
||||
!INCLUDE "duelvoice.dep"
|
||||
!ELSE
|
||||
!MESSAGE Warning: cannot find "duelvoice.dep"
|
||||
!ENDIF
|
||||
!ENDIF
|
||||
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release" || "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
SOURCE=.\ddutil.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\ddutil.obj" "$(INTDIR)\ddutil.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\diutil.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\diutil.obj" "$(INTDIR)\diutil.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\dpconnect.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dpconnect.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dpconnect.obj" "$(INTDIR)\dpconnect.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\dputil.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dputil.obj" "$(INTDIR)\dputil.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\dsutil.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\dsutil.obj" "$(INTDIR)\dsutil.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\duel.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\duel.obj" "$(INTDIR)\duel.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\duelvoice.rc
|
||||
|
||||
"$(INTDIR)\duelvoice.res" : $(SOURCE) "$(INTDIR)"
|
||||
$(RSC) $(RSC_PROJ) $(SOURCE)
|
||||
|
||||
|
||||
SOURCE=.\gameproc.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gameproc.obj" "$(INTDIR)\gameproc.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\gfx.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\gfx.obj" "$(INTDIR)\gfx.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\lobby.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\lobby.obj" "$(INTDIR)\lobby.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
SOURCE=.\util.cpp
|
||||
|
||||
!IF "$(CFG)" == "duelvoice - Win32 Release"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ELSEIF "$(CFG)" == "duelvoice - Win32 Debug"
|
||||
|
||||
|
||||
"$(INTDIR)\util.obj" "$(INTDIR)\util.sbr" : $(SOURCE) "$(INTDIR)"
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
|
||||
!ENDIF
|
||||
|
||||
269
Library/dxx8/samples/Multimedia/Demos/DuelVoice/duelvoice.rc
Normal file
@@ -0,0 +1,269 @@
|
||||
//Microsoft Developer Studio generated resource script.
|
||||
//
|
||||
#include "resource.h"
|
||||
|
||||
#define APSTUDIO_READONLY_SYMBOLS
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 2 resource.
|
||||
//
|
||||
#include "afxres.h"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#undef APSTUDIO_READONLY_SYMBOLS
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
// English (U.S.) resources
|
||||
|
||||
#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)
|
||||
#ifdef _WIN32
|
||||
LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US
|
||||
#pragma code_page(1252)
|
||||
#endif //_WIN32
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// TEXTINCLUDE
|
||||
//
|
||||
|
||||
1 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"resource.h\0"
|
||||
END
|
||||
|
||||
2 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"#include ""afxres.h""\r\n"
|
||||
" \0"
|
||||
END
|
||||
|
||||
3 TEXTINCLUDE DISCARDABLE
|
||||
BEGIN
|
||||
"\r\n"
|
||||
"\0"
|
||||
END
|
||||
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Dialog
|
||||
//
|
||||
|
||||
IDD_MULTIPLAYER_GAMES DIALOG DISCARDABLE 0, 0, 282, 140
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Multiplayer Games"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Select Game To Join:",-1,7,15,69,8
|
||||
CONTROL "Start Search",IDC_SEARCH_CHECK,"Button",BS_AUTOCHECKBOX |
|
||||
BS_PUSHLIKE | WS_TABSTOP,220,7,55,14
|
||||
LISTBOX IDC_GAMES_LIST,7,24,268,91,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
PUSHBUTTON "Join",IDC_JOIN,7,119,50,14
|
||||
PUSHBUTTON "Create",IDC_CREATE,61,119,50,14
|
||||
PUSHBUTTON "Cancel",IDC_BACK,225,119,50,14
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CONNECT DIALOG DISCARDABLE 0, 0, 282, 151
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Multiplayer Connect"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
LTEXT "Player Name:",IDC_STATIC,7,10,43,8
|
||||
EDITTEXT IDC_PLAYER_NAME_EDIT,7,22,268,14,ES_AUTOHSCROLL
|
||||
LTEXT "Connection Type:",IDC_STATIC,7,41,57,8
|
||||
LISTBOX IDC_CONNECTION_LIST,7,53,268,72,LBS_SORT |
|
||||
LBS_NOINTEGRALHEIGHT | WS_VSCROLL | WS_TABSTOP
|
||||
DEFPUSHBUTTON "OK",IDOK,171,130,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,225,130,50,14
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CREATE DIALOG DISCARDABLE 0, 0, 186, 77
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_CAPTION | WS_SYSMENU
|
||||
CAPTION "Create Game"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
EDITTEXT IDC_EDIT_SESSION_NAME,7,19,172,14,ES_AUTOHSCROLL
|
||||
DEFPUSHBUTTON "OK",IDOK,7,56,50,14
|
||||
PUSHBUTTON "Cancel",IDCANCEL,129,56,50,14
|
||||
LTEXT "Game Name:",IDC_STATIC,7,7,42,8
|
||||
END
|
||||
|
||||
IDD_LOBBY_WAIT_STATUS DIALOG DISCARDABLE 120, 110, 162, 52
|
||||
STYLE DS_MODALFRAME | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION
|
||||
CAPTION "Lobby Connection Status"
|
||||
FONT 8, "MS Shell Dlg"
|
||||
BEGIN
|
||||
DEFPUSHBUTTON "&Cancel",IDC_LOBBYCONNECTCANCEL,55,31,51,14
|
||||
CTEXT "Finding Game...",IDC_WAIT_TEXT,7,14,141,8
|
||||
END
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Bitmap
|
||||
//
|
||||
|
||||
SPLASH BITMAP MOVEABLE PURE "SPLASH.BMP"
|
||||
DUEL8 BITMAP MOVEABLE PURE "DUEL.BMP"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Icon
|
||||
//
|
||||
|
||||
// Icon with lowest ID value placed first to ensure application icon
|
||||
// remains consistent on all systems.
|
||||
IDI_MAIN ICON DISCARDABLE "duel.ico"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// WAVE
|
||||
//
|
||||
|
||||
SBOUNCE WAVE DISCARDABLE "Sbounce.wav"
|
||||
LBOOM WAVE DISCARDABLE "Lboom.wav"
|
||||
SBOOM WAVE DISCARDABLE "Sboom.wav"
|
||||
BFIRE WAVE DISCARDABLE "Bfire.wav"
|
||||
SENGINE WAVE DISCARDABLE "Sengine.wav"
|
||||
SSTART WAVE DISCARDABLE "Sstart.wav"
|
||||
SSTOP WAVE DISCARDABLE "Sstop.wav"
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// DESIGNINFO
|
||||
//
|
||||
|
||||
#ifdef APSTUDIO_INVOKED
|
||||
GUIDELINES DESIGNINFO DISCARDABLE
|
||||
BEGIN
|
||||
IDD_MULTIPLAYER_GAMES, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 275
|
||||
VERTGUIDE, 141
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 133
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CONNECT, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 275
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 144
|
||||
END
|
||||
|
||||
IDD_MULTIPLAYER_CREATE, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 179
|
||||
VERTGUIDE, 94
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 70
|
||||
END
|
||||
|
||||
IDD_LOBBY_WAIT_STATUS, DIALOG
|
||||
BEGIN
|
||||
LEFTMARGIN, 7
|
||||
RIGHTMARGIN, 148
|
||||
TOPMARGIN, 7
|
||||
BOTTOMMARGIN, 45
|
||||
END
|
||||
END
|
||||
#endif // APSTUDIO_INVOKED
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// String Table
|
||||
//
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_WIZARD_FONTNAME "Times"
|
||||
IDS_WIZARD_TITLE "Duel Setup"
|
||||
IDS_WIZARD_TITLE_SP "Communications Channel (Step 2 of 3)"
|
||||
IDS_WIZARD_TITLE_GS "Game Setup (Step 1 of 3)"
|
||||
IDS_WIZARD_TITLE_JS "Join Session (Step 3 of 3)"
|
||||
IDS_WIZARD_TITLE_HS "Host Session (Step 3 of 3)"
|
||||
IDS_DUEL_HELP "Spacebar\t\t- Fire\nRight Arrow\t- Rotate right\nLeft Arrow\t- Rotate left\nUp Arrow\t\t- Forward\nDown Arrow\t- Backward\nNumPad 5\t- Stop\nA\t\t- Asynchronous Messaging\nR\t\t- Reliable Messaging\nF1\t\t- Help\nF5\t\t- Frames/sec\nESC or F12\t- Quit\n"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DDRAW_ERROR_DDC "DirectDraw create failed"
|
||||
IDS_DDRAW_ERROR_SCL "SetCooperativeLevel failed"
|
||||
IDS_DDRAW_ERROR_SDM "SetDisplayMode failed"
|
||||
IDS_DDRAW_ERROR_CREATESURFACE "IDirectDraw::CreateSurface() failed"
|
||||
IDS_DDRAW_ERROR_GAS "Backbuffer couldn't be obtained"
|
||||
IDS_DDRAW_ERROR_CC "CreateClipper failed"
|
||||
IDS_DDRAW_ERROR_SH "Clipper SetHwnd failed"
|
||||
IDS_DDRAW_ERROR_SC "Clipper object couldn't be attached to the front buffer"
|
||||
IDS_DDRAW_ERROR_RS "Surfaces couldn't be restored"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DINPUT_ERROR_DIC "DirectInputCreate failed"
|
||||
IDS_DINPUT_ERROR_ED "Enum keyboard devices failed"
|
||||
IDS_DINPUT_ERROR_CD "Create keyboard device failed"
|
||||
IDS_DINPUT_ERROR_SP "Set non-exclusive mode failed"
|
||||
IDS_DINPUT_ERROR_A "Keyboard acquire failed"
|
||||
IDS_DINPUT_ERROR_DF "Set keyboard data format failed"
|
||||
IDS_DDUTIL_ERROR_LI "LoadImage failed. Handle is NULL."
|
||||
IDS_DDUTIL_ERROR_DDCB "DDUtil_CopyBitmap failed"
|
||||
IDS_DDUTIL_ERROR_CCDC "CreateCompatibleDC failed"
|
||||
IDS_DSOUND_LOADWAVES "Could not load WAVE resource."
|
||||
IDS_DSOUND_DUPBUF "Could not duplicate a sound buffer for new ship"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DPLAY_ERROR_CP "Player create failed"
|
||||
IDS_DPLAY_ERROR_JS "Session join failed"
|
||||
IDS_DPLAY_ERROR_CS "Session create failed"
|
||||
IDS_DPLAY_ERROR_IDC "DirectPlay object create failed"
|
||||
IDS_DPLAY_ERROR_SL "You have been disconnected from the session"
|
||||
IDS_DPLAY_ERROR_GPLD "Get player local data failed"
|
||||
IDS_DPLAY_ERROR_SPLD "Set player local data failed"
|
||||
IDS_DPLAY_ERROR_GPRD "Get player remote data failed"
|
||||
IDS_DPLAY_ERROR_SPRD "Set player remote data failed"
|
||||
IDS_DPLAY_ERROR_GSD "Get session description failed"
|
||||
IDS_DPLAY_ERROR_EP "Enumerate players failed"
|
||||
IDS_DPLAY_ERROR_ES "Enumerate sessions failed"
|
||||
IDS_DPLAY_ERROR_C "DirectPlay Close failed"
|
||||
IDS_DPLAY_ERROR_R "DirectPlay Release failed"
|
||||
IDS_DPLAY_ERROR_DP "Destroy player failed"
|
||||
IDS_DPLAY_ERROR_CLSID "This application requires DirectPlay 6 or later"
|
||||
END
|
||||
|
||||
STRINGTABLE DISCARDABLE
|
||||
BEGIN
|
||||
IDS_DPLOBBY_ERROR_R "DirectPlayLobby Release failed"
|
||||
IDS_DPLOBBY_ERROR_GCS "DirectPlayLobby GetConnectionSettings failed"
|
||||
IDS_DPLOBBY_ERROR_SCS "DirectPlayLobby SetConnectionSettings failed"
|
||||
IDS_DPLOBBY_ERROR_C "DirectPlayLobby Create failed"
|
||||
IDS_DPLOBBY_ERROR_CONNECT "DirectPlayLobby Connect failed"
|
||||
IDS_WIZARD_ERROR_GSG "Session guid couldn't be obtained from the parent item"
|
||||
IDS_WIN_ERROR "Windows API failure"
|
||||
END
|
||||
|
||||
#endif // English (U.S.) resources
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
|
||||
#ifndef APSTUDIO_INVOKED
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Generated from the TEXTINCLUDE 3 resource.
|
||||
//
|
||||
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////
|
||||
#endif // not APSTUDIO_INVOKED
|
||||
|
||||
1948
Library/dxx8/samples/Multimedia/Demos/DuelVoice/gameproc.cpp
Normal file
226
Library/dxx8/samples/Multimedia/Demos/DuelVoice/gameproc.h
Normal file
@@ -0,0 +1,226 @@
|
||||
//-----------------------------------------------------------------------------
|
||||
// File: GameProc.h
|
||||
//
|
||||
// Desc: Game processing routines
|
||||
//
|
||||
// Copyright (C) 1995-2001 Microsoft Corporation. All Rights Reserved.
|
||||
//-----------------------------------------------------------------------------
|
||||
#define IDIRECTPLAY2_OR_GREATER
|
||||
#include <ddraw.h>
|
||||
#include <dplay.h>
|
||||
#include <dsound.h>
|
||||
|
||||
// align on single byte boundaries
|
||||
// this is a stop-gap measure until the structures can be re-arranged.
|
||||
#pragma pack(1)
|
||||
|
||||
#define MAX_SHIP_X (MAX_SCREEN_X - 32)
|
||||
#define MAX_SHIP_Y (MAX_SCREEN_Y - 32)
|
||||
#define MAX_SHIP_FRAME 40
|
||||
#define MAX_BULLET_X (MAX_SCREEN_X - 3)
|
||||
#define MAX_BULLET_Y (MAX_SCREEN_Y - 3)
|
||||
#define MAX_BULLET_FRAME 400
|
||||
|
||||
#define NUM_SHIP_TYPES 4
|
||||
|
||||
#define DEF_SHOW_DELAY (2000)
|
||||
#define MAX_BUFFER_SIZE 256
|
||||
|
||||
#define UPDATE_INTERVAL 40 // interval between position updates in milliseconds (25 FPS)
|
||||
#define SYNC_INTERVAL 1000 // synchronize once every second
|
||||
#define HIDE_TIMEOUT 5000 // time for which a ship is disabled after a hit
|
||||
|
||||
// Keyboard commands
|
||||
#define KEY_STOP 0x00000001l
|
||||
#define KEY_DOWN 0x00000002l
|
||||
#define KEY_LEFT 0x00000004l
|
||||
#define KEY_RIGHT 0x00000008l
|
||||
#define KEY_UP 0x00000010l
|
||||
#define KEY_FIRE 0x00000020l
|
||||
#define KEY_ENGINEOFF 0x00000040l
|
||||
|
||||
// Offsets for the bullet bitmap
|
||||
#define BULLET_X 304
|
||||
#define BULLET_Y 0
|
||||
|
||||
struct FRAG
|
||||
{
|
||||
double dPosX;
|
||||
double dPosY;
|
||||
LPDIRECTDRAWSURFACE pdds;
|
||||
RECT src;
|
||||
double dVelX;
|
||||
double dVelY;
|
||||
BOOL valid;
|
||||
};
|
||||
|
||||
struct SHIP
|
||||
{
|
||||
double dPosX, dPosY; // ship x and y position
|
||||
double dBulletPosX, dBulletPosY; // bullet x and y position
|
||||
DWORD dwBulletFrame; // bullet frame
|
||||
char cFrame; // current ship frame
|
||||
BYTE byType; // ship type
|
||||
BOOL bEnable; // is this ship active?
|
||||
BOOL bBulletEnable; // Is there an active bullet?
|
||||
|
||||
double dVelX, dVelY; // ship x and y velocity (pixels/millisecond)
|
||||
double dBulletVelX, dBulletVelY; // bullet x and y velocity (pixels/millisecond)
|
||||
DWORD dwScore; // current score
|
||||
DWORD dwLastTick; // most recent time stamp
|
||||
BOOL bIgnore; // flag used to synchronize ship explosions
|
||||
int iCountDown; // enable time-out
|
||||
DWORD dwFrameCount; // number of frames since beginning of time
|
||||
|
||||
// DSound members
|
||||
DWORD dwKeys; // the keyboard state
|
||||
BOOL bEngineRunning; // These BOOLs keep track of the ship's
|
||||
BOOL bMoving; // last condition so we can play sounds
|
||||
BOOL bBounced; // when they change
|
||||
BOOL bBlockHit;
|
||||
BOOL bDeath;
|
||||
BOOL bFiring;
|
||||
|
||||
// DPlayVoice
|
||||
LPDIRECTSOUND3DBUFFER pDSBVoice; // 3D buffer for the voice
|
||||
DPID dpidID;
|
||||
};
|
||||
|
||||
struct BLOCKS
|
||||
{
|
||||
BYTE bits[30][5];
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// communication packet structures
|
||||
//-----------------------------------------------------------------------------
|
||||
#define MSG_HOST 0x11 // message containing field layout, sent by host
|
||||
#define MSG_BLOCKHIT 0x22 // block hit message
|
||||
#define MSG_SHIPHIT 0x33 // ship hit message
|
||||
#define MSG_ADDBLOCK 0x44 // add block message
|
||||
#define MSG_CONTROL 0x55 // game keys message
|
||||
#define MSG_SYNC 0x66 // synchronization message containing the rendezvous location
|
||||
|
||||
struct GENERICMSG
|
||||
{
|
||||
BYTE byType;
|
||||
};
|
||||
|
||||
struct OLDHOSTMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BLOCKS Blocks;
|
||||
};
|
||||
|
||||
struct HOSTMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BLOCKS Blocks;
|
||||
int usedShipTypes[NUM_SHIP_TYPES];
|
||||
};
|
||||
|
||||
struct BLOCKHITMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byRow;
|
||||
BYTE byCol;
|
||||
BYTE byMask;
|
||||
};
|
||||
|
||||
struct SHIPHITMSG
|
||||
{
|
||||
BYTE byType;
|
||||
DPID Id;
|
||||
};
|
||||
|
||||
struct ADDBLOCKMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byX;
|
||||
BYTE byY;
|
||||
};
|
||||
|
||||
struct CONTROLMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byState;
|
||||
};
|
||||
|
||||
struct SYNCMSG
|
||||
{
|
||||
BYTE byType;
|
||||
BYTE byShipType; // this is needed only when sends are unreliable
|
||||
char cFrame;
|
||||
double dPosX;
|
||||
double dPosY;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Prototypes
|
||||
//-----------------------------------------------------------------------------
|
||||
VOID LaunchGame();
|
||||
VOID ExitGame();
|
||||
HRESULT InitOurShip();
|
||||
|
||||
HRESULT InitLocalSoundData();
|
||||
HRESULT InitPlayerLocalSoundData( SHIP* pShip );
|
||||
BOOL WINAPI SetPlayerLocalSoundDataCB( DPID dpId, DWORD dwPlayerType,
|
||||
LPCDPNAME pName, DWORD dwFlags,
|
||||
VOID* pContext );
|
||||
|
||||
VOID ReleaseLocalData();
|
||||
HRESULT ReleasePlayerLocalSoundData( SHIP* pShip );
|
||||
BOOL WINAPI ReleasePlayerLocalDataCB( DPID dpId, DWORD dwPlayerType,
|
||||
LPCDPNAME pName, DWORD dwFlags,
|
||||
VOID* pContext );
|
||||
|
||||
VOID UpdateState( SHIP* pShip, DWORD dwControls );
|
||||
VOID SendSync( SHIP* pShip );
|
||||
VOID UpdateDisplayStatus( SHIP* pShip );
|
||||
VOID UpdatePosition( DPID dpId, SHIP* ship );
|
||||
BOOL IsHit( int x, int y );
|
||||
VOID InitField();
|
||||
BOOL setBlock( int x, int y );
|
||||
VOID AddFrag( SHIP* pShip, int offX, int offY );
|
||||
VOID UpdateFragment( int i );
|
||||
VOID DestroyShip( SHIP* pShip );
|
||||
VOID DestroyGame();
|
||||
BOOL UpdateFrame();
|
||||
|
||||
VOID ProcessSoundFlags( SHIP* pShip );
|
||||
BOOL WINAPI RenderPlayerCB( DPID dpId, DWORD dwPlayerType, LPCDPNAME pName,
|
||||
DWORD dwFlags, VOID* pContext );
|
||||
BOOL DrawScreen();
|
||||
BOOL DrawScore();
|
||||
VOID DrawShip( SHIP* pShip );
|
||||
VOID DrawBlock( int x, int y );
|
||||
VOID DrawBullet( SHIP* pShip );
|
||||
VOID DrawFragments();
|
||||
VOID DisplayFrameRate();
|
||||
|
||||
VOID GetConnection();
|
||||
HRESULT ReceiveMessages();
|
||||
VOID DoSystemMessage( DPMSG_GENERIC* pMsg, DWORD dwMsgSize, DPID idFrom,
|
||||
DPID idTo );
|
||||
VOID DoApplicationMessage( GENERICMSG* pMsg, DWORD dwMsgSize, DPID idFrom,
|
||||
DPID idTo );
|
||||
VOID SendGameMessage( GENERICMSG* pMsg, DPID idTo );
|
||||
VOID CleanupComm();
|
||||
|
||||
|
||||
HRESULT InitializeGameSounds();
|
||||
VOID CleanupGameSounds();
|
||||
|
||||
|
||||
|
||||
// restore default alignment
|
||||
#pragma pack()
|
||||
|
||||
|
||||
|
||||