home *** CD-ROM | disk | FTP | other *** search
/ Windows Game Programming for Dummies (2nd Edition) / WinGamProgFD.iso / mac / Source / GPCHAP18 / GPDUMB2.H < prev    next >
C/C++ Source or Header  |  2002-05-01  |  5KB  |  145 lines

  1. // GPDUMB2.H - Header file for GPDUMB2.CPP game engine library
  2.  
  3. // watch for multiple inclusions
  4. #ifndef GPDUMB2
  5. #define GPDUMB2
  6.  
  7. // DEFINES ////////////////////////////////////////////////
  8.  
  9. #define MAX_SOUNDS     64 // max number of sounds in system at once 
  10.  
  11. #define SOUND_NULL     0
  12. #define SOUND_LOADED   1
  13. #define SOUND_PLAYING  2
  14. #define SOUND_STOPPED  3
  15.  
  16. // voc file defines
  17. #define NVB_SIZE       6  // size of new voice block in bytes
  18.  
  19. // screen transition commands
  20. #define SCREEN_DARKNESS  0         // fade to black
  21. #define SCREEN_WHITENESS 1         // fade to white
  22. #define SCREEN_SWIPE_X   2         // do a horizontal swipe
  23. #define SCREEN_SWIPE_Y   3         // do a vertical swipe
  24. #define SCREEN_DISOLVE   4         // a pixel disolve
  25. #define SCREEN_SCRUNCH   5         // a square compression
  26. #define SCREEN_BLUENESS  6         // fade to blue
  27. #define SCREEN_REDNESS   7         // fade to red
  28. #define SCREEN_GREENNESS 8         // fade to green
  29.  
  30. // BOB defines
  31. #define BOB_ATTR_CLONE   256 // the bob is a clone
  32.  
  33. // MACROS /////////////////////////////////////////////////
  34.  
  35. #define DSVOLUME_TO_DB(volume) ((DWORD)(-30*(100 - volume)))
  36.  
  37. // directx 7+ compatibility, MS got rid of this constant, but I like it
  38. #ifndef DSBCAPS_CTRLDEFAULT
  39. #define DSBCAPS_CTRLDEFAULT (DSBCAPS_CTRLFREQUENCY | DSBCAPS_CTRLPAN | DSBCAPS_CTRLVOLUME )
  40. #endif
  41.  
  42. // TYPES //////////////////////////////////////////////////
  43.  
  44. // this holds a single sound
  45. typedef struct pcm_sound_typ
  46.     {
  47.     LPDIRECTSOUNDBUFFER dsbuffer;   // the ds buffer containing the sound
  48.     int state;                      // state of the sound
  49.     int rate;                       // playback rate
  50.     int size;                       // size of sound
  51.     int id;                         // id number of the sound
  52.     } pcm_sound, *pcm_sound_ptr;
  53.  
  54. // PROTOTYPES /////////////////////////////////////////////
  55.  
  56. // sound
  57. int Load_VOC(char *filename);
  58. int Load_WAV(char *filename, int control_flags = DSBCAPS_CTRLDEFAULT);
  59. int Replicate_Sound(int source_id);
  60. int Play_Sound(int id, int flags=0,int volume=0, int rate=0, int pan=0);
  61. int Stop_Sound(int id);
  62. int Stop_All_Sounds(void);
  63. int DSound_Init(void);
  64. int DSound_Shutdown(void);
  65. int Delete_Sound(int id);
  66. int Delete_All_Sounds(void);
  67. int Status_Sound(int id);
  68. int Set_Sound_Volume(int id,int vol);
  69. int Set_Sound_Freq(int id,int freq);
  70. int Set_Sound_Pan(int id,int pan);
  71.  
  72. // new graphics, 8-bit only
  73. void HLine(int x1,int x2,int y,int color, UCHAR *vbuffer, int lpitch);
  74. void VLine(int y1,int y2,int x,int color, UCHAR *vbuffer, int lpitch);
  75. void Screen_Transitions(int effect, UCHAR *vbuffer, int lpitch);
  76.  
  77. // new graphics, 16-bit only
  78. void HLine16(int x1,int x2,int y,int color, UCHAR *vbuffer, int lpitch);
  79. void VLine16(int y1,int y2,int x,int color, UCHAR *vbuffer, int lpitch);
  80.  
  81. // input
  82. int DInput_Init(void);
  83. void DInput_Shutdown(void);
  84. int DI_Init_Joystick(int min_x=-256, int max_x=256, int min_y=-256, int max_y=256);
  85. int DI_Init_Mouse(void);
  86. int DI_Init_Keyboard(void);
  87. int DI_Read_Joystick(void);
  88. int DI_Read_Mouse(void);
  89. int DI_Read_Keyboard(void);
  90. void DI_Release_Joystick(void);
  91. void DI_Release_Mouse(void);
  92. void DI_Release_Keyboard(void);
  93.  
  94. // bobs
  95. int Destroy_BOBX(BOB_PTR bob);
  96. int Clone_BOBX(BOB_PTR source, BOB_PTR dest);
  97.  
  98. // general util
  99. int Collision_Test(int x1, int y1, int w1, int h1, 
  100.                    int x2, int y2, int w2, int h2); 
  101.  
  102. int Color_Scan(int x1, int y1, int x2, int y2, 
  103.                UCHAR scan_start, UCHAR scan_end, 
  104.                UCHAR *scan_buffer, int scan_lpitch);
  105.  
  106. int Color_Scan16(int x1, int y1, int x2, int y2, 
  107.                  UCHAR scan_start, UCHAR scan_end, 
  108.                  UCHAR *scan_buffer, int scan_lpitch);
  109.  
  110. // GLOBALS ////////////////////////////////////////////////
  111.  
  112.  
  113. // EXTERNALS //////////////////////////////////////////////
  114.  
  115. extern HWND main_window_handle;             // save the window handle
  116. extern HINSTANCE main_instance;             // save the instance
  117.  
  118. extern LPDIRECTSOUND        lpds;           // directsound interface pointer
  119. extern DSBUFFERDESC            dsbd;           // directsound description
  120. extern DSCAPS                dscaps;         // directsound caps
  121. extern HRESULT                dsresult;       // general directsound result
  122. extern DSBCAPS                dsbcaps;        // directsound buffer caps
  123.  
  124. extern LPDIRECTSOUNDBUFFER    lpdsbprimary;   // the primary mixing buffer
  125. extern pcm_sound            sound_fx[MAX_SOUNDS];    // the array of secondary sound buffers
  126.  
  127. extern WAVEFORMATEX            pcmwf;          // generic waveformat structure
  128.  
  129. // directinput globals
  130. extern LPDIRECTINPUT8       lpdi;         // dinput object
  131. extern LPDIRECTINPUTDEVICE8 lpdikey;      // dinput keyboard
  132. extern LPDIRECTINPUTDEVICE8 lpdimouse;    // dinput mouse
  133. extern LPDIRECTINPUTDEVICE8 lpdijoy;      // dinput joystick 
  134. extern GUID                 joystickGUID; // guid for main joystick
  135. extern char                 joyname[80];  // name of joystick
  136.  
  137. // these contain the target records for all di input packets
  138. extern UCHAR keyboard_state[256]; // contains keyboard state table
  139. extern DIMOUSESTATE mouse_state;  // contains state of mouse
  140. extern DIJOYSTATE joy_state;      // contains state of joystick
  141. extern int joystick_found;        // tracks if stick is plugged in
  142. #endif
  143.  
  144.  
  145.