Subversion Repositories pentevo

Rev

Rev 1074 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed | ?url?

  1. #include "std.h"
  2.  
  3. #include "emul.h"
  4. #include "vars.h"
  5.  
  6. #include "util.h"
  7.  
  8. #if defined(MOD_GSZ80) || defined(MOD_GSBASS)
  9. namespace BASS
  10. {
  11. /* BASS-specific functions and variables */
  12. TGetVersion          GetVersion;
  13. TInit                Init;
  14. TFree                Free;
  15. TPause               Pause;
  16. TStart               Start;
  17. TStop                Stop;
  18. TGetConfig           GetConfig;
  19. TSetConfig           SetConfig;
  20. TGetInfo             GetInfo;
  21.  
  22. TMusicFree           MusicFree;
  23. TMusicLoad           MusicLoad;
  24. TChannelPause        ChannelPause;
  25. TChannelPlay         ChannelPlay;
  26. TChannelStop         ChannelStop;
  27.  
  28. TChannelGetPosition  ChannelGetPosition;
  29. TChannelSetPosition  ChannelSetPosition;
  30. TChannelSetAttribute ChannelSetAttribute;
  31. TChannelGetAttribute ChannelGetAttribute;
  32. TChannelGetLevel     ChannelGetLevel;
  33. TErrorGetCode        ErrorGetCode;
  34. TChannelFlags        ChannelFlags;
  35.  
  36. TChannelBytes2Seconds ChannelBytes2Seconds;
  37.  
  38. TChannelIsActive ChannelIsActive;
  39.  
  40. TStreamCreate        StreamCreate;
  41. TStreamCreateFileUser StreamCreateFileUser;
  42. TStreamFree          StreamFree;
  43.  
  44. HMODULE Bass = nullptr;
  45. bool Initialized = false;
  46.  
  47. void Load()
  48. {
  49.    if(Bass)
  50.        return;
  51. #if defined(_WIN64) || defined(AMD64)
  52.    Bass = LoadLibrary("bass64.dll");
  53.    if (!Bass)
  54.            errexit("can't load bass64.dll");
  55. #else
  56.    Bass = LoadLibrary("bass.dll");
  57.    if (!Bass)
  58.            errexit("can't load bass.dll");
  59. #endif
  60.  
  61.    GetVersion = (TGetVersion)GetProcAddress(Bass, "BASS_GetVersion");
  62.    if (!GetVersion || (HIWORD(GetVersion()) != 0x0204))
  63.       errexit("unexpected BASS version. unreal requires BASS 2.4");
  64.  
  65.    ErrorGetCode = (BASS::TErrorGetCode)GetProcAddress(Bass, "BASS_ErrorGetCode");
  66.    Init = (TInit)GetProcAddress(Bass, "BASS_Init");
  67.    Free = (TFree)GetProcAddress(Bass, "BASS_Free");
  68.    Pause = (TPause)GetProcAddress(Bass, "BASS_Pause");
  69.    Start = (TStart)GetProcAddress(Bass, "BASS_Start");
  70.    Stop = (TStop)GetProcAddress(Bass, "BASS_Stop");
  71.    SetConfig = (TSetConfig)GetProcAddress(Bass, "BASS_SetConfig");
  72.    GetConfig = (TGetConfig)GetProcAddress(Bass, "BASS_GetConfig");
  73.    GetInfo = (TGetInfo)GetProcAddress(Bass, "BASS_GetInfo");
  74.  
  75.    MusicFree = (TMusicFree)GetProcAddress(Bass, "BASS_MusicFree");
  76.    MusicLoad = (TMusicLoad)GetProcAddress(Bass, "BASS_MusicLoad");
  77.    ChannelPlay = (TChannelPlay)GetProcAddress(Bass, "BASS_ChannelPlay");
  78.    ChannelPause = (TChannelPause)GetProcAddress(Bass, "BASS_ChannelPause");
  79.    ChannelStop = (TChannelStop)GetProcAddress(Bass, "BASS_ChannelStop");
  80.  
  81.    ChannelGetPosition = (TChannelGetPosition)GetProcAddress(Bass, "BASS_ChannelGetPosition");
  82.    ChannelSetPosition = (TChannelSetPosition)GetProcAddress(Bass, "BASS_ChannelSetPosition");
  83.    ChannelSetAttribute = (TChannelSetAttribute)GetProcAddress(Bass, "BASS_ChannelSetAttribute");
  84.    ChannelGetAttribute = (TChannelGetAttribute)GetProcAddress(Bass, "BASS_ChannelGetAttribute");
  85.    ChannelFlags = (TChannelFlags)GetProcAddress(Bass, "BASS_ChannelFlags");
  86.    ChannelGetLevel = (TChannelGetLevel)GetProcAddress(Bass, "BASS_ChannelGetLevel");
  87.    ChannelBytes2Seconds = (TChannelBytes2Seconds)GetProcAddress(Bass, "BASS_ChannelBytes2Seconds");
  88.    ChannelIsActive = (TChannelIsActive)GetProcAddress(Bass, "BASS_ChannelIsActive");
  89.  
  90.    StreamCreate = (TStreamCreate)GetProcAddress(Bass, "BASS_StreamCreate");
  91.    StreamCreateFileUser = (TStreamCreateFileUser)GetProcAddress(Bass, "BASS_StreamCreateFileUser");
  92.    StreamFree = (TStreamFree)GetProcAddress(Bass, "BASS_StreamFree");
  93.  
  94.    if (!Init)
  95.        errexit("can't import BASS API: BASS_Init");
  96.    if (!Free)
  97.        errexit("can't import BASS API: BASS_Free");
  98.    if (!Pause)
  99.        errexit("can't import BASS API: BASS_Pause");
  100.    if (!Start)
  101.        errexit("can't import BASS API: BASS_Start");
  102.    if (!Stop)
  103.        errexit("can't import BASS API: BASS_Stop");
  104.    if (!MusicFree)
  105.        errexit("can't import BASS API: BASS_MusicFree");
  106.    if (!MusicLoad)
  107.        errexit("can't import BASS API: BASS_MusicLoad");
  108.    if (!GetConfig)
  109.        errexit("can't import BASS API: BASS_GetConfig");
  110.    if (!SetConfig)
  111.        errexit("can't import BASS API: BASS_SetConfig");
  112.    if (!GetInfo)
  113.        errexit("can't import BASS API: BASS_GetInfo");
  114.    if (!ChannelFlags)
  115.        errexit("can't import BASS API: BASS_ChannelFlags");
  116.    if (!ChannelSetAttribute)
  117.        errexit("can't import BASS API: BASS_ChannelSetAttribute");
  118.    if(!ChannelGetAttribute)
  119.        errexit("can't import BASS API: BASS_ChannelGetAttribute");
  120.    if (!ChannelGetPosition)
  121.        errexit("can't import BASS API: BASS_ChannelGetPosition");
  122.    if (!ChannelSetPosition)
  123.        errexit("can't import BASS API: BASS_ChannelSetPosition");
  124.    if (!ChannelGetLevel)
  125.        errexit("can't import BASS API: BASS_ChannelGetLevel");
  126.    if (!ChannelBytes2Seconds)
  127.        errexit("can't import BASS API: BASS_ChannelBytes2Seconds");
  128.    if (!ChannelIsActive)
  129.        errexit("can't import BASS API: BASS_ChannelIsActive");
  130.    if (!ChannelPlay)
  131.        errexit("can't import BASS API: BASS_ChannelPlay");
  132.    if (!ChannelPause)
  133.        errexit("can't import BASS API: BASS_ChannelPause");
  134.    if (!ChannelStop)
  135.        errexit("can't import BASS API: BASS_ChannelStop");
  136.    if (!ErrorGetCode)
  137.        errexit("can't import BASS API: BASS_ErrorGetCode");
  138.    if (!StreamCreate)
  139.        errexit("can't import BASS API: BASS_StreamCreate");
  140.    if (!StreamCreateFileUser)
  141.        errexit("can't import BASS API: BASS_StreamCreateFileUser");
  142.    if (!StreamFree)
  143.        errexit("can't import BASS API: BASS_StreamFree");
  144. }
  145.  
  146. void Unload()
  147. {
  148.     if(Bass)
  149.     {
  150.         if(Free)
  151.         {
  152.             Free();
  153.         }
  154.         FreeLibrary(Bass);
  155.         Initialized = false;
  156.         Bass = nullptr;
  157.     }
  158. }
  159.  
  160. }
  161. #endif
  162.