home *** CD-ROM | disk | FTP | other *** search
/ The Net: Ultimate Internet Guide / WWLCD1.ISO / pc / directx2 / sdk / samples / rockem / directx.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-05-28  |  4.4 KB  |  142 lines

  1. /*==========================================================================
  2.  *
  3.  *  Copyright (C) 1995, 1996 Microsoft Corporation. All Rights Reserved.
  4.  *
  5.  *  File: directx.h
  6.  *
  7.  ***************************************************************************/
  8.  
  9. #ifndef __DIRECTX_H_
  10. #define __DIRECTX_H_
  11.  
  12. // Includes....
  13. #include "d3drmwin.h"
  14. #include "dsound.h"     
  15. #include "stdio.h"
  16.  
  17. // Defines....
  18. #define NUM_SOUNDS      24
  19.  
  20. #define INTRO           0
  21. #define PLAYER1_PUNCH1  1
  22. #define PLAYER1_PUNCH2  2
  23. #define PLAYER2_PUNCH1  3
  24. #define PLAYER2_PUNCH2  4
  25. #define PLAYER1_WALK    5
  26. #define PLAYER2_WALK    6
  27. #define WHOOSH1         7
  28. #define WHOOSH2         8
  29. #define PLAYER1_OUCH    9
  30. #define PLAYER2_OUCH    10
  31. #define HEAD_SPRING     11      
  32. #define BLOCK1          12
  33. #define BLOCK2          13
  34. #define BLOCK3          14
  35. #define VICTORY_BOO     15
  36. #define VICTORY_YEAH    16
  37. #define CROWD_LOOP      17
  38. #define SERVO_DOWN_1    18
  39. #define SERVO_DOWN_2    19
  40. #define SERVO_DOWN_3    20
  41. #define SERVO_UP_1      21
  42. #define SERVO_UP_2      22
  43. #define SERVO_UP_3      23
  44.  
  45. #define NUM_VID_MODES   50
  46.  
  47. // Macros
  48.  
  49. // The following macros are used for proper error handling for DirectDraw,
  50. // DirectSound, Direct3D and Direct3D retained mode
  51. #define TRY_DD(exp) { { HRESULT rval = exp; if (rval != DD_OK) { TraceErrorDD(rval, __FILE__, __LINE__); return FALSE; } } }
  52. #define TRY_DS(exp) { { HRESULT rval = exp; if (rval != DS_OK) { TraceErrorDS(rval, __FILE__, __LINE__); return FALSE; } } }
  53. #define TRY_D3D(exp) { { HRESULT rval = exp; if (rval != D3D_OK) { TraceErrorD3D(rval, __FILE__, __LINE__); return FALSE; } } }
  54. #define TRY_D3DRM(exp) { { HRESULT rval = exp; if (rval != D3DRM_OK) { TraceErrorD3DRM(rval, __FILE__, __LINE__); return FALSE; } } }
  55.  
  56. // Structures....
  57. typedef struct _D3DDeviceInfo
  58. {
  59.     D3DCOLORMODEL cm;
  60.     LPGUID        lpHWGuid;
  61.     D3DDEVICEDESC HWDeviceDesc;
  62.     LPGUID        lpSWGuid;
  63.     D3DDEVICEDESC SWDeviceDesc;
  64. } D3DDeviceInfo;
  65.  
  66. #pragma pack(1)
  67. struct WaveHeader
  68. {
  69.     BYTE        RIFF[4];          // "RIFF"
  70.     DWORD       dwSize;           // Size of data to follow
  71.     BYTE        WAVE[4];          // "WAVE"
  72.     BYTE        fmt_[4];          // "fmt "
  73.     DWORD       dw16;             // 16
  74.     WORD        wOne_0;           // 1
  75.     WORD        wChnls;           // Number of Channels
  76.     DWORD       dwSRate;          // Sample Rate
  77.     DWORD       BytesPerSec;      // Sample Rate
  78.     WORD        wBlkAlign;        // 1
  79.     WORD        BitsPerSample;    // Sample size
  80.     BYTE        DATA[4];          // "DATA"
  81.     DWORD       dwDSize;          // Number of Samples
  82. };
  83. #pragma pack()
  84.  
  85. struct VideoMode
  86. {
  87.     int         width;
  88.     int         height;
  89.     int         bpp;
  90.     BOOL        bUsable;
  91. };
  92.  
  93. // Prototypes....
  94.  
  95. // Error handling
  96. void TraceErrorDD(HRESULT hErr, char *sFile, int nLine);
  97. void TraceErrorDS(HRESULT hErr, char *sFile, int nLine);
  98. void TraceErrorD3D(HRESULT hErr, char *sFile, int nLine);
  99. void TraceErrorD3DRM(HRESULT hErr, char *sFile, int nLine);
  100.  
  101. // Callbacks
  102. BOOL FAR PASCAL  DDEnumCallback(GUID FAR* lpGUID, LPSTR lpDriverDesc, LPSTR lpDriverName, LPVOID lpContext);
  103. HRESULT CALLBACK DDEnumDisplayModesCallback(LPDDSURFACEDESC pddsd, LPVOID Context);
  104. HRESULT WINAPI   D3DEnumDeviceCallBack(LPGUID lpGuid, LPSTR lpDeviceDescription, LPSTR lpDeviceName, 
  105.                                                                            LPD3DDEVICEDESC lpHWDesc,  LPD3DDEVICEDESC lpHELDesc, LPVOID lpContext);
  106.  
  107. // Initialisation
  108. BOOL InitD3DDevice();
  109.  
  110. BOOL InitDirectX();
  111. BOOL SetDirectDrawExclusiveMode();
  112.  
  113. // Termination
  114. void TermDirectX();
  115.  
  116. void SortDisplayModes();
  117.  
  118. BOOL EnterVideoMode(int mode);
  119. BOOL EnterVideoModeWHBD(int width, int height, int bitdepth);
  120. BOOL EnterNextVideoMode();
  121. BOOL EnterPrevVideoMode();
  122. BOOL EnterLowestVideoMode();
  123. BOOL EnterHighestVideoMode();
  124. BOOL ReenterCurrentVideoMode();
  125. void CleanUp();
  126.  
  127. BOOL DoSplashScreen(DWORD delay);
  128. void ReleaseSplashScreen();
  129.  
  130. BOOL RestoreSurfaces();
  131.  
  132. BOOL CreateSoundBuffer(DWORD dwBuf, DWORD dwBufSize, DWORD dwFreq, DWORD dwBitsPerSample, DWORD dwBlkAlign, BOOL bStereo, BOOL bStaticBuf);
  133. BOOL ReadData(LPDIRECTSOUNDBUFFER lpDSB, FILE* pFile, DWORD dwSize, DWORD dwPos);
  134. BOOL CreateBufferFromWaveFile(char* FileName, DWORD dwBuf);
  135. BOOL StopAllSounds();
  136. BOOL PlaySoundDS(DWORD dwSound, DWORD dwFlags = 0);
  137.  
  138. void RecalcPowerBars(DWORD player1health, DWORD player2health);
  139.  
  140. #endif
  141.  
  142.