Subversion Repositories pentevo

Rev

Blame | 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.  
  52.    Bass = LoadLibrary("bass.dll");
  53.    if (!Bass)
  54.        errexit("can't load bass.dll");
  55.  
  56.    GetVersion = (TGetVersion)GetProcAddress(Bass, "BASS_GetVersion");
  57.    if (!GetVersion || (HIWORD(GetVersion()) != 0x0204))
  58.       errexit("unexpected BASS version. unreal requires BASS 2.4");
  59.  
  60.    ErrorGetCode = (BASS::TErrorGetCode)GetProcAddress(Bass, "BASS_ErrorGetCode");
  61.    Init = (TInit)GetProcAddress(Bass, "BASS_Init");
  62.    Free = (TFree)GetProcAddress(Bass, "BASS_Free");
  63.    Pause = (TPause)GetProcAddress(Bass, "BASS_Pause");
  64.    Start = (TStart)GetProcAddress(Bass, "BASS_Start");
  65.    Stop = (TStop)GetProcAddress(Bass, "BASS_Stop");
  66.    SetConfig = (TSetConfig)GetProcAddress(Bass, "BASS_SetConfig");
  67.    GetConfig = (TGetConfig)GetProcAddress(Bass, "BASS_GetConfig");
  68.    GetInfo = (TGetInfo)GetProcAddress(Bass, "BASS_GetInfo");
  69.  
  70.    MusicFree = (TMusicFree)GetProcAddress(Bass, "BASS_MusicFree");
  71.    MusicLoad = (TMusicLoad)GetProcAddress(Bass, "BASS_MusicLoad");
  72.    ChannelPlay = (TChannelPlay)GetProcAddress(Bass, "BASS_ChannelPlay");
  73.    ChannelPause = (TChannelPause)GetProcAddress(Bass, "BASS_ChannelPause");
  74.    ChannelStop = (TChannelStop)GetProcAddress(Bass, "BASS_ChannelStop");
  75.  
  76.    ChannelGetPosition = (TChannelGetPosition)GetProcAddress(Bass, "BASS_ChannelGetPosition");
  77.    ChannelSetPosition = (TChannelSetPosition)GetProcAddress(Bass, "BASS_ChannelSetPosition");
  78.    ChannelSetAttribute = (TChannelSetAttribute)GetProcAddress(Bass, "BASS_ChannelSetAttribute");
  79.    ChannelGetAttribute = (TChannelGetAttribute)GetProcAddress(Bass, "BASS_ChannelGetAttribute");
  80.    ChannelFlags = (TChannelFlags)GetProcAddress(Bass, "BASS_ChannelFlags");
  81.    ChannelGetLevel = (TChannelGetLevel)GetProcAddress(Bass, "BASS_ChannelGetLevel");
  82.    ChannelBytes2Seconds = (TChannelBytes2Seconds)GetProcAddress(Bass, "BASS_ChannelBytes2Seconds");
  83.    ChannelIsActive = (TChannelIsActive)GetProcAddress(Bass, "BASS_ChannelIsActive");
  84.  
  85.    StreamCreate = (TStreamCreate)GetProcAddress(Bass, "BASS_StreamCreate");
  86.    StreamCreateFileUser = (TStreamCreateFileUser)GetProcAddress(Bass, "BASS_StreamCreateFileUser");
  87.    StreamFree = (TStreamFree)GetProcAddress(Bass, "BASS_StreamFree");
  88.  
  89.    if (!Init)
  90.        errexit("can't import BASS API: BASS_Init");
  91.    if (!Free)
  92.        errexit("can't import BASS API: BASS_Free");
  93.    if (!Pause)
  94.        errexit("can't import BASS API: BASS_Pause");
  95.    if (!Start)
  96.        errexit("can't import BASS API: BASS_Start");
  97.    if (!Stop)
  98.        errexit("can't import BASS API: BASS_Stop");
  99.    if (!MusicFree)
  100.        errexit("can't import BASS API: BASS_MusicFree");
  101.    if (!MusicLoad)
  102.        errexit("can't import BASS API: BASS_MusicLoad");
  103.    if (!GetConfig)
  104.        errexit("can't import BASS API: BASS_GetConfig");
  105.    if (!SetConfig)
  106.        errexit("can't import BASS API: BASS_SetConfig");
  107.    if (!GetInfo)
  108.        errexit("can't import BASS API: BASS_GetInfo");
  109.    if (!ChannelFlags)
  110.        errexit("can't import BASS API: BASS_ChannelFlags");
  111.    if (!ChannelSetAttribute)
  112.        errexit("can't import BASS API: BASS_ChannelSetAttribute");
  113.    if(!ChannelGetAttribute)
  114.        errexit("can't import BASS API: BASS_ChannelGetAttribute");
  115.    if (!ChannelGetPosition)
  116.        errexit("can't import BASS API: BASS_ChannelGetPosition");
  117.    if (!ChannelSetPosition)
  118.        errexit("can't import BASS API: BASS_ChannelSetPosition");
  119.    if (!ChannelGetLevel)
  120.        errexit("can't import BASS API: BASS_ChannelGetLevel");
  121.    if (!ChannelBytes2Seconds)
  122.        errexit("can't import BASS API: BASS_ChannelBytes2Seconds");
  123.    if (!ChannelIsActive)
  124.        errexit("can't import BASS API: BASS_ChannelIsActive");
  125.    if (!ChannelPlay)
  126.        errexit("can't import BASS API: BASS_ChannelPlay");
  127.    if (!ChannelPause)
  128.        errexit("can't import BASS API: BASS_ChannelPause");
  129.    if (!ChannelStop)
  130.        errexit("can't import BASS API: BASS_ChannelStop");
  131.    if (!ErrorGetCode)
  132.        errexit("can't import BASS API: BASS_ErrorGetCode");
  133.    if (!StreamCreate)
  134.        errexit("can't import BASS API: BASS_StreamCreate");
  135.    if (!StreamCreateFileUser)
  136.        errexit("can't import BASS API: BASS_StreamCreateFileUser");
  137.    if (!StreamFree)
  138.        errexit("can't import BASS API: BASS_StreamFree");
  139. }
  140.  
  141. void Unload()
  142. {
  143.     if(Bass)
  144.     {
  145.         if(Free)
  146.         {
  147.             Free();
  148.         }
  149.         FreeLibrary(Bass);
  150.         Initialized = false;
  151.         Bass = nullptr;
  152.     }
  153. }
  154.  
  155. }
  156. #endif
  157.