Audio_DLL.cpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #include <windows.h>
  2. #include "hunt.h"
  3. #define req_versionH 0x0001
  4. #define req_versionL 0x0002
  5. HINSTANCE hAudioDLL = NULL;
  6. void DoHalt(LPSTR);
  7. typedef void (WINAPI * LPFUNC1)(void);
  8. typedef void (WINAPI * LPFUNC2)(HWND, HANDLE);
  9. typedef void (WINAPI * LPFUNC3)(float, float, float, float, float);
  10. typedef void (WINAPI * LPFUNC4)(int, short int*, int);
  11. typedef void (WINAPI * LPFUNC5)(int, short int*, float, float, float);
  12. typedef void (WINAPI * LPFUNC6)(int, short int*, float, float, float, int);
  13. typedef int (WINAPI * LPFUNC7)(void);
  14. typedef void (WINAPI * LPFUNC8)(int, float);
  15. typedef void (WINAPI * LPFUNC9)(int, AudioQuad *);
  16. LPFUNC9 audio_uploadgeometry;
  17. LPFUNC1 audio_restore;
  18. LPFUNC1 audiostop;
  19. LPFUNC1 audio_shutdown;
  20. LPFUNC2 initaudiosystem;
  21. LPFUNC3 audiosetcamerapos;
  22. LPFUNC4 setambient;
  23. LPFUNC5 setambient3d;
  24. LPFUNC6 addvoice3dv;
  25. LPFUNC7 audio_getversion;
  26. LPFUNC8 audio_setenvironment;
  27. void Audio_Shutdown()
  28. {
  29. if (audio_shutdown) audio_shutdown();
  30. if (hAudioDLL) FreeLibrary(hAudioDLL);
  31. hAudioDLL = NULL;
  32. audio_shutdown = NULL;
  33. }
  34. void InitAudioSystem(HWND hw, HANDLE hlog, int driver)
  35. {
  36. Audio_Shutdown();
  37. switch (driver) {
  38. case 0:
  39. hAudioDLL = LoadLibrary("a_soft.dll");
  40. if (!hAudioDLL) DoHalt("Can't load A_SOFT.DLL");
  41. break;
  42. case 1:
  43. hAudioDLL = LoadLibrary("a_ds3d.dll");
  44. if (!hAudioDLL) DoHalt("Can't load A_DS3D.DLL");
  45. break;
  46. case 2:
  47. hAudioDLL = LoadLibrary("a_a3d.dll");
  48. if (!hAudioDLL) DoHalt("Can't load A_A3D.DLL");
  49. break;
  50. case 3:
  51. hAudioDLL = LoadLibrary("a_eax.dll");
  52. if (!hAudioDLL) DoHalt("Can't load A_EAX.DLL");
  53. break;
  54. }
  55. initaudiosystem = (LPFUNC2) GetProcAddress(hAudioDLL, "InitAudioSystem");
  56. if (!initaudiosystem) DoHalt("Can't find procedure address.");
  57. audio_restore = (LPFUNC1) GetProcAddress(hAudioDLL, "Audio_Restore");
  58. if (!audio_restore) DoHalt("Can't find procedure address.");
  59. audiostop = (LPFUNC1) GetProcAddress(hAudioDLL, "AudioStop");
  60. if (!audiostop) DoHalt("Can't find procedure address.");
  61. audio_shutdown = (LPFUNC1) GetProcAddress(hAudioDLL, "Audio_Shutdown");
  62. if (!audio_shutdown) DoHalt("Can't find procedure address.");
  63. audiosetcamerapos = (LPFUNC3) GetProcAddress(hAudioDLL, "AudioSetCameraPos");
  64. if (!audiosetcamerapos) DoHalt("Can't find procedure address.");
  65. setambient = (LPFUNC4) GetProcAddress(hAudioDLL, "SetAmbient");
  66. if (!setambient) DoHalt("Can't find procedure address.");
  67. setambient3d = (LPFUNC5) GetProcAddress(hAudioDLL, "SetAmbient3d");
  68. if (!setambient3d) DoHalt("Can't find procedure address.");
  69. addvoice3dv = (LPFUNC6) GetProcAddress(hAudioDLL, "AddVoice3dv");
  70. if (!addvoice3dv) DoHalt("Can't find procedure address.");
  71. audio_getversion = (LPFUNC7) GetProcAddress(hAudioDLL, "Audio_GetVersion");
  72. if (!audio_getversion) DoHalt("Can't find procedure address.");
  73. audio_setenvironment = (LPFUNC8) GetProcAddress(hAudioDLL, "Audio_SetEnvironment");
  74. if (!audio_setenvironment) DoHalt("Can't find procedure address.");
  75. audio_uploadgeometry = (LPFUNC9) GetProcAddress(hAudioDLL, "Audio_UploadGeometry");
  76. if (!audio_uploadgeometry) DoHalt("Can't find procedure Audio_UploadGeometry address.");
  77. int v1 = audio_getversion()>>16;
  78. int v2 = audio_getversion() & 0xFFFF;
  79. if ( (v1!=req_versionH) || (v2<req_versionL) )
  80. DoHalt("Incorrect audio driver version.");
  81. initaudiosystem(hw, hlog);
  82. }
  83. void Audio_UploadGeometry()
  84. {
  85. UploadGeometry();
  86. audio_uploadgeometry(AudioFCount, data);
  87. }
  88. void AudioStop()
  89. {
  90. audiostop();
  91. }
  92. void Audio_Restore()
  93. {
  94. if (audio_restore)
  95. audio_restore();
  96. }
  97. void AudioSetCameraPos(float cx, float cy, float cz, float ca, float cb)
  98. {
  99. audiosetcamerapos(cx, cy, cz, ca, cb);
  100. }
  101. void Audio_SetEnvironment(int e, float f)
  102. {
  103. audio_setenvironment(e, f);
  104. }
  105. void SetAmbient(int length, short int* lpdata, int av)
  106. {
  107. setambient(length, lpdata, av);
  108. }
  109. void SetAmbient3d(int length, short int* lpdata, float cx, float cy, float cz)
  110. {
  111. setambient3d(length, lpdata, cx, cy, cz);
  112. }
  113. void AddVoice3dv(int length, short int* lpdata, float cx, float cy, float cz, int vol)
  114. {
  115. addvoice3dv(length, lpdata, cx, cy, cz, vol);
  116. }
  117. void AddVoice3d(int length, short int* lpdata, float cx, float cy, float cz)
  118. {
  119. AddVoice3dv(length, lpdata, cx, cy, cz, 256);
  120. }
  121. void AddVoicev(int length, short int* lpdata, int v)
  122. {
  123. AddVoice3dv(length, lpdata, 0,0,0, v);
  124. }
  125. void AddVoice(int length, short int* lpdata)
  126. {
  127. AddVoice3dv(length, lpdata, 0,0,0, 256);
  128. }